public HttpResponseBase GetBLSList() { string json = string.Empty; try { BrandLogoSort query = new BrandLogoSort(); List<BrandLogoSort> store = new List<BrandLogoSort>(); if (!string.IsNullOrEmpty(Request.Params["category_id"])) { uint n = 99999999; if (uint.TryParse(Request.Params["category_id"].ToString().Trim(), out n)) { query.category_id = Convert.ToUInt32(Request.Params["category_id"].ToString().Trim()); } else { query.category_id = 99999999; } } if (!string.IsNullOrEmpty(Request.Params["brand_id"])) { uint n = 99999999; if (uint.TryParse(Request.Params["brand_id"].ToString().Trim(), out n)) { query.brand_id = Convert.ToUInt32(Request.Params["brand_id"].ToString().Trim()); } else { query.brand_id = 99999999; } } query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); int totalCount = 0; _BrandLSMgr = new BrandLogoSortMgr(mySqlConnectionString); store = _BrandLSMgr.GetBLSList(query, out totalCount); foreach (var item in store) { if (!string.IsNullOrEmpty(item.brand_logo)) { string folder1 = item.brand_logo.Substring(0, 2) + "/"; //圖片名前兩碼 string folder2 = item.brand_logo.Substring(2, 2) + "/"; //圖片名第三四碼 item.brand_logo = imgServerPath + brandPath + folder1 + folder2 + item.brand_logo; } else { item.brand_logo = defaultImg; } } 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; }