| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Microsoft.AspNetCore.Identity; |
| | | using Model.ModelDto.LogDto; |
| | | using Model.ModelVm.LogVm; |
| | | using SqlSugar; |
| | | using Utility; |
| | | using WMS.DAL; |
| | | using WMS.Entity.Context; |
| | | using WMS.Entity.LogEntity; |
| | |
| | | public class OperationCrServer: DbHelper<LogOperationCR>,IOperationCRServer |
| | | { |
| | | private static readonly SqlSugarScope Db = DataContext.Db; |
| | | private readonly UserManager _userManager; |
| | | public OperationCrServer() : base(Db) |
| | | { |
| | | } |
| | | public List<OperationDto> GetLogOperationCrList(string menuName, string type, string msg, string startTime, string endTime, int page, int limit, out int count) |
| | | public OperationCrServer(UserManager userManager) : base(Db) |
| | | { |
| | | _userManager = userManager; |
| | | } |
| | | public async Task<List<OperationDto>> GetLogOperationCrList(string menuName, string type, string msg, string startTime, string endTime, int page, int limit, RefAsync<int> count) |
| | | { |
| | | try |
| | | { |
| | |
| | | .AndIF(!string.IsNullOrWhiteSpace(startTime), it => it.CreateTime >= Convert.ToDateTime(startTime)) |
| | | .AndIF(!string.IsNullOrWhiteSpace(endTime), it => it.CreateTime <= Convert.ToDateTime(endTime).AddDays(1)) |
| | | .ToExpression();//注意 这一句 不能少 |
| | | var total = 0; |
| | | var list = GetAllWhereAsync(item) |
| | | var list = await GetAllWhereAsync(item) |
| | | .LeftJoin<SysDictionary>((it, dic) => it.Type == dic.Id.ToString()) |
| | | .LeftJoin<SysUserInfor>((it, dic, users) => it.CreateUser == users.Id) |
| | | .Select((it, dic, users) => new OperationDto() |
| | |
| | | CreateUserName = users.RealName, |
| | | }) |
| | | .OrderByDescending(it => it.CreateTime) |
| | | .ToOffsetPage(page, limit, ref total); |
| | | |
| | | count = total; |
| | | return list.OrderByDescending(m => m.CreateTime).ToList(); |
| | | .ToPageListAsync(page, limit, count); |
| | | return list; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | var contextDb = DataContext.Db; |
| | | var menu = contextDb.Queryable<SysFunctionMenu>().Where(m => m.IsDel == "0").ToList(); |
| | | var dic = contextDb.Queryable<SysDictionary>().Where(m => m.ParentNo == "LogType" && m.IsDel == "0").ToList(); |
| | | var menu = Db.Queryable<SysFunctionMenu>().Where(m => m.IsDel == "0").ToList(); |
| | | var dic = Db.Queryable<SysDictionary>().Where(m => m.ParentNo == "LogType" && m.IsDel == "0").ToList(); |
| | | var typeId = dic.FirstOrDefault(m => m.DictName == type); |
| | | |
| | | var n = Add(new LogOperationCR() |
| | |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 新增系统操作日志 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<int> AddLogOperationCr(OperationInputVm input) |
| | | { |
| | | input.ParentNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == input.ParentName && s.IsDel == "0"))?.MenuNo; |
| | | input.MenuNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == input.MenuName && s.IsDel == "0"))?.MenuNo; |
| | | input.Type = (await Db.Queryable<SysDictionary>().FirstAsync(s => s.DictName == input.TypeName && s.IsDel == "0"))?.Id.ToString(); |
| | | input.CreateUser = _userManager.UserId; |
| | | input.CreateTime = DateTime.Now; |
| | | return await Db.Insertable<LogOperationCR>(input).ExecuteCommandAsync(); |
| | | } |
| | | } |
| | | } |