public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (EquipmentStateEventServiceClient client = new EquipmentStateEventServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <EquipmentStateEvent> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial", new EquipmentStateEventViewModel())); }
public async Task <ActionResult> Query(EquipmentStateEventQueryViewModel model) { if (ModelState.IsValid) { using (EquipmentStateEventServiceClient client = new EquipmentStateEventServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (string.IsNullOrEmpty(model.EquipmentCode)) { where.AppendFormat(" {0} EquipmentCode LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.EquipmentCode); } if (!string.IsNullOrEmpty(model.ChangeStateName)) { where.AppendFormat(" {0} EquipmentChangeStateName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.ChangeStateName); } if (!string.IsNullOrEmpty(model.FromStateName)) { where.AppendFormat(" {0} EquipmentFromStateName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.FromStateName); } if (!string.IsNullOrEmpty(model.ToStateName)) { where.AppendFormat(" {0} EquipmentToStateName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.ToStateName); } if (model.EndCreateTime != null) { where.AppendFormat(" {0} CreateTime <= '{1:yyyy-MM-dd HH:mm:ss}'" , where.Length > 0 ? "AND" : string.Empty , model.EndCreateTime); } if (model.StartCreateTime != null) { where.AppendFormat(" {0} CreateTime >= '{1:yyyy-MM-dd HH:mm:ss}'" , where.Length > 0 ? "AND" : string.Empty , model.StartCreateTime); } } PagingConfig cfg = new PagingConfig() { OrderBy = "CreateTime DESC", Where = where.ToString() }; MethodReturnResult <IList <EquipmentStateEvent> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", new EquipmentStateEventViewModel())); } else { return(View("Index", model)); } }