protected override GetEventListRD ProcessRequest(DTO.Base.APIRequest <GetEventListRP> pRequest) { var rd = new GetEventListRD(); //string customerId = pRequest.CustomerID; string eventTypeId = pRequest.Parameters.EventTypeId; string eventName = pRequest.Parameters.EventName; int drawMethodId = pRequest.Parameters.DrowMethodId; bool?beginFlag = pRequest.Parameters.BeginFlag; bool?endFlag = pRequest.Parameters.EndFlag; int?pageSize = pRequest.Parameters.PageSize; int?pageIndex = pRequest.Parameters.PageIndex; int?eventStatus = pRequest.Parameters.EventStatus; //var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); var bll = new LEventsBLL(CurrentUserInfo); var ds = bll.GetEventList(CurrentUserInfo.ClientID, eventTypeId, eventName, drawMethodId, beginFlag, endFlag, eventStatus ?? 0, pageIndex ?? 0, pageSize ?? 15); if (ds.Tables[0].Rows.Count == 0) { //throw new APIException("没有数据") { ErrorCode = Error_EmptyData }; rd.EventList = null; rd.TotalPages = 0; } else { var temp = ds.Tables[0].AsEnumerable().Select(t => new EventInfo { EventId = t["EventId"].ToString(), EventName = t["Title"].ToString(), EventTypeId = t["EventTypeId"].ToString(), EventTypeName = t["EventTypeName"].ToString(), BegTime = t["BeginTime"].ToString(), EndTime = t["EndTime"].ToString(), //DisplayIndex = Convert.ToInt32(t["_row"]), DrawMethod = t["DrawMethodName"].ToString(), EventStatus = Convert.ToInt32(t["EventStatus"]), EventStatusName = t["EventStatusName"].ToString(), CityName = t["cityid"].ToString() }); rd.EventList = temp.ToArray(); int totalCount = bll.GetEventListCount(CurrentUserInfo.ClientID, eventTypeId, eventName, drawMethodId, beginFlag, endFlag, eventStatus ?? 0); rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalCount * 1.00 / (pageSize ?? 15) * 1.00))); } return(rd); }
public string GetEventList(string pRequest) { EventListRD rd = new EventListRD(); var reqObj = pRequest.DeserializeJSONTo <APIRequest <EventListRP> >(); var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; LEventsBLL bll = new LEventsBLL(loggingSessionInfo); DataSet ds = bll.GetEventList(reqObj.Parameters.PageIndex, reqObj.Parameters.PageSize, reqObj.Parameters.Title, reqObj.Parameters.DrawMethodName, reqObj.Parameters.BeginTime, reqObj.Parameters.EndTime); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { rd.LEventsList = DataTableToObject.ConvertToList <EventsList>(ds.Tables[0]).ToArray();//直接根据所需要的字段反序列化 rd.TotalCount = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"].ToString()); rd.PageCount = Convert.ToInt32(ds.Tables[1].Rows[0]["PageCount"].ToString()); } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }