|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Windows.Forms.VisualStyles;
|
|
|
|
|
using Chloe;
|
|
|
|
|
using DB.Dto;
|
|
|
|
|
using DB.Entity;
|
|
|
|
|
|
|
|
|
|
using Tool;
|
|
|
|
|
|
|
|
|
|
namespace DB.Service
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数修改日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UpdateLogService
|
|
|
|
|
{
|
|
|
|
|
public bool AddOrUpdateLog(UserDto user,string address,int value)
|
|
|
|
|
{
|
|
|
|
|
UpdateLog log = new UpdateLog
|
|
|
|
|
{
|
|
|
|
|
ID = SnowflakeFactory.NewId,
|
|
|
|
|
PointName = address,
|
|
|
|
|
CreateDate = DateTime.Now,
|
|
|
|
|
CreateUserId = user.Id.ToString(),
|
|
|
|
|
CreateUserName = user.UserName,
|
|
|
|
|
LastModifyUserId = "",
|
|
|
|
|
LastModifyUserName = "",
|
|
|
|
|
LastModifyDate = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using (var dbContext = DbFactory.GetContext)
|
|
|
|
|
{
|
|
|
|
|
var firstOrDefault = dbContext.Query<UpdateLog>()
|
|
|
|
|
.Where(x=>x.PointName==address)
|
|
|
|
|
.OrderByDesc(x=>x.ID).FirstOrDefault();
|
|
|
|
|
if (firstOrDefault != null)
|
|
|
|
|
{
|
|
|
|
|
if (firstOrDefault.NewValue != value.ToString())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
log.OldValue = firstOrDefault.NewValue;
|
|
|
|
|
log.NewValue = value.ToString();
|
|
|
|
|
dbContext.Insert(log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
log.OldValue = "";
|
|
|
|
|
log.NewValue = value.ToString();
|
|
|
|
|
dbContext.Insert(log);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PagedList<UpdateLog> GetPagedList(int pageIndex, int pageSize, string key)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PagingResult<UpdateLog> pagePagingResult;
|
|
|
|
|
using (var dbContext = DbFactory.GetContext)
|
|
|
|
|
{
|
|
|
|
|
pagePagingResult = dbContext.Query<UpdateLog>()
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(key),x=>x.PointName.Contains(key))
|
|
|
|
|
.OrderByDesc(x => x.ID)
|
|
|
|
|
.Paging(pageIndex, pageSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PagedList<UpdateLog> paged = new PagedList<UpdateLog>(pagePagingResult.DataList,
|
|
|
|
|
pagePagingResult.Totals.ToInt(), pageIndex, pageSize);
|
|
|
|
|
|
|
|
|
|
return paged;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|