From 9ed7e378d489ebbdb3cf13f806301d4b5cf21034 Mon Sep 17 00:00:00 2001 From: dathlin Date: Fri, 6 Oct 2017 13:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=88=9D=E6=AD=A5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A4=9A=E8=AF=AD=E8=A8=80=E7=89=88=E6=9C=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=9B=B4=E6=96=B0readme=EF=BC=8Cv1.6.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ClientsLibrary/AccountSupport/AccountLogin.cs | 14 +- .../FormAccountDetails.Designer.cs | 180 ++++++++-------- .../AccountSupport/FormAccountDetails.cs | 29 +++ .../FormAccountSelect.Designer.cs | 145 +++++++++++++ .../AccountSupport/FormAccountSelect.cs | 144 +++++++++++++ .../AccountSupport/FormAccountSelect.resx | 135 ++++++++++++ .../AccountSupport/FormRegisterAccount.cs | 20 +- .../FormGetInputString.Designer.cs | 93 ++++++++ .../BasicSupport/FormGetInputString.cs | 55 +++++ .../BasicSupport/FormGetInputString.resx | 120 +++++++++++ ClientsLibrary/ClientsLibrary.csproj | 27 +++ .../Configuration/FormConfiguration.cs | 15 +- .../Configuration/ListConfiguration.cs | 2 + .../RolesConfiguration.Designer.cs | 203 ++++++++++++++++++ .../Configuration/RolesConfiguration.cs | 136 ++++++++++++ .../Configuration/RolesConfiguration.resx | 120 +++++++++++ ClientsLibrary/UserClient.cs | 35 ++- CommonLibrary/AccountSupport/Attribute.cs | 35 +++ CommonLibrary/AccountSupport/RoleAssign.cs | 105 +++++++++ CommonLibrary/AccountSupport/UserAccount.cs | 1 + .../BasicSupport/FormGetInputString.resx | 120 +++++++++++ CommonLibrary/CommonLibrary.csproj | 6 + .../ChineseLocalization.cs | 47 ++++ .../EnglishLocalization.cs | 47 ++++ .../LocalizationSupport/Localization.cs | 90 ++++++++ .../ProtocolSupport/CommonProtocol.cs | 2 +- CommonLibrary/ProtocolSupport/CustomerCode.cs | 3 + Design.xlsx | Bin 39362 -> 42631 bytes Public/HslCommunication.dll | Bin 313856 -> 313856 bytes README.md | 8 +- img/Design7.png | Bin 0 -> 52633 bytes 软件系统客户端Wpf/MainWindow.xaml.cs | 7 +- 软件系统客户端模版/FormMainWindow.cs | 11 +- .../FormServerWindow.Designer.cs | 1 + 软件系统服务端模版/FormServerWindow.cs | 53 +++-- 软件系统服务端模版/UserServer.cs | 13 +- 36 files changed, 1899 insertions(+), 123 deletions(-) create mode 100644 ClientsLibrary/AccountSupport/FormAccountSelect.Designer.cs create mode 100644 ClientsLibrary/AccountSupport/FormAccountSelect.cs create mode 100644 ClientsLibrary/AccountSupport/FormAccountSelect.resx create mode 100644 ClientsLibrary/BasicSupport/FormGetInputString.Designer.cs create mode 100644 ClientsLibrary/BasicSupport/FormGetInputString.cs create mode 100644 ClientsLibrary/BasicSupport/FormGetInputString.resx create mode 100644 ClientsLibrary/Configuration/RolesConfiguration.Designer.cs create mode 100644 ClientsLibrary/Configuration/RolesConfiguration.cs create mode 100644 ClientsLibrary/Configuration/RolesConfiguration.resx create mode 100644 CommonLibrary/AccountSupport/Attribute.cs create mode 100644 CommonLibrary/AccountSupport/RoleAssign.cs create mode 100644 CommonLibrary/BasicSupport/FormGetInputString.resx create mode 100644 CommonLibrary/LocalizationSupport/ChineseLocalization.cs create mode 100644 CommonLibrary/LocalizationSupport/EnglishLocalization.cs create mode 100644 CommonLibrary/LocalizationSupport/Localization.cs create mode 100644 img/Design7.png diff --git a/ClientsLibrary/AccountSupport/AccountLogin.cs b/ClientsLibrary/AccountSupport/AccountLogin.cs index 8d9190f..a3101b3 100644 --- a/ClientsLibrary/AccountSupport/AccountLogin.cs +++ b/ClientsLibrary/AccountSupport/AccountLogin.cs @@ -14,7 +14,12 @@ namespace ClientsLibrary /********************************************************************************* * * 统一的账户登录模型 - * + * 包含的功能有 + * 1、维护状态检查 + * 2、账户检查 + * 3、框架版本检查、 + * 4、系统版本号检查 + * 5、初始化数据 * *********************************************************************************/ @@ -78,9 +83,11 @@ namespace ClientsLibrary // 延时 Thread.Sleep(200); - //=================================================================================== + //======================================================================================= + // // 根据实际情况校验,选择数据库校验或是将用户名密码发至服务器校验 // 以下展示了服务器校验的方法,如您需要数据库校验,请删除下面并改成SQL访问验证的方式 + // 如果还有其他数据一并传到服务器进行验证的,都在下面进行数据包装 // 包装数据 JObject json = new JObject @@ -146,6 +153,7 @@ namespace ClientsLibrary } else { + // 超级管理员可以使用超前版本进行登录 if (UserClient.CurrentVersion < sv) { // 保存新版本信息 @@ -182,7 +190,7 @@ namespace ClientsLibrary { // 服务器返回初始化的数据,此处进行数据的提取,有可能包含了多个数据 json = JObject.Parse(result.Content); - // 例如公告数据 + // 例如公告数据和分厂数据 UserClient.Announcement = SoftBasic.GetValueFromJsonObject(json, nameof(UserClient.Announcement), ""); if (json[nameof(UserClient.SystemFactories)] != null) { diff --git a/ClientsLibrary/AccountSupport/FormAccountDetails.Designer.cs b/ClientsLibrary/AccountSupport/FormAccountDetails.Designer.cs index 231694c..0743b45 100644 --- a/ClientsLibrary/AccountSupport/FormAccountDetails.Designer.cs +++ b/ClientsLibrary/AccountSupport/FormAccountDetails.Designer.cs @@ -55,16 +55,16 @@ this.textBox_UserName = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.textBox_file_uploadTime = new System.Windows.Forms.TextBox(); + this.label_uploadTime = new System.Windows.Forms.Label(); + this.textBox_file_size = new System.Windows.Forms.TextBox(); + this.label_fileSize = new System.Windows.Forms.Label(); + this.textBox_file_name = new System.Windows.Forms.TextBox(); + this.label_fileName = new System.Windows.Forms.Label(); this.userButton_delete = new HslCommunication.Controls.UserButton(); this.userButton_download = new HslCommunication.Controls.UserButton(); this.userButton_upload = new HslCommunication.Controls.UserButton(); this.treeView1 = new System.Windows.Forms.TreeView(); - this.textBox_file_name = new System.Windows.Forms.TextBox(); - this.label_fileName = new System.Windows.Forms.Label(); - this.textBox_file_size = new System.Windows.Forms.TextBox(); - this.label_fileSize = new System.Windows.Forms.Label(); - this.textBox_file_uploadTime = new System.Windows.Forms.TextBox(); - this.label_uploadTime = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox_UserPortrait)).BeginInit(); this.groupBox2.SuspendLayout(); @@ -109,7 +109,7 @@ // this.pictureBox_UserPortrait.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pictureBox_UserPortrait.Cursor = System.Windows.Forms.Cursors.Hand; - this.pictureBox_UserPortrait.Location = new System.Drawing.Point(112, 22); + this.pictureBox_UserPortrait.Location = new System.Drawing.Point(153, 22); this.pictureBox_UserPortrait.Name = "pictureBox_UserPortrait"; this.pictureBox_UserPortrait.Size = new System.Drawing.Size(136, 136); this.pictureBox_UserPortrait.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -129,10 +129,10 @@ // textBox_LoginFailedCount // this.textBox_LoginFailedCount.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LoginFailedCount.Location = new System.Drawing.Point(112, 459); + this.textBox_LoginFailedCount.Location = new System.Drawing.Point(153, 459); this.textBox_LoginFailedCount.Name = "textBox_LoginFailedCount"; this.textBox_LoginFailedCount.ReadOnly = true; - this.textBox_LoginFailedCount.Size = new System.Drawing.Size(177, 23); + this.textBox_LoginFailedCount.Size = new System.Drawing.Size(136, 23); this.textBox_LoginFailedCount.TabIndex = 21; // // label11 @@ -147,10 +147,10 @@ // textBox_LastLoginWay // this.textBox_LastLoginWay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LastLoginWay.Location = new System.Drawing.Point(112, 428); + this.textBox_LastLoginWay.Location = new System.Drawing.Point(153, 428); this.textBox_LastLoginWay.Name = "textBox_LastLoginWay"; this.textBox_LastLoginWay.ReadOnly = true; - this.textBox_LastLoginWay.Size = new System.Drawing.Size(177, 23); + this.textBox_LastLoginWay.Size = new System.Drawing.Size(136, 23); this.textBox_LastLoginWay.TabIndex = 19; // // label10 @@ -165,10 +165,10 @@ // textBox_LastLoginIpAddress // this.textBox_LastLoginIpAddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LastLoginIpAddress.Location = new System.Drawing.Point(112, 398); + this.textBox_LastLoginIpAddress.Location = new System.Drawing.Point(153, 398); this.textBox_LastLoginIpAddress.Name = "textBox_LastLoginIpAddress"; this.textBox_LastLoginIpAddress.ReadOnly = true; - this.textBox_LastLoginIpAddress.Size = new System.Drawing.Size(177, 23); + this.textBox_LastLoginIpAddress.Size = new System.Drawing.Size(136, 23); this.textBox_LastLoginIpAddress.TabIndex = 17; // // label9 @@ -183,10 +183,10 @@ // textBox_LastLoginTime // this.textBox_LastLoginTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LastLoginTime.Location = new System.Drawing.Point(112, 368); + this.textBox_LastLoginTime.Location = new System.Drawing.Point(153, 368); this.textBox_LastLoginTime.Name = "textBox_LastLoginTime"; this.textBox_LastLoginTime.ReadOnly = true; - this.textBox_LastLoginTime.Size = new System.Drawing.Size(177, 23); + this.textBox_LastLoginTime.Size = new System.Drawing.Size(136, 23); this.textBox_LastLoginTime.TabIndex = 15; // // label8 @@ -201,10 +201,10 @@ // textBox_LoginFrequency // this.textBox_LoginFrequency.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LoginFrequency.Location = new System.Drawing.Point(112, 338); + this.textBox_LoginFrequency.Location = new System.Drawing.Point(153, 338); this.textBox_LoginFrequency.Name = "textBox_LoginFrequency"; this.textBox_LoginFrequency.ReadOnly = true; - this.textBox_LoginFrequency.Size = new System.Drawing.Size(177, 23); + this.textBox_LoginFrequency.Size = new System.Drawing.Size(136, 23); this.textBox_LoginFrequency.TabIndex = 13; // // label7 @@ -219,10 +219,10 @@ // textBox_LoginEnable // this.textBox_LoginEnable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_LoginEnable.Location = new System.Drawing.Point(112, 308); + this.textBox_LoginEnable.Location = new System.Drawing.Point(153, 308); this.textBox_LoginEnable.Name = "textBox_LoginEnable"; this.textBox_LoginEnable.ReadOnly = true; - this.textBox_LoginEnable.Size = new System.Drawing.Size(177, 23); + this.textBox_LoginEnable.Size = new System.Drawing.Size(136, 23); this.textBox_LoginEnable.TabIndex = 11; // // label6 @@ -237,10 +237,10 @@ // textBox_RegisterTime // this.textBox_RegisterTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_RegisterTime.Location = new System.Drawing.Point(112, 279); + this.textBox_RegisterTime.Location = new System.Drawing.Point(153, 279); this.textBox_RegisterTime.Name = "textBox_RegisterTime"; this.textBox_RegisterTime.ReadOnly = true; - this.textBox_RegisterTime.Size = new System.Drawing.Size(177, 23); + this.textBox_RegisterTime.Size = new System.Drawing.Size(136, 23); this.textBox_RegisterTime.TabIndex = 9; // // label5 @@ -255,10 +255,10 @@ // textBox_GradeDescription // this.textBox_GradeDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_GradeDescription.Location = new System.Drawing.Point(112, 251); + this.textBox_GradeDescription.Location = new System.Drawing.Point(153, 251); this.textBox_GradeDescription.Name = "textBox_GradeDescription"; this.textBox_GradeDescription.ReadOnly = true; - this.textBox_GradeDescription.Size = new System.Drawing.Size(177, 23); + this.textBox_GradeDescription.Size = new System.Drawing.Size(136, 23); this.textBox_GradeDescription.TabIndex = 7; // // label4 @@ -273,10 +273,10 @@ // textBox_Factory // this.textBox_Factory.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_Factory.Location = new System.Drawing.Point(112, 223); + this.textBox_Factory.Location = new System.Drawing.Point(153, 223); this.textBox_Factory.Name = "textBox_Factory"; this.textBox_Factory.ReadOnly = true; - this.textBox_Factory.Size = new System.Drawing.Size(177, 23); + this.textBox_Factory.Size = new System.Drawing.Size(136, 23); this.textBox_Factory.TabIndex = 5; // // label3 @@ -291,10 +291,10 @@ // textBox_NameAlias // this.textBox_NameAlias.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_NameAlias.Location = new System.Drawing.Point(112, 194); + this.textBox_NameAlias.Location = new System.Drawing.Point(153, 194); this.textBox_NameAlias.Name = "textBox_NameAlias"; this.textBox_NameAlias.ReadOnly = true; - this.textBox_NameAlias.Size = new System.Drawing.Size(177, 23); + this.textBox_NameAlias.Size = new System.Drawing.Size(136, 23); this.textBox_NameAlias.TabIndex = 3; // // label2 @@ -309,10 +309,10 @@ // textBox_UserName // this.textBox_UserName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_UserName.Location = new System.Drawing.Point(112, 164); + this.textBox_UserName.Location = new System.Drawing.Point(153, 164); this.textBox_UserName.Name = "textBox_UserName"; this.textBox_UserName.ReadOnly = true; - this.textBox_UserName.Size = new System.Drawing.Size(177, 23); + this.textBox_UserName.Size = new System.Drawing.Size(136, 23); this.textBox_UserName.TabIndex = 1; // // label1 @@ -345,6 +345,67 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "个人文件,支持拖拽上传,双击下载"; // + // textBox_file_uploadTime + // + this.textBox_file_uploadTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBox_file_uploadTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.textBox_file_uploadTime.Location = new System.Drawing.Point(252, 432); + this.textBox_file_uploadTime.Name = "textBox_file_uploadTime"; + this.textBox_file_uploadTime.ReadOnly = true; + this.textBox_file_uploadTime.Size = new System.Drawing.Size(111, 23); + this.textBox_file_uploadTime.TabIndex = 16; + // + // label_uploadTime + // + this.label_uploadTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label_uploadTime.AutoSize = true; + this.label_uploadTime.Location = new System.Drawing.Point(182, 434); + this.label_uploadTime.Name = "label_uploadTime"; + this.label_uploadTime.Size = new System.Drawing.Size(68, 17); + this.label_uploadTime.TabIndex = 15; + this.label_uploadTime.Text = "上传日期:"; + // + // textBox_file_size + // + this.textBox_file_size.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBox_file_size.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.textBox_file_size.Location = new System.Drawing.Point(66, 432); + this.textBox_file_size.Name = "textBox_file_size"; + this.textBox_file_size.ReadOnly = true; + this.textBox_file_size.Size = new System.Drawing.Size(110, 23); + this.textBox_file_size.TabIndex = 14; + // + // label_fileSize + // + this.label_fileSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label_fileSize.AutoSize = true; + this.label_fileSize.Location = new System.Drawing.Point(7, 434); + this.label_fileSize.Name = "label_fileSize"; + this.label_fileSize.Size = new System.Drawing.Size(44, 17); + this.label_fileSize.TabIndex = 13; + this.label_fileSize.Text = "大小:"; + // + // textBox_file_name + // + this.textBox_file_name.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox_file_name.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.textBox_file_name.Location = new System.Drawing.Point(66, 405); + this.textBox_file_name.Name = "textBox_file_name"; + this.textBox_file_name.ReadOnly = true; + this.textBox_file_name.Size = new System.Drawing.Size(297, 23); + this.textBox_file_name.TabIndex = 12; + // + // label_fileName + // + this.label_fileName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label_fileName.AutoSize = true; + this.label_fileName.Location = new System.Drawing.Point(7, 407); + this.label_fileName.Name = "label_fileName"; + this.label_fileName.Size = new System.Drawing.Size(56, 17); + this.label_fileName.TabIndex = 11; + this.label_fileName.Text = "文件名:"; + // // userButton_delete // this.userButton_delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -409,67 +470,6 @@ this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView1_DragEnter); this.treeView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseDoubleClick); // - // textBox_file_name - // - this.textBox_file_name.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBox_file_name.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_file_name.Location = new System.Drawing.Point(66, 405); - this.textBox_file_name.Name = "textBox_file_name"; - this.textBox_file_name.ReadOnly = true; - this.textBox_file_name.Size = new System.Drawing.Size(297, 23); - this.textBox_file_name.TabIndex = 12; - // - // label_fileName - // - this.label_fileName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label_fileName.AutoSize = true; - this.label_fileName.Location = new System.Drawing.Point(7, 407); - this.label_fileName.Name = "label_fileName"; - this.label_fileName.Size = new System.Drawing.Size(56, 17); - this.label_fileName.TabIndex = 11; - this.label_fileName.Text = "文件名:"; - // - // textBox_file_size - // - this.textBox_file_size.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBox_file_size.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_file_size.Location = new System.Drawing.Point(66, 432); - this.textBox_file_size.Name = "textBox_file_size"; - this.textBox_file_size.ReadOnly = true; - this.textBox_file_size.Size = new System.Drawing.Size(110, 23); - this.textBox_file_size.TabIndex = 14; - // - // label_fileSize - // - this.label_fileSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label_fileSize.AutoSize = true; - this.label_fileSize.Location = new System.Drawing.Point(7, 434); - this.label_fileSize.Name = "label_fileSize"; - this.label_fileSize.Size = new System.Drawing.Size(44, 17); - this.label_fileSize.TabIndex = 13; - this.label_fileSize.Text = "大小:"; - // - // textBox_file_uploadTime - // - this.textBox_file_uploadTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBox_file_uploadTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox_file_uploadTime.Location = new System.Drawing.Point(252, 432); - this.textBox_file_uploadTime.Name = "textBox_file_uploadTime"; - this.textBox_file_uploadTime.ReadOnly = true; - this.textBox_file_uploadTime.Size = new System.Drawing.Size(111, 23); - this.textBox_file_uploadTime.TabIndex = 16; - // - // label_uploadTime - // - this.label_uploadTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label_uploadTime.AutoSize = true; - this.label_uploadTime.Location = new System.Drawing.Point(182, 434); - this.label_uploadTime.Name = "label_uploadTime"; - this.label_uploadTime.Size = new System.Drawing.Size(68, 17); - this.label_uploadTime.TabIndex = 15; - this.label_uploadTime.Text = "上传日期:"; - // // FormAccountDetails // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); diff --git a/ClientsLibrary/AccountSupport/FormAccountDetails.cs b/ClientsLibrary/AccountSupport/FormAccountDetails.cs index 51008fb..c6bb485 100644 --- a/ClientsLibrary/AccountSupport/FormAccountDetails.cs +++ b/ClientsLibrary/AccountSupport/FormAccountDetails.cs @@ -52,6 +52,9 @@ namespace ClientsLibrary // 加载文件列表 DownloadUserFileNames(); + + // 本地化显示 + UILocalization(); } private void AccountDetails_Load(object sender, EventArgs e) @@ -66,6 +69,32 @@ namespace ClientsLibrary treeView1.Nodes[0].SelectedImageIndex = 0; } + #endregion + + #region Localization Support + + /// + /// 本地化显示的操作,还未完成 + /// + private void UILocalization() + { + Text = UserLocalization.Localization.AccountDetails; + groupBox1.Text = UserLocalization.Localization.AccountDetails; + label12.Text = UserLocalization.Localization.AccountPortrait + ":"; + label1.Text = UserLocalization.Localization.AccountName + ":"; + label2.Text = UserLocalization.Localization.AccountAlias + ":"; + label3.Text = UserLocalization.Localization.AccountFactory + ":"; + label4.Text = UserLocalization.Localization.AccountGrade + ":"; + label5.Text = UserLocalization.Localization.AccountRegisterTime + ":"; + label6.Text = UserLocalization.Localization.AccountLoginEnable + ":"; + label7.Text = UserLocalization.Localization.AccountLoginFrequency + ":"; + label8.Text = UserLocalization.Localization.AccountLastLoginTime + ":"; + label9.Text = UserLocalization.Localization.AccountLastLoginIpAddress + ":"; + label10.Text = UserLocalization.Localization.AccountLastLoginWay + ":"; + label11.Text = UserLocalization.Localization.AccountLoginFailedCount + ":"; + } + + #endregion #region Load Portrait diff --git a/ClientsLibrary/AccountSupport/FormAccountSelect.Designer.cs b/ClientsLibrary/AccountSupport/FormAccountSelect.Designer.cs new file mode 100644 index 0000000..e512429 --- /dev/null +++ b/ClientsLibrary/AccountSupport/FormAccountSelect.Designer.cs @@ -0,0 +1,145 @@ +namespace ClientsLibrary +{ + partial class FormAccountSelect + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.userButton_login = new HslCommunication.Controls.UserButton(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // userButton_login + // + 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(309, 442); + 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(108, 27); + this.userButton_login.TabIndex = 8; + this.userButton_login.UIText = "确认"; + this.userButton_login.Click += new System.EventHandler(this.userButton_login_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.BackgroundColor = System.Drawing.Color.White; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2, + this.Column3, + this.Column4, + this.Column5}); + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.MultiSelect = false; + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(721, 433); + this.dataGridView1.TabIndex = 9; + // + // Column1 + // + this.Column1.HeaderText = "选择"; + this.Column1.Name = "Column1"; + this.Column1.Width = 70; + // + // Column2 + // + this.Column2.HeaderText = "账户名"; + this.Column2.Name = "Column2"; + this.Column2.ReadOnly = true; + this.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column3 + // + this.Column3.HeaderText = "别名"; + this.Column3.Name = "Column3"; + this.Column3.ReadOnly = true; + this.Column3.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column4 + // + this.Column4.HeaderText = "分厂"; + this.Column4.Name = "Column4"; + this.Column4.ReadOnly = true; + this.Column4.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column5 + // + this.Column5.HeaderText = "注册时间"; + this.Column5.Name = "Column5"; + this.Column5.ReadOnly = true; + this.Column5.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Column5.Width = 200; + // + // FormAccountSelect + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(721, 480); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.userButton_login); + 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 = "FormAccountSelect"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "账号选择"; + this.Load += new System.EventHandler(this.FormAccountSelect_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private HslCommunication.Controls.UserButton userButton_login; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.DataGridViewCheckBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column2; + private System.Windows.Forms.DataGridViewTextBoxColumn Column3; + private System.Windows.Forms.DataGridViewTextBoxColumn Column4; + private System.Windows.Forms.DataGridViewTextBoxColumn Column5; + } +} \ No newline at end of file diff --git a/ClientsLibrary/AccountSupport/FormAccountSelect.cs b/ClientsLibrary/AccountSupport/FormAccountSelect.cs new file mode 100644 index 0000000..3b59bde --- /dev/null +++ b/ClientsLibrary/AccountSupport/FormAccountSelect.cs @@ -0,0 +1,144 @@ +using CommonLibrary; +using HslCommunication; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ClientsLibrary +{ + public partial class FormAccountSelect : Form + { + #region Constructor + + + public FormAccountSelect(List selected = null) + { + InitializeComponent(); + + Icon = UserClient.GetFormWindowIcon(); + m_selected = selected; + } + + + #endregion + + #region Form Load + + + private void FormAccountSelect_Load(object sender, EventArgs e) + { + // 初始化 + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.获取账户, ""); + if (result.IsSuccess) + { + List accounts = JArray.Parse(result.Content).ToObject>(); + // 添加到数据表 + + foreach (var m in accounts) + { + DataGridViewRow dgvr = dataGridView1.Rows[dataGridView1.Rows.Add()]; + if(m_selected != null) + { + if(m_selected.Contains(m.UserName)) + { + dgvr.Cells[0].Value = true; + } + } + + dgvr.Cells[1].Value = m.UserName; + dgvr.Cells[2].Value = m.NameAlias; + dgvr.Cells[3].Value = m.Factory; + dgvr.Cells[4].Value = m.RegisterTime.ToString(); + dgvr.Tag = m; + } + } + else + { + MessageBox.Show("请求服务器失败,请稍后重试!"); + + } + + // 本地化 + UILocalization(); + + dataGridView1.RowsDefaultCellStyle.SelectionBackColor = dataGridView1.RowsDefaultCellStyle.BackColor; + dataGridView1.RowsDefaultCellStyle.SelectionForeColor = dataGridView1.RowsDefaultCellStyle.ForeColor; + } + + + #endregion + + #region Localization Support + + private void UILocalization() + { + + Text = UserLocalization.Localization.AccountSelect; + Column1.HeaderText = UserLocalization.Localization.AccountSelect; + Column2.HeaderText = UserLocalization.Localization.AccountName; + Column3.HeaderText = UserLocalization.Localization.AccountAlias; + Column4.HeaderText = UserLocalization.Localization.AccountFactory; + Column5.HeaderText = UserLocalization.Localization.AccountRegisterTime; + + userButton_login.UIText = UserLocalization.Localization.ButtonEnsure; + } + + #endregion + + #region Public Property + /// + /// 返回已经选择的账户 + /// + public List SelectAccounts + { + get + { + return m_result; + } + } + + #endregion + + #region Button Click + + private void userButton_login_Click(object sender, EventArgs e) + { + m_result = new List(); + + for (int i = 0; i < dataGridView1.Rows.Count; i++) + { + DataGridViewRow dgvr = dataGridView1.Rows[i]; + if(dgvr.Cells[0].Value != null) + { + if ((bool)dgvr.Cells[0].Value) + { + m_result.Add((UserAccount)dgvr.Tag); + } + } + } + + DialogResult = DialogResult.OK; + } + + + + #endregion + + #region Private Members + + + private List m_selected; + private List m_result; + + #endregion + + + } +} diff --git a/ClientsLibrary/AccountSupport/FormAccountSelect.resx b/ClientsLibrary/AccountSupport/FormAccountSelect.resx new file mode 100644 index 0000000..a59896e --- /dev/null +++ b/ClientsLibrary/AccountSupport/FormAccountSelect.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/ClientsLibrary/AccountSupport/FormRegisterAccount.cs b/ClientsLibrary/AccountSupport/FormRegisterAccount.cs index 06e297d..fbba605 100644 --- a/ClientsLibrary/AccountSupport/FormRegisterAccount.cs +++ b/ClientsLibrary/AccountSupport/FormRegisterAccount.cs @@ -14,6 +14,8 @@ namespace ClientsLibrary { public partial class FormRegisterAccount : Form { + #region Constructor + /// /// 实例化对象 /// @@ -32,7 +34,9 @@ namespace ClientsLibrary Factories.Add("总公司"); } - private List Factories = null; + #endregion + + #region Form Load private void FormRegisterAccount_Load(object sender, EventArgs e) { @@ -47,7 +51,10 @@ namespace ClientsLibrary textBox4.Text = (new UserAccount()).ForbidMessage; } - private NetSimplifyClient net_client = null; + #endregion + + #region Register Account + private void userButton_login_Click(object sender, EventArgs e) { @@ -76,5 +83,14 @@ namespace ClientsLibrary MessageBox.Show("注册失败!"); } } + + #endregion + + #region Private Members + + private List Factories = null; // 分厂信息 + private NetSimplifyClient net_client = null; // 服务器数据交换的通信对象 + + #endregion } } diff --git a/ClientsLibrary/BasicSupport/FormGetInputString.Designer.cs b/ClientsLibrary/BasicSupport/FormGetInputString.Designer.cs new file mode 100644 index 0000000..2715219 --- /dev/null +++ b/ClientsLibrary/BasicSupport/FormGetInputString.Designer.cs @@ -0,0 +1,93 @@ +namespace ClientsLibrary +{ + partial class FormGetInputString + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.userButton_login = new HslCommunication.Controls.UserButton(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(21, 67); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(383, 29); + this.textBox1.TabIndex = 0; + // + // userButton_login + // + 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(154, 101); + 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(108, 27); + this.userButton_login.TabIndex = 7; + this.userButton_login.UIText = "确认"; + this.userButton_login.Click += new System.EventHandler(this.userButton_login_Click); + // + // label1 + // + 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(18, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(386, 55); + this.label1.TabIndex = 8; + this.label1.Text = "label1"; + // + // FormGetInputString + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(434, 133); + this.Controls.Add(this.label1); + this.Controls.Add(this.userButton_login); + this.Controls.Add(this.textBox1); + this.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormGetInputString"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "等待输入信息"; + this.Load += new System.EventHandler(this.FormGetInputString_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private HslCommunication.Controls.UserButton userButton_login; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/ClientsLibrary/BasicSupport/FormGetInputString.cs b/ClientsLibrary/BasicSupport/FormGetInputString.cs new file mode 100644 index 0000000..5d4e7d4 --- /dev/null +++ b/ClientsLibrary/BasicSupport/FormGetInputString.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ClientsLibrary +{ + public partial class FormGetInputString : Form + { + public FormGetInputString( + string info, + string defaultValue = "", + string title = "等待输入信息", + int maxlength = 100 + ) + { + InitializeComponent(); + + Icon = UserClient.GetFormWindowIcon(); + Info = info; + DefaultValue = defaultValue; + Title = title; + MaxLength = maxlength; + } + + private void FormGetInputString_Load(object sender, EventArgs e) + { + textBox1.Text = DefaultValue; + textBox1.MaxLength = MaxLength; + Text = Title; + label1.Text = Info; + } + + + + + private string Info; + private string DefaultValue; + private string Title; + private int MaxLength = 100; + private string m_outPut; + + public string InputString { get => m_outPut; private set => m_outPut = value; } + + private void userButton_login_Click(object sender, EventArgs e) + { + m_outPut = textBox1.Text; + DialogResult = DialogResult.OK; + } + } +} diff --git a/ClientsLibrary/BasicSupport/FormGetInputString.resx b/ClientsLibrary/BasicSupport/FormGetInputString.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ClientsLibrary/BasicSupport/FormGetInputString.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/ClientsLibrary.csproj b/ClientsLibrary/ClientsLibrary.csproj index f230e9d..4f2e542 100644 --- a/ClientsLibrary/ClientsLibrary.csproj +++ b/ClientsLibrary/ClientsLibrary.csproj @@ -56,12 +56,24 @@ FormAccountDetails.cs + + Form + + + FormAccountSelect.cs + Form FormDownloading.cs + + Form + + + FormGetInputString.cs + Form @@ -92,6 +104,12 @@ FormConfiguration.cs + + UserControl + + + RolesConfiguration.cs + UserControl @@ -148,9 +166,15 @@ FormAccountDetails.cs + + FormAccountSelect.cs + FormDownloading.cs + + FormGetInputString.cs + FormShowMachineId.cs @@ -166,6 +190,9 @@ FormConfiguration.cs + + RolesConfiguration.cs + FileItemShow.cs diff --git a/ClientsLibrary/Configuration/FormConfiguration.cs b/ClientsLibrary/Configuration/FormConfiguration.cs index c396e3e..dc8927f 100644 --- a/ClientsLibrary/Configuration/FormConfiguration.cs +++ b/ClientsLibrary/Configuration/FormConfiguration.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using CommonLibrary; namespace ClientsLibrary { @@ -21,15 +22,17 @@ namespace ClientsLibrary private void FormConfiguration_Load(object sender, EventArgs e) { - Text = "配置系统的参数"; + Text = UserLocalization.Localization.SettingsText; treeView1.AfterSelect += TreeView1_AfterSelect; TreeNode treeNodeSystem = treeView1.Nodes[0]; + treeNodeSystem.Text = UserLocalization.Localization.SettingsSystem; - treeNodeSystem.Nodes.Add("General", "常规配置"); - treeNodeSystem.Nodes.Add("Factory", "配置分厂信息"); - treeNodeSystem.Nodes.Add("Client", "客户端信任功能"); + treeNodeSystem.Nodes.Add("General", UserLocalization.Localization.SettingsGeneral); + treeNodeSystem.Nodes.Add("Factory", UserLocalization.Localization.SettingsAccountFactory); + treeNodeSystem.Nodes.Add("Client", UserLocalization.Localization.SettingsTrustClient); + treeNodeSystem.Nodes.Add("Roles", UserLocalization.Localization.SettingsRoleAssign); treeNodeSystem.Expand(); } @@ -64,6 +67,10 @@ namespace ClientsLibrary { control = new ClientConfiguration(); } + else if (e.Node.Name == "Roles") + { + control = new RolesConfiguration(); + } else { control = new UserControl(); diff --git a/ClientsLibrary/Configuration/ListConfiguration.cs b/ClientsLibrary/Configuration/ListConfiguration.cs index c10379e..9915bcc 100644 --- a/ClientsLibrary/Configuration/ListConfiguration.cs +++ b/ClientsLibrary/Configuration/ListConfiguration.cs @@ -39,6 +39,8 @@ namespace ClientsLibrary.Configuration #endregion + + public void SetInfomation(int download, int upload, string headText) { Download = download; diff --git a/ClientsLibrary/Configuration/RolesConfiguration.Designer.cs b/ClientsLibrary/Configuration/RolesConfiguration.Designer.cs new file mode 100644 index 0000000..ada79d3 --- /dev/null +++ b/ClientsLibrary/Configuration/RolesConfiguration.Designer.cs @@ -0,0 +1,203 @@ +namespace ClientsLibrary.Configuration +{ + partial class RolesConfiguration + { + /// + /// 必需的设计器变量。 + /// + 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.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.userButton4 = new HslCommunication.Controls.UserButton(); + this.userButton3 = new HslCommunication.Controls.UserButton(); + this.userButton2 = new HslCommunication.Controls.UserButton(); + this.userButton1 = new HslCommunication.Controls.UserButton(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 3); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(80, 17); + this.label1.TabIndex = 2; + this.label1.Text = "角色名称列表"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 3); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(80, 17); + this.label2.TabIndex = 4; + this.label2.Text = "关联账号列表"; + // + // userButton4 + // + this.userButton4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.userButton4.BackColor = System.Drawing.Color.Transparent; + this.userButton4.CustomerInformation = ""; + this.userButton4.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton4.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton4.Location = new System.Drawing.Point(458, 427); + this.userButton4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton4.Name = "userButton4"; + this.userButton4.Size = new System.Drawing.Size(78, 25); + this.userButton4.TabIndex = 7; + this.userButton4.UIText = "保存"; + this.userButton4.Click += new System.EventHandler(this.userButton4_Click); + // + // userButton3 + // + this.userButton3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + 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(5, 392); + this.userButton3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton3.Name = "userButton3"; + this.userButton3.Size = new System.Drawing.Size(78, 25); + this.userButton3.TabIndex = 6; + this.userButton3.UIText = "编辑"; + this.userButton3.Click += new System.EventHandler(this.userButton3_Click); + // + // userButton2 + // + this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + 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(87, 392); + this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton2.Name = "userButton2"; + this.userButton2.Size = new System.Drawing.Size(78, 25); + this.userButton2.TabIndex = 5; + this.userButton2.UIText = "删除"; + this.userButton2.Click += new System.EventHandler(this.userButton2_Click); + // + // 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(3, 392); + this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton1.Name = "userButton1"; + this.userButton1.Size = new System.Drawing.Size(78, 25); + this.userButton1.TabIndex = 1; + this.userButton1.UIText = "新增"; + this.userButton1.Click += new System.EventHandler(this.userButton1_Click); + // + // splitContainer1 + // + this.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(0, 3); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.listBox1); + this.splitContainer1.Panel1.Controls.Add(this.label1); + this.splitContainer1.Panel1.Controls.Add(this.userButton1); + this.splitContainer1.Panel1.Controls.Add(this.userButton2); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.listBox2); + this.splitContainer1.Panel2.Controls.Add(this.label2); + this.splitContainer1.Panel2.Controls.Add(this.userButton3); + this.splitContainer1.Size = new System.Drawing.Size(536, 421); + this.splitContainer1.SplitterDistance = 264; + this.splitContainer1.TabIndex = 8; + // + // 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, 23); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(257, 361); + this.listBox1.TabIndex = 6; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.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.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 17; + this.listBox2.Location = new System.Drawing.Point(3, 23); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(258, 361); + this.listBox2.TabIndex = 7; + // + // RolesConfiguration + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.userButton4); + 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 = "RolesConfiguration"; + this.Size = new System.Drawing.Size(539, 456); + this.Load += new System.EventHandler(this.RolesConfiguration_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private HslCommunication.Controls.UserButton userButton1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private HslCommunication.Controls.UserButton userButton2; + private HslCommunication.Controls.UserButton userButton3; + private HslCommunication.Controls.UserButton userButton4; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ListBox listBox2; + } +} diff --git a/ClientsLibrary/Configuration/RolesConfiguration.cs b/ClientsLibrary/Configuration/RolesConfiguration.cs new file mode 100644 index 0000000..200cd0f --- /dev/null +++ b/ClientsLibrary/Configuration/RolesConfiguration.cs @@ -0,0 +1,136 @@ +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; +using CommonLibrary; + +namespace ClientsLibrary.Configuration +{ + public partial class RolesConfiguration : UserControl + { + public RolesConfiguration() + { + InitializeComponent(); + } + + private void RolesConfiguration_Load(object sender, EventArgs e) + { + // 初始化 + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求角色配置, ""); + if (result.IsSuccess) + { + List roles = JArray.Parse(result.Content).ToObject>(); + + foreach(var m in roles) + { + listBox1.Items.Add(m); + } + } + else + { + MessageBox.Show("请求服务器失败,请稍后重试!"); + userButton4.Enabled = false; + } + } + + private void listBox1_SelectedIndexChanged(object sender, EventArgs e) + { + if(listBox1.SelectedItem is RoleItem role) + { + listBox2.DataSource = role.Accounts; + } + } + + private void userButton2_Click(object sender, EventArgs e) + { + // delete list item + if (listBox1.SelectedItem != null) + { + if (MessageBox.Show("是否真的删除该角色信息?", "删除确认", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + listBox1.Items.Remove(listBox1.SelectedItem); + listBox2.DataSource = null; + } + } + } + + private bool CheckRoleWhetherExisting(string role) + { + foreach(var m in listBox1.Items) + { + if(m.ToString() == role) + { + return true; + } + } + return false; + } + + private void userButton1_Click(object sender, EventArgs e) + { + // add a new role + using (FormGetInputString form = new FormGetInputString("请输入新的角色名称")) + { + if (form.ShowDialog() == DialogResult.OK) + { + string role = form.InputString; + if(!CheckRoleWhetherExisting(role)) + { + // add + listBox1.Items.Add(new RoleItem() + { + RoleName = role + }); + } + } + } + } + + private void userButton3_Click(object sender, EventArgs e) + { + if (listBox1.SelectedItem is RoleItem role) + { + // select account + using (FormAccountSelect form = new FormAccountSelect(role.Accounts)) + { + if(form.ShowDialog() == DialogResult.OK) + { + role.Accounts = form.SelectAccounts.ConvertAll(m => m.UserName); + listBox2.DataSource = role.Accounts; + } + } + } + } + + private void userButton4_Click(object sender, EventArgs e) + { + // save + List roles = new List(); + foreach(var m in listBox1.Items) + { + if(m is RoleItem item) + { + roles.Add(item); + } + } + + OperateResultString result = UserClient.Net_simplify_client.ReadFromServer( + CommonHeadCode.SimplifyHeadCode.上传角色配置, JArray.FromObject(roles).ToString()); + if (result.IsSuccess) + { + MessageBox.Show("上传数据成功!"); + } + else + { + MessageBox.Show("上传数据失败:"+result.Message); + } + } + } +} diff --git a/ClientsLibrary/Configuration/RolesConfiguration.resx b/ClientsLibrary/Configuration/RolesConfiguration.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ClientsLibrary/Configuration/RolesConfiguration.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/UserClient.cs b/ClientsLibrary/UserClient.cs index b81b5d9..f05301d 100644 --- a/ClientsLibrary/UserClient.cs +++ b/ClientsLibrary/UserClient.cs @@ -8,6 +8,7 @@ using CommonLibrary; using System.Net; using System.Drawing; using System.Windows.Forms; +using Newtonsoft.Json.Linq; namespace ClientsLibrary { @@ -35,7 +36,7 @@ namespace ClientsLibrary /// /// 本软件的当前版本,用来验证更新的关键依据 /// - public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0.170930"); + public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0.171006"); /// @@ -106,6 +107,33 @@ namespace ClientsLibrary }; + /// + /// 检查当前账户是否有role角色的权限 + /// + /// 角色名称 + /// + public static bool CheckUserAccountRole(string role) + { + JObject json = new JObject + { + { "Name", UserAccount.UserName }, + { "Role", role } + }; + HslCommunication.OperateResultString result = Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.检查角色权限, + json.ToString()); + + if(result.IsSuccess) + { + if(result.Content.ToUpper() == "TRUE") + { + return true; + } + } + + return false; + } + + @@ -155,7 +183,10 @@ namespace ClientsLibrary } - + /// + /// 统一的窗体图标显示 + /// + /// public static Icon GetFormWindowIcon() { return Icon.ExtractAssociatedIcon(Application.ExecutablePath); diff --git a/CommonLibrary/AccountSupport/Attribute.cs b/CommonLibrary/AccountSupport/Attribute.cs new file mode 100644 index 0000000..5767a44 --- /dev/null +++ b/CommonLibrary/AccountSupport/Attribute.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CommonLibrary +{ + + + /************************************************************************************* + * + * 说明:本来考虑使用特性来给账户标注,但是考虑到以后将要实现多语言版本,那么特性支持就 + * 不是个好选择,所以放弃了,保留了特性类 + * + *************************************************************************************/ + + + + + + + + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class HslDisplayAttribute : Attribute + { + public string m_display; + + + public HslDisplayAttribute(string display) + { + m_display = display; + } + } +} diff --git a/CommonLibrary/AccountSupport/RoleAssign.cs b/CommonLibrary/AccountSupport/RoleAssign.cs new file mode 100644 index 0000000..907112b --- /dev/null +++ b/CommonLibrary/AccountSupport/RoleAssign.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using HslCommunication; +using Newtonsoft.Json.Linq; + +namespace CommonLibrary +{ + + /********************************************************************************** + * + * 说明:本系统的角色设计 + * + * 角色功能的设计就是针对一些特殊功能权限的账户设计的,我们希望实现对某一个功能的角色可以 + * 任意的配置账户 + * + **********************************************************************************/ + + + + public class RoleAssign : HslCommunication.BasicFramework.SoftFileSaveBase + { + #region Constructor + + public RoleAssign() + { + // 添加一个初始化的测试例子 + m_roles.Add(new RoleItem() + { + RoleName = "审计员", + Accounts = new List() + { + "admin" + } + }); + } + + #endregion + + #region Override Method + + public override string ToSaveString() + { + string json = string.Empty; + hybirdLock.Enter(); + json = JArray.FromObject(m_roles).ToString(); + hybirdLock.Leave(); + return json; + } + + public override void LoadByString(string content) + { + hybirdLock.Enter(); + m_roles = JArray.Parse(content).ToObject>(); + hybirdLock.Leave(); + } + + #endregion + + #region Public Method + + public bool IsAllowAccountOperate(string role,string name) + { + bool result = false; + hybirdLock.Enter(); + + for (int i = 0; i < m_roles.Count; i++) + { + if (m_roles[i].RoleName == role) + { + if(m_roles[i].Accounts.Contains(name)) + { + result = true; + } + } + } + + hybirdLock.Leave(); + return result; + } + + + #endregion + + #region Private Members + + private List m_roles = new List(); + private SimpleHybirdLock hybirdLock = new SimpleHybirdLock(); + + #endregion + } + + + public class RoleItem + { + public string RoleName { get; set; } + public List Accounts { get; set; } = new List(); + + public override string ToString() + { + return RoleName; + } + } +} diff --git a/CommonLibrary/AccountSupport/UserAccount.cs b/CommonLibrary/AccountSupport/UserAccount.cs index 807730d..acea6b6 100644 --- a/CommonLibrary/AccountSupport/UserAccount.cs +++ b/CommonLibrary/AccountSupport/UserAccount.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Newtonsoft.Json.Linq; + namespace CommonLibrary { /// diff --git a/CommonLibrary/BasicSupport/FormGetInputString.resx b/CommonLibrary/BasicSupport/FormGetInputString.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/CommonLibrary/BasicSupport/FormGetInputString.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/CommonLibrary/CommonLibrary.csproj b/CommonLibrary/CommonLibrary.csproj index d073f2b..ba8acf3 100644 --- a/CommonLibrary/CommonLibrary.csproj +++ b/CommonLibrary/CommonLibrary.csproj @@ -47,6 +47,7 @@ + Form @@ -65,6 +66,7 @@ FormPasswordModify.cs + @@ -86,6 +88,9 @@ FormVersionControl.cs + + + @@ -117,6 +122,7 @@ +