From 5ff23f2e07bae2d400e7a39af79fd8fc741adf36 Mon Sep 17 00:00:00 2001 From: dathlin Date: Fri, 19 May 2017 10:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E6=97=A5=E5=BF=97=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=85=B6=E4=BB=96=E7=9A=84=E5=B0=8FBUG?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CommonLibrary/AccountSupport/ServerAccount.cs | 5 +- CommonLibrary/HeadCode.cs | 2 + CommonLibrary/Resource.cs | 5 +- 软件系统客户端模版/FormLog.Designer.cs | 56 +++++++++++++++---- 软件系统客户端模版/FormLog.cs | 10 ++++ 软件系统客户端模版/FormRegisterAccount.cs | 1 + .../UIControls/ShareFilesRender.cs | 2 +- 软件系统服务端模版/Form1.cs | 25 +++++++-- 8 files changed, 88 insertions(+), 18 deletions(-) diff --git a/CommonLibrary/AccountSupport/ServerAccount.cs b/CommonLibrary/AccountSupport/ServerAccount.cs index cb43401..4afacb7 100644 --- a/CommonLibrary/AccountSupport/ServerAccount.cs +++ b/CommonLibrary/AccountSupport/ServerAccount.cs @@ -47,6 +47,7 @@ namespace CommonLibrary if (name == all_list_accounts[i].UserName) { all_list_accounts[i].Password = password; + LogHelper?.LogSave(Resource.StringResouce.AccountModifyPassword + name); break; } } @@ -144,6 +145,7 @@ namespace CommonLibrary } } all_list_accounts.Add(account); + LogHelper?.LogSave(Resource.StringResouce.AccountAddSuccess + account.UserName); } return true; } @@ -161,6 +163,7 @@ namespace CommonLibrary if (name == all_list_accounts[i].UserName) { all_list_accounts.RemoveAt(i); + LogHelper?.LogSave(Resource.StringResouce.AccountDeleteSuccess + name); break; } } @@ -208,7 +211,7 @@ namespace CommonLibrary } catch(Exception ex) { - LogHelper.LogSave(Resource.StringResouce.AccountLoadFailed, ex); + LogHelper?.LogSave(Resource.StringResouce.AccountLoadFailed, ex); } } } diff --git a/CommonLibrary/HeadCode.cs b/CommonLibrary/HeadCode.cs index 73d91f4..9e14c16 100644 --- a/CommonLibrary/HeadCode.cs +++ b/CommonLibrary/HeadCode.cs @@ -43,6 +43,8 @@ namespace CommonLibrary public static string 同步日志清空 { get; } = "B004"; public static string 更新日志查看 { get; } = "B005"; public static string 更新日志清空 { get; } = "B006"; + public static string 运行日志查看 { get; } = "B007"; + public static string 运行日志清空 { get; } = "B008"; /************************************************************************************** * diff --git a/CommonLibrary/Resource.cs b/CommonLibrary/Resource.cs index 70ca24b..99f19ca 100644 --- a/CommonLibrary/Resource.cs +++ b/CommonLibrary/Resource.cs @@ -20,7 +20,10 @@ namespace CommonLibrary - public const string AccountLoadFailed = "新增账户失败"; + public const string AccountLoadFailed = "新增账户失败"; + public const string AccountDeleteSuccess = "账户删除:"; + public const string AccountAddSuccess = "账户新增:"; + public const string AccountModifyPassword = "账户更改密码:"; } } } diff --git a/软件系统客户端模版/FormLog.Designer.cs b/软件系统客户端模版/FormLog.Designer.cs index 003abdf..ae71181 100644 --- a/软件系统客户端模版/FormLog.Designer.cs +++ b/软件系统客户端模版/FormLog.Designer.cs @@ -31,12 +31,14 @@ namespace 软件系统客户端模版 private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); - this.userButton_login = new UserButton(); - this.userButton1 = new UserButton(); - this.userButton2 = new UserButton(); - this.userButton3 = new UserButton(); - this.userButton4 = new UserButton(); - this.userButton5 = new UserButton(); + this.userButton_login = new HslCommunication.Controls.UserButton(); + this.userButton1 = new HslCommunication.Controls.UserButton(); + this.userButton2 = new HslCommunication.Controls.UserButton(); + this.userButton3 = new HslCommunication.Controls.UserButton(); + this.userButton4 = new HslCommunication.Controls.UserButton(); + this.userButton5 = new HslCommunication.Controls.UserButton(); + this.userButton6 = new HslCommunication.Controls.UserButton(); + this.userButton7 = new HslCommunication.Controls.UserButton(); this.SuspendLayout(); // // textBox1 @@ -88,7 +90,7 @@ namespace 软件系统客户端模版 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(619, 118); + this.userButton2.Location = new System.Drawing.Point(619, 96); this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton2.Name = "userButton2"; this.userButton2.Size = new System.Drawing.Size(103, 26); @@ -103,7 +105,7 @@ namespace 软件系统客户端模版 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(619, 152); + this.userButton3.Location = new System.Drawing.Point(619, 130); this.userButton3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton3.Name = "userButton3"; this.userButton3.Size = new System.Drawing.Size(103, 26); @@ -118,7 +120,7 @@ namespace 软件系统客户端模版 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(619, 225); + this.userButton4.Location = new System.Drawing.Point(619, 181); this.userButton4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton4.Name = "userButton4"; this.userButton4.Size = new System.Drawing.Size(103, 26); @@ -133,7 +135,7 @@ namespace 软件系统客户端模版 this.userButton5.CustomerInformation = ""; this.userButton5.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); this.userButton5.Font = new System.Drawing.Font("微软雅黑", 9F); - this.userButton5.Location = new System.Drawing.Point(619, 259); + this.userButton5.Location = new System.Drawing.Point(619, 215); this.userButton5.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.userButton5.Name = "userButton5"; this.userButton5.Size = new System.Drawing.Size(103, 26); @@ -141,11 +143,43 @@ namespace 软件系统客户端模版 this.userButton5.UIText = "更新日志清空"; this.userButton5.Click += new System.EventHandler(this.userButton5_Click); // + // userButton6 + // + this.userButton6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.userButton6.BackColor = System.Drawing.Color.Transparent; + this.userButton6.CustomerInformation = ""; + this.userButton6.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton6.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton6.Location = new System.Drawing.Point(619, 303); + this.userButton6.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton6.Name = "userButton6"; + this.userButton6.Size = new System.Drawing.Size(103, 26); + this.userButton6.TabIndex = 13; + this.userButton6.UIText = "运行日志清空"; + this.userButton6.Click += new System.EventHandler(this.userButton6_Click); + // + // userButton7 + // + this.userButton7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.userButton7.BackColor = System.Drawing.Color.Transparent; + this.userButton7.CustomerInformation = ""; + this.userButton7.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton7.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton7.Location = new System.Drawing.Point(619, 269); + this.userButton7.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton7.Name = "userButton7"; + this.userButton7.Size = new System.Drawing.Size(103, 26); + this.userButton7.TabIndex = 12; + this.userButton7.UIText = "运行日志查看"; + this.userButton7.Click += new System.EventHandler(this.userButton7_Click); + // // FormLog // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(732, 492); + this.Controls.Add(this.userButton6); + this.Controls.Add(this.userButton7); this.Controls.Add(this.userButton5); this.Controls.Add(this.userButton4); this.Controls.Add(this.userButton3); @@ -173,5 +207,7 @@ namespace 软件系统客户端模版 private UserButton userButton3; private UserButton userButton4; private UserButton userButton5; + private UserButton userButton6; + private UserButton userButton7; } } \ No newline at end of file diff --git a/软件系统客户端模版/FormLog.cs b/软件系统客户端模版/FormLog.cs index d69b750..a3e1455 100644 --- a/软件系统客户端模版/FormLog.cs +++ b/软件系统客户端模版/FormLog.cs @@ -71,5 +71,15 @@ namespace 软件系统客户端模版 { ClearFromServer(CommonHeadCode.SimplifyHeadCode.更新日志清空); } + + private void userButton7_Click(object sender, EventArgs e) + { + ReadFromServer(CommonHeadCode.SimplifyHeadCode.运行日志查看); + } + + private void userButton6_Click(object sender, EventArgs e) + { + ClearFromServer(CommonHeadCode.SimplifyHeadCode.运行日志清空); + } } } diff --git a/软件系统客户端模版/FormRegisterAccount.cs b/软件系统客户端模版/FormRegisterAccount.cs index 517b150..a0a7897 100644 --- a/软件系统客户端模版/FormRegisterAccount.cs +++ b/软件系统客户端模版/FormRegisterAccount.cs @@ -40,6 +40,7 @@ namespace 软件系统客户端模版 UserAccount account = new UserAccount(); account.UserName = textBox1.Text; account.Password = textBox2.Text; + account.Factory = textBox3.Text; switch (comboBox1.SelectedIndex) { case 0: account.Grade = AccountGrade.SuperAdministrator; break; diff --git a/软件系统客户端模版/UIControls/ShareFilesRender.cs b/软件系统客户端模版/UIControls/ShareFilesRender.cs index 808f20b..6208b63 100644 --- a/软件系统客户端模版/UIControls/ShareFilesRender.cs +++ b/软件系统客户端模版/UIControls/ShareFilesRender.cs @@ -77,7 +77,7 @@ namespace 软件系统客户端模版.UIControls } else { - return true; + return MessageBox.Show("请确认是否真的删除?", "删除确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes; } }); panel2.Controls.Add(item); diff --git a/软件系统服务端模版/Form1.cs b/软件系统服务端模版/Form1.cs index 320dea7..a0aec12 100644 --- a/软件系统服务端模版/Form1.cs +++ b/软件系统服务端模版/Form1.cs @@ -65,7 +65,7 @@ namespace 软件系统服务端模版 private void Form1_Load(object sender, EventArgs e) { //初始化日志工具 - LogHelper = new SoftLogHelper() + RuntimeLogHelper = new SoftLogHelper() { LogSaveFileName = Application.StartupPath + @"\log.txt", }; @@ -78,7 +78,7 @@ namespace 软件系统服务端模版 //加载账户信息 UserServer.ServerAccounts.FileSavePath = Application.StartupPath + @"\accounts.txt"; UserServer.ServerAccounts.LoadByFile(); - UserServer.ServerAccounts.LogHelper = LogHelper; + UserServer.ServerAccounts.LogHelper = RuntimeLogHelper; } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { @@ -449,6 +449,15 @@ namespace 软件系统服务端模版 net_soft_update_Server.LogHelper.ClearLogText(); net_simplify_server.SendMessage(object1, "成功"); } + else if (headCode == CommonHeadCode.SimplifyHeadCode.运行日志查看) + { + net_simplify_server.SendMessage(object1, RuntimeLogHelper.GetLogText()); + } + else if (headCode == CommonHeadCode.SimplifyHeadCode.运行日志清空) + { + RuntimeLogHelper.ClearLogText(); + net_simplify_server.SendMessage(object1, "成功"); + } else { net_simplify_server.SendMessage(object1, object2); @@ -680,9 +689,9 @@ namespace 软件系统服务端模版 IpEndPoints.Add(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.10." + i), 6000)); } - //每隔1000秒钟访问一次 + //每隔1秒钟访问一次 MelsecMulti = new HslCommunication.Profinet.MelsecNetMultiAsync(0, 0, HslCommunication.Profinet.MelsecDataType.D, 6000, 20, 700, 1000, IpEndPoints.ToArray()); - MelsecMulti.OnReceivedData += MelsecMulti_OnReceivedData; + MelsecMulti.OnReceivedData += MelsecMulti_OnReceivedData;//所有机台的数据都返回时触发 } private void MelsecMulti_OnReceivedData(byte[] object1) @@ -696,7 +705,13 @@ namespace 软件系统服务端模版 * 每台设备的前两个字节都为0才说明本次数据访问正常,为0x00,0x01说明连接失败,其他说明说明三菱本身的异常 * ********************************************************************************************/ + for (int i = 0; i < 100; i++) + { + int startIndex = i * 42; + ushort netState = BitConverter.ToUInt16(object1, startIndex);//为0,说明数据正常,不为0说明网络访问失败或是指令出错 + + } } @@ -711,6 +726,6 @@ namespace 软件系统服务端模版 /// /// 用来记录一般的事物日志 /// - private SoftLogHelper LogHelper { get; set; } + private SoftLogHelper RuntimeLogHelper { get; set; } } }