123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using DevExpress.Mvvm.Native;
- using DevExpress.Utils;
- using DevExpress.Utils.Html;
- using DevExpress.XtraEditors;
- using DxHelper;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Forms;
- using XdCxRhDW.App.Controllers;
- using XdCxRhDW.App.EditForms;
- using XdCxRhDW.App.Model;
- using XdCxRhDW.Dto;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.UserControl
- {
- public partial class CtrlSvrLog : DevExpress.XtraEditors.XtraUserControl
- {
- List<LogInfo> list = new List<LogInfo>();
- public CtrlSvrLog()
- {
- InitializeComponent();
- this.txtStart.UseDefault();
- this.txtEnd.UseDefault();
- }
- private async void CtrlSvrs_Load(object sender, EventArgs e)
- {
- gridLog.UseDefault(list).UseEmptyText("无结果").UseRowNumber().UseDeleteAsync<LogInfo>(async data =>
- {
- 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;
- 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())
- {
- foreach (var item in res.data)
- {
- this.txtLogModules.Properties.Items.Add(item.Module, item.Module, -1);
- }
- }
- this.txtLogModules.SelectedIndex = 0;
- }
- private async void btnQuery_Click(object sender, EventArgs e)
- {
- btnQuery.Enabled = false;
- this.list.Clear();
- try
- {
- LogQueryDto dto = new LogQueryDto()
- {
- Module = this.txtLogModules.Text,
- LogTimeBegin = txtStart.DateTime,
- LogTimeEnd = txtEnd.DateTime,
- };
- var res = await HttpHelper.PostRequestAsync<List<LogInfoDto>>(SysConfig.GetUrl("Log/Query"), dto);
- if (res.code != 200)
- {
- MsgBoxHelper.ShowError(res.msg);
- }
- else
- {
- var items = res.data.Select(t => new LogInfo()
- {
- ID = t.ID,
- LogTime = t.LogTime,
- LogType = (Model.EnumLogType)(int)t.LogType,
- Module = t.Module,
- Msg = t.Msg
- });
- this.list.AddRange(items);
- if (!list.Any())
- {
- await Task.Delay(200);
- }
- this.BeginInvoke(new Action(() =>
- {
- gridView1.RefreshData();
- }));
- }
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "查询日志出错");
- MsgBoxHelper.ShowError("查询日志出错");
- }
- btnQuery.Enabled = true;
- }
- }
- }
|