增加一个运行时日志,修复一些其他的小BUG,调整文件删除确认

This commit is contained in:
dathlin
2017-05-19 10:20:10 +08:00
parent 5188163510
commit 5ff23f2e07
8 changed files with 88 additions and 18 deletions

View File

@@ -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);
}
}
}

View File

@@ -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";
/**************************************************************************************
*

View File

@@ -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 = "账户更改密码:";
}
}
}

View File

@@ -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;
}
}

View File

@@ -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.);
}
}
}

View File

@@ -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;

View File

@@ -77,7 +77,7 @@ namespace 软件系统客户端模版.UIControls
}
else
{
return true;
return MessageBox.Show("请确认是否真的删除?", "删除确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes;
}
});
panel2.Controls.Add(item);

View File

@@ -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 软件系统服务端模版
/// <summary>
/// 用来记录一般的事物日志
/// </summary>
private SoftLogHelper LogHelper { get; set; }
private SoftLogHelper RuntimeLogHelper { get; set; }
}
}