gongqiuhong 4 months ago
parent
commit
40e69a00e3

+ 87 - 90
DW5S.App/UserControl/CtrlSvrLog.Designer.cs

@@ -28,114 +28,111 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
-            this.gridLog = new DevExpress.XtraGrid.GridControl();
-            this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
-            this.txtLogModules = new DevExpress.XtraEditors.ImageComboBoxEdit();
-            this.txtStart = new DevExpress.XtraEditors.DateEdit();
-            this.txtEnd = new DevExpress.XtraEditors.DateEdit();
-            this.btnQuery = new DevExpress.XtraEditors.SimpleButton();
-            ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
-            this.panelControl1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.gridLog)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtLogModules.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtStart.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtStart.Properties.CalendarTimeProperties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtEnd.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtEnd.Properties.CalendarTimeProperties)).BeginInit();
-            this.SuspendLayout();
+            panelControl1 = new DevExpress.XtraEditors.PanelControl();
+            btnQuery = new DevExpress.XtraEditors.SimpleButton();
+            txtEnd = new DevExpress.XtraEditors.DateEdit();
+            txtStart = new DevExpress.XtraEditors.DateEdit();
+            txtLogModules = new DevExpress.XtraEditors.ImageComboBoxEdit();
+            gridLog = new DevExpress.XtraGrid.GridControl();
+            gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
+            ((System.ComponentModel.ISupportInitialize)panelControl1).BeginInit();
+            panelControl1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)txtEnd.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtEnd.Properties.CalendarTimeProperties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtStart.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtStart.Properties.CalendarTimeProperties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtLogModules.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)gridLog).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)gridView1).BeginInit();
+            SuspendLayout();
             // 
             // panelControl1
             // 
-            this.panelControl1.Controls.Add(this.btnQuery);
-            this.panelControl1.Controls.Add(this.txtEnd);
-            this.panelControl1.Controls.Add(this.txtStart);
-            this.panelControl1.Controls.Add(this.txtLogModules);
-            this.panelControl1.Dock = System.Windows.Forms.DockStyle.Top;
-            this.panelControl1.Location = new System.Drawing.Point(0, 0);
-            this.panelControl1.Name = "panelControl1";
-            this.panelControl1.Size = new System.Drawing.Size(805, 31);
-            this.panelControl1.TabIndex = 2;
+            panelControl1.Controls.Add(btnQuery);
+            panelControl1.Controls.Add(txtEnd);
+            panelControl1.Controls.Add(txtStart);
+            panelControl1.Controls.Add(txtLogModules);
+            panelControl1.Dock = System.Windows.Forms.DockStyle.Top;
+            panelControl1.Location = new System.Drawing.Point(0, 0);
+            panelControl1.Name = "panelControl1";
+            panelControl1.Size = new System.Drawing.Size(805, 31);
+            panelControl1.TabIndex = 2;
             // 
-            // gridLog
+            // btnQuery
             // 
-            this.gridLog.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.gridLog.Location = new System.Drawing.Point(0, 31);
-            this.gridLog.MainView = this.gridView1;
-            this.gridLog.Name = "gridLog";
-            this.gridLog.Size = new System.Drawing.Size(805, 459);
-            this.gridLog.TabIndex = 3;
-            this.gridLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
-            this.gridView1});
+            btnQuery.Location = new System.Drawing.Point(642, 4);
+            btnQuery.Name = "btnQuery";
+            btnQuery.Size = new System.Drawing.Size(75, 23);
+            btnQuery.TabIndex = 2;
+            btnQuery.Text = "查询";
+            btnQuery.Click += btnQuery_Click;
             // 
-            // gridView1
+            // txtEnd
             // 
-            this.gridView1.GridControl = this.gridLog;
-            this.gridView1.Name = "gridView1";
+            txtEnd.EditValue = null;
+            txtEnd.Location = new System.Drawing.Point(420, 5);
+            txtEnd.Name = "txtEnd";
+            txtEnd.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
+            txtEnd.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
+            txtEnd.Properties.NullText = "结束时间";
+            txtEnd.Properties.NullValuePrompt = "所示";
+            txtEnd.Size = new System.Drawing.Size(216, 20);
+            txtEnd.TabIndex = 1;
+            txtEnd.ToolTip = "dd";
             // 
-            // txtLogModules
+            // txtStart
             // 
-            this.txtLogModules.Location = new System.Drawing.Point(5, 5);
-            this.txtLogModules.Name = "txtLogModules";
-            this.txtLogModules.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.txtLogModules.Size = new System.Drawing.Size(187, 20);
-            this.txtLogModules.TabIndex = 0;
+            txtStart.EditValue = null;
+            txtStart.Location = new System.Drawing.Point(198, 5);
+            txtStart.Name = "txtStart";
+            txtStart.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
+            txtStart.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
+            txtStart.Properties.NullText = "开始时间";
+            txtStart.Size = new System.Drawing.Size(216, 20);
+            txtStart.TabIndex = 1;
             // 
-            // txtStart
+            // txtLogModules
             // 
-            this.txtStart.EditValue = null;
-            this.txtStart.Location = new System.Drawing.Point(198, 5);
-            this.txtStart.Name = "txtStart";
-            this.txtStart.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.txtStart.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.txtStart.Size = new System.Drawing.Size(216, 20);
-            this.txtStart.TabIndex = 1;
+            txtLogModules.Location = new System.Drawing.Point(5, 5);
+            txtLogModules.Name = "txtLogModules";
+            txtLogModules.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
+            txtLogModules.Size = new System.Drawing.Size(187, 20);
+            txtLogModules.TabIndex = 0;
             // 
-            // txtEnd
+            // gridLog
             // 
-            this.txtEnd.EditValue = null;
-            this.txtEnd.Location = new System.Drawing.Point(420, 5);
-            this.txtEnd.Name = "txtEnd";
-            this.txtEnd.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.txtEnd.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.txtEnd.Size = new System.Drawing.Size(216, 20);
-            this.txtEnd.TabIndex = 1;
+            gridLog.Dock = System.Windows.Forms.DockStyle.Fill;
+            gridLog.Location = new System.Drawing.Point(0, 31);
+            gridLog.MainView = gridView1;
+            gridLog.Name = "gridLog";
+            gridLog.Size = new System.Drawing.Size(805, 459);
+            gridLog.TabIndex = 3;
+            gridLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { gridView1 });
             // 
-            // btnQuery
+            // gridView1
             // 
-            this.btnQuery.Location = new System.Drawing.Point(642, 4);
-            this.btnQuery.Name = "btnQuery";
-            this.btnQuery.Size = new System.Drawing.Size(75, 23);
-            this.btnQuery.TabIndex = 2;
-            this.btnQuery.Text = "查询";
-            this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
+            gridView1.GridControl = gridLog;
+            gridView1.Name = "gridView1";
             // 
             // CtrlSvrLog
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Controls.Add(this.gridLog);
-            this.Controls.Add(this.panelControl1);
-            this.Name = "CtrlSvrLog";
-            this.Size = new System.Drawing.Size(805, 490);
-            this.Load += new System.EventHandler(this.CtrlSvrs_Load);
-            ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
-            this.panelControl1.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.gridLog)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtLogModules.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtStart.Properties.CalendarTimeProperties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtStart.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtEnd.Properties.CalendarTimeProperties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtEnd.Properties)).EndInit();
-            this.ResumeLayout(false);
-
+            AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
+            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            Controls.Add(gridLog);
+            Controls.Add(panelControl1);
+            Name = "CtrlSvrLog";
+            Size = new System.Drawing.Size(805, 490);
+            Load += CtrlSvrs_Load;
+            ((System.ComponentModel.ISupportInitialize)panelControl1).EndInit();
+            panelControl1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)txtEnd.Properties.CalendarTimeProperties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtEnd.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtStart.Properties.CalendarTimeProperties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtStart.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtLogModules.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)gridLog).EndInit();
+            ((System.ComponentModel.ISupportInitialize)gridView1).EndInit();
+            ResumeLayout(false);
         }
 
         #endregion

+ 13 - 10
DW5S.App/UserControl/CtrlSvrLog.cs

@@ -23,12 +23,14 @@ using DW5S.DTO;
 using DW5S.Repostory;
 using Serilog;
 using DW5S.Service;
+using DW5S.ViewModel;
+using DW5S.Entity;
 
 namespace DW5S.App.UserControl
 {
     public partial class CtrlSvrLog : DevExpress.XtraEditors.XtraUserControl
     {
-        List<LogInfo> list = new List<LogInfo>();
+        List<LogResViewModel> list = new List<LogResViewModel>();
         public CtrlSvrLog()
         {
             InitializeComponent();
@@ -39,16 +41,17 @@ namespace DW5S.App.UserControl
 
         private async void CtrlSvrs_Load(object sender, EventArgs e)
         {
-            gridLog.UseDefault(list).UseEmptyText("无结果").UseRowNumber().UseDeleteAsync<LogInfo>(async data =>
+           
+            gridLog.UseDefault(list).UseEmptyText("无结果").UseRowNumber().UseDeleteAsync<LogResViewModel>(async data =>
             {
-                var delItems = data.Select(t => new LogDeleteDto(t.ID));
+                var delItems = data.Select(t => new LogDeleteDto(t.Id));
                 var rsp = await HttpHelper.PostRequestAsync(SysConfig.GetUrl("Log/Delete"), delItems);
                 return rsp.code == 200;
 
-            }).UseExportCsv().SetLogImageColumn(nameof(LogInfo.LogType), typeof(EnumLogType));
-            gridView1.Columns[nameof(LogInfo.LogType)].MaxWidth = 100;
-            gridView1.Columns[nameof(LogInfo.LogTime)].MaxWidth = 160;
-            gridView1.Columns[nameof(LogInfo.Msg)].AppearanceCell.TextOptions.HAlignment = HorzAlignment.Near;
+            }).UseExportCsv().SetLogImageColumn(nameof(LogResViewModel.LogType), typeof(EnumLogType));
+            gridView1.Columns[nameof(LogResViewModel.LogType)].MaxWidth = 100;
+            gridView1.Columns[nameof(LogResViewModel.LogTime)].MaxWidth = 160;
+            gridView1.Columns[nameof(LogResViewModel.Msg)].AppearanceCell.TextOptions.HAlignment = HorzAlignment.Near;
             this.txtLogModules.Properties.Items.Add("全部", "全部", -1);
             var res = await HttpHelper.PostRequestAsync<List<LogModulesResDto>>(SysConfig.GetUrl("Log/GetModules"), null);
             if (res.data != null && res.data.Any())
@@ -80,11 +83,11 @@ namespace DW5S.App.UserControl
                 }
                 else
                 {
-                    var items = res.data.Select(t => new LogInfo()
+                    var items = res.data.Select(t => new LogResViewModel()
                     {
-                        ID = t.ID,
+                        Id = t.ID,
                         LogTime = t.LogTime,
-                        LogType = (Model.EnumLogType)(int)t.LogType,
+                        LogType = (EnumLogType)(int)t.LogType,
                         Module = t.Module,
                         Msg = t.Msg
 

+ 25 - 25
DW5S.App/UserControl/CtrlSvrLog.resx

@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <root>
-  <!-- 
+  <!--
     Microsoft ResX Schema 
-    
+
     Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
+
+    The primary goals of this format is to allow a simple XML format
+    that is mostly human readable. The generation and parsing of the
+    various data types are done through the TypeConverter classes
     associated with the data types.
-    
+
     Example:
-    
+
     ... ado.net/XML headers & schema ...
     <resheader name="resmimetype">text/microsoft-resx</resheader>
     <resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
         <comment>This is a comment</comment>
     </data>
-                
-    There are any number of "resheader" rows that contain simple 
+
+    There are any number of "resheader" rows that contain simple
     name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
+
+    Each data row contains a name, and value. The row also contains a
+    type or mimetype. Type corresponds to a .NET class that support
+    text/value conversion through the TypeConverter architecture.
+    Classes that don't support this are serialized and stored with the
     mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
+
+    The mimetype is used for serialized objects, and tells the
+    ResXResourceReader how to depersist the object. This is currently not
     extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
+
+    Note - application/x-microsoft.net.object.binary.base64 is the format
+    that the ResXResourceWriter will generate, however the reader can
     read any of the formats listed below.
-    
+
     mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
             : and then encoded with base64 encoding.
 
     mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
+    value   : The object must be serialized into a byte array
             : using a System.ComponentModel.TypeConverter
             : and then encoded with base64 encoding.
     -->

+ 1 - 2
DW5S.Controller/LogController.cs

@@ -131,8 +131,7 @@ namespace DW5S.Controllers
             try
             {
                 var repsLog = unitOfWork.OfLong<LogRes>();
-                var ids = dto.Select(p => p.ID);
-                await repsLog.DeleteAsync(p => ids.Contains(p.Id));
+                await repsLog.DeleteAsync(dto.To<List<LogRes>>());
                 await unitOfWork.SaveAsync();
                 return Success();
             }

+ 12 - 23
DW5S.App/Model/LogInfo.cs → DW5S.ViewModel/LogResViewModel.cs

@@ -1,44 +1,33 @@
-using System;
+using DW5S.Entity;
+using Microsoft.EntityFrameworkCore;
+using System;
 using System.Collections.Generic;
-using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace DW5S.App.Model
+namespace DW5S.ViewModel
 {
-    public class LogInfo
-    {
-        public LogInfo()
-        {
-            this.LogTime = DateTime.Now;
-            this.LogType = EnumLogType.Info;
-        }
-        [Display(Name = "ID")]
-        public long ID { get; set; }
 
+    public class LogResViewModel : BaseViewModel<long>
+    {
+       
         [Display(Name = "所属模块")]
         public string Module { get; set; }
 
+        
         [Display(Name = "时间")]
         public DateTime LogTime { get;  set; }
 
+      
         [Display(Name = "日志类型")]
         public EnumLogType LogType { get; set; }
 
+       
         [Display(Name = "内容")]
         public string Msg { get; set; }
     }
-    public enum EnumLogType
-    {
-        [Display(Name = "消息")]
-        Info,
-
-        [Display(Name = "警告")]
-        Warning,
-
-        [Display(Name = "错误")]
-        Error
-    }
 }