public IActionResult GetEventLogByParameter(DateTime startTime, DateTime endTime, int currentPage, int pageSize, Guid?[] eventLevelId, Guid?[] eventSourceId, Guid?[] eventLogTypeId, Guid organizationId) { try { using (var db = new AllInOneContext.AllInOneContext()) { var query = from p in db.EventLog .Include(t => t.Application).Include(t => t.EventLevel) .Include(t => t.EventLogType).Include(t => t.EventSource) .Include(t => t.Organization) orderby p.TimeCreated descending where p.TimeCreated >= startTime && p.TimeCreated <= endTime && ((eventLevelId == null || eventLevelId.Length == 0) || eventLevelId.Contains(p.EventLevel.SystemOptionId)) && ((eventSourceId == null || eventSourceId.Length == 0) || eventSourceId.Contains(p.EventSource.SystemOptionId)) && ((eventLogTypeId == null || eventLogTypeId.Length == 0) || eventLogTypeId.Contains(p.EventLogType.SystemOptionId)) && p.Organization.OrganizationId == organizationId select p; if (currentPage == 0) { currentPage = 1; } if (pageSize <= 0) { pageSize = 10; } var data = query.Skip(pageSize * (currentPage - 1)).Take(pageSize * currentPage).ToList(); if (data.Count() == 0) { return(NoContent()); } QueryPagingRecord queryPagingRecord = new QueryPagingRecord { SumRecordCount = query.Count(), Record = data.ToList() }; return(new ObjectResult(queryPagingRecord)); } } catch (Exception ex) { _logger.LogError("GetEventLogByParameter:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public IActionResult GetShiftHandoverLogByParameter(DateTime startTime, DateTime endTime, int currentPage, int pageSize, Guid organizationId, Guid?statusId) { try { using (var db = new AllInOneContext.AllInOneContext()) { var query = from p in db.ShiftHandoverLog .Include(t => t.OffGoing) .Include(t => t.OnComing) .Include(t => t.Organization) .Include(t => t.Status) orderby p.HandoverDate descending where p.HandoverDate >= startTime && p.HandoverDate <= endTime && p.Organization.OrganizationId.Equals(organizationId) && ((statusId == null) || p.Status.SystemOptionId.Equals(statusId)) select p; if (currentPage == 0) { currentPage = 1; } if (pageSize <= 0) { pageSize = 10; } var data = query.Skip(pageSize * (currentPage - 1)).Take(pageSize * currentPage).ToList(); //if (data.ToList().Count == 0) //{ // return NoContent(); //} QueryPagingRecord queryPagingRecord = new QueryPagingRecord { SumRecordCount = query.Count(), Record = data.ToList() }; return(new ObjectResult(queryPagingRecord)); } } catch (Exception ex) { return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
//public IEnumerable<AlarmLog> GetByAlarmQuery([FromBody]AlarmQuery query) public IActionResult SearchAlarmLog(DateTime startTime, DateTime endTime, Guid[] alarmTypeIds, Guid[] alarmSourceIds, int pageNo = 1, int pageSize = 10) { using (var db = new AllInOneContext.AllInOneContext()) { if (pageNo <= 0) { pageNo = 1; } if (pageSize <= 10) { pageSize = 10; } var res = db.AlarmLog.Include(t => t.AlarmLevel).Include(t => t.AlarmSource).Include(t => t.AlarmType).Include(t => t.AlarmStatus).Include(t => t.Organization).Where(t => ((alarmTypeIds == null || alarmTypeIds.Length == 0) || alarmTypeIds.Contains(t.AlarmTypeId)) && ((alarmSourceIds == null || alarmSourceIds.Length == 0) || alarmSourceIds.Contains(t.AlarmSourceId)) && (t.TimeCreated >= startTime && t.TimeCreated <= endTime)).OrderByDescending(t => t.TimeCreated); var log = res.Skip((pageNo - 1) * pageSize).Take(pageSize); QueryPagingRecord queryPagingRecord = new QueryPagingRecord { SumRecordCount = res.Count(), Record = log.ToList() }; return(new ObjectResult(queryPagingRecord)); } }
public IActionResult QueryFieldDutyCheckView(DateTime data, Guid statusId, int currentPage, int pageSize) { using (var db = new AllInOneContext.AllInOneContext()) { //测试数据 List <FieldDutyCheckLog> list = new List <FieldDutyCheckLog>(); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "张三", DutyCheckTime = "2017-01-11 10:32:01", OrganizationName = "xx中队", PlanDutyCheckStaffName = "张三", PlanDutyCheckTime = "2017-01-11 08:00-12:00", SentinelName = "一号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "张三", DutyCheckTime = "2017-01-11 11::21", OrganizationName = "xx中队", PlanDutyCheckStaffName = "张三", PlanDutyCheckTime = "2017-01-11 08:00-12:00", SentinelName = "二号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "张三", DutyCheckTime = "2017-01-11 11::42", OrganizationName = "xx中队", PlanDutyCheckStaffName = "张三", PlanDutyCheckTime = "2017-01-11 08:00-12:00", SentinelName = "三号哨", Status = "正常" }); // list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "李四", DutyCheckTime = "2017-01-11 12:12", OrganizationName = "xx中队", PlanDutyCheckStaffName = "李四", PlanDutyCheckTime = "2017-01-11 12:00-18:00", SentinelName = "一号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "李四", DutyCheckTime = "2017-01-11 14:05", OrganizationName = "xx中队", PlanDutyCheckStaffName = "李四", PlanDutyCheckTime = "2017-01-11 12:00-18:00", SentinelName = "二号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "李四", DutyCheckTime = "2017-01-11 17:35", OrganizationName = "xx中队", PlanDutyCheckStaffName = "李四", PlanDutyCheckTime = "2017-01-11 12:00-18:00", SentinelName = "三号哨", Status = "正常" }); // list.Add(new FieldDutyCheckLog { Appriase = "中", AttachmentPath = "", DutyCheckStaffName = "王五", DutyCheckTime = "2017-01-11 19:55", OrganizationName = "xx中队", PlanDutyCheckStaffName = "王五", PlanDutyCheckTime = "2017-01-11 18:00-00:00", SentinelName = "一号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "王五", DutyCheckTime = "2017-01-11 21:55", OrganizationName = "xx中队", PlanDutyCheckStaffName = "王五", PlanDutyCheckTime = "2017-01-11 18:00-00:00", SentinelName = "二号哨", Status = "正常" }); list.Add(new FieldDutyCheckLog { Appriase = "好", AttachmentPath = "", DutyCheckStaffName = "王五", DutyCheckTime = "2017-01-12 1:55", OrganizationName = "xx中队", PlanDutyCheckStaffName = "王五", PlanDutyCheckTime = "2017-01-11 18:00-00:00", SentinelName = "三号哨", Status = "异常" }); QueryPagingRecord queryPagingRecord = new QueryPagingRecord { SumRecordCount = 9, Record = list }; return(new ObjectResult(queryPagingRecord)); } }
public IActionResult GetDutyCheckLogByParameter(DateTime startTime, DateTime endTime, int currentPage, int pageSize, Guid?[] filedStaffId, Guid?[] dutyCheckSiteScheduleId, Guid?organizationId, Guid?[] appriseId, Guid?[] recordTypeId) { try { if (filedStaffId == null || filedStaffId.Length == 0) { } using (var db = new AllInOneContext.AllInOneContext()) { var query = from p in db.DutyCheckLog .Include(t => t.Apprises).ThenInclude(t => t.DutyCheckAppraise).ThenInclude(t => t.AppraiseICO) .Include(t => t.Apprises).ThenInclude(t => t.DutyCheckAppraise).ThenInclude(t => t.AppraiseType) .Include(t => t.DutyCheckOperation).ThenInclude(t => t.Attachments).ThenInclude(t => t.Attachment) .Include(t => t.DutyCheckOperation).ThenInclude(t => t.Attachments).ThenInclude(t => t.AttachmentType) .Include(t => t.DutyCheckSiteSchedule) /*.ThenInclude(t => t.CheckDutySite)*/ .Include(t => t.DutyCheckSiteSchedule).ThenInclude(t => t.CheckMan) .Include(t => t.DutyCheckStaff) .Include(t => t.Organization) .Include(t => t.RecordType) .Include(t => t.CircularTypes).ThenInclude(t => t.Dispose) .Include(t => t.MainApprise) .Include(t => t.AppraiseICO) orderby p.RecordTime descending where p.RecordTime >= startTime && p.RecordTime <= endTime && ((filedStaffId == null || filedStaffId.Length == 0) || filedStaffId.Contains(p.DutyCheckStaff.StaffId)) && ((dutyCheckSiteScheduleId == null || dutyCheckSiteScheduleId.Length == 0 || p.DutyCheckSiteSchedule.CheckMan == null) || dutyCheckSiteScheduleId.Contains(p.DutyCheckSiteSchedule.CheckMan.StaffId)) && ((organizationId == null) || p.Organization.OrganizationId.Equals(organizationId)) && (p.Status.SystemOptionId.Equals(new Guid("24AC9875-C463-47B6-8147-5845874C3CAF"))) && //已结束 只显示已结束的记录 ((appriseId == null || appriseId.Length == 0) || appriseId.Contains(p.MainAppriseId)) && ((recordTypeId == null || recordTypeId.Length == 0) || recordTypeId.Contains(p.RecordType.SystemOptionId)) select p; if (currentPage == 0) { currentPage = 1; } if (pageSize <= 0) { pageSize = 10; } var data = query.Skip(pageSize * (currentPage - 1)).Take(pageSize * currentPage).ToList(); //if (data.ToList().Count == 0) //{ // return NoContent(); //} QueryPagingRecord queryPagingRecord = new QueryPagingRecord { SumRecordCount = query.Count(), Record = data.ToList() }; return(new ObjectResult(queryPagingRecord)); } } catch (Exception ex) { return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }