public string GetShopName(uint brandId) { _IvendorBrandSet = new VendorBrandSetMgr(connectionString); uint id = brandId; return _IvendorBrandSet.GetShopName(id); }
/// <summary> /// 新增或修改供應商品牌信息 /// </summary> /// <returns></returns> public HttpResponseBase UpdVendorBrand() { List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>(); query = new VendorBrandSetQuery(); VendorBrandSetQuery oldquery = new VendorBrandSetQuery(); _IvendorBrandSet = new VendorBrandSetMgr(connectionString); _productMgr = new ProductMgr(connectionString); string json = string.Empty; string errorInfo = string.Empty; try { #region 獲取數據 query.Brand_Id = UInt32.Parse(Request.Params["Brand_Id"]); oldquery = _IvendorBrandSet.GetModelById(Int32.Parse(Request.Params["Brand_Id"])); try { query.Brand_Name = Request.Params["brandName"].ToString(); } catch (Exception) { query.Brand_Name = oldquery.Brand_Name; } try { query.vendor_id = uint.Parse(Request.Params["vendorid"].ToString()); } catch (Exception) { query.vendor_id = oldquery.vendor_id; } try { query.Brand_Sort = uint.Parse(Request.Params["brandsort"].ToString()); } catch (Exception) { query.Brand_Sort = oldquery.Brand_Sort; } try { query.Brand_Status = uint.Parse(Request.Params["brandstatus"].ToString()); } catch (Exception) { query.Brand_Status = oldquery.Brand_Status; } try { query.Image_Status = uint.Parse(Request.Params["imagestatus"].ToString()); } catch (Exception) { query.Image_Status = oldquery.Image_Status; } try { query.Image_Link_Mode = uint.Parse(Request.Params["imagelinkmode"].ToString()); } catch (Exception) { query.Image_Link_Mode = oldquery.Image_Link_Mode; } try { query.Image_Link_Url = Request.Params["imagelinkurl"].ToString(); } catch (Exception) { query.Image_Link_Url = oldquery.Image_Link_Url; } try { query.Resume_Image_Link = Request.Params["resumeimagelink"].ToString(); } catch (Exception) { query.Resume_Image_Link = oldquery.Resume_Image_Link; } try { query.Media_Report_Link_Url = Request.Params["mediareportlinkurl"].ToString(); } catch (Exception) { query.Media_Report_Link_Url = oldquery.Media_Report_Link_Url; } try { query.Brand_Msg = Request.Params["brandmsg"].ToString(); } catch (Exception) { query.Brand_Msg = oldquery.Brand_Msg; } long start = CommonFunction.GetPHPTime(Request.Params["begin_time"].ToString()); long end = CommonFunction.GetPHPTime(Request.Params["end_time"].ToString()); try { query.Brand_Msg_Start_Time = uint.Parse(start.ToString()); } catch (Exception) { query.Brand_Msg_Start_Time = oldquery.Brand_Msg_Start_Time; } try { query.Brand_Msg_End_Time = uint.Parse(end.ToString()); } catch (Exception) { query.Brand_Msg_End_Time = oldquery.Brand_Msg_End_Time; } try { query.Brand_Createdate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()); } catch (Exception) { query.Brand_Createdate = oldquery.Brand_Createdate; } try { query.classIds = Request["shopclass"].ToString(); } catch (Exception) { query.classIds = oldquery.classIds; } query.Brand_Ipfrom = Request.UserHostAddress; try { query.Cucumber_Brand = uint.Parse(Request.Params["cucumberbrand"].ToString()); } catch { query.Cucumber_Brand = oldquery.Cucumber_Brand; } try { query.Image_Name = Request.Params["imagename"].ToString(); } catch (Exception) { query.Image_Name = oldquery.Image_Name; } try { query.Promotion_Banner_Image_Link = Request.Params["promotionbannerimagelink"].ToString(); } catch (Exception) { query.Promotion_Banner_Image_Link = oldquery.Promotion_Banner_Image_Link; } try { query.short_description = Request.Params["short_description"].ToString(); } catch (Exception) { query.short_description = oldquery.short_description; } query.Image_Name = oldquery.Image_Name; query.Resume_Image = oldquery.Resume_Image; query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image; query.brand_logo = oldquery.brand_logo; #endregion #region 上傳圖片 string path = Server.MapPath(xmlPath); SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path); SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format"); SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue"); SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue"); SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME"); SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD"); //擴展名、最小值、最大值 string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value; string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value; string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value; string localPromoPath = imgLocalPath + brandPath;//圖片存儲地址 FileManagement fileLoad = new FileManagement(); for (int i = 0; i < Request.Files.Count; i++) { string fileName = string.Empty; //當前文件名 HttpPostedFileBase file = Request.Files[i]; fileName = Path.GetFileName(file.FileName); if (string.IsNullOrEmpty(fileName)) { continue; } fileLoad = new FileManagement(); string oldFileName = string.Empty; //舊文件名 string fileExtention = string.Empty;//當前文件的擴展名 bool result = false; string NewFileName = string.Empty; string ServerPath = string.Empty; string newRand = string.Empty; string ErrorMsg = string.Empty; newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32"); fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower(); NewFileName = newRand + fileExtention; string folder1 = NewFileName.Substring(0, 2) + "/"; //圖片名前兩碼 string folder2 = NewFileName.Substring(2, 2) + "/"; //圖片名第三四碼 FTP f_cf = new FTP(); localPromoPath = imgLocalPath + brandPath + folder1 + folder2; //圖片存儲地址 string s = localPromoPath.Substring(0, localPromoPath.Length - (brandPath + folder1 + folder2).Length + 1); f_cf.MakeMultiDirectory(s, (brandPath + folder1 + folder2).Substring(1, (brandPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd); ServerPath = Server.MapPath(imgLocalServerPath + brandPath + folder1 + folder2); fileName = NewFileName; NewFileName = localPromoPath + NewFileName;//絕對路徑 Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件 //上傳 result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); if (result)//上傳成功 { //圖片上傳成功后記錄新圖片名稱 switch (i) { case 0: query.Image_Name = fileName; break; case 1: query.Resume_Image = fileName; break; case 2: query.Promotion_Banner_Image = fileName; break; case 3: query.brand_logo = fileName; break; default: break; } //圖片上傳成功后如果存在舊圖片則根據舊圖片名刪除舊圖片 if (!string.IsNullOrEmpty(oldFileName)) { switch (i) { case 0: oldFileName = oldquery.Image_Name; break; case 1: oldFileName = oldquery.Resume_Image; break; case 2: oldFileName = oldquery.Promotion_Banner_Image; break; case 3: oldFileName = oldquery.brand_logo; break; default: break; } DeletePicFile(ServerPath + oldFileName);//刪除本地圖片 } } else { //圖片上傳失敗則圖片名稱為原有圖片名稱 switch (i) { case 0: query.Image_Name = oldquery.Image_Name;//形象圖片 break; case 1: query.Resume_Image = oldquery.Resume_Image;//安心聲明圖片 break; case 2: query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image;//促銷圖片 break; case 3: query.brand_logo = oldquery.brand_logo;//品牌logo break; default: break; } errorInfo += "第" + (i + 1) + "張" + ErrorMsg + "<br/>"; //json = "{success:false,msg:\"第" + i + "張" + ErrorMsg + ",之後圖片未作處理" + "\"}"; } } #endregion //更新數據庫記錄 if (_IvendorBrandSet.Update(query) > 0) { if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = query.vendor_id, Brand_Id = query.Brand_Id })) { json = "{success:true,msg:\"數據保存成功!\"}"; } } if (!string.IsNullOrEmpty(errorInfo)) { json = "{success:true,msg:\"<div>數據保存成功!<br/>但<br/>" + errorInfo + "</div>\"}"; } } 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,msg:\"保存失敗,請稍后再試!\"}"; if (!string.IsNullOrEmpty(errorInfo)) { json = "{success:false,msg:\"<div>保存失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase UpdateSortByPicture() { string json = string.Empty; VendorBrandSetQuery query = new VendorBrandSetQuery(); VendorBrandSetQuery old = new VendorBrandSetQuery(); string name = Request.Params["picture"]; name = name.Substring(name.LastIndexOf('/') + 1, name.Length - 1 - name.LastIndexOf('/')); _IvendorBrandSet = new VendorBrandSetMgr(connectionString); old = _IvendorBrandSet.GetSingleImage(name); query.image_filename = name; try { if (!string.IsNullOrEmpty(Request.Params["sort_id"])) { query.image_sort = Convert.ToUInt32(Request.Params["sort_id"]); } else { query.image_sort = old.image_sort; } if (!string.IsNullOrEmpty(Request.Params["this_type"])) { query.image_state = Convert.ToUInt32(Request.Params["this_type"]); } else { query.image_state = old.image_state; } if (_IvendorBrandSet.UpdateImage(query) > 0) { json = "{success:true}";//返回json數據 } else { json = "{success:false}"; } } 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}"; } this.Response.Clear(); this.Response.Write(json.ToString()); this.Response.End(); return this.Response; }
public HttpResponseBase GetImageInfo() { VendorBrandSetQuery query = new VendorBrandSetQuery(); string brandid = Request.Params["brand_id"].ToString(); query.Brand_Id = uint.Parse(brandid); List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>(); string json = string.Empty; try { _IvendorBrandSet = new VendorBrandSetMgr(connectionString); int totalCount = 0; stores = _IvendorBrandSet.GetImageInfo(query); foreach (var item in stores) { if (!string.IsNullOrEmpty(item.image_filename)) { item.image_filename = imgServerPath + vendorOriginalPath + item.image_filename.Substring(0, 2) + "/" + item.image_filename.Substring(2, 2) + "/" + item.image_filename; } } json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據 } 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:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase upLoadImg() { string json = string.Empty; string errorInfo = string.Empty; VendorBrandSetQuery query = new VendorBrandSetQuery(); query.Brand_Id = uint.Parse(Request.Params["brand_id"]); query.image_sort = 0; query.image_state = 1; query.image_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()); _IvendorBrandSet = new VendorBrandSetMgr(connectionString); ImagePathConfig(); string fileName = String.Empty, fileExtention = String.Empty, newFileName = String.Empty, oldFileName = String.Empty; //string localPromoPath = imgLocalPath + vendorPath;//圖片存儲地址 string localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址 FileManagement fileLoad;//+++++++++++++++++ Boolean sort_repeat = false; for (int i = 0; i < Request.Files.Count; i++) { fileLoad = new FileManagement();//+++++++++++++++ HttpPostedFileBase file = Request.Files[i]; fileName = Path.GetFileName(file.FileName); fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower(); string[] arrary = fileName.Split('_'); if (arrary.Length < 3) { errorInfo += "[" + file.FileName + "] "; errorInfo += Resources.Product.FILE_NAME_ERROR; errorInfo += " 例:brand_1_tupian" + fileExtention; continue; } string brandStr = fileName.Split('_')[0].ToString(); string sortStr = fileName.Split('_')[1].ToString(); string filenameStr = fileName.Split('_')[2].ToString(); Regex reg = new Regex("^?[1-9][0-9]*$"); if (!brandStr.Equals("brand") || !reg.IsMatch(sortStr)) { errorInfo += "[" + file.FileName + "] "; errorInfo += Resources.Product.FILE_NAME_ERROR; errorInfo += " 例:brand_1_tupian" + fileExtention; continue; } query.image_sort = Convert.ToUInt32(sortStr); if (query.image_sort > 255) query.image_sort = 0; //大於數據庫存儲範圍時,默認為0; string newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32"); fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower(); newFileName = newRand + fileExtention; string folder1 = newFileName.Substring(0, 2) + "/";//圖片名前兩碼 string folder2 = newFileName.Substring(2, 2) + "/";//圖片名第三四碼 string ServerPath = string.Empty; FTP f_cf = new FTP(); localPromoPath = imgLocalPath + vendorOriginalPath + folder1 + folder2;//圖片存儲地址 string s = localPromoPath.Substring(0, localPromoPath.Length - (vendorOriginalPath + folder1 + folder2).Length + 1); f_cf.MakeMultiDirectory(s, (vendorOriginalPath + folder1 + folder2).Substring(1, (vendorOriginalPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd); ServerPath = Server.MapPath(imgLocalServerPath + vendorOriginalPath + folder1 + folder2); fileName = newFileName; newFileName = localPromoPath + newFileName;//絕對路徑 string ErrorMsg = string.Empty; //錯誤消息 //Resource.CoreMessage = new CoreResource("Vendor");//尋找product.resx中的資源文件 try { bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, 150, int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); if (result)//上傳成功 { //查詢image_sort是否存在重複 if (_IvendorBrandSet.GetSortIsRepeat(query)) { sort_repeat = true; } query.image_filename = fileName; _IvendorBrandSet.SaveBrandStory(query); errorInfo += "[" + file.FileName + "] " + "上傳成功!"; } else { errorInfo += "[" + file.FileName + "] " + ErrorMsg; } } 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); errorInfo += "[" + file.FileName + "] 上傳失敗<br/>"; //json = "{success:false,msg:\"操作失敗,請稍后再試!\"}"; //if (!string.IsNullOrEmpty(errorInfo)) //{ // json = "{success:false,msg:\"<div>操作失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}"; //} } fileName = String.Empty; fileExtention = String.Empty; newFileName = String.Empty; oldFileName = String.Empty;//++++++++++++++++++ localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址//++++++++++++++++++++ } if (sort_repeat)// json = "{success:true,sort_repeat:true,msg:\"<div>" + errorInfo + "</div>\"}"; else json = "{success:true,sort_repeat:false,msg:\"<div>" + errorInfo + "</div>\"}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 圖檔維護中上傳圖片 /// </summary> /// <returns></returns> public HttpResponseBase UploadPicture() { string json = string.Empty; string errorInfo = string.Empty; VendorBrandSetQuery query = new VendorBrandSetQuery(); query.Brand_Id = uint.Parse(Request.Params["brand_id"]); query.image_sort = 0; query.image_state = 1; query.image_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()); _IvendorBrandSet = new VendorBrandSetMgr(connectionString); ImagePathConfig(); string fileName = String.Empty, fileExtention = String.Empty, newFileName = String.Empty, oldFileName = String.Empty; //string localPromoPath = imgLocalPath + vendorPath;//圖片存儲地址 string localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址 FileManagement fileLoad;//+++++++++++++++++ for (int i = 0; i < Request.Files.Count; i++) { fileLoad = new FileManagement();//+++++++++++++++ HttpPostedFileBase file = Request.Files[i]; fileName = Path.GetFileName(file.FileName); string newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32"); fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower(); newFileName = newRand + fileExtention; string folder1 = newFileName.Substring(0, 2) + "/";//圖片名前兩碼 string folder2 = newFileName.Substring(2, 2) + "/";//圖片名第三四碼 string ServerPath = string.Empty; FTP f_cf = new FTP(); localPromoPath = imgLocalPath + vendorOriginalPath + folder1 + folder2;//圖片存儲地址 string s = localPromoPath.Substring(0, localPromoPath.Length - (vendorOriginalPath + folder1 + folder2).Length + 1); f_cf.MakeMultiDirectory(s, (vendorOriginalPath + folder1 + folder2).Substring(1, (vendorOriginalPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd); ServerPath = Server.MapPath(imgLocalServerPath + vendorOriginalPath + folder1 + folder2); fileName = newFileName; newFileName = localPromoPath + newFileName;//絕對路徑 string ErrorMsg = string.Empty; //錯誤消息 Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件 try { //bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, 150, int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); if (result)//上傳成功 { query.image_filename = fileName; _IvendorBrandSet.SaveBrandStory(query); //json = "{success:true,msg:\"圖片上傳成功!\"}"; } else { errorInfo += "第" + (i + 1) + "張" + ErrorMsg + "<br/>"; //json = "{success:false,msg:\"<div>圖片上傳成功!<br/>但第" + countError + "張" + ErrorMsg + "</div>\"}"; } json = "{success:true,msg:\"圖片上傳成功!\"}"; if (!string.IsNullOrEmpty(errorInfo)) { json = "{success:true,msg:\"<div>操作完成!<br/>但<br/>" + errorInfo + "</div>\"}"; } } 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,msg:\"操作失敗,請稍后再試!\"}"; if (!string.IsNullOrEmpty(errorInfo)) { json = "{success:false,msg:\"<div>操作失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}"; } } fileName = String.Empty; fileExtention = String.Empty; newFileName = String.Empty; oldFileName = String.Empty;//++++++++++++++++++ localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址//++++++++++++++++++++ } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase DeleteImage() { string jsonStr = String.Empty; _IvendorBrandSet = new VendorBrandSetMgr(connectionString); if (!String.IsNullOrEmpty(Request.Params["rowID"])) { try { foreach (string rid in Request.Params["rowID"].ToString().Split('|')) { if (!string.IsNullOrEmpty(rid)) { string name = rid.Substring(rid.LastIndexOf('/') + 1, rid.Length - 1 - rid.LastIndexOf('/')); if (_IvendorBrandSet.DeleteImage(name) > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } } } 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); jsonStr = "{success:false}"; } } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
/// <summary> /// 獲取供應商品牌列表數據 /// </summary> /// <returns></returns> public HttpResponseBase GetVendorBrandList() { string jsonStr = string.Empty; List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>(); try { query = new VendorBrandSetQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 _IvendorBrandSet = new VendorBrandSetMgr(connectionString); int totalCount = 0; query.SearchType = Convert.ToInt32(Request.Params["serchs"]); query.SearchCondition = Request.Params["serchcontent"]; if (!string.IsNullOrEmpty(Request.Params["relation_id"])) { query.Brand_Id = Convert.ToUInt32(Request.Params["relation_id"].ToString()); } stores = _IvendorBrandSet.GetVendorBrandList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; #region todo:自己优化的方法--代码较多,但速度快了很多 string brandId = " "; if (totalCount != 0) { foreach (var item in stores) { brandId += item.Brand_Id + ","; } brandId = brandId.Remove(brandId.LastIndexOf(',')); _IvendorBrandSet = new VendorBrandSetMgr(connectionString); DataTable dtShopName = _IvendorBrandSet.GetShop(brandId); foreach (var item in stores) { DataRow[] rShopName = dtShopName.Select("Brand_Id='" + item.Brand_Id + "'"); string classIds = ""; string class_name = ""; if (rShopName.Length > 0) { foreach (var rows in rShopName) { classIds += rows["class_id"] + ","; class_name += rows["class_name"] + "|"; } item.classIds = classIds.Remove(classIds.LastIndexOf(',')); item.class_name = class_name.Remove(class_name.LastIndexOf('|')); } if (Convert.ToBoolean(Request.Params["isSecret"])) { if (!string.IsNullOrEmpty(item.vendor_name_full)) { item.vendor_name_full = item.vendor_name_full.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.vendor_name_simple)) { item.vendor_name_simple = item.vendor_name_simple.Substring(0, 1) + "**"; } } item.begin_time = CommonFunction.GetNetTime(item.Brand_Msg_Start_Time); item.end_time = CommonFunction.GetNetTime(item.Brand_Msg_End_Time); //顯示圖片的絕對路徑 if (!string.IsNullOrEmpty(item.Image_Name)) { string folder1 = item.Image_Name.Substring(0, 2) + "/"; //圖片名前兩碼 string folder2 = item.Image_Name.Substring(2, 2) + "/"; //圖片名第三四碼 item.Image_Name = imgServerPath + brandPath + folder1 + folder2 + item.Image_Name; } else { item.Image_Name = defaultImg; } if (!string.IsNullOrEmpty(item.Resume_Image)) { string folder3 = item.Resume_Image.Substring(0, 2) + "/"; //圖片名前兩碼 string folder4 = item.Resume_Image.Substring(2, 2) + "/"; //圖片名第三四碼 item.Resume_Image = imgServerPath + brandPath + folder3 + folder4 + item.Resume_Image; } else { item.Resume_Image = defaultImg; } if (!string.IsNullOrEmpty(item.Promotion_Banner_Image)) { string folder5 = item.Promotion_Banner_Image.Substring(0, 2) + "/"; //圖片名前兩碼 string folder6 = item.Promotion_Banner_Image.Substring(2, 2) + "/"; //圖片名第三四碼 item.Promotion_Banner_Image = imgServerPath + brandPath + folder5 + folder6 + item.Promotion_Banner_Image; } else { item.Promotion_Banner_Image = defaultImg; } if (!string.IsNullOrEmpty(item.brand_logo)) { string folder5 = item.brand_logo.Substring(0, 2) + "/"; //圖片名前兩碼 string folder6 = item.brand_logo.Substring(2, 2) + "/"; //圖片名第三四碼 item.brand_logo = imgServerPath + brandPath + folder5 + folder6 + item.brand_logo; } else { item.brand_logo = defaultImg; } } } #endregion jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Newtonsoft.Json.Formatting.Indented, timeConverter) + "}";//返回json數據 } 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); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }