using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using AutoMapper; using Model.ModelDto.LogDto; using SqlSugar; using WMS.DAL; using WMS.Entity.Context; using WMS.Entity.LogEntity; using WMS.Entity.SysEntity; using WMS.IBLL.ILogServer; using WMS.IDAL.ILogInterface; namespace WMS.BLL.LogServer { public class OperationSysServer : DbHelper, IOperationSysServer { private readonly IOperationSysRepository _operation; private readonly IMapper _mapper; private static readonly SqlSugarScope Db = DataContext.Db; /// /// 构造函数 /// /// 日志 /// automapper public OperationSysServer(IOperationSysRepository operation, IMapper mapper) : base(Db) { _operation = operation; //日志 _mapper = mapper; //automapper } ///// ///// 查询操作日志 ///// ///// 菜单名称 ///// 类型 ///// 内容 ///// 开始日期 ///// 结束日期 ///// ///// ///// ///// //public List GetOperationSysList(string menuName, string type, string msg, string startTime, string endTime, int page, int limit, out int count) //{ // try // { // Expression> item = Expressionable.Create() // .AndIF(!string.IsNullOrWhiteSpace(menuName), it => it.MenuName.Contains(menuName.Trim())) // .AndIF(!string.IsNullOrWhiteSpace(type), it => it.Type == type) // .AndIF(!string.IsNullOrWhiteSpace(msg), it => it.Msg.Contains(msg.Trim())) // .AndIF(!string.IsNullOrWhiteSpace(startTime), it => it.CreateTime >= Convert.ToDateTime(startTime)) // .AndIF(!string.IsNullOrWhiteSpace(endTime), it => it.CreateTime <= Convert.ToDateTime(startTime).AddDays(1)) // .ToExpression();//注意 这一句 不能少 // var data = GetAllWhereAsync(item) // .Includes(x => x.TypeInfo) // .Includes(x => x.CreateUserInfo) // .Includes(x => x.UpdateUserInfo).ToList(); // count = data.Count; // return data.Select(m => new OperationDto() // { // Id = m.Id, // ParentNo = m.ParentNo, // MenuNo = m.MenuNo, // MenuName = m.MenuName, // FkNo = m.FkNo, // Type = m.TypeInfo == null ? "" : m.TypeInfo.DictName, // Msg = m.Msg, // CreateTime = m.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), // CreateUserName = m.CreateUserInfo == null ? "" : m.CreateUserInfo.UserName, // UpdateTime = m.UpdateTime == null ? "" : ((DateTime)m.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"), // UpdateUserName = m.UpdateUserInfo == null ? "" : m.UpdateUserInfo.UserName // }).ToList(); // } // catch (Exception e) // { // throw new Exception(e.Message); // } //} /// /// 添加操作日志 /// /// 模块号 /// 菜单号 /// 菜单名称 /// 数据编号 /// 类型 添加 修改 删除 停用 启用 /// 操作 /// /// public async Task AddOperationSys(string parentNo, string menuNo, string menuName, string fkNo, string type, string msg, int userId) { try { var num = await AddAsync(new LogOperationSys() { ParentNo = parentNo, MenuNo = menuNo, MenuName = menuName, FkNo = fkNo, Type = type, Msg = msg, CreateUser = userId }); if (num > 0) { return true; } else { return false; } } catch (Exception e) { throw new Exception(e.Message); } } /// /// 获取系统操作日志数据列表 /// /// 菜单名称 /// 操作类型 /// 操作内容 /// 菜单号 /// 模块号 /// public List GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo) { List operationlist = _operation.GetSysOperationList(menuName, type, msg, menuNo, parentNo); return operationlist; } /// /// 新增系统操作日志 /// /// 模块号 /// 菜单号 /// 数据编号 /// 操作类型 /// 操作内容 /// 创建人 /// public async Task InsertOperation(string parentName, string menuName, string fkNo, string type, string msg, int createuser) { //捕获异常 try { var parentNo = _operation.GetMenuList(parentName).MenuNo; var menuNo = _operation.GetMenuList(menuName).MenuNo; int i = await _operation.InsertOperation(parentNo, menuNo, parentName + "-" + menuName, fkNo, type, msg, createuser); return i; } catch (Exception ex) { //抛出异常 throw new Exception("新增操作日志异常", ex); } } /// /// 获取类型菜单 /// /// 字典名称 /// public List GetDicTypeList(string dicName) { List diclist = _operation.GetDicTypeList( dicName); return diclist; } } }