public Resp_Query <SysModuleDTO> Query(SysMoudule_Query request) { var response = new Resp_Query <SysModuleDTO>(); List <SysModule> recodes = null; //recodes = _sysModuleRepository.GetSysModules(request.ParentId).ToList(); if (string.IsNullOrEmpty(request.ParentId)) { recodes = _sysModuleRepository.GetByWhere(t => t.SuperSysModule == null).ToList(); } else { if (int.TryParse(request.ParentId, out int result)) { recodes = _sysModuleRepository.GetByWhere(t => t.SuperSysModule.ID == result).ToList(); } } recodes.ForEach(t => { if (t.SubSysModules.IsNullOrEmpty()) { t.IsLast = 1; } }); response.entities = recodes.IsNotNull() ? recodes.ConvertoDto <SysModule, SysModuleDTO>().ToList() : new List <SysModuleDTO>(); response.totalCounts = response.entities.Count(); response.totalRows = 1; return(response); }
public Resp_Query <RecordManagerDTO> Query(RecordManager_Query request) { var response = new Resp_Query <RecordManagerDTO>(); var records = _repository.GetAll(); records.ToMaybe() .Do(d => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.CarNumber.NullToString().Trim()), d => records = records.Where(s => s.CarNumber.Contains(request.CarNumber))) .DoWhen(t => !string.IsNullOrEmpty(request.DLicense.NullToString().Trim()), d => records = records.Where(s => s.DLicense.Contains(request.DLicense))) .DoWhen(t => !string.IsNullOrEmpty(request.TLicense.NullToString().Trim()), d => records = records.Where(s => s.TLicense.Contains(request.TLicense))) .DoWhen(t => !string.IsNullOrEmpty(request.Driver.NullToString().Trim()), d => records = records.Where(s => s.Driver.Contains(request.Driver))) .DoWhen(t => !string.IsNullOrEmpty(request.Contact.NullToString().Trim()), d => records = records.Where(s => s.Contact.Contains(request.Contact))) .DoWhen(t => !string.IsNullOrEmpty(request.RecordMGrade.NullToString().Trim()), d => records = records.Where(s => s.RecordMGrade.Equals(request.RecordMGrade))) .DoWhen(t => !string.IsNullOrEmpty(request.CarColor.NullToString().Trim()), d => records = records.Where(s => s.CarColor.Equals(request.CarColor))) .DoWhen(t => !string.IsNullOrEmpty(request.CarType.NullToString().Trim()), d => records = records.Where(s => s.CarType.Equals(request.CarType))) .DoWhen(t => !string.IsNullOrEmpty(request.Channel.NullToString().Trim()), d => records = records.Where(s => s.Channel.Contains(request.Channel))); //.DoWhen(t => !string.IsNullOrEmpty(request.Type.NullToString().Trim()), d => records = records.Where(s => s.Type == request.Type.ToInt())); if (!string.IsNullOrEmpty(request.Type) && int.TryParse(request.Type, out int typeresult)) { records = records.Where(s => s.Type == typeresult); } if (!string.IsNullOrEmpty(request.IsValid) && int.TryParse(request.IsValid, out int result)) { if (result == 0) { records = records.Where(s => s.IsValid == 0); } else if (result == 1) { records = records.Where(s => s.IsValid == 1); } } if (!string.IsNullOrEmpty(request.BeginTime) && DateTime.TryParse(request.BeginTime, out DateTime start)) //Linq to entity 不支持datatime.parse函数 { records = records.Where(s => s.CreateTime >= start); } if (!string.IsNullOrEmpty(request.EndTime) && DateTime.TryParse(request.EndTime, out DateTime end)) { records = records.Where(s => s.CreateTime <= end); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } response.entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList().ConvertoDto <RecordManager, RecordManagerDTO>().ToList(); return(response); }
public Resp_Query <RecordMGrade> Query(RMG_Query request) { var response = new Resp_Query <RecordMGrade>(); var records = _recordMGradeRepository.GetAll(); records.ToMaybe() .Do(t => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.QueryStr), d => records = records.Where(s => s.Name.Contains(request.QueryStr))); response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } var entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList(); response.entities = entities; return(response); }
public Resp_All_Sync All_Sync(Req_All_Sync request) { var datas = new Resp_Query <Layout>(); var pgSize = System.Configuration.ConfigurationManager.AppSettings["syncSize"].ToInt(); var response = new Resp_All_Sync(); response.lastSyncTime = DateTime.Now.ToString(); var records = _repository.GetAll().OrderBy(o => o.ID); datas.totalCounts = records.Count(); datas.totalRows = (int)Math.Ceiling((double)datas.totalCounts / pgSize); if (request.PgIndex >= 1) { datas.entities = records.Skip(pgSize * (request.PgIndex - 1)).Take(pgSize).ToList(); } else { datas.entities = new List <Layout>(); } response.batchDatas = datas; response.done = request.PgIndex >= datas.totalRows; return(response); }
private Resp_Query <SysRightViewModel> GetRightsByCondition(List <SysUserRightView> datas, SysRightGetByUser request) { var response = new Resp_Query <SysRightViewModel>(); var views = new List <SysRightViewModel>(); if (datas.IsNotNull() && datas.Count > 0) { var groups = datas.GroupBy(t => new { t.ModuleName, t.SysModuleId, t.ParentId }); var sysModules = Cache.GetSysModules(); foreach (var group in groups) { var view = new SysRightViewModel(); view.ModuleName = GetModuleName(sysModules, group.Key.ParentId, group.Key.ModuleName);//group.Key.ModuleName; view.SysModuleId = group.Key.SysModuleId; view.ParentId = group.Key.ParentId; foreach (var temp in group) { view.Operaties.Add(new SysRightOperateViewModel { KeyCode = temp.KeyCode, Name = temp.Name, IsValid = temp.IsValid }); } views.Add(view); } response.entities = views.Skip((request.PgIndex - 1) * request.PgSize).Take(request.PgSize).ToList(); response.totalCounts = views.Count; response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); } return(response); }
public Resp_Query <SysModuleOperateDTO> QueryByModuleId(SysModuleOperate_Query request) { var response = new Resp_Query <SysModuleOperateDTO>(); response.entities = _sysModuleOperateRepository.GetByWhere(t => t.ModuleId == request.ModuleId).ConvertoDto <SysModuleOperate, SysModuleOperateDTO>().ToList(); response.totalCounts = response.entities.Count; response.totalRows = 1; return(response); }
public Resp_Query <AlarmDTO> Query(Alarm_Query request) { var records = _repository.GetAll(); var response = new Resp_Query <AlarmDTO>(); records.ToMaybe() .Do(d => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.CarNumber), d => records = records.Where(s => s.CarNumber.Contains(request.CarNumber))) .DoWhen(t => !string.IsNullOrEmpty(request.Channel), d => records = records.Where(s => s.Channel.Equals(request.Channel))); if (!string.IsNullOrEmpty(request.IsDeal) && int.TryParse(request.IsDeal, out int result)) { records = records.Where(s => s.IsDeal == result); } if (!string.IsNullOrEmpty(request.AlarmBeginTime) && DateTime.TryParse(request.AlarmBeginTime, out DateTime a_start)) { records = records.Where(s => s.AlarmTime >= a_start); } if (!string.IsNullOrEmpty(request.AlarmEndTime) && DateTime.TryParse(request.AlarmEndTime, out DateTime a_end)) { records = records.Where(s => s.AlarmTime <= a_end); } if (!string.IsNullOrEmpty(request.HandlerBeginTime) && DateTime.TryParse(request.HandlerBeginTime, out DateTime h_start)) { records = records.Where(s => s.HandlerTime >= h_start); } if (!string.IsNullOrEmpty(request.HandlerEndTime) && DateTime.TryParse(request.HandlerEndTime, out DateTime h_end)) { records = records.Where(s => s.HandlerTime <= h_end); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(o => o.ID); } response.entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList().ConvertoDto <Alarm, AlarmDTO>().ToList(); return(response); }
public Resp_Query <LayoutDTO> Query(Layout_Query request) { var response = new Resp_Query <LayoutDTO>(); var records = _repository.GetAll(); records.ToMaybe() .Do(d => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.CarNumber), d => records = records.Where(s => s.CarNumber.Contains(request.CarNumber))) .DoWhen(t => !string.IsNullOrEmpty(request.Channel), d => records = records.Where(s => s.Channel.Equals(request.Channel))); if (!string.IsNullOrEmpty(request.Trigger) && int.TryParse(request.Trigger, out int result)) { records = records.Where(s => s.TriggerType == result); } if (request.IsValid.ToInt() == 1) { records = records.Where(s => s.IsValid == 1); } if (request.IsValid.ToInt() == 0) { records = records.Where(s => s.IsValid == 0); } if (!string.IsNullOrEmpty(request.BeginTime) && DateTime.TryParse(request.BeginTime, out DateTime start)) //Linq to entity 不支持datatime.parse函数 { records = records.Where(s => s.CreateTime >= start); } if (!string.IsNullOrEmpty(request.EndTime) && DateTime.TryParse(request.EndTime, out DateTime end)) { records = records.Where(s => s.CreateTime <= end); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(o => o.ID); } response.entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList().ConvertoDto <Layout, LayoutDTO>().ToList(); return(response); }
public Resp_Query <SysUserDTO> Query(SysUser_Query request) { var response = new Resp_Query <SysUserDTO>(); var records = _sysUserRepository.GetAll(); records.ToMaybe() .Do(d => request.Verify()) .Do(d => records = records.Where(s => s.ID > 1)) //系统管理员不展示 .DoWhen(t => !string.IsNullOrEmpty(request.QueryStr), d => records = records.Where(s => s.Name.Contains(request.QueryStr) || s.TrueName.Contains(request.QueryStr))); if (!string.IsNullOrEmpty(request.State) && int.TryParse(request.State, out int result)) { records = records.Where(s => s.State == result); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } var entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList(); response.entities = entities.ConvertoDto <SysUser, SysUserDTO>().ToList(); response.entities.ForEach(f => { var temp = entities.Find(t => t.ID == f.ID.ToInt()); var RoleName = new StringBuilder(); if (temp.IsNotNull()) { temp.SysRoles.ToList().ForEach(s => RoleName.Append("[" + s.Name + "]")); } f.RoleName = RoleName.ToString(); var channelName = new StringBuilder(); if (temp.IsNotNull()) { temp.SysChannels.ToList().ForEach(s => channelName.Append("[" + s.Name + "]")); } f.ChannelName = channelName.ToString(); }); return(response); }
public Resp_Query <SysChannelDTO> Query(SysRole_Query request) { var response = new Resp_Query <SysChannelDTO>(); var records = sysChannelRepository.GetAll(); records.ToMaybe() .Do(d => request.Verify()) //系统角色不展现 .DoWhen(t => !string.IsNullOrEmpty(request.QueryStr), d => records = records.Where(s => s.Name.Contains(request.QueryStr))); response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } var entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList(); response.entities = entities.ConvertoDto <SysChannel, SysChannelDTO>().ToList(); response.entities.ForEach(f => { var temp = entities.Find(t => t.ID == f.ID); var UserName = new StringBuilder(); if (temp.IsNotNull()) { temp.SysUsers.ToList().ForEach(s => UserName.Append("[" + s.Name + "]")); } f.UserName = UserName.ToString(); }); return(response); }
public Resp_Query <SysErrorLogDTO> Query(SysErrorLog_Query request) { var response = new Resp_Query <SysErrorLogDTO>(); var records = _sysErrorLogRepository.GetAll(); records.ToMaybe() .Do(d => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.ErrorType), d => records = records.Where(s => s.ErrType.Equals(request.ErrorType))); if (!string.IsNullOrEmpty(request.BeginTime) && DateTime.TryParse(request.BeginTime, out DateTime start)) //Linq to entity 不支持datatime.parse函数 { records = records.Where(s => s.ErrTime >= start); } if (!string.IsNullOrEmpty(request.EndTime) && DateTime.TryParse(request.EndTime, out DateTime end)) { records = records.Where(s => s.ErrTime <= end); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } var entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList(); response.entities = entities.ConvertoDto <SysErrorLog, SysErrorLogDTO>().ToList(); return(response); }
public Resp_Query <CaptureDTO> Query(Capture_Query request) { var records = _repository.GetAll(); var response = new Resp_Query <CaptureDTO>(); records.ToMaybe() .Do(d => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.CarNumber), d => records = records.Where(s => s.CarNumber.Contains(request.CarNumber.Trim()))) .DoWhen(t => !string.IsNullOrEmpty(request.Channel), d => records = records.Where(s => s.Channel.Equals(request.Channel))) .DoWhen(t => !string.IsNullOrEmpty(request.ParkId), d => records = records.Where(s => s.ParkId.Contains(request.ParkId.Trim()))); //.DoWhen(t => !string.IsNullOrEmpty(request.Type), d => records = records.Where(s => s.BeiAn == request.Type)); if (!string.IsNullOrEmpty(request.Type) && int.TryParse(request.Type, out int typeresult)) { records = records.Where(s => s.BeiAn == typeresult); } if (!string.IsNullOrEmpty(request.Pass) && int.TryParse(request.Pass, out int result)) { if (result == 2) { records = records.Where(s => s.Pass == 1 && s.WithOut == 0); } else { records = records.Where(s => s.Pass == result); } } if (!string.IsNullOrEmpty(request.StayHours) && int.TryParse(request.StayHours, out int stayHours)) { var dt = DateTime.Now.AddHours(-stayHours); records = records.Where(t => t.CreateTime < dt); } if (!string.IsNullOrEmpty(request.BeginTime) && DateTime.TryParse(request.BeginTime, out DateTime start)) //Linq to entity 不支持datatime.parse函数 { records = records.Where(s => s.CreateTime >= start); } if (!string.IsNullOrEmpty(request.EndTime) && DateTime.TryParse(request.EndTime, out DateTime end)) { records = records.Where(s => s.CreateTime <= end); } response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(o => o.ID); } response.entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList().ConvertoDto <Capture, CaptureDTO>().ToList(); return(response); }