添加loading窗体,修改不可计数进度条窗体展示部分为loading窗体。

Former-commit-id: 21b16e296327c4cfb56f6cfe8aeaef92236738a5
TangShanKaiPing
wanggang 5 years ago
parent c126c9cf6f
commit ea209e9982

@ -95,12 +95,19 @@
<Compile Include="Controls\IdCard.Designer.cs">
<DependentUpon>IdCard.cs</DependentUpon>
</Compile>
<Compile Include="Infrastructure\FormExtensions.cs" />
<Compile Include="Infrastructure\ImageHelper.cs" />
<Compile Include="Infrastructure\CVRHelper.cs" />
<Compile Include="Infrastructure\CVRSDK.cs" />
<Compile Include="Infrastructure\ICameraHelper.cs" />
<Compile Include="Infrastructure\IdCardModel.cs" />
<Compile Include="Infrastructure\OpenCvSharpCameraHelper.cs" />
<Compile Include="LoadingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoadingForm.Designer.cs">
<DependentUpon>LoadingForm.cs</DependentUpon>
</Compile>
<Compile Include="LoginForm.cs">
<SubType>Form</SubType>
</Compile>
@ -124,6 +131,9 @@
<EmbeddedResource Include="Controls\IdCard.resx">
<DependentUpon>IdCard.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoadingForm.resx">
<DependentUpon>LoadingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource>
@ -173,6 +183,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="lib\DirectShowLib-2005.dll" />
<Content Include="loading.gif" />
<Content Include="sdtapi.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

@ -0,0 +1,42 @@
using CameraCard;
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
public static class FormExtensions
{
public static void Run(this Form form, Action action)
{
form.BeginInvoke(action);
}
public static void CloseForm(this Form form)
{
form.Invoke(new Action(() =>
{
if (form.IsHandleCreated)
{
form.Close();
}
}));
}
public static void RunWithLoading(this Form form, Action action, string title = "加载中")
{
var loading = new LoadingForm(title);
form.Run(() => loading.ShowDialog());
Task.Run(() =>
{
try
{
form.Invoke(action);
loading.CloseForm();
}
catch (Exception ex)
{
loading.CloseForm();
MessageBox.Show(ex.Message);
}
});
}
}

@ -0,0 +1,61 @@
namespace CameraCard
{
partial class LoadingForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoadingForm));
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
this.label1.Location = new System.Drawing.Point(55, 11);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 48);
this.label1.TabIndex = 0;
//
// LoadingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(164, 68);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "LoadingForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "加载中";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label label1;
}
}

@ -0,0 +1,15 @@
using System;
using System.Windows.Forms;
namespace CameraCard
{
public partial class LoadingForm : Form
{
public LoadingForm(string title = "加载中")
{
InitializeComponent();
this.ControlBox = false;
this.Text = title;
}
}
}

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="label1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
R0lGODlhMAAwAOZ8APv7+0BAQH9/f8HBwc/Pz/z8/Orq6vX19fj4+MfHx/b29uDg4PHx8eTk5NXV1f39
/fPz887Ozvf39/n5+ebm5tra2tfX1/T09MbGxsDAwN7e3uLi4uHh4d3d3YODg+Pj46CgoPLy8kFBQYSE
hMjIyLW1tdbW1tzc3Pr6+qysrEZGRggICFlZWbCwsJ+fn5CQkOfn53Fxce3t7YCAgKenp8rKyp2dnZSU
lAkJCcTExO/v70dHR+Xl5dPT0319faOjo9LS0u7u7oeHh7a2tjw8PNjY2ElJSY+Pj29vbz8/P6urq4mJ
iZubm1ZWVry8vAICAoqKiq2trY6OjlhYWDs7OyAgIOjo6K+vr2xsbG1tbYKCgnl5eURERAEBAR0dHYiI
iD09PVVVVevr6wYGBo2NjYaGhh4eHiEhIb29vaGhoa6urhwcHHp6ent7e83NzZycnPDw8NnZ2QUFBTo6
OrS0tHBwcNHR0UpKSkhISOnp6b+/vwAAAP///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtY
TVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlk
Ij8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBD
b3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpS
REYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4g
PHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5j
b20veGFwLzEu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129qMCC
JCKtOAbGhCcgN0XN09SMCAYNViHTC3UB398sA8ZN4OYBB8Bh5+DpugtI51MZ09cNMNvV+vuL1zAK1D6A
EEBwxINmA2YQXFjAWI6FC1MYK+ABogAbCIwhgKjFScNmNa6UcAOBUAEHegYAoPYggp6XJQcBWJlKw8uX
FwYZeMksFIoBN/XQ5JPgZQJRFIISkBl0qKcKQXMJkhBUQigLNxcQUhAUIKgGKTkUQhA0YyingwoE/TiN
wMul1QoOJMCQk59dTIEAACH5BAUAAHwALAAAAAAwADAAAAf/gHyCg4SFhoeIiYqLjI2OjQcYGAePlY0E
enoElpwkBoYFmZkFhwCchz57K1CFCKJ6CIUbA3oNp4VEe7ojhAqvCoQLoha3hEa6e08kgxKvEoMMGaIV
xYNCyHsigwCvpoKYohTVgh9j2CeDCZkJ268DE+OCW9gggwaZn4IHrx3xghNUkN0gBMCbIAiiIjzg1GLJ
iyFBCDFgsQdHEUUAaDkwyGcChQoWbCE6EKBkABVMOH7IV+mBBlqiOBJUYbJkFkrFCkR4pWeAIho1S3qo
5oCnHg6LfogIKrOS0QWNTMQwuYPULZiaGFS6sOBEiGoAIFxo6q+sWX8oGMjQAewsHwAS+hQgsErIgAsB
ePG+cFDWgLpXBHAKkpK3sIBY47gZ1YOBEBnDeRGDXcy47t3CR/j688szsKG0a9uehSuXrtvTqCsBOACB
7KOwYysxANezGlYCWhktkPaqGs8MUBVtMKr5VlGeSBNhzRTBtSOdPH0iUpwpQ4eF41wud97AQgUK8AYV
KDrA+VuNHD2CFNlyZyYIBDkiZI49noZXF+zhG7RPVL94KGyXzjrtiPJOPBQAVmAmBtGmhzjjVPBKbnw0
I8ozgkQzTTwWiBKcIL6IIhofwmRCzDgN9JTcIK6IIpkgs9TiD1mhiGLaNqkNAs4mOSpyQAIY5NfjkEQy
EggAOw==
</value>
</data>
</root>

@ -41,47 +41,53 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(41, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 0;
this.label1.Text = "登录名:";
//
// userNameInput
//
this.userNameInput.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.userNameInput.Location = new System.Drawing.Point(96, 50);
this.userNameInput.Name = "userNameInput";
this.userNameInput.Size = new System.Drawing.Size(157, 21);
this.userNameInput.Size = new System.Drawing.Size(157, 23);
this.userNameInput.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(56, 18);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(197, 12);
this.label2.Size = new System.Drawing.Size(200, 17);
this.label2.TabIndex = 2;
this.label2.Text = "普通高中学业水平考试信息管理系统";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(41, 105);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 12);
this.label3.Size = new System.Drawing.Size(44, 17);
this.label3.TabIndex = 3;
this.label3.Text = "密码:";
//
// passwordInput
//
this.passwordInput.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.passwordInput.Location = new System.Drawing.Point(96, 100);
this.passwordInput.Name = "passwordInput";
this.passwordInput.PasswordChar = '*';
this.passwordInput.Size = new System.Drawing.Size(157, 21);
this.passwordInput.Size = new System.Drawing.Size(157, 23);
this.passwordInput.TabIndex = 4;
//
// login
//
this.login.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.login.Location = new System.Drawing.Point(96, 149);
this.login.Name = "login";
this.login.Size = new System.Drawing.Size(157, 30);
@ -93,20 +99,22 @@
// userNameValid
//
this.userNameValid.AutoSize = true;
this.userNameValid.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.userNameValid.ForeColor = System.Drawing.Color.Red;
this.userNameValid.Location = new System.Drawing.Point(96, 78);
this.userNameValid.Name = "userNameValid";
this.userNameValid.Size = new System.Drawing.Size(29, 12);
this.userNameValid.Size = new System.Drawing.Size(32, 17);
this.userNameValid.TabIndex = 6;
this.userNameValid.Text = "验证";
//
// passwordValid
//
this.passwordValid.AutoSize = true;
this.passwordValid.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.passwordValid.ForeColor = System.Drawing.Color.Red;
this.passwordValid.Location = new System.Drawing.Point(95, 127);
this.passwordValid.Name = "passwordValid";
this.passwordValid.Size = new System.Drawing.Size(29, 12);
this.passwordValid.Size = new System.Drawing.Size(32, 17);
this.passwordValid.TabIndex = 7;
this.passwordValid.Text = "验证";
//

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
@ -13,8 +14,6 @@ namespace CameraCard
{
public partial class LoginForm : Form
{
private ProgressForm _progress;
public LoginForm()
{
InitializeComponent();
@ -59,7 +58,6 @@ namespace CameraCard
var user = db.Users.FirstOrDefault(o => o.UserName == userName && o.Password == password);
if (user != null)
{
this._progress?.SetProgress("本地登录成功", 100);
MainForm.User = user;
this.Hide();
new MainForm().Show();
@ -71,10 +69,38 @@ namespace CameraCard
}
else
{
this.BeginInvoke(new Action(() =>
var loading = new LoadingForm("登录中");
this.Run(() => loading.ShowDialog());
Task.Run(() =>
{
this.LoginFromServer(userName, password);
}));
try
{
this.LoginFromServer(userName, password);
loading.CloseForm();
var progress = new ProgressForm("更新中", "正在下载数据", 0, 100);
this.Run(() => progress.ShowDialog());
try
{
MainForm.LoadData(progress);
progress.CloseForm();
this.Invoke(new Action(() =>
{
this.Hide();
new MainForm().Show();
}));
}
catch (Exception ex)
{
progress.CloseForm();
MessageBox.Show(ex.Message);
}
}
catch (Exception ex)
{
loading.CloseForm();
MessageBox.Show(ex.Message);
}
});
}
}
}
@ -82,81 +108,40 @@ namespace CameraCard
private void LoginFromServer(string userName, string password)
{
if (this._progress == null)
var url = ConfigurationManager.AppSettings["login"];
var client = HttpClientFactory.Create();
var content = new StringContent(new JavaScriptSerializer().Serialize(new { userName = userName, password = password }), Encoding.UTF8, "application/json");
var response = client.PostAsync(url, content).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
var thread = new Thread(() =>
var result = new JavaScriptSerializer().Deserialize<LoginResponse>(response.Content.ReadAsStringAsync().Result);
if (result.code == 0)
{
try
using (var db = new MyDbContext())
{
this._progress?.SetProgress("正在登录,请稍候", 30);
var url = ConfigurationManager.AppSettings["login"];
var client = HttpClientFactory.Create();
var content = new StringContent(new JavaScriptSerializer().Serialize(new { userName = userName, password = password }), Encoding.UTF8, "application/json");
var response = client.PostAsync(url, content).Result;
this._progress?.SetProgress("正在登录,请稍候", 50);
if (response.StatusCode == HttpStatusCode.OK)
var user = db.Users.FirstOrDefault(o => o.UserName == userName);
if (user == null)
{
var result = new JavaScriptSerializer().Deserialize<LoginResponse>(response.Content.ReadAsStringAsync().Result);
if (result.code == 0)
{
using (var db = new MyDbContext())
{
var user = db.Users.FirstOrDefault(o => o.UserName == userName);
if (user == null)
{
user = new User { UserName = userName, Password = password, PasswordHash = result.data };
db.Users.Add(user);
}
else
{
user.Password = password;
user.PasswordHash = result.data;
}
db.SaveChanges();
MainForm.User = user;
}
this._progress?.SetProgress("登录成功,正在更新数据", 50);
MainForm.LoadData(this._progress);
this._progress?.SetProgress("数据更新完毕", 100);
this._progress.CloseProgress();
this.Invoke(new Action(() =>
{
this.Hide();
new MainForm().Show();
}));
}
else
{
MessageBox.Show($"错误代码:{result.code},错误消息:{result.message}");
this._progress?.SetProgress("登录失败", 100);
this._progress.CloseProgress();
}
user = new User { UserName = userName, Password = password, PasswordHash = result.data };
db.Users.Add(user);
}
else
{
MessageBox.Show(response.Content.ReadAsStringAsync().Result);
this._progress?.SetProgress("登录失败", 100);
this._progress.CloseProgress();
user.Password = password;
user.PasswordHash = result.data;
}
db.SaveChanges();
MainForm.User = user;
}
catch (ThreadAbortException ex)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
});
this._progress = new ProgressForm("登录中", "正在登录,请稍候", 0, 100, this.Width, () =>
}
else
{
this._progress = null;
if (thread != null && thread.IsAlive)
{
thread.Abort();
}
});
thread.Start();
this._progress.ShowDialog();
MessageBox.Show($"错误代码:{result.code},错误消息:{result.message}");
}
}
else
{
MessageBox.Show(response.Content.ReadAsStringAsync().Result);
}
}
@ -167,5 +152,23 @@ namespace CameraCard
this.login_Click(sender, e);
}
}
private void button1_Click(object sender, EventArgs e)
{
var loading = new LoadingForm("登录中");
this.Run(() => loading.ShowDialog());
Task.Run(() =>
{
try
{
loading.CloseForm();
}
catch (Exception ex)
{
loading.CloseForm();
MessageBox.Show(ex.Message);
}
});
}
}
}

@ -76,7 +76,6 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.versionLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.idCard = new CameraCard.IdCard();
this.StudentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Sex = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Nation = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -89,6 +88,9 @@
this.HasChedked = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.HasUploaded = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.StudentId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.idCard = new CameraCard.IdCard();
this.push = new System.Windows.Forms.Button();
this.pull = new System.Windows.Forms.Button();
tab1 = new System.Windows.Forms.TabPage();
tab1.SuspendLayout();
this.idcGroupBox.SuspendLayout();
@ -345,6 +347,8 @@
//
// tab3
//
this.tab3.Controls.Add(this.pull);
this.tab3.Controls.Add(this.push);
this.tab3.Controls.Add(this.totalPageValue);
this.tab3.Controls.Add(this.pageIndexSelector);
this.tab3.Controls.Add(this.pageMenu);
@ -420,7 +424,7 @@
//
// searchBtn
//
this.searchBtn.Location = new System.Drawing.Point(730, 18);
this.searchBtn.Location = new System.Drawing.Point(768, 18);
this.searchBtn.Name = "searchBtn";
this.searchBtn.Size = new System.Drawing.Size(75, 23);
this.searchBtn.TabIndex = 7;
@ -430,7 +434,7 @@
//
// nameInput
//
this.nameInput.Location = new System.Drawing.Point(457, 20);
this.nameInput.Location = new System.Drawing.Point(593, 20);
this.nameInput.Name = "nameInput";
this.nameInput.Size = new System.Drawing.Size(120, 21);
this.nameInput.TabIndex = 6;
@ -438,7 +442,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(398, 24);
this.label3.Location = new System.Drawing.Point(534, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 12);
this.label3.TabIndex = 5;
@ -446,7 +450,7 @@
//
// numberInput
//
this.numberInput.Location = new System.Drawing.Point(252, 21);
this.numberInput.Location = new System.Drawing.Point(388, 21);
this.numberInput.Name = "numberInput";
this.numberInput.Size = new System.Drawing.Size(120, 21);
this.numberInput.TabIndex = 4;
@ -454,7 +458,7 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(200, 24);
this.label2.Location = new System.Drawing.Point(336, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 3;
@ -463,7 +467,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 24);
this.label1.Location = new System.Drawing.Point(145, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 2;
@ -473,7 +477,7 @@
//
this.classSelector.DisplayMember = "Class";
this.classSelector.FormattingEnabled = true;
this.classSelector.Location = new System.Drawing.Point(56, 21);
this.classSelector.Location = new System.Drawing.Point(192, 21);
this.classSelector.Name = "classSelector";
this.classSelector.Size = new System.Drawing.Size(121, 20);
this.classSelector.TabIndex = 1;
@ -628,13 +632,6 @@
this.versionLabel.Size = new System.Drawing.Size(14, 17);
this.versionLabel.Text = "v";
//
// idCard
//
this.idCard.Location = new System.Drawing.Point(-1, 16);
this.idCard.Name = "idCard";
this.idCard.Size = new System.Drawing.Size(420, 200);
this.idCard.TabIndex = 8;
//
// StudentName
//
this.StudentName.DataPropertyName = "Name";
@ -723,6 +720,32 @@
this.StudentId.ReadOnly = true;
this.StudentId.Visible = false;
//
// idCard
//
this.idCard.Location = new System.Drawing.Point(-1, 16);
this.idCard.Name = "idCard";
this.idCard.Size = new System.Drawing.Size(420, 200);
this.idCard.TabIndex = 8;
//
// push
//
this.push.Location = new System.Drawing.Point(893, 19);
this.push.Name = "push";
this.push.Size = new System.Drawing.Size(75, 23);
this.push.TabIndex = 14;
this.push.Text = "上传";
this.push.UseVisualStyleBackColor = true;
//
// pull
//
this.pull.Location = new System.Drawing.Point(20, 18);
this.pull.Name = "pull";
this.pull.Size = new System.Drawing.Size(75, 23);
this.pull.TabIndex = 15;
this.pull.Text = "下载";
this.pull.UseVisualStyleBackColor = true;
this.pull.Click += new System.EventHandler(this.pull_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -819,5 +842,7 @@
private System.Windows.Forms.DataGridViewCheckBoxColumn HasChedked;
private System.Windows.Forms.DataGridViewCheckBoxColumn HasUploaded;
private System.Windows.Forms.DataGridViewTextBoxColumn StudentId;
private System.Windows.Forms.Button pull;
private System.Windows.Forms.Button push;
}
}

@ -21,7 +21,6 @@ namespace CameraCard
public partial class MainForm : Form
{
private ICameraHelper _cameraHelper = new OpenCvSharpCameraHelper();
private CVRHelper _cvrHelper = new CVRHelper();
public MainForm()
@ -178,36 +177,45 @@ namespace CameraCard
public static void LoadData(ProgressForm progress)
{
var url = ConfigurationManager.AppSettings["pull"];
var client = HttpClientFactory.Create();
var content = new StringContent(new JavaScriptSerializer().Serialize(new { userName = MainForm.User.UserName }), Encoding.UTF8, "application/json");
var response = client.PostAsync(url, content).Result;
var result = new JavaScriptSerializer().Deserialize<PullResponse>(response.Content.ReadAsStringAsync().Result);
if (result.code == 0)
try
{
using (var db = new MyDbContext())
var url = ConfigurationManager.AppSettings["pull"];
var client = HttpClientFactory.Create();
var content = new StringContent(new JavaScriptSerializer().Serialize(new { userName = MainForm.User.UserName }), Encoding.UTF8, "application/json");
var response = client.PostAsync(url, content).Result;
var result = new JavaScriptSerializer().Deserialize<PullResponse>(response.Content.ReadAsStringAsync().Result);
if (result.code == 0)
{
foreach (var item in result.data)
using (var db = new MyDbContext())
{
var entity = db.Students.FirstOrDefault(o => o.Id == item.Id);
if (entity == null)
{
entity = item;
db.Students.Add(entity);
progress?.SetProgress($"正在加载{entity.Name}", 50);
}
else
int i = 1;
foreach (var item in result.data)
{
progress?.SetProgress($"正在更新{entity.Name}", 50);
entity.Adapt(item);
var entity = db.Students.FirstOrDefault(o => o.Id == item.Id);
if (entity == null)
{
entity = item;
db.Students.Add(entity);
progress?.SetProgress($"正在加载{entity.Name}", i * 100 / result.data.Count);
}
else
{
progress?.SetProgress($"正在更新{entity.Name}", i * 100 / result.data.Count);
entity.Adapt(item);
}
db.SaveChanges();
i++;
}
db.SaveChanges();
}
}
else
{
MessageBox.Show($"错误代码:{result.code},错误消息:{result.message}");
}
}
else
catch (Exception ex)
{
MessageBox.Show($"错误代码:{result.code},错误消息:{result.message}");
MessageBox.Show(ex.Message);
}
}
@ -340,210 +348,192 @@ namespace CameraCard
{
if (e.TabPage.Text == "采集进度")
{
RefreshGroup();
this.RunWithLoading(RefreshGroup);
}
else if (e.TabPage.Text == "图像管理")
{
RefreshData();
this.RunWithLoading(RefreshData);
}
}
private void RefreshGroup()
{
this._progress = new ProgressForm("加载中", "正在统计,请稍候", 0, 100, 320, null, false);
Task.Run(() =>
using (var db = new MyDbContext())
{
this.Invoke(new Action(() =>
var list = db.Students.GroupBy(o => o.Class, (k, g) => new GroupData
{
using (var db = new MyDbContext())
Class = k,
Total = g.Count(),
HasImage = g.Sum(c => c.HasImage ? 1 : 0),
NotHasImage = g.Sum(c => c.HasImage ? 0 : 1),
HasUpload = g.Sum(c => c.HasUploaded ? 1 : 0),
NotHasUpload = g.Sum(c => c.HasUploaded ? 0 : 1),
HasChecked = g.Sum(c => c.HasChecked ? 1 : 0),
IsNotChecked = g.Sum(c => c.HasChecked ? 0 : 1),
Progress = g.Sum(c => c.HasUploaded ? 1 : 0) / (g.Count() * 1.0f)
})
.OrderBy(o => o.Class)
.ToList();
var total = new GroupData
{
Class = "合计",
Total = list.Sum(o => o.Total),
HasImage = list.Sum(o => o.HasImage),
NotHasImage = list.Sum(o => o.NotHasImage),
HasUpload = list.Sum(o => o.HasUpload),
NotHasUpload = list.Sum(o => o.NotHasUpload),
HasChecked = list.Sum(o => o.HasChecked),
IsNotChecked = list.Sum(o => o.HasChecked),
Progress = list.Sum(o => o.NotHasUpload) / (list.Sum(o => o.Total) * 1.0f)
};
list.Insert(0, total);
groupGrid.DataSource = list;
var headers = new string[] { "班级", "总人数", "已采集", "未采集", "已上传", "未上传", "已审核", "未审核", "完成进度" };
for (int i = 0; i < headers.Length; i++)
{
groupGrid.Columns[i].HeaderText = headers[i];
if (headers[i] == "完成进度")
{
this._progress.SetProgress("开始统计数据", 0);
var list = db.Students.GroupBy(o => o.Class, (k, g) => new GroupData
{
Class = k,
Total = g.Count(),
HasImage = g.Sum(c => c.HasImage ? 1 : 0),
NotHasImage = g.Sum(c => c.HasImage ? 0 : 1),
HasUpload = g.Sum(c => c.HasUploaded ? 1 : 0),
NotHasUpload = g.Sum(c => c.HasUploaded ? 0 : 1),
HasChecked = g.Sum(c => c.HasChecked ? 1 : 0),
IsNotChecked = g.Sum(c => c.HasChecked ? 0 : 1),
Progress = g.Sum(c => c.HasUploaded ? 1 : 0) / (g.Count() * 1.0f)
})
.OrderBy(o => o.Class)
.ToList();
this._progress.SetProgress("开始合计数据", 30);
var total = new GroupData
{
Class = "合计",
Total = list.Sum(o => o.Total),
HasImage = list.Sum(o => o.HasImage),
NotHasImage = list.Sum(o => o.NotHasImage),
HasUpload = list.Sum(o => o.HasUpload),
NotHasUpload = list.Sum(o => o.NotHasUpload),
HasChecked = list.Sum(o => o.HasChecked),
IsNotChecked = list.Sum(o => o.HasChecked),
Progress = list.Sum(o => o.NotHasUpload) / (list.Sum(o => o.Total) * 1.0f)
};
list.Insert(0, total);
groupGrid.DataSource = list;
this._progress.SetProgress("开始设置表头", 60);
var headers = new string[] { "班级", "总人数", "已采集", "未采集", "已上传", "未上传", "已审核", "未审核", "完成进度" };
for (int i = 0; i < headers.Length; i++)
{
groupGrid.Columns[i].HeaderText = headers[i];
if (headers[i] == "完成进度")
{
groupGrid.Columns[i].DefaultCellStyle.Format = "P0";
}
}
this._progress.SetProgress("加载完毕", 100);
groupGrid.Columns[i].DefaultCellStyle.Format = "P0";
}
}));
this._progress.CloseProgress();
this._progress = null;
});
this._progress.ShowDialog();
}
}
}
private void RefreshData()
{
this._progress = new ProgressForm("加载中", "正在读取,请稍候", 0, 100, 320, null, false);
Task.Run(() =>
var pageIndex = this.pageIndexSelector.SelectedValue == null ? 1 : Convert.ToInt32(this.pageIndexSelector.SelectedValue?.ToString());
var classValue = this.classSelector.SelectedValue == null ? "全部班级" : this.classSelector.SelectedValue.ToString();
using (var db = new MyDbContext())
{
this.Invoke(new Action(() =>
//pagesize
if (this.pageSizeSelector.DataSource == null)
{
this._progress.SetProgress("开始读取数据", 0);
var pageIndex = this.pageIndexSelector.SelectedValue == null ? 1 : Convert.ToInt32(this.pageIndexSelector.SelectedValue?.ToString());
var classValue = this.classSelector.SelectedValue == null ? "全部班级" : this.classSelector.SelectedValue.ToString();
using (var db = new MyDbContext())
this.pageSizeSelector.SelectedIndexChanged -= this.pageSizeSelector_SelectedIndexChanged;
this.pageSizeSelector.DataSource = new List<object> {
new { Value=20,Text="20条/页"},
new { Value=50,Text="50条/页"},
new { Value=100,Text="100条/页"}
};
this.pageSizeSelector.SelectedIndexChanged += this.pageSizeSelector_SelectedIndexChanged;
}
//class
if (this.classSelector.DataSource == null)
{
this.classSelector.SelectedIndexChanged -= this.classSelector_SelectedIndexChanged;
var classList = db.Students.Select(o => new { o.Class }).Distinct().OrderBy(o => o.Class).ToList();
classList.Insert(0, new { Class = "全部班级" });
this.classSelector.DataSource = classList;
this.classSelector.SelectedValue = classValue;
this.classSelector.SelectedIndexChanged += this.classSelector_SelectedIndexChanged;
}
//search
var query = db.Set<Student>().AsQueryable();
if (classValue != "全部班级")
{
query = query.Where(o => o.Class == classValue);
}
var total = query.Count();
this.totalValue.Text = $"共{total}条";
var pageSize = (int)this.pageSizeSelector.SelectedValue;
var paged = new PagedList(pageSize);
paged.TotalCount = total;
var pageCount = paged.PageCount();
pageIndex = pageIndex > pageCount ? 1 : pageIndex;
this.totalPageValue.Text = $"共{pageCount}页";
if (this.dataGrid.Rows.Count > 0)
{
foreach (DataGridViewRow row in this.dataGrid.Rows)
{
//pagesize
if (this.pageSizeSelector.DataSource == null)
{
this.pageSizeSelector.DataSource = new List<object> {
new { Value=20,Text="20条/页"},
new { Value=50,Text="50条/页"},
new { Value=100,Text="100条/页"}
};
}
//class
if (this.classSelector.DataSource == null)
{
var classList = db.Students.Select(o => new { o.Class }).Distinct().OrderBy(o => o.Class).ToList();
classList.Insert(0, new { Class = "全部班级" });
this.classSelector.DataSource = classList;
this.classSelector.SelectedValue = classValue;
}
//search
var query = db.Set<Student>().AsQueryable();
if (classValue != "全部班级")
{
query = query.Where(o => o.Class == classValue);
}
var total = query.Count();
this.totalValue.Text = $"共{total}条";
var pageSize = (int)this.pageSizeSelector.SelectedValue;
var paged = new PagedList(pageSize);
paged.TotalCount = total;
var pageCount = paged.PageCount();
pageIndex = pageIndex > pageCount ? 1 : pageIndex;
this.totalPageValue.Text = $"共{pageCount}页";
if (this.dataGrid.Rows.Count > 0)
{
foreach (DataGridViewRow row in this.dataGrid.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (this.dataGrid.Columns[cell.ColumnIndex].Name == "图像")
{
(cell.Value as Image).Dispose();
}
}
}
}
this.dataGrid.DataSource = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
var pageList = new List<object>();
for (int i = 0; i < paged.PageCount(); i++)
{
pageList.Add(new { Value = i + 1, Text = $"第{i + 1}页" });
}
this.pageIndexSelector.DataSource = pageList;
this.pageIndexSelector.SelectedValue = pageIndex;
this.pageMenu.Controls.Clear();
paged.PageIndex = pageIndex;
if (paged.HasPrev())
{
this.pageMenu.Controls.Add(new Button { Text = "<", Width = 30, Tag = pageIndex - 1 });
}
foreach (var item in paged.GetPageIndexs())
foreach (DataGridViewCell cell in row.Cells)
{
var button = new Button { Text = item.ToString(), Width = 30, Tag = item };
if (item == pageIndex)
if (this.dataGrid.Columns[cell.ColumnIndex].Name == "图像")
{
button.ForeColor = Color.Red;
(cell.Value as Image).Dispose();
}
this.pageMenu.Controls.Add(button);
}
if (paged.HasNext())
{
this.pageMenu.Controls.Add(new Button { Text = ">", Width = 30, Tag = pageIndex + 1 });
}
foreach (var item in this.pageMenu.Controls)
}
}
this.dataGrid.DataSource = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
var pageList = new List<object>();
for (int i = 0; i < paged.PageCount(); i++)
{
pageList.Add(new { Value = i + 1, Text = $"第{i + 1}页" });
}
this.pageIndexSelector.SelectedIndexChanged -= this.pageIndexSelector_SelectedIndexChanged;
this.pageIndexSelector.DataSource = pageList;
this.pageIndexSelector.SelectedValue = pageIndex;
this.pageIndexSelector.SelectedIndexChanged += this.pageIndexSelector_SelectedIndexChanged;
this.pageMenu.Controls.Clear();
paged.PageIndex = pageIndex;
if (paged.HasPrev())
{
this.pageMenu.Controls.Add(new Button { Text = "<", Width = 30, Tag = pageIndex - 1 });
}
foreach (var item in paged.GetPageIndexs())
{
var button = new Button { Text = item.ToString(), Width = 30, Tag = item };
if (item == pageIndex)
{
button.ForeColor = Color.Red;
}
this.pageMenu.Controls.Add(button);
}
if (paged.HasNext())
{
this.pageMenu.Controls.Add(new Button { Text = ">", Width = 30, Tag = pageIndex + 1 });
}
foreach (var item in this.pageMenu.Controls)
{
(item as Button).Click += (s, e) =>
{
if (this._progress == null)
{
(item as Button).Click += (s, e) =>
{
if (this._progress == null)
{
this.pageIndexSelector.SelectedValue = Convert.ToInt32((s as Button).Tag);
}
};
this.pageIndexSelector.SelectedValue = Convert.ToInt32((s as Button).Tag);
}
//header
//var dataGridHeaders = new string[] { "姓名", "性别", "民族", "身份证号", "班级", "考籍号", "图像", "已采集", "相片已审核", "已上传", "身份证已验证" };
//for (int i = 0; i < dataGridHeaders.Length; i++)
//{
// dataGrid.Columns[i].HeaderText = dataGridHeaders[i];
//}
this._progress.SetProgress("加载完毕", 100);
}
this._progress.CloseProgress();
this._progress = null;
}));
});
this._progress.ShowDialog();
};
}
}
}
private void pageIndexSelector_SelectedIndexChanged(object sender, EventArgs e)
{
if (this._progress == null)
{
this.RefreshData();
}
this.RunWithLoading(RefreshData);
}
private void classSelector_SelectedIndexChanged(object sender, EventArgs e)
{
if (this._progress == null)
{
this.RefreshData();
}
this.RunWithLoading(RefreshData);
}
private void pageSizeSelector_SelectedIndexChanged(object sender, EventArgs e)
{
if (this._progress == null)
{
this.RefreshData();
}
this.RunWithLoading(RefreshData);
}
private void searchBtn_Click(object sender, EventArgs e)
{
if (this._progress == null)
this.RunWithLoading(RefreshData);
}
private void pull_Click(object sender, EventArgs e)
{
var progress = new ProgressForm("更新中", "正在下载数据", 0, 100);
this.Run(() => progress.ShowDialog());
Task.Run(() =>
{
this.RefreshData();
}
try
{
MainForm.LoadData(progress);
progress.CloseForm();
this.RunWithLoading(RefreshData);
}
catch (Exception ex)
{
progress.CloseForm();
MessageBox.Show(ex.Message);
}
});
}
}
}

@ -32,17 +32,9 @@ namespace CameraCard
this.Invoke(new Action(() =>
{
this.status.Text = label;
this.progressBar.Value = progress;
this.progressBar.Value = progress < this.progressBar.Maximum ? progress : this.progressBar.Maximum;
}));
}
}
public void CloseProgress()
{
this.Invoke(new Action(() =>
{
this.Close();
}));
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

@ -40,14 +40,15 @@ namespace WebApi.Controllers
var list = new List<Student>();
for (int i = 0; i < 222; i++)
{
list.Add(new Student {
Id = Guid.NewGuid().ToString(),
Name = $"小明{i+1}",
Class = $"{i%10+1}班",
list.Add(new Student
{
Id = i.ToString(),
Name = $"小明{i + 1}",
Class = $"{i % 10 + 1}班",
Sex = "男",
Nation = "汉",
IdCardNo = $"01234567891234{i+1}",
Number = $"01234567891234{i+1}"
IdCardNo = $"01234567891234{i + 1}",
Number = $"01234567891234{i + 1}"
});
}
return new ApiResponse

Loading…
Cancel
Save