示例#1
0
        public HttpResponseBase GetEdmContentList()
        {
            string json = string.Empty;
            List<EdmContentQuery> store = new List<EdmContentQuery>();
            EdmContentQuery query = new EdmContentQuery();
            try
            {
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                if (!string.IsNullOrEmpty(Request.Params["searchStatus"]))
                {
                    query.searchStatus = Request.Params["searchStatus"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["search_text"]))
                {
                    query.search_text = Request.Params["search_text"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["tstart"]))
                {
                    query.s_content_start = Convert.ToDateTime(Request.Params["tstart"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["tend"]))
                {
                    query.s_content_end = Convert.ToDateTime(Request.Params["tend"]);
                }
                _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString);
                int totalCount = 0;
                store = _IEdmContentMgr.GetEdmContentList(query, out totalCount);
                foreach (var item in store)
                {
                    item.content_send_count = item.content_send_success + item.content_send_failed;
                    item.content_body = Server.HtmlDecode(Server.HtmlDecode(item.content_body));
                    item.s_content_start = CommonFunction.GetNetTime(item.content_start);
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }