public ActionResult ExportTrouble() { var troubleList = new List <HseSafetyTroubleView>(); string txtDate = Request["txtDate"]; Expression <Func <HseSafetyTroubleEntity, bool> > predicate = x => x.Id > 0 && x.IsDeleted == false; if (!string.IsNullOrEmpty(txtDate)) { DateTime dateTime = Convert.ToDateTime(txtDate); DateTime dateAdd = dateTime.AddDays(1); predicate = predicate.AndAlso(a => a.OccurrenceDate == dateTime); } var list = _hseSafetyTroubleService.GetList <HseSafetyTroubleView>(predicate).OrderByDescending(x => x.Id).ToList(); troubleList = (from s in list select new HseSafetyTroubleView { Id = s.Id, ReportedUserName = s.ReportedUserName, CreatedUserID = s.CreatedUserID, OccurrenceDate = s.OccurrenceDate, Location = SafetyReportHelper.GetLocation(s.Location) == "" ? s.OtherLocation : SafetyReportHelper.GetLocation(s.Location), OtherLocation = s.OtherLocation, Description = s.Description, CreatedDate = s.CreatedDate }).ToList(); return(ExportToTroubleCsv(troubleList)); }
public HseInjuredSafetyIncidentView GetSafetyReportById(int id, string type) { var safetyReport = new HseInjuredSafetyIncidentView(); var _hseInjuredSafetyIncidentService = new BaseService <HseInjuredSafetyIncidentEntity>("CAAdmin"); var _hseSafetyTroubleService = new BaseService <HseSafetyTroubleEntity>("CAAdmin"); if (type == "SafetyTrouble") { safetyReport = (from s in _hseSafetyTroubleService.Repository.Entities.ToList() where s.Id == id && s.IsDeleted == false select new HseInjuredSafetyIncidentView { ReportedUserName = s.ReportedUserName, CreatedUserID = s.CreatedUserID, OccurrenceDate = s.OccurrenceDate, Location = SafetyReportHelper.GetLocation(s.Location), OtherLocation = s.OtherLocation, Description = s.Description, type = "SafetyTrouble", SafetyReportImages = GetImgListById(id, type) }).FirstOrDefault(); } else { safetyReport = (from s in _hseInjuredSafetyIncidentService.Repository.Entities.ToList() where s.Id == id && s.IsDeleted == false select new HseInjuredSafetyIncidentView { PatientInfo = s.PatientInfo, PatientLillyId = s.PatientLillyId, PatientName = s.PatientName, ReportedUserName = s.ReportedUserName, CreatedUserID = s.CreatedUserID, OccurrenceDate = s.OccurrenceDate, Location = SafetyReportHelper.GetLocation(s.Location), OtherLocation = s.OtherLocation, InjuredType = SafetyReportHelper.GetInjuredType(s.InjuredType), InjurySites = SafetyReportHelper.GetInjurySites(s.InjurySites), OtherInjurySites = s.OtherInjurySites, Description = s.Description, type = "SafetyIncident", SafetyReportImages = GetImgListById(id, type) }).FirstOrDefault(); } return(safetyReport); }
public ActionResult ExportIncident() { var incidentList = new List <HseInjuredSafetyIncidentView>(); string txtDate = Request["txtDate"]; Expression <Func <HseInjuredSafetyIncidentEntity, bool> > predicate = x => x.Id > 0 && x.IsDeleted == false; if (!string.IsNullOrEmpty(txtDate)) { DateTime dateTime = Convert.ToDateTime(txtDate); DateTime dateAdd = dateTime.AddDays(1); predicate = predicate.AndAlso(a => a.OccurrenceDate == dateTime); } var list = _hseInjuredSafetyIncidentService.GetList <HseInjuredSafetyIncidentView>(predicate).OrderByDescending(x => x.Id).ToList(); incidentList = (from m in list select new HseInjuredSafetyIncidentView { Id = m.Id, PatientInfo = m.PatientInfo, PatientName = m.PatientName == null ? m.ReportedUserName : m.PatientName, PatientLillyId = m.PatientLillyId == null ? m.CreatedUserID : m.PatientLillyId, OccurrenceDate = m.OccurrenceDate, Location = SafetyReportHelper.GetLocation(m.Location) == "" ? m.OtherLocation : SafetyReportHelper.GetLocation(m.Location), OtherLocation = m.OtherLocation, InjuredType = SafetyReportHelper.GetInjuredType(m.InjuredType), InjurySites = SafetyReportHelper.GetInjurySites(m.InjurySites) == "" ? m.OtherInjurySites : SafetyReportHelper.GetInjurySites(m.InjurySites), OtherInjurySites = m.OtherInjurySites, Description = m.Description, ReportedUserName = m.ReportedUserName, CreatedUserID = m.CreatedUserID, CreatedDate = m.CreatedDate }).ToList(); return(ExportToIncidentCsv(incidentList)); }
public ActionResult GetIncidentList() { string txtDate = Request["txtDate"]; Expression <Func <HseInjuredSafetyIncidentEntity, bool> > predicate; predicate = p => p.IsDeleted == false; if (!string.IsNullOrEmpty(txtDate)) { DateTime dateTime = Convert.ToDateTime(txtDate); DateTime dateAdd = dateTime.AddDays(1); predicate = predicate.AndAlso(a => a.OccurrenceDate == dateTime); } var param = new PageParameter(); TryUpdateModel(param); //实现对用户和多条件的分页的查询,rows表示一共多少条,page表示当前第几页 param.length = param.length == 0 ? 10 : param.length; var iTotal = param.iRecordsTotal; var incidentCount = _hseInjuredSafetyIncidentService.Repository.Entities.Where(predicate).Count(); // 取当前页 var page = (int)Math.Floor(param.start / param.length * 1.0d) + 1; if (incidentCount != 0) { iTotal = incidentCount; var incidentList = _hseInjuredSafetyIncidentService.Repository.Entities.Where(predicate).OrderByDescending(o => o.OccurrenceDate).ToList().Skip((page - 1) * param.length).Take(param.length).ToList(); var t = from m in incidentList select new { Id = m.Id, PatientInfo = m.PatientInfo, PatientName = m.PatientName, PatientLillyId = m.PatientLillyId, OccurrenceDate = m.OccurrenceDate, Location = SafetyReportHelper.GetLocation(m.Location) == "" ? m.OtherLocation : SafetyReportHelper.GetLocation(m.Location), OtherLocation = m.OtherLocation, InjuredType = SafetyReportHelper.GetInjuredType(m.InjuredType), InjurySites = SafetyReportHelper.GetInjurySites(m.InjurySites) == "" ? m.OtherInjurySites : SafetyReportHelper.GetInjurySites(m.InjurySites), OtherInjurySites = m.OtherInjurySites, Description = m.Description, ReportedUserName = m.ReportedUserName, CreatedUserID = m.CreatedUserID, CreatedDate = m.CreatedDate }; return(Json(new { sEcho = param.draw, iTotalRecords = iTotal, iTotalDisplayRecords = iTotal, aaData = t }, JsonRequestBehavior.AllowGet)); } else { var t = from m in _hseInjuredSafetyIncidentService.Repository.Entities.Where(predicate).OrderByDescending(o => o.OccurrenceDate).ToList().Skip((page - 1) * param.length).Take(param.length).ToList() select new { Id = m.Id, PatientInfo = m.PatientInfo, PatientName = m.PatientName, PatientLillyId = m.PatientLillyId, OccurrenceDate = m.OccurrenceDate, Location = SafetyReportHelper.GetLocation(m.Location) == "" ? m.OtherLocation : SafetyReportHelper.GetLocation(m.Location), OtherLocation = m.OtherLocation, InjuredType = SafetyReportHelper.GetInjuredType(m.InjuredType), InjurySites = SafetyReportHelper.GetInjurySites(m.InjurySites) == "" ? m.OtherInjurySites : SafetyReportHelper.GetInjurySites(m.InjurySites), OtherInjurySites = m.OtherInjurySites, Description = m.Description, ReportedUserName = m.ReportedUserName, CreatedUserID = m.CreatedUserID, CreatedDate = m.CreatedDate }; return(Json(new { sEcho = param.draw, iTotalRecords = iTotal, iTotalDisplayRecords = iTotal, aaData = t }, JsonRequestBehavior.AllowGet)); } }