From f5a76a7e43c009af26aab0d57f09b56bafd19f7d Mon Sep 17 00:00:00 2001 From: dathlin Date: Sun, 24 Sep 2017 12:42:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E9=9B=86=E4=B8=AD=E5=A4=84=E7=90=86=E7=B3=BB=E7=BB=9F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=AE=8C=E6=88=90=E4=BF=A1?= =?UTF-8?q?=E4=BB=BB=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=88=97=E8=A1=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8Cv1.4.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountSupport/FormAccountDetails.cs | 1 + .../AccountSupport/FormRegisterAccount.cs | 1 + .../BasicSupport/FormDownloading.cs | 3 + ClientsLibrary/ClientsLibrary.csproj | 18 ++ .../ClientConfiguration.Designer.cs | 175 ++++++++++++++++++ .../Configuration/ClientConfiguration.cs | 96 ++++++++++ .../Configuration/ClientConfiguration.resx | 120 ++++++++++++ .../FormConfiguration.Designer.cs | 31 +++- .../Configuration/FormConfiguration.cs | 59 +++++- .../GeneralConfiguration.Designer.cs | 97 ++++++++++ .../Configuration/GeneralConfiguration.cs | 58 ++++++ .../Configuration/GeneralConfiguration.resx | 120 ++++++++++++ .../ListConfiguration.Designer.cs | 20 +- .../Configuration/ListConfiguration.cs | 52 ++++-- .../Configuration/ListConfiguration.resx | 3 - ClientsLibrary/LogsSupport/FormLogView.cs | 3 + .../SoftUpdateSupport/FormUpdateRemote.cs | 2 + ClientsLibrary/UserClient.cs | 7 + CommonLibrary/BasicSupport/SoftSettings.cs | 6 + .../ProtocolSupport/CommonProtocol.cs | 2 +- CommonLibrary/ProtocolSupport/CustomerCode.cs | 9 +- 软件系统客户端Wpf/MainWindow.xaml | 2 +- 软件系统客户端Wpf/MainWindow.xaml.cs | 18 +- 软件系统客户端模版/FormMainWindow.Designer.cs | 32 ++-- 软件系统客户端模版/FormMainWindow.cs | 20 +- 软件系统服务端模版/FormServerWindow.cs | 59 +++++- 26 files changed, 940 insertions(+), 74 deletions(-) create mode 100644 ClientsLibrary/Configuration/ClientConfiguration.Designer.cs create mode 100644 ClientsLibrary/Configuration/ClientConfiguration.cs create mode 100644 ClientsLibrary/Configuration/ClientConfiguration.resx create mode 100644 ClientsLibrary/Configuration/GeneralConfiguration.Designer.cs create mode 100644 ClientsLibrary/Configuration/GeneralConfiguration.cs create mode 100644 ClientsLibrary/Configuration/GeneralConfiguration.resx diff --git a/ClientsLibrary/AccountSupport/FormAccountDetails.cs b/ClientsLibrary/AccountSupport/FormAccountDetails.cs index b13d568..874e8cf 100644 --- a/ClientsLibrary/AccountSupport/FormAccountDetails.cs +++ b/ClientsLibrary/AccountSupport/FormAccountDetails.cs @@ -23,6 +23,7 @@ namespace ClientsLibrary public FormAccountDetails(UserPortrait userPortrait) { InitializeComponent(); + Icon = UserClient.GetFormWindowIcon(); UserPortrait = userPortrait; } diff --git a/ClientsLibrary/AccountSupport/FormRegisterAccount.cs b/ClientsLibrary/AccountSupport/FormRegisterAccount.cs index 5659ada..06e297d 100644 --- a/ClientsLibrary/AccountSupport/FormRegisterAccount.cs +++ b/ClientsLibrary/AccountSupport/FormRegisterAccount.cs @@ -22,6 +22,7 @@ namespace ClientsLibrary public FormRegisterAccount(string[] factories) { InitializeComponent(); + Icon = UserClient.GetFormWindowIcon(); net_client = UserClient.Net_simplify_client; Factories = new List(factories); diff --git a/ClientsLibrary/BasicSupport/FormDownloading.cs b/ClientsLibrary/BasicSupport/FormDownloading.cs index bad49eb..625f530 100644 --- a/ClientsLibrary/BasicSupport/FormDownloading.cs +++ b/ClientsLibrary/BasicSupport/FormDownloading.cs @@ -25,6 +25,9 @@ namespace ClientsLibrary public FormDownloading(int customer,Action action) { InitializeComponent(); + + Icon = UserClient.GetFormWindowIcon(); + net_cmd = customer; DealWithResult = action; DoubleBuffered = true; diff --git a/ClientsLibrary/ClientsLibrary.csproj b/ClientsLibrary/ClientsLibrary.csproj index 953a68d..6830405 100644 --- a/ClientsLibrary/ClientsLibrary.csproj +++ b/ClientsLibrary/ClientsLibrary.csproj @@ -68,6 +68,18 @@ FormShowMachineId.cs + + UserControl + + + ClientConfiguration.cs + + + UserControl + + + GeneralConfiguration.cs + UserControl @@ -117,6 +129,12 @@ FormShowMachineId.cs + + ClientConfiguration.cs + + + GeneralConfiguration.cs + ListConfiguration.cs diff --git a/ClientsLibrary/Configuration/ClientConfiguration.Designer.cs b/ClientsLibrary/Configuration/ClientConfiguration.Designer.cs new file mode 100644 index 0000000..71a81d5 --- /dev/null +++ b/ClientsLibrary/Configuration/ClientConfiguration.Designer.cs @@ -0,0 +1,175 @@ +namespace ClientsLibrary.Configuration +{ + partial class ClientConfiguration + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.userButton_delete = new HslCommunication.Controls.UserButton(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.userButton1 = new HslCommunication.Controls.UserButton(); + this.userButton2 = new HslCommunication.Controls.UserButton(); + this.userButton3 = new HslCommunication.Controls.UserButton(); + this.SuspendLayout(); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(3, 3); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(183, 21); + this.checkBox1.TabIndex = 0; + this.checkBox1.Text = "是否强制启用指定客户端登录"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34))))); + this.label1.Location = new System.Drawing.Point(0, 31); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(92, 17); + this.label1.TabIndex = 1; + this.label1.Text = "允许登录列表:"; + // + // listBox1 + // + this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 17; + this.listBox1.Location = new System.Drawing.Point(3, 51); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(435, 327); + this.listBox1.TabIndex = 2; + // + // userButton_delete + // + this.userButton_delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.userButton_delete.BackColor = System.Drawing.Color.Transparent; + this.userButton_delete.CustomerInformation = ""; + this.userButton_delete.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton_delete.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton_delete.Location = new System.Drawing.Point(444, 51); + this.userButton_delete.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton_delete.Name = "userButton_delete"; + this.userButton_delete.Size = new System.Drawing.Size(111, 27); + this.userButton_delete.TabIndex = 9; + this.userButton_delete.UIText = "删除选中项"; + this.userButton_delete.Click += new System.EventHandler(this.userButton_delete_Click); + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.Location = new System.Drawing.Point(3, 391); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(435, 23); + this.textBox1.TabIndex = 10; + // + // userButton1 + // + this.userButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.userButton1.BackColor = System.Drawing.Color.Transparent; + this.userButton1.CustomerInformation = ""; + this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton1.Location = new System.Drawing.Point(444, 389); + this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton1.Name = "userButton1"; + this.userButton1.Size = new System.Drawing.Size(111, 27); + this.userButton1.TabIndex = 11; + this.userButton1.UIText = "添加客户端标识"; + this.userButton1.Click += new System.EventHandler(this.userButton1_Click); + // + // userButton2 + // + this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.userButton2.BackColor = System.Drawing.Color.Transparent; + this.userButton2.CustomerInformation = ""; + this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton2.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton2.Location = new System.Drawing.Point(444, 354); + this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton2.Name = "userButton2"; + this.userButton2.Size = new System.Drawing.Size(111, 27); + this.userButton2.TabIndex = 12; + this.userButton2.UIText = "获取本机标识"; + this.userButton2.Click += new System.EventHandler(this.userButton2_Click); + // + // userButton3 + // + this.userButton3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.userButton3.BackColor = System.Drawing.Color.Transparent; + this.userButton3.CustomerInformation = ""; + this.userButton3.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton3.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton3.Location = new System.Drawing.Point(444, 434); + this.userButton3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton3.Name = "userButton3"; + this.userButton3.Size = new System.Drawing.Size(111, 27); + this.userButton3.TabIndex = 13; + this.userButton3.UIText = "保存"; + this.userButton3.Click += new System.EventHandler(this.userButton3_Click); + // + // ClientConfiguration + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.userButton3); + this.Controls.Add(this.userButton2); + this.Controls.Add(this.userButton1); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.userButton_delete); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.label1); + this.Controls.Add(this.checkBox1); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "ClientConfiguration"; + this.Size = new System.Drawing.Size(558, 465); + this.Load += new System.EventHandler(this.ClientConfiguration_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListBox listBox1; + private HslCommunication.Controls.UserButton userButton_delete; + private System.Windows.Forms.TextBox textBox1; + private HslCommunication.Controls.UserButton userButton1; + private HslCommunication.Controls.UserButton userButton2; + private HslCommunication.Controls.UserButton userButton3; + } +} diff --git a/ClientsLibrary/Configuration/ClientConfiguration.cs b/ClientsLibrary/Configuration/ClientConfiguration.cs new file mode 100644 index 0000000..9c7940d --- /dev/null +++ b/ClientsLibrary/Configuration/ClientConfiguration.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Newtonsoft.Json.Linq; +using HslCommunication; + +namespace ClientsLibrary.Configuration +{ + public partial class ClientConfiguration : UserControl + { + public ClientConfiguration() + { + InitializeComponent(); + } + + private void userButton_delete_Click(object sender, EventArgs e) + { + if(listBox1.SelectedItem!=null) + { + listBox1.Items.Remove(listBox1.SelectedItem); + } + } + + private void userButton2_Click(object sender, EventArgs e) + { + textBox1.Text = UserClient.JsonSettings.SystemInfo; + } + + private void userButton1_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBox1.Text)) return; + + if(!listBox1.Items.Contains(textBox1.Text)) + { + listBox1.Items.Add(textBox1.Text); + } + } + + private void ClientConfiguration_Load(object sender, EventArgs e) + { + // 初始化 + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求信任客户端, ""); + if(result.IsSuccess) + { + JObject json=JObject.Parse(result.Content); + checkBox1.Checked = json["TrustEnable"].ToObject(); + string[] data = json["TrustList"].ToObject(); + foreach(var m in data) + { + listBox1.Items.Add(m); + } + } + else + { + MessageBox.Show("请求服务器失败,请稍后重试!"); + userButton3.Enabled = false; + } + } + + private void userButton3_Click(object sender, EventArgs e) + { + List list = new List(); + foreach(var m in listBox1.Items) + { + if(!string.IsNullOrEmpty(m.ToString())) + { + list.Add(m.ToString()); + } + } + + JObject json = new JObject + { + { "TrustEnable", new JValue(checkBox1.Checked) }, + { "TrustList", new JArray(list.ToArray()) } + }; + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer( + CommonLibrary.CommonHeadCode.SimplifyHeadCode.上传信任客户端, json.ToString()); + + if(result.IsSuccess) + { + MessageBox.Show("上传成功!"); + } + else + { + MessageBox.Show("上传失败!"); + } + } + } +} diff --git a/ClientsLibrary/Configuration/ClientConfiguration.resx b/ClientsLibrary/Configuration/ClientConfiguration.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ClientsLibrary/Configuration/ClientConfiguration.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ClientsLibrary/Configuration/FormConfiguration.Designer.cs b/ClientsLibrary/Configuration/FormConfiguration.Designer.cs index c7a9f24..3a3abbc 100644 --- a/ClientsLibrary/Configuration/FormConfiguration.Designer.cs +++ b/ClientsLibrary/Configuration/FormConfiguration.Designer.cs @@ -28,25 +28,48 @@ /// private void InitializeComponent() { + System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("系统相关"); + this.panel1 = new System.Windows.Forms.Panel(); this.treeView1 = new System.Windows.Forms.TreeView(); this.SuspendLayout(); // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Location = new System.Drawing.Point(232, 12); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(573, 525); + this.panel1.TabIndex = 1; + // // treeView1 // + this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.treeView1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.treeView1.Location = new System.Drawing.Point(12, 12); this.treeView1.Name = "treeView1"; - this.treeView1.Size = new System.Drawing.Size(199, 507); - this.treeView1.TabIndex = 0; + treeNode1.Name = "System"; + treeNode1.Text = "系统相关"; + this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { + treeNode1}); + this.treeView1.ShowLines = false; + this.treeView1.Size = new System.Drawing.Size(199, 525); + this.treeView1.TabIndex = 2; // // FormConfiguration // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(801, 533); + this.ClientSize = new System.Drawing.Size(812, 549); this.Controls.Add(this.treeView1); + this.Controls.Add(this.panel1); this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.MaximizeBox = false; this.Name = "FormConfiguration"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "FormConfiguration"; this.Load += new System.EventHandler(this.FormConfiguration_Load); this.ResumeLayout(false); @@ -54,7 +77,7 @@ } #endregion - + private System.Windows.Forms.Panel panel1; private System.Windows.Forms.TreeView treeView1; } } \ No newline at end of file diff --git a/ClientsLibrary/Configuration/FormConfiguration.cs b/ClientsLibrary/Configuration/FormConfiguration.cs index 832ad42..c396e3e 100644 --- a/ClientsLibrary/Configuration/FormConfiguration.cs +++ b/ClientsLibrary/Configuration/FormConfiguration.cs @@ -1,4 +1,5 @@ -using System; +using ClientsLibrary.Configuration; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -14,6 +15,7 @@ namespace ClientsLibrary public FormConfiguration() { InitializeComponent(); + Icon = UserClient.GetFormWindowIcon(); } @@ -21,16 +23,63 @@ namespace ClientsLibrary { Text = "配置系统的参数"; - treeView1.ShowRootLines = false; - treeView1.Nodes.Clear(); + treeView1.AfterSelect += TreeView1_AfterSelect; + TreeNode treeNodeSystem = treeView1.Nodes[0]; - TreeNode root = new TreeNode("配置系统数据"); + treeNodeSystem.Nodes.Add("General", "常规配置"); + treeNodeSystem.Nodes.Add("Factory", "配置分厂信息"); + treeNodeSystem.Nodes.Add("Client", "客户端信任功能"); + treeNodeSystem.Expand(); + } + + private void TreeView1_AfterSelect(object sender, TreeViewEventArgs e) + { + if (e.Node.Name == "System") return; + + if (m_Current != null) + { + if (m_Current.Tag.ToString() == e.Node.Name) + { + return; + } + } + m_Current?.Dispose(); + UserControl control; - treeView1.Nodes.Add(root); + if (e.Node.Name == "General") + { + control = new GeneralConfiguration(); + } + else if (e.Node.Name == "Factory") + { + control = new ArrayConfiguration( + CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求分厂, + CommonLibrary.CommonHeadCode.SimplifyHeadCode.上传分厂, + e.Node.Text); + } + else if(e.Node.Name == "Client") + { + control = new ClientConfiguration(); + } + else + { + control = new UserControl(); + } + + + + control.Width = panel1.Width; + control.Height = panel1.Height; + control.Location = new Point(0, 0); + control.Parent = panel1; + control.Tag = e.Node.Name; + m_Current = control; } + + private UserControl m_Current = null; } } diff --git a/ClientsLibrary/Configuration/GeneralConfiguration.Designer.cs b/ClientsLibrary/Configuration/GeneralConfiguration.Designer.cs new file mode 100644 index 0000000..27c0cf8 --- /dev/null +++ b/ClientsLibrary/Configuration/GeneralConfiguration.Designer.cs @@ -0,0 +1,97 @@ +namespace ClientsLibrary.Configuration +{ + partial class GeneralConfiguration + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.userButton2 = new HslCommunication.Controls.UserButton(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(3, 3); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(247, 21); + this.checkBox1.TabIndex = 0; + this.checkBox1.Text = "是否允许一个账户重复登录 (admin 除外)"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.AutoScroll = true; + this.panel1.Controls.Add(this.checkBox1); + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(561, 391); + this.panel1.TabIndex = 1; + // + // userButton2 + // + this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.userButton2.BackColor = System.Drawing.Color.Transparent; + this.userButton2.CustomerInformation = ""; + this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton2.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton2.Location = new System.Drawing.Point(503, 398); + this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton2.Name = "userButton2"; + this.userButton2.Size = new System.Drawing.Size(55, 27); + this.userButton2.TabIndex = 10; + this.userButton2.UIText = "保存"; + this.userButton2.Click += new System.EventHandler(this.userButton2_Click); + // + // GeneralConfiguration + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.userButton2); + this.Controls.Add(this.panel1); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "GeneralConfiguration"; + this.Size = new System.Drawing.Size(561, 433); + this.Load += new System.EventHandler(this.GeneralConfiguration_Load); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Panel panel1; + private HslCommunication.Controls.UserButton userButton2; + } +} diff --git a/ClientsLibrary/Configuration/GeneralConfiguration.cs b/ClientsLibrary/Configuration/GeneralConfiguration.cs new file mode 100644 index 0000000..2358b19 --- /dev/null +++ b/ClientsLibrary/Configuration/GeneralConfiguration.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using HslCommunication; +using Newtonsoft.Json.Linq; + +namespace ClientsLibrary.Configuration +{ + public partial class GeneralConfiguration : UserControl + { + public GeneralConfiguration() + { + InitializeComponent(); + } + + private void GeneralConfiguration_Load(object sender, EventArgs e) + { + // 初始化 + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求信任客户端, ""); + if (result.IsSuccess) + { + JObject json = JObject.Parse(result.Content); + checkBox1.Checked = HslCommunication.BasicFramework.SoftBasic.GetValueFromJsonObject(json, "AllowUserMulti", false); + } + else + { + MessageBox.Show("请求服务器失败,请稍后重试!"); + userButton2.Enabled = false; + } + } + + private void userButton2_Click(object sender, EventArgs e) + { + JObject json = new JObject + { + { "AllowUserMulti", new JValue(checkBox1.Checked) }, + }; + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer( + CommonLibrary.CommonHeadCode.SimplifyHeadCode.上传信任客户端, json.ToString()); + + if (result.IsSuccess) + { + MessageBox.Show("上传成功!"); + } + else + { + MessageBox.Show("上传失败!"); + } + } + } +} diff --git a/ClientsLibrary/Configuration/GeneralConfiguration.resx b/ClientsLibrary/Configuration/GeneralConfiguration.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ClientsLibrary/Configuration/GeneralConfiguration.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ClientsLibrary/Configuration/ListConfiguration.Designer.cs b/ClientsLibrary/Configuration/ListConfiguration.Designer.cs index 4813d53..a2f10b5 100644 --- a/ClientsLibrary/Configuration/ListConfiguration.Designer.cs +++ b/ClientsLibrary/Configuration/ListConfiguration.Designer.cs @@ -1,6 +1,6 @@ -namespace ClientsLibrary +namespace ClientsLibrary.Configuration { - partial class FactoryConfiguration + partial class ArrayConfiguration { /// /// 必需的设计器变量。 @@ -40,6 +40,9 @@ // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView1.BackgroundColor = System.Drawing.Color.White; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -48,7 +51,7 @@ this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView1.Size = new System.Drawing.Size(509, 404); + this.dataGridView1.Size = new System.Drawing.Size(500, 408); this.dataGridView1.TabIndex = 0; // // Factory @@ -59,11 +62,12 @@ // // userButton_login // + this.userButton_login.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.userButton_login.BackColor = System.Drawing.Color.Transparent; this.userButton_login.CustomerInformation = ""; this.userButton_login.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); this.userButton_login.Font = new System.Drawing.Font("微软雅黑", 9F); - this.userButton_login.Location = new System.Drawing.Point(3, 411); + this.userButton_login.Location = new System.Drawing.Point(3, 415); this.userButton_login.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton_login.Name = "userButton_login"; this.userButton_login.Size = new System.Drawing.Size(55, 27); @@ -73,11 +77,12 @@ // // userButton1 // + this.userButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.userButton1.BackColor = System.Drawing.Color.Transparent; this.userButton1.CustomerInformation = ""; this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F); - this.userButton1.Location = new System.Drawing.Point(64, 411); + this.userButton1.Location = new System.Drawing.Point(64, 415); this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton1.Name = "userButton1"; this.userButton1.Size = new System.Drawing.Size(55, 27); @@ -87,11 +92,12 @@ // // userButton2 // + this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.userButton2.BackColor = System.Drawing.Color.Transparent; this.userButton2.CustomerInformation = ""; this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); this.userButton2.Font = new System.Drawing.Font("微软雅黑", 9F); - this.userButton2.Location = new System.Drawing.Point(451, 411); + this.userButton2.Location = new System.Drawing.Point(442, 415); this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton2.Name = "userButton2"; this.userButton2.Size = new System.Drawing.Size(55, 27); @@ -110,7 +116,7 @@ this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FactoryConfiguration"; - this.Size = new System.Drawing.Size(509, 442); + this.Size = new System.Drawing.Size(500, 446); this.Load += new System.EventHandler(this.FactoryConfiguration_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); diff --git a/ClientsLibrary/Configuration/ListConfiguration.cs b/ClientsLibrary/Configuration/ListConfiguration.cs index 1e3c653..c10379e 100644 --- a/ClientsLibrary/Configuration/ListConfiguration.cs +++ b/ClientsLibrary/Configuration/ListConfiguration.cs @@ -6,21 +6,31 @@ using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; +using HslCommunication; -namespace ClientsLibrary +namespace ClientsLibrary.Configuration { - public partial class FactoryConfiguration : UserControl + public partial class ArrayConfiguration : UserControl { - public FactoryConfiguration(int download,int upload,string headText) + #region Constructor + + + public ArrayConfiguration(int download, int upload, string headText) { InitializeComponent(); - Download = download; - Upload = upload; - HeadText = headText; + SetInfomation(download, upload, headText); + } - + public ArrayConfiguration() + { + InitializeComponent(); + + } + + #endregion + #region Private Member private int Download = 0; @@ -29,13 +39,19 @@ namespace ClientsLibrary #endregion + public void SetInfomation(int download, int upload, string headText) + { + Download = download; + Upload = upload; + HeadText = headText; + } private void FactoryConfiguration_Load(object sender, EventArgs e) { dataGridView1.Columns[0].HeaderText = HeadText; - HslCommunication.OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Download, ""); + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Download, ""); if (result.IsSuccess) { @@ -50,6 +66,7 @@ namespace ClientsLibrary else { MessageBox.Show(result.Message); + userButton2.Enabled = false; } } @@ -63,22 +80,35 @@ namespace ClientsLibrary { if (dataGridView1.SelectedRows != null) { - dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]); + if (dataGridView1.Rows.Count > 0) + { + dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]); + } } } private void userButton2_Click(object sender, EventArgs e) { List data = new List(); - for(int i=0;i True - - True - \ No newline at end of file diff --git a/ClientsLibrary/LogsSupport/FormLogView.cs b/ClientsLibrary/LogsSupport/FormLogView.cs index 3cdf83f..acc7241 100644 --- a/ClientsLibrary/LogsSupport/FormLogView.cs +++ b/ClientsLibrary/LogsSupport/FormLogView.cs @@ -17,6 +17,9 @@ namespace ClientsLibrary public FormLogView() { InitializeComponent(); + + Icon = UserClient.GetFormWindowIcon(); + net_simplify_client = UserClient.Net_simplify_client; } diff --git a/ClientsLibrary/SoftUpdateSupport/FormUpdateRemote.cs b/ClientsLibrary/SoftUpdateSupport/FormUpdateRemote.cs index 357dcba..42dd894 100644 --- a/ClientsLibrary/SoftUpdateSupport/FormUpdateRemote.cs +++ b/ClientsLibrary/SoftUpdateSupport/FormUpdateRemote.cs @@ -27,6 +27,8 @@ namespace ClientsLibrary public FormUpdateRemote() { InitializeComponent(); + + Icon = UserClient.GetFormWindowIcon(); } private void userButton_file_Click(object sender, EventArgs e) diff --git a/ClientsLibrary/UserClient.cs b/ClientsLibrary/UserClient.cs index aaa71ee..ec465b6 100644 --- a/ClientsLibrary/UserClient.cs +++ b/ClientsLibrary/UserClient.cs @@ -6,6 +6,8 @@ using HslCommunication.Enthernet; using HslCommunication.BasicFramework; using CommonLibrary; using System.Net; +using System.Drawing; +using System.Windows.Forms; namespace ClientsLibrary { @@ -134,5 +136,10 @@ namespace ClientsLibrary Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.异常消息, info); } } + + public static Icon GetFormWindowIcon() + { + return Icon.ExtractAssociatedIcon(Application.ExecutablePath); + } } } diff --git a/CommonLibrary/BasicSupport/SoftSettings.cs b/CommonLibrary/BasicSupport/SoftSettings.cs index 15ebfc0..b965dcc 100644 --- a/CommonLibrary/BasicSupport/SoftSettings.cs +++ b/CommonLibrary/BasicSupport/SoftSettings.cs @@ -54,6 +54,10 @@ namespace CommonLibrary /// public bool Can_Account_Login { get; set; } = true; /// + /// 是否允许一个用户名重复登录系统 + /// + public bool AllowUserMultiOnline { get; set; } = false; + /// /// 不允许登录系统的原因 /// public string Account_Forbidden_Reason { get; set; } = "系统处于维护中,请稍后登录。"; @@ -149,6 +153,7 @@ namespace CommonLibrary { nameof(SystemVersion), new JValue(SystemVersion.ToString()) }, { nameof(Announcement), new JValue(Announcement) }, { nameof(Can_Account_Login), new JValue(Can_Account_Login) }, + { nameof(AllowUserMultiOnline),new JValue(AllowUserMultiOnline) }, { nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) }, { nameof(SystemFactories), new JArray(SystemFactories) }, { nameof(WhetherToEnableTrustedClientAuthentication),new JValue(WhetherToEnableTrustedClientAuthentication) }, @@ -166,6 +171,7 @@ namespace CommonLibrary SystemVersion = new SystemVersion(SoftBasic.GetValueFromJsonObject(json, nameof(SystemVersion), "1.0.0")); Announcement = SoftBasic.GetValueFromJsonObject(json, nameof(Announcement), Announcement); Can_Account_Login = SoftBasic.GetValueFromJsonObject(json, nameof(Can_Account_Login), Can_Account_Login); + AllowUserMultiOnline = SoftBasic.GetValueFromJsonObject(json, nameof(AllowUserMultiOnline), AllowUserMultiOnline); Account_Forbidden_Reason = SoftBasic.GetValueFromJsonObject(json, nameof(Account_Forbidden_Reason), Account_Forbidden_Reason); if (json[nameof(SystemFactories)] != null) diff --git a/CommonLibrary/ProtocolSupport/CommonProtocol.cs b/CommonLibrary/ProtocolSupport/CommonProtocol.cs index 362079e..03364d8 100644 --- a/CommonLibrary/ProtocolSupport/CommonProtocol.cs +++ b/CommonLibrary/ProtocolSupport/CommonProtocol.cs @@ -43,7 +43,7 @@ namespace CommonLibrary * **************************************************************************/ - SoftBasic.FrameworkVersion = new SystemVersion("1.4.6"); + SoftBasic.FrameworkVersion = new SystemVersion("1.4.7"); } diff --git a/CommonLibrary/ProtocolSupport/CustomerCode.cs b/CommonLibrary/ProtocolSupport/CustomerCode.cs index e23b4a0..d9e6d5e 100644 --- a/CommonLibrary/ProtocolSupport/CustomerCode.cs +++ b/CommonLibrary/ProtocolSupport/CustomerCode.cs @@ -13,7 +13,7 @@ namespace CommonLibrary * * 关于 NetHandle: * 一个数据结构值,无论实际数据还是用法上等同于int,可以和int数据无缝的转化 - * 将4个字节的int数据拆分成了三个属性,一个ushort和两个byte,可以分别访问 + * 本质上将4个字节的int数据拆分成了三个属性,一个ushort和两个byte,可以分别访问 * * 2个低字节 第二高字节 最高的字节 * [byte1][byte2] [byte3] [byte4] @@ -61,17 +61,20 @@ namespace CommonLibrary public static NetHandle 上传头像MD5 { get; } = new NetHandle(1, 1, 00016); public static NetHandle 请求分厂 { get; } = new NetHandle(1, 1, 00017); public static NetHandle 上传分厂 { get; } = new NetHandle(1, 1, 00018); + public static NetHandle 请求信任客户端 { get; } = new NetHandle(1, 1, 00019); + public static NetHandle 上传信任客户端 { get; } = new NetHandle(1, 1, 00020); + public static NetHandle 请求一般配置 { get; } = new NetHandle(1, 1, 00021); + public static NetHandle 上传一般配置 { get; } = new NetHandle(1, 1, 00022); - /******************************************************************************************* * * 1.2.* 的指令为日志的请求与查看相关 * *******************************************************************************************/ - + public static NetHandle 网络日志查看 { get; } = new NetHandle(1, 2, 00001);//1.2.开头的是日志请求和清空 public static NetHandle 网络日志清空 { get; } = new NetHandle(1, 2, 00002); diff --git a/软件系统客户端Wpf/MainWindow.xaml b/软件系统客户端Wpf/MainWindow.xaml index 0fcf12b..56c9c7a 100644 --- a/软件系统客户端Wpf/MainWindow.xaml +++ b/软件系统客户端Wpf/MainWindow.xaml @@ -62,7 +62,7 @@ - + diff --git a/软件系统客户端Wpf/MainWindow.xaml.cs b/软件系统客户端Wpf/MainWindow.xaml.cs index 07a8505..ac254b0 100644 --- a/软件系统客户端Wpf/MainWindow.xaml.cs +++ b/软件系统客户端Wpf/MainWindow.xaml.cs @@ -34,9 +34,9 @@ namespace 软件系统客户端Wpf /*************************************************************************************** * - * 模版日期 2017-07-11 - * 创建人 胡少林 - * 版权所有 胡少林 + * 模版日期 2017-09-24 + * 创建人 Richard Hu + * 版权所有 Richard Hu * 授权说明 模版仅授权个人使用,如需商用,请联系hsl200909@163.com洽谈 * 说明一 JSON组件引用自james newton-king,遵循MIT授权协议 * 说明二 主题及各种主件来自:https://github.com/ButchersBoy/MaterialDesignInXamlToolkit @@ -123,7 +123,7 @@ namespace 软件系统客户端Wpf MenuItem注册账户.IsEnabled = false; MenuItem消息发送.IsEnabled = false; MenuItem开发中心.IsEnabled = false; - MenuItem分厂配置.IsEnabled = false; + MenuItem系统配置.IsEnabled = false; } @@ -375,15 +375,11 @@ namespace 软件系统客户端Wpf } - private void MenuItem分厂配置_Click(object sender, RoutedEventArgs e) + private void MenuItem系统配置_Click(object sender, RoutedEventArgs e) { - using (FormInputAndAction fiaa = new FormInputAndAction( - str => UserClient.Net_simplify_client.ReadFromServer( - CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess, - JArray.FromObject(UserClient.SystemFactories).ToString(), - "请按照JSON格式更新分厂信息,然后提交:")) + using (FormConfiguration fc = new FormConfiguration()) { - fiaa.ShowDialog(); + fc.ShowDialog(); } } diff --git a/软件系统客户端模版/FormMainWindow.Designer.cs b/软件系统客户端模版/FormMainWindow.Designer.cs index fcd4edd..9ff6673 100644 --- a/软件系统客户端模版/FormMainWindow.Designer.cs +++ b/软件系统客户端模版/FormMainWindow.Designer.cs @@ -45,10 +45,11 @@ this.注册账号ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.消息发送ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.开发中心ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.分厂配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.系统配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.修改密码ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.留言板ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.我的信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.关于本软件ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.更新日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -79,7 +80,6 @@ this.label10 = new System.Windows.Forms.Label(); this.panel_main = new System.Windows.Forms.Panel(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.我的信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.panel_right.SuspendLayout(); @@ -172,7 +172,7 @@ this.注册账号ToolStripMenuItem, this.消息发送ToolStripMenuItem, this.开发中心ToolStripMenuItem, - this.分厂配置ToolStripMenuItem}); + this.系统配置ToolStripMenuItem}); this.管理员ToolStripMenuItem.Image = global::软件系统客户端模版.Properties.Resources.Team_32xLG; this.管理员ToolStripMenuItem.Name = "管理员ToolStripMenuItem"; this.管理员ToolStripMenuItem.Size = new System.Drawing.Size(100, 31); @@ -227,12 +227,12 @@ this.开发中心ToolStripMenuItem.Text = "开发中心"; this.开发中心ToolStripMenuItem.Click += new System.EventHandler(this.开发中心ToolStripMenuItem_Click); // - // 分厂配置ToolStripMenuItem + // 系统配置ToolStripMenuItem // - this.分厂配置ToolStripMenuItem.Name = "分厂配置ToolStripMenuItem"; - this.分厂配置ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); - this.分厂配置ToolStripMenuItem.Text = "分厂配置"; - this.分厂配置ToolStripMenuItem.Click += new System.EventHandler(this.分厂配置ToolStripMenuItem_Click); + this.系统配置ToolStripMenuItem.Name = "系统配置ToolStripMenuItem"; + this.系统配置ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); + this.系统配置ToolStripMenuItem.Text = "系统配置"; + this.系统配置ToolStripMenuItem.Click += new System.EventHandler(this.系统配置ToolStripMenuItem_Click); // // 设置ToolStripMenuItem // @@ -259,6 +259,13 @@ this.留言板ToolStripMenuItem.Text = "留言板"; this.留言板ToolStripMenuItem.Click += new System.EventHandler(this.留言板ToolStripMenuItem_Click); // + // 我的信息ToolStripMenuItem + // + this.我的信息ToolStripMenuItem.Name = "我的信息ToolStripMenuItem"; + this.我的信息ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); + this.我的信息ToolStripMenuItem.Text = "我的信息"; + this.我的信息ToolStripMenuItem.Click += new System.EventHandler(this.我的信息ToolStripMenuItem_Click); + // // 关于ToolStripMenuItem // this.关于ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -559,13 +566,6 @@ this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); // - // 我的信息ToolStripMenuItem - // - this.我的信息ToolStripMenuItem.Name = "我的信息ToolStripMenuItem"; - this.我的信息ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); - this.我的信息ToolStripMenuItem.Text = "我的信息"; - this.我的信息ToolStripMenuItem.Click += new System.EventHandler(this.我的信息ToolStripMenuItem_Click); - // // FormMainWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -651,7 +651,7 @@ private System.Windows.Forms.ToolStripMenuItem 消息发送ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 开发中心ToolStripMenuItem; private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.ToolStripMenuItem 分厂配置ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 系统配置ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 我的信息ToolStripMenuItem; } } diff --git a/软件系统客户端模版/FormMainWindow.cs b/软件系统客户端模版/FormMainWindow.cs index f98b0f1..7e19d39 100644 --- a/软件系统客户端模版/FormMainWindow.cs +++ b/软件系统客户端模版/FormMainWindow.cs @@ -117,7 +117,7 @@ namespace 软件系统客户端模版 注册账号ToolStripMenuItem.Enabled = false; 消息发送ToolStripMenuItem.Enabled = false; 开发中心ToolStripMenuItem.Enabled = false; - 分厂配置ToolStripMenuItem.Enabled = false; + 系统配置ToolStripMenuItem.Enabled = false; } //启动定时器 TimeTickInitilization(); @@ -311,15 +311,19 @@ namespace 软件系统客户端模版 } } - private void 分厂配置ToolStripMenuItem_Click(object sender, EventArgs e) + private void 系统配置ToolStripMenuItem_Click(object sender, EventArgs e) { - using (FormInputAndAction fiaa = new FormInputAndAction( - str => UserClient.Net_simplify_client.ReadFromServer( - CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess, - JArray.FromObject(UserClient.SystemFactories).ToString(), - "请按照JSON格式更新分厂信息,然后提交:")) + //using (FormInputAndAction fiaa = new FormInputAndAction( + // str => UserClient.Net_simplify_client.ReadFromServer( + // CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess, + // JArray.FromObject(UserClient.SystemFactories).ToString(), + // "请按照JSON格式更新分厂信息,然后提交:")) + //{ + // fiaa.ShowDialog(); + //} + using (FormConfiguration fc = new FormConfiguration()) { - fiaa.ShowDialog(); + fc.ShowDialog(); } } diff --git a/软件系统服务端模版/FormServerWindow.cs b/软件系统服务端模版/FormServerWindow.cs index e51c044..26ed897 100644 --- a/软件系统服务端模版/FormServerWindow.cs +++ b/软件系统服务端模版/FormServerWindow.cs @@ -526,17 +526,33 @@ namespace 软件系统服务端模版 string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, ""); string password = SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, ""); string way = SoftBasic.GetValueFromJsonObject(json, UserAccount.LoginWayText, "winform"); + string machineId= SoftBasic.GetValueFromJsonObject(json, UserAccount.DeviceUniqueID, "ABCDEFHIGKLMN"); + - UserAccount account = UserServer.ServerAccounts.CheckAccount(name, password, state.GetRemoteEndPoint().Address.ToString(), way); + UserAccount account = UserServer.ServerAccounts.CheckAccount(name, password, state.GetRemoteEndPoint().Address.ToString(), way); //检测是否重复登录 if (account.LoginEnable) { - if (IsClinetOnline(account.UserName)) + if (!UserServer.ServerSettings.AllowUserMultiOnline) { - account.LoginEnable = false; - account.ForbidMessage = "该账户已经登录"; + if (IsClinetOnline(account.UserName)) + { + account.LoginEnable = false; + account.ForbidMessage = "该账户已经登录"; + } } } + + // 检测客户端id是否被授权 + if(UserServer.ServerSettings.WhetherToEnableTrustedClientAuthentication) + { + if(!UserServer.ServerSettings.CanClientLogin(machineId)) + { + account.LoginEnable = false; + account.ForbidMessage = "该客户端不再服务器信任列表"; + } + } + net_simplify_server.SendMessage(state, handle, JObject.FromObject(account).ToString()); } else if (handle == CommonHeadCode.SimplifyHeadCode.更新公告) @@ -628,6 +644,10 @@ namespace 软件系统服务端模版 net_simplify_server.SendMessage(state, handle, "失败,原因是:" + ex.Message); } } + else if(handle==CommonHeadCode.SimplifyHeadCode.请求分厂) + { + net_simplify_server.SendMessage(state, handle, JArray.FromObject(UserServer.ServerSettings.SystemFactories).ToString()); + } else if (handle == CommonHeadCode.SimplifyHeadCode.上传分厂) { try @@ -641,6 +661,36 @@ namespace 软件系统服务端模版 } net_simplify_server.SendMessage(state, handle, "1"); } + else if (handle == CommonHeadCode.SimplifyHeadCode.请求信任客户端) + { + JObject json = new JObject + { + { "TrustEnable", new JValue(UserServer.ServerSettings.WhetherToEnableTrustedClientAuthentication) }, + { "TrustList", new JArray(UserServer.ServerSettings.TrustedClientList) } + }; + net_simplify_server.SendMessage(state, handle, json.ToString()); + } + else if (handle == CommonHeadCode.SimplifyHeadCode.上传信任客户端) + { + JObject json = JObject.Parse(data); + UserServer.ServerSettings.WhetherToEnableTrustedClientAuthentication = json["TrustEnable"].ToObject(); + UserServer.ServerSettings.TrustedClientList = json["TrustList"].ToObject>(); + net_simplify_server.SendMessage(state, handle, "成功"); + } + else if (handle == CommonHeadCode.SimplifyHeadCode.请求一般配置) + { + JObject json = new JObject + { + { "AllowUserMulti", new JValue(UserServer.ServerSettings.AllowUserMultiOnline) }, + }; + net_simplify_server.SendMessage(state, handle, json.ToString()); + } + else if (handle == CommonHeadCode.SimplifyHeadCode.上传一般配置) + { + JObject json = JObject.Parse(data); + UserServer.ServerSettings.AllowUserMultiOnline = SoftBasic.GetValueFromJsonObject(json, "AllowUserMulti", false); + net_simplify_server.SendMessage(state, handle, json.ToString()); + } else { net_simplify_server.SendMessage(state, handle, data); @@ -945,6 +995,7 @@ namespace 软件系统服务端模版 /// 所有在线客户端的信息 /// private string Net_Socket_All_Clients = string.Empty; + /// /// 用来判断客户端是否已经在线,除了超级管理员,其他的账户不允许重复在线,重复登录的账户予以特殊标记 ///