From 184502543bc5d68de65c2f8b5b08e5b828e5c107 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Wed, 11 Dec 2024 17:23:30 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=BA=93=20=E6=93=8D=E4=BD=9C=E7=B1=BB=20=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Log4net/LogHelper.cs | 22 +- HighWayIot.Repository/SqlSugarHelper.cs | 2 +- .../domain/SysErrorLogEntity.cs | 22 +- HighWayIot.Repository/domain/SysLogEntity.cs | 19 +- .../service/SysErrorLogService.cs | 34 +- .../service/SysLogService.cs | 36 +- .../service/SysShiftTimeService.cs | 4 +- HighWayIot.Winform/Business/GeneralUtils.cs | 21 +- HighWayIot.Winform/Business/SqlLogHelper.cs | 51 ++- HighWayIot.Winform/MainForm/BaseForm.cs | 2 +- .../LogPages/AlarmLogPage.Designer.cs | 310 +++++++++++++++-- .../UserControlPages/LogPages/AlarmLogPage.cs | 46 ++- .../LogPages/AlarmLogPage.resx | 21 ++ .../LogPages/OperateConfigPage.Designer.cs | 316 ++++++++++++++++-- .../LogPages/OperateConfigPage.cs | 43 ++- .../LogPages/OperateConfigPage.resx | 21 ++ .../MonitorMainPages/MonitorMainPage.cs | 6 +- .../UserControlPages/TestPage.cs | 8 +- 18 files changed, 857 insertions(+), 127 deletions(-) diff --git a/HighWayIot.Log4net/LogHelper.cs b/HighWayIot.Log4net/LogHelper.cs index dd53eba..aedb568 100644 --- a/HighWayIot.Log4net/LogHelper.cs +++ b/HighWayIot.Log4net/LogHelper.cs @@ -46,7 +46,7 @@ namespace HighWayIot.Log4net } /// - /// 记录Info日志 + /// 记录Info日志 控制台 log /// /// /// @@ -59,7 +59,7 @@ namespace HighWayIot.Log4net } /// - /// 记录PLC日志 + /// 记录PLC日志 log /// /// public void PlcLog(string msg) @@ -71,7 +71,7 @@ namespace HighWayIot.Log4net } /// - /// 记录Rfid日志 + /// 记录Rfid日志 log /// /// public void RfidLog(string msg) @@ -83,7 +83,7 @@ namespace HighWayIot.Log4net } /// - /// 界面日志 + /// 界面日志 log /// /// public void ViewLog(string msg) @@ -94,6 +94,10 @@ namespace HighWayIot.Log4net } } + /// + /// 数据库日志 log + /// + /// public void SqlLog(string msg) { if (sqllog.IsInfoEnabled) @@ -102,6 +106,10 @@ namespace HighWayIot.Log4net } } + /// + /// 信号量日志 log + /// + /// public void SemaphoreLog(string msg) { if (semaphorelog.IsInfoEnabled) @@ -111,7 +119,7 @@ namespace HighWayIot.Log4net } /// - /// 记录Error日志 + /// 记录Error日志 控制台 log /// /// /// @@ -119,12 +127,12 @@ namespace HighWayIot.Log4net { if (!string.IsNullOrEmpty(info) && ex == null) { - logerror.ErrorFormat("【附加信息】 : {0}
", new object[] { info }); + logerror.ErrorFormat("[错误信息] : {0}", new object[] { info }); } else if (!string.IsNullOrEmpty(info) && ex != null) { string errorMsg = BeautyErrorMsg(ex); - logerror.ErrorFormat("【附加信息】 : {0}
{1}", new object[] { info, errorMsg }); + logerror.ErrorFormat("[附加信息] : {0} message : {1}", new object[] { info, errorMsg }); } else if (string.IsNullOrEmpty(info) && ex != null) { diff --git a/HighWayIot.Repository/SqlSugarHelper.cs b/HighWayIot.Repository/SqlSugarHelper.cs index 9a3a18a..f5c075e 100644 --- a/HighWayIot.Repository/SqlSugarHelper.cs +++ b/HighWayIot.Repository/SqlSugarHelper.cs @@ -69,7 +69,7 @@ namespace HighWayIot.Repository //调试SQL事件,可以删掉 db.Aop.OnLogExecuting = (sql, pars) => { - logHelper.SqlLog($"{sql};参数:{jsonChange.ModeToJson(pars)}"); + logHelper.SqlLog($"[ {sql} ]"); }; }); diff --git a/HighWayIot.Repository/domain/SysErrorLogEntity.cs b/HighWayIot.Repository/domain/SysErrorLogEntity.cs index afbb98f..a97eba9 100644 --- a/HighWayIot.Repository/domain/SysErrorLogEntity.cs +++ b/HighWayIot.Repository/domain/SysErrorLogEntity.cs @@ -31,7 +31,7 @@ namespace HighWayIot.Repository.domain /// 默认值: /// [SugarColumn(ColumnName = "log_time")] - public DateTime? Log_time { get; set; } + public DateTime? LogTime { get; set; } /// /// 备 注:操作者 @@ -41,11 +41,25 @@ namespace HighWayIot.Repository.domain public string Operator { get; set; } = null; /// - /// 备 注: + /// 备 注:参数1 + /// 默认值: + /// + [SugarColumn(ColumnName = "p1")] + public int? P1 { get; set; } + + /// + /// 备 注:参数2 + /// 默认值: + /// + [SugarColumn(ColumnName = "p2")] + public int? P2 { get; set; } + + /// + /// 备 注:参数3 /// 默认值: /// - [SugarColumn(ColumnName = "device_no")] - public int? Device_no { get; set; } + [SugarColumn(ColumnName = "p3")] + public int? P3 { get; set; } } diff --git a/HighWayIot.Repository/domain/SysLogEntity.cs b/HighWayIot.Repository/domain/SysLogEntity.cs index 10883c3..7859e33 100644 --- a/HighWayIot.Repository/domain/SysLogEntity.cs +++ b/HighWayIot.Repository/domain/SysLogEntity.cs @@ -8,7 +8,7 @@ namespace HighWayIot.Repository.domain /// /// [SugarTable("sys_log")] - public class Sys_log + public class SysLogEntity { @@ -31,7 +31,14 @@ namespace HighWayIot.Repository.domain /// 默认值: /// [SugarColumn(ColumnName = "log_time")] - public DateTime? Log_time { get; set; } + public DateTime? LogTime { get; set; } + + /// + /// 备 注:操作者 + /// 默认值: + /// + [SugarColumn(ColumnName = "operator")] + public string Operator { get; set; } = null; /// /// 备 注:参数1 @@ -54,14 +61,6 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "p3")] public int? P3 { get; set; } - /// - /// 备 注:操作者 - /// 默认值: - /// - [SugarColumn(ColumnName = "operator")] - public string Operator { get; set; } = null; - - } } \ No newline at end of file diff --git a/HighWayIot.Repository/service/SysErrorLogService.cs b/HighWayIot.Repository/service/SysErrorLogService.cs index cac4db9..6f5cad2 100644 --- a/HighWayIot.Repository/service/SysErrorLogService.cs +++ b/HighWayIot.Repository/service/SysErrorLogService.cs @@ -25,23 +25,47 @@ namespace HighWayIot.Repository.service Repository _repository => new Repository("sqlserver"); /// - /// 查询所有班次信息 + /// 查询所有报警日志信息 /// /// - public List GetShiftInfos() + public List GetErrorLogInfos(Expression> expression = null) { try { - List entity = _repository.GetList(); + List entity; + if (expression != null) + { + entity = _repository.GetList(expression); + } + else + { + entity = _repository.GetList(); + } return entity; } catch (Exception ex) { - log.Error("用户信息获取异常", ex); + log.Error("报警日志信息获取异常", ex); return null; } } - + /// + /// 添加报警日志 + /// + /// + /// + public bool InsertErrorLogInfo(SysErrorLogEntity entity) + { + try + { + return _repository.Insert(entity); + } + catch (Exception ex) + { + log.Error("报警日志信息插入异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/SysLogService.cs b/HighWayIot.Repository/service/SysLogService.cs index 3c1e2bf..739b8a0 100644 --- a/HighWayIot.Repository/service/SysLogService.cs +++ b/HighWayIot.Repository/service/SysLogService.cs @@ -22,26 +22,50 @@ namespace HighWayIot.Repository.service } private LogHelper log = LogHelper.Instance; - Repository _repository => new Repository("sqlserver"); + Repository _repository => new Repository("sqlserver"); /// - /// 查询所有班次信息 + /// 查询所有日志信息 /// /// - public List GetShiftInfos() + public List GetLogInfos(Expression> expression = null) { try { - List entity = _repository.GetList(); + List entity; + if (expression != null) + { + entity = _repository.GetList(expression); + } + else + { + entity = _repository.GetList(); + } return entity; } catch (Exception ex) { - log.Error("用户信息获取异常", ex); + log.Error("日志信息获取异常", ex); return null; } } - + /// + /// 添加日志 + /// + /// + /// + public bool InsertLogInfo(SysLogEntity entity) + { + try + { + return _repository.Insert(entity); + } + catch (Exception ex) + { + log.Error("日志信息插入异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/SysShiftTimeService.cs b/HighWayIot.Repository/service/SysShiftTimeService.cs index b1a8e13..b00e6df 100644 --- a/HighWayIot.Repository/service/SysShiftTimeService.cs +++ b/HighWayIot.Repository/service/SysShiftTimeService.cs @@ -37,7 +37,7 @@ namespace HighWayIot.Repository.service } catch (Exception ex) { - log.Error("用户信息获取异常", ex); + log.Error("班次信息获取异常", ex); return null; } } @@ -55,7 +55,7 @@ namespace HighWayIot.Repository.service } catch(Exception ex) { - log.Error("用户信息修改异常", ex); + log.Error("班次信息修改异常", ex); return false; } } diff --git a/HighWayIot.Winform/Business/GeneralUtils.cs b/HighWayIot.Winform/Business/GeneralUtils.cs index 883b309..65c82c2 100644 --- a/HighWayIot.Winform/Business/GeneralUtils.cs +++ b/HighWayIot.Winform/Business/GeneralUtils.cs @@ -22,26 +22,15 @@ namespace HighWayIot.Winform.Business } /// - /// 转换string为int? + /// 转换 /// - /// + /// /// - public static int? StringNullOrToInt(string intValue) + public static int? StringNullOrToInt(string text) { - if (string.IsNullOrEmpty(intValue.Trim())) - { - return null; - } - if (int.TryParse(intValue, out int result)) - { - return result; - } - else - { - return null; - } + return int.TryParse(text, out int result) ? (int?)result : null; } - + public static string IntEmptyOrToString(int? value) { if (value == null) diff --git a/HighWayIot.Winform/Business/SqlLogHelper.cs b/HighWayIot.Winform/Business/SqlLogHelper.cs index 3d721a3..e2377b9 100644 --- a/HighWayIot.Winform/Business/SqlLogHelper.cs +++ b/HighWayIot.Winform/Business/SqlLogHelper.cs @@ -1,13 +1,60 @@ -using System; +using HighWayIot.Repository.service; +using HighWayIot.Repository.domain; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using HighWayIot.Log4net; namespace HighWayIot.Winform.Business { public class SqlLogHelper { - + private static LogHelper logHelper = LogHelper.Instance; + + /// + /// 日志信息服务类 + /// + private static SysLogService sysLogService = SysLogService.Instance; + + /// + /// 报警日志信息服务类 + /// + private static SysErrorLogService sysErrorLogService = SysErrorLogService.Instance; + + /// + /// 日志插入数据库 + /// + public static void AddLog(string text, int? p1 = null, int? p2 = null, int? p3 = null) + { + logHelper.Info(text); + sysLogService.InsertLogInfo(new SysLogEntity() + { + Text = text, + LogTime = DateTime.Now, + Operator = RoleBusiness.LoginUserName, + P1 = p1, + P2 = p2, + P3 = p3, + }); + } + + /// + /// 错误日志插入数据库 + /// + public static void AddErrorLog(string text, int? p1 = null, int? p2 = null, int? p3 = null) + { + logHelper.Error(text); + sysErrorLogService.InsertErrorLogInfo(new SysErrorLogEntity() + { + Text = text, + LogTime = DateTime.Now, + Operator = RoleBusiness.LoginUserName, + P1 = p1, + P2 = p2, + P3 = p3, + }); + } } } diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index e65d9ad..be0aeaa 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -90,7 +90,7 @@ namespace HighWayIot.Winform.MainForm UserPanelSwitch(typeof(UserConfigPage), button.Text); break; case "操作日志": - UserPanelSwitch(typeof(MaterialConfigPage), button.Text); + UserPanelSwitch(typeof(OperateConfigPage), button.Text); break; case "报警日志": UserPanelSwitch(typeof(AlarmConfigPage), button.Text); diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs index debf606..92f30a3 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs @@ -31,69 +31,321 @@ namespace HighWayIot.Winform.UserControlPages /// private void InitializeComponent() { - this.RoleDataGridView = new System.Windows.Forms.DataGridView(); - this.AddRole = new System.Windows.Forms.Button(); + this.LogDataGridView = new System.Windows.Forms.DataGridView(); + this.SelectErrorLog = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).BeginInit(); + this.P3TextBox = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.P2TextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.P1TextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.SelectLogEndTime = new System.Windows.Forms.DateTimePicker(); + this.SelectLogBeginTime = new System.Windows.Forms.DateTimePicker(); + this.IsCheckByLogTime = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.OperatorNameTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.LogTextTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); // - // RoleDataGridView + // LogDataGridView // - this.RoleDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.LogDataGridView.AllowUserToAddRows = false; + this.LogDataGridView.AllowUserToDeleteRows = false; + this.LogDataGridView.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.RoleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.RoleDataGridView.Location = new System.Drawing.Point(0, 65); - this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.RoleDataGridView.Name = "RoleDataGridView"; - this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(883, 497); - this.RoleDataGridView.TabIndex = 0; - // - // AddRole - // - this.AddRole.Location = new System.Drawing.Point(11, 11); - this.AddRole.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.AddRole.Name = "AddRole"; - this.AddRole.Size = new System.Drawing.Size(103, 39); - this.AddRole.TabIndex = 1; - this.AddRole.Text = "查询报警信息"; - this.AddRole.UseVisualStyleBackColor = true; + this.LogDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.LogDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Id, + this.Text, + this.LogTime, + this.Operator, + this.P1, + this.P2, + this.P3}); + this.LogDataGridView.Location = new System.Drawing.Point(0, 65); + this.LogDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.LogDataGridView.Name = "LogDataGridView"; + this.LogDataGridView.ReadOnly = true; + this.LogDataGridView.RowHeadersVisible = false; + this.LogDataGridView.RowTemplate.Height = 25; + this.LogDataGridView.Size = new System.Drawing.Size(1170, 816); + this.LogDataGridView.TabIndex = 0; + // + // SelectErrorLog + // + this.SelectErrorLog.Location = new System.Drawing.Point(11, 11); + this.SelectErrorLog.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.SelectErrorLog.Name = "SelectErrorLog"; + this.SelectErrorLog.Size = new System.Drawing.Size(103, 39); + this.SelectErrorLog.TabIndex = 1; + this.SelectErrorLog.Text = "查询报警信息"; + this.SelectErrorLog.UseVisualStyleBackColor = true; + this.SelectErrorLog.Click += new System.EventHandler(this.SelectErrorLog_Click); // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.AddRole); + this.ButtonPanel.Controls.Add(this.P3TextBox); + this.ButtonPanel.Controls.Add(this.label7); + this.ButtonPanel.Controls.Add(this.P2TextBox); + this.ButtonPanel.Controls.Add(this.label6); + this.ButtonPanel.Controls.Add(this.P1TextBox); + this.ButtonPanel.Controls.Add(this.label5); + this.ButtonPanel.Controls.Add(this.label4); + this.ButtonPanel.Controls.Add(this.SelectLogEndTime); + this.ButtonPanel.Controls.Add(this.SelectLogBeginTime); + this.ButtonPanel.Controls.Add(this.IsCheckByLogTime); + this.ButtonPanel.Controls.Add(this.label3); + this.ButtonPanel.Controls.Add(this.OperatorNameTextBox); + this.ButtonPanel.Controls.Add(this.label2); + this.ButtonPanel.Controls.Add(this.LogTextTextBox); + this.ButtonPanel.Controls.Add(this.label1); + this.ButtonPanel.Controls.Add(this.SelectErrorLog); this.ButtonPanel.Location = new System.Drawing.Point(0, 0); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(883, 61); + this.ButtonPanel.Size = new System.Drawing.Size(1170, 61); this.ButtonPanel.TabIndex = 4; this.ButtonPanel.Tag = "报警日志"; // + // P3TextBox + // + this.P3TextBox.Location = new System.Drawing.Point(943, 32); + this.P3TextBox.Name = "P3TextBox"; + this.P3TextBox.Size = new System.Drawing.Size(53, 21); + this.P3TextBox.TabIndex = 41; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(902, 36); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(35, 12); + this.label7.TabIndex = 40; + this.label7.Text = "字段3"; + // + // P2TextBox + // + this.P2TextBox.Location = new System.Drawing.Point(843, 32); + this.P2TextBox.Name = "P2TextBox"; + this.P2TextBox.Size = new System.Drawing.Size(53, 21); + this.P2TextBox.TabIndex = 39; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(802, 36); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(35, 12); + this.label6.TabIndex = 38; + this.label6.Text = "字段2"; + // + // P1TextBox + // + this.P1TextBox.Location = new System.Drawing.Point(743, 32); + this.P1TextBox.Name = "P1TextBox"; + this.P1TextBox.Size = new System.Drawing.Size(53, 21); + this.P1TextBox.TabIndex = 37; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(702, 36); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(35, 12); + this.label5.TabIndex = 36; + this.label5.Text = "字段1"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(488, 35); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(17, 12); + this.label4.TabIndex = 35; + this.label4.Text = "到"; + // + // SelectLogEndTime + // + this.SelectLogEndTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss"; + this.SelectLogEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.SelectLogEndTime.Location = new System.Drawing.Point(511, 32); + this.SelectLogEndTime.Name = "SelectLogEndTime"; + this.SelectLogEndTime.Size = new System.Drawing.Size(185, 21); + this.SelectLogEndTime.TabIndex = 34; + // + // SelectLogBeginTime + // + this.SelectLogBeginTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss"; + this.SelectLogBeginTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.SelectLogBeginTime.Location = new System.Drawing.Point(297, 32); + this.SelectLogBeginTime.Name = "SelectLogBeginTime"; + this.SelectLogBeginTime.Size = new System.Drawing.Size(185, 21); + this.SelectLogBeginTime.TabIndex = 33; + this.SelectLogBeginTime.Value = new System.DateTime(2024, 11, 26, 13, 36, 9, 0); + // + // IsCheckByLogTime + // + this.IsCheckByLogTime.AutoSize = true; + this.IsCheckByLogTime.Location = new System.Drawing.Point(366, 14); + this.IsCheckByLogTime.Name = "IsCheckByLogTime"; + this.IsCheckByLogTime.Size = new System.Drawing.Size(120, 16); + this.IsCheckByLogTime.TabIndex = 32; + this.IsCheckByLogTime.Text = "是否根据时间判断"; + this.IsCheckByLogTime.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(295, 16); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(65, 12); + this.label3.TabIndex = 31; + this.label3.Text = "登陆时间:"; + // + // OperatorNameTextBox + // + this.OperatorNameTextBox.Location = new System.Drawing.Point(191, 32); + this.OperatorNameTextBox.Name = "OperatorNameTextBox"; + this.OperatorNameTextBox.Size = new System.Drawing.Size(100, 21); + this.OperatorNameTextBox.TabIndex = 30; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(120, 36); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 12); + this.label2.TabIndex = 29; + this.label2.Text = "操作员名称"; + // + // LogTextTextBox + // + this.LogTextTextBox.Location = new System.Drawing.Point(191, 9); + this.LogTextTextBox.Name = "LogTextTextBox"; + this.LogTextTextBox.Size = new System.Drawing.Size(100, 21); + this.LogTextTextBox.TabIndex = 28; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(132, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 12); + this.label1.TabIndex = 27; + this.label1.Text = "日志内容"; + // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Width = 50; + // + // Text + // + this.Text.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Text.DataPropertyName = "Text"; + this.Text.HeaderText = "日志内容"; + this.Text.Name = "Text"; + this.Text.ReadOnly = true; + // + // LogTime + // + this.LogTime.DataPropertyName = "LogTime"; + this.LogTime.HeaderText = "日志时间"; + this.LogTime.Name = "LogTime"; + this.LogTime.ReadOnly = true; + this.LogTime.Width = 150; + // + // Operator + // + this.Operator.DataPropertyName = "Operator"; + this.Operator.HeaderText = "操作者用户名"; + this.Operator.Name = "Operator"; + this.Operator.ReadOnly = true; + // + // P1 + // + this.P1.DataPropertyName = "P1"; + this.P1.HeaderText = "字段1"; + this.P1.Name = "P1"; + this.P1.ReadOnly = true; + // + // P2 + // + this.P2.DataPropertyName = "P2"; + this.P2.HeaderText = "字段2"; + this.P2.Name = "P2"; + this.P2.ReadOnly = true; + // + // P3 + // + this.P3.DataPropertyName = "P3"; + this.P3.HeaderText = "字段3"; + this.P3.Name = "P3"; + this.P3.ReadOnly = true; + // // AlarmConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; this.Controls.Add(this.ButtonPanel); - this.Controls.Add(this.RoleDataGridView); + this.Controls.Add(this.LogDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "AlarmConfigPage"; - this.Size = new System.Drawing.Size(883, 562); + this.Size = new System.Drawing.Size(1170, 881); this.Tag = ""; - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).EndInit(); this.ButtonPanel.ResumeLayout(false); + this.ButtonPanel.PerformLayout(); this.ResumeLayout(false); } #endregion - private DataGridView RoleDataGridView; - private Button AddRole; + private DataGridView LogDataGridView; + private Button SelectErrorLog; private Panel ButtonPanel; + private TextBox P3TextBox; + private Label label7; + private TextBox P2TextBox; + private Label label6; + private TextBox P1TextBox; + private Label label5; + private Label label4; + private DateTimePicker SelectLogEndTime; + private DateTimePicker SelectLogBeginTime; + private CheckBox IsCheckByLogTime; + private Label label3; + private TextBox OperatorNameTextBox; + private Label label2; + private TextBox LogTextTextBox; + private Label label1; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn Text; + private DataGridViewTextBoxColumn LogTime; + private DataGridViewTextBoxColumn Operator; + private DataGridViewTextBoxColumn P1; + private DataGridViewTextBoxColumn P2; + private DataGridViewTextBoxColumn P3; } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs index e561cde..1a4ae4a 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs @@ -1,4 +1,7 @@ -using System; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,14 +15,53 @@ namespace HighWayIot.Winform.UserControlPages { public partial class AlarmConfigPage : UserControl { + private static SysErrorLogService sysErrorLogService = SysErrorLogService.Instance; + + private List Lists; + public AlarmConfigPage() { InitializeComponent(); + Init(); } - private void UpdateRole_Click(object sender, EventArgs e) + private void Init() { + LogDataGridView.AutoGenerateColumns = false; + + Lists = sysErrorLogService.GetErrorLogInfos(); + LogDataGridView.DataSource = null; + LogDataGridView.DataSource = Lists; } + + private void SelectErrorLog_Click(object sender, EventArgs e) + { + List list = sysErrorLogService.GetErrorLogInfos(); + + int? p1 = GeneralUtils.StringNullOrToInt(P1TextBox.Text); + int? p2 = GeneralUtils.StringNullOrToInt(P2TextBox.Text); + int? p3 = GeneralUtils.StringNullOrToInt(P3TextBox.Text); + + string logText = LogTextTextBox.Text.Trim(); + string operatorName = OperatorNameTextBox.Text.Trim(); + bool logTimeChecked = IsCheckByLogTime.Checked; + DateTime logBeginTime = SelectLogBeginTime.Value; + DateTime logEndTime = SelectLogEndTime.Value; + + Lists = list.Where(x => + (string.IsNullOrEmpty(logText) || x.Text.Contains(logText)) && + (string.IsNullOrEmpty(operatorName) || x.Operator == operatorName) && + (!p1.HasValue || x.P1 == p1.Value) && + (!p2.HasValue || x.P2 == p2.Value) && + (!p3.HasValue || x.P3 == p3.Value) && + (!logTimeChecked || (x.LogTime >= logBeginTime && x.LogTime <= logEndTime)) + ).ToList(); + + LogDataGridView.DataSource = null; + LogDataGridView.DataSource = Lists; + } + + } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx index 1af7de1..e86d420 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx @@ -117,4 +117,25 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs index 000f0f4..93bb95e 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs @@ -31,68 +31,318 @@ namespace HighWayIot.Winform.UserControlPages /// private void InitializeComponent() { - this.RoleDataGridView = new System.Windows.Forms.DataGridView(); - this.AddRole = new System.Windows.Forms.Button(); + this.SelectRole = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).BeginInit(); + this.P3TextBox = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.P2TextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.P1TextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.SelectLogEndTime = new System.Windows.Forms.DateTimePicker(); + this.SelectLogBeginTime = new System.Windows.Forms.DateTimePicker(); + this.IsCheckByLogTime = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.OperatorNameTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.LogTextTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.LogDataGridView = new System.Windows.Forms.DataGridView(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ButtonPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit(); this.SuspendLayout(); // - // RoleDataGridView + // SelectRole // - this.RoleDataGridView.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.RoleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.RoleDataGridView.Location = new System.Drawing.Point(0, 65); - this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.RoleDataGridView.Name = "RoleDataGridView"; - this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(883, 497); - this.RoleDataGridView.TabIndex = 0; - this.RoleDataGridView.Tag = ""; - // - // AddRole - // - this.AddRole.Location = new System.Drawing.Point(11, 11); - this.AddRole.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.AddRole.Name = "AddRole"; - this.AddRole.Size = new System.Drawing.Size(103, 39); - this.AddRole.TabIndex = 1; - this.AddRole.Text = "查询操作信息"; - this.AddRole.UseVisualStyleBackColor = true; + this.SelectRole.Location = new System.Drawing.Point(11, 11); + this.SelectRole.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.SelectRole.Name = "SelectRole"; + this.SelectRole.Size = new System.Drawing.Size(103, 39); + this.SelectRole.TabIndex = 1; + this.SelectRole.Text = "查询操作信息"; + this.SelectRole.UseVisualStyleBackColor = true; + this.SelectRole.Click += new System.EventHandler(this.SelectRole_Click); // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.AddRole); + this.ButtonPanel.Controls.Add(this.P3TextBox); + this.ButtonPanel.Controls.Add(this.label7); + this.ButtonPanel.Controls.Add(this.P2TextBox); + this.ButtonPanel.Controls.Add(this.label6); + this.ButtonPanel.Controls.Add(this.P1TextBox); + this.ButtonPanel.Controls.Add(this.label5); + this.ButtonPanel.Controls.Add(this.label4); + this.ButtonPanel.Controls.Add(this.SelectLogEndTime); + this.ButtonPanel.Controls.Add(this.SelectLogBeginTime); + this.ButtonPanel.Controls.Add(this.IsCheckByLogTime); + this.ButtonPanel.Controls.Add(this.label3); + this.ButtonPanel.Controls.Add(this.OperatorNameTextBox); + this.ButtonPanel.Controls.Add(this.label2); + this.ButtonPanel.Controls.Add(this.LogTextTextBox); + this.ButtonPanel.Controls.Add(this.label1); + this.ButtonPanel.Controls.Add(this.SelectRole); this.ButtonPanel.Location = new System.Drawing.Point(0, 0); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(883, 61); + this.ButtonPanel.Size = new System.Drawing.Size(1162, 61); this.ButtonPanel.TabIndex = 4; // + // P3TextBox + // + this.P3TextBox.Location = new System.Drawing.Point(943, 32); + this.P3TextBox.Name = "P3TextBox"; + this.P3TextBox.Size = new System.Drawing.Size(53, 21); + this.P3TextBox.TabIndex = 26; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(902, 36); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(35, 12); + this.label7.TabIndex = 25; + this.label7.Text = "字段3"; + // + // P2TextBox + // + this.P2TextBox.Location = new System.Drawing.Point(843, 32); + this.P2TextBox.Name = "P2TextBox"; + this.P2TextBox.Size = new System.Drawing.Size(53, 21); + this.P2TextBox.TabIndex = 24; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(802, 36); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(35, 12); + this.label6.TabIndex = 23; + this.label6.Text = "字段2"; + // + // P1TextBox + // + this.P1TextBox.Location = new System.Drawing.Point(743, 32); + this.P1TextBox.Name = "P1TextBox"; + this.P1TextBox.Size = new System.Drawing.Size(53, 21); + this.P1TextBox.TabIndex = 22; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(702, 36); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(35, 12); + this.label5.TabIndex = 21; + this.label5.Text = "字段1"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(488, 35); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(17, 12); + this.label4.TabIndex = 18; + this.label4.Text = "到"; + // + // SelectLogEndTime + // + this.SelectLogEndTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss"; + this.SelectLogEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.SelectLogEndTime.Location = new System.Drawing.Point(511, 32); + this.SelectLogEndTime.Name = "SelectLogEndTime"; + this.SelectLogEndTime.Size = new System.Drawing.Size(185, 21); + this.SelectLogEndTime.TabIndex = 17; + // + // SelectLogBeginTime + // + this.SelectLogBeginTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss"; + this.SelectLogBeginTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.SelectLogBeginTime.Location = new System.Drawing.Point(297, 32); + this.SelectLogBeginTime.Name = "SelectLogBeginTime"; + this.SelectLogBeginTime.Size = new System.Drawing.Size(185, 21); + this.SelectLogBeginTime.TabIndex = 16; + this.SelectLogBeginTime.Value = new System.DateTime(2024, 11, 26, 13, 36, 9, 0); + // + // IsCheckByLogTime + // + this.IsCheckByLogTime.AutoSize = true; + this.IsCheckByLogTime.Location = new System.Drawing.Point(366, 14); + this.IsCheckByLogTime.Name = "IsCheckByLogTime"; + this.IsCheckByLogTime.Size = new System.Drawing.Size(120, 16); + this.IsCheckByLogTime.TabIndex = 15; + this.IsCheckByLogTime.Text = "是否根据时间判断"; + this.IsCheckByLogTime.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(295, 16); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(65, 12); + this.label3.TabIndex = 14; + this.label3.Text = "登陆时间:"; + // + // OperatorNameTextBox + // + this.OperatorNameTextBox.Location = new System.Drawing.Point(191, 32); + this.OperatorNameTextBox.Name = "OperatorNameTextBox"; + this.OperatorNameTextBox.Size = new System.Drawing.Size(100, 21); + this.OperatorNameTextBox.TabIndex = 5; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(120, 36); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 12); + this.label2.TabIndex = 4; + this.label2.Text = "操作员名称"; + // + // LogTextTextBox + // + this.LogTextTextBox.Location = new System.Drawing.Point(191, 9); + this.LogTextTextBox.Name = "LogTextTextBox"; + this.LogTextTextBox.Size = new System.Drawing.Size(100, 21); + this.LogTextTextBox.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(132, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 12); + this.label1.TabIndex = 2; + this.label1.Text = "日志内容"; + // + // LogDataGridView + // + this.LogDataGridView.AllowUserToAddRows = false; + this.LogDataGridView.AllowUserToDeleteRows = false; + this.LogDataGridView.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.LogDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.LogDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Id, + this.Text, + this.LogTime, + this.Operator, + this.P1, + this.P2, + this.P3}); + this.LogDataGridView.Location = new System.Drawing.Point(0, 65); + this.LogDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.LogDataGridView.Name = "LogDataGridView"; + this.LogDataGridView.ReadOnly = true; + this.LogDataGridView.RowHeadersVisible = false; + this.LogDataGridView.RowTemplate.Height = 25; + this.LogDataGridView.Size = new System.Drawing.Size(1162, 760); + this.LogDataGridView.TabIndex = 5; + // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Width = 50; + // + // Text + // + this.Text.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Text.DataPropertyName = "Text"; + this.Text.HeaderText = "日志内容"; + this.Text.Name = "Text"; + this.Text.ReadOnly = true; + // + // LogTime + // + this.LogTime.DataPropertyName = "LogTime"; + this.LogTime.HeaderText = "日志时间"; + this.LogTime.Name = "LogTime"; + this.LogTime.ReadOnly = true; + this.LogTime.Width = 150; + // + // Operator + // + this.Operator.DataPropertyName = "Operator"; + this.Operator.HeaderText = "操作者用户名"; + this.Operator.Name = "Operator"; + this.Operator.ReadOnly = true; + // + // P1 + // + this.P1.DataPropertyName = "P1"; + this.P1.HeaderText = "字段1"; + this.P1.Name = "P1"; + this.P1.ReadOnly = true; + // + // P2 + // + this.P2.DataPropertyName = "P2"; + this.P2.HeaderText = "字段2"; + this.P2.Name = "P2"; + this.P2.ReadOnly = true; + // + // P3 + // + this.P3.DataPropertyName = "P3"; + this.P3.HeaderText = "字段3"; + this.P3.Name = "P3"; + this.P3.ReadOnly = true; + // // OperateConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; + this.Controls.Add(this.LogDataGridView); this.Controls.Add(this.ButtonPanel); - this.Controls.Add(this.RoleDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "OperateConfigPage"; - this.Size = new System.Drawing.Size(883, 562); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); + this.Size = new System.Drawing.Size(1162, 825); this.ButtonPanel.ResumeLayout(false); + this.ButtonPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).EndInit(); this.ResumeLayout(false); } #endregion - - private DataGridView RoleDataGridView; - private Button AddRole; + private Button SelectRole; private Panel ButtonPanel; + private Label label1; + private TextBox OperatorNameTextBox; + private Label label2; + private TextBox LogTextTextBox; + private Label label4; + private DateTimePicker SelectLogEndTime; + private DateTimePicker SelectLogBeginTime; + private CheckBox IsCheckByLogTime; + private Label label3; + private TextBox P3TextBox; + private Label label7; + private TextBox P2TextBox; + private Label label6; + private TextBox P1TextBox; + private Label label5; + private DataGridView LogDataGridView; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn Text; + private DataGridViewTextBoxColumn LogTime; + private DataGridViewTextBoxColumn Operator; + private DataGridViewTextBoxColumn P1; + private DataGridViewTextBoxColumn P2; + private DataGridViewTextBoxColumn P3; } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs index 6f8f531..03cb5f4 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs @@ -1,4 +1,7 @@ -using System; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,14 +15,50 @@ namespace HighWayIot.Winform.UserControlPages { public partial class OperateConfigPage : UserControl { + private static SysLogService sysLogService = SysLogService.Instance; + + private List Lists; + public OperateConfigPage() { InitializeComponent(); + Init(); } - private void UpdateRole_Click(object sender, EventArgs e) + private void Init() { + LogDataGridView.AutoGenerateColumns = false; + + Lists = sysLogService.GetLogInfos(); + LogDataGridView.DataSource = null; + LogDataGridView.DataSource = Lists; + } + + private void SelectRole_Click(object sender, EventArgs e) + { + List list = sysLogService.GetLogInfos(); + + int? p1 = GeneralUtils.StringNullOrToInt(P1TextBox.Text); + int? p2 = GeneralUtils.StringNullOrToInt(P2TextBox.Text); + int? p3 = GeneralUtils.StringNullOrToInt(P3TextBox.Text); + + string logText = LogTextTextBox.Text.Trim(); + string operatorName = OperatorNameTextBox.Text.Trim(); + bool logTimeChecked = IsCheckByLogTime.Checked; + DateTime logBeginTime = SelectLogBeginTime.Value; + DateTime logEndTime = SelectLogEndTime.Value; + + Lists = list.Where(x => + (string.IsNullOrEmpty(logText) || x.Text.Contains(logText)) && + (string.IsNullOrEmpty(operatorName) || x.Operator == operatorName) && + (!p1.HasValue || x.P1 == p1.Value) && + (!p2.HasValue || x.P2 == p2.Value) && + (!p3.HasValue || x.P3 == p3.Value) && + (!logTimeChecked || (x.LogTime >= logBeginTime && x.LogTime <= logEndTime)) + ).ToList(); + LogDataGridView.DataSource = null; + LogDataGridView.DataSource = Lists; } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx index 1af7de1..e86d420 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx @@ -117,4 +117,25 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs index ce00730..73b589c 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs @@ -21,6 +21,7 @@ namespace HighWayIot.Winform.UserControlPages public MonitorMainPage() { InitializeComponent(); + DateTimeRefresh(); } /// @@ -30,7 +31,10 @@ namespace HighWayIot.Winform.UserControlPages /// private void DataRefresh_Tick(object sender, EventArgs e) { - DateTimeRefresh(); + if(DateTime.Now.Second == 0) + { + DateTimeRefresh(); + } } /// diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index 049512a..ab3fafd 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -34,12 +34,8 @@ namespace HighWayIot.Winform.UserControlPages private void button2_Click(object sender, EventArgs e) { - char[] chars = new char[100]; - for (int i = 0; i < 100; i++) - { - chars[i] = '0'; - } - string originalRole = new string(chars); + SqlLogHelper.AddLog("wdas", 7, 8, 9); + SqlLogHelper.AddErrorLog("wocasda", 4, 5, 6); } } }