You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/DB/Service/UpdateLogService.cs

90 lines
2.4 KiB
C#

2 weeks ago
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Forms.VisualStyles;
1 week ago
using Chloe;
2 weeks ago
using DB.Dto;
using DB.Entity;
using Tool;
namespace DB.Service
{
1 week ago
/// <summary>
/// 参数修改日志
/// </summary>
2 weeks ago
public class UpdateLogService
{
4 days ago
public bool AddOrUpdateLog(UserDto user,string address,int value)
2 weeks ago
{
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;
}
1 week ago
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;
}
2 weeks ago
}
}