public ActionResult SystemMessageManage(SystemAlertMessageSM sm, int Page = 1, int PageSize = 20) { var list = systemAlertMessageRepo.GetPagedList(sm, Page, PageSize); var vms = Mapper.Map <IList <SystemAlertMessageVM> >(list.Results); var result = new PagedResult <SystemAlertMessageVM>(vms, Page, PageSize, list.RowCount); if (Request.IsAjaxRequest()) { return(PartialView("_ListSystemMessageManage", result)); } ViewBag.userList = SelectHelper.GetUserList(); ViewBag.messageTypeList = SelectHelper.GetEnumList(MessageType.Notification); ViewBag.alertDateTypeList = SelectHelper.GetEnumList(SystemMessageDateTimeType.CreateDate); ViewBag.alertTypeList = SelectHelper.GetEnumList(AlertedStstusType.Alerted); return(View(result)); }
public PagedResult <EM_System_AlertMessage> GetPagedList(SystemAlertMessageSM sm, int Page, int PageSize) { var sql = @"select * from EM_System_AlertMessage where 1=1 "; if (sm.Sender.HasValue) { sql += " and a.Sender=@Sender "; } if (sm.Receiver.HasValue) { sql += " and a.Receiver=@Receiver "; } if (sm.MessageType.HasValue) { sql += " and a.MessageType=@MessageType "; } if (!string.IsNullOrWhiteSpace(sm.Message)) { sql += " and a.Message like '%'+ @Message +'%' "; } if (sm.AlertedStstus.HasValue) { if (sm.AlertedStstus.Value == (int)AlertedStstusType.Alerted) { sql += " and a.AlertedTime is not null "; } else if (sm.AlertedStstus.Value == (int)AlertedStstusType.Waiting) { sql += " and a.AlertedTime is null "; } } if (sm.DateTimeType.HasValue) { var dateField = "CreateTime"; var systemMessageDateTimeType = (SystemMessageDateTimeType)Enum.ToObject(typeof(SystemMessageDateTimeType), sm.DateTimeType.Value); switch (systemMessageDateTimeType) { case SystemMessageDateTimeType.AlertDate: dateField = "AlertTime"; break; case SystemMessageDateTimeType.AlertedDate: dateField = "AlertedTime"; break; } if (sm.SDate.HasValue) { sql += " and a." + dateField + ">=@SDate "; } if (sm.EDate.HasValue) { sql += " and a." + dateField + " <=@EDate "; } } var list = DapperHelper.QueryWithPage <EM_System_AlertMessage>(sql, sm, " CreateTime desc ", Page, PageSize); return(list); }