void UploadImage(HttpContext context, HttpPostedFile file) { string uploadPath = HiContext.Current.GetStoragePath() + "/" + uploadType; string newFilename = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(file.FileName); string originalSavePath = uploadPath + "/images/" + newFilename; string thumbnail40SavePath = uploadPath + "/thumbs40/40_" + newFilename; string thumbnail60SavePath = uploadPath + "/thumbs60/60_" + newFilename; string thumbnail100SavePath = uploadPath + "/thumbs100/100_" + newFilename; string thumbnail160SavePath = uploadPath + "/thumbs160/160_" + newFilename; string thumbnail180SavePath = uploadPath + "/thumbs180/180_" + newFilename; string thumbnail220SavePath = uploadPath + "/thumbs220/220_" + newFilename; string thumbnail310SavePath = uploadPath + "/thumbs310/310_" + newFilename; string thumbnail410SavePath = uploadPath + "/thumbs410/410_" + newFilename; file.SaveAs(context.Request.MapPath(Globals.ApplicationPath + originalSavePath)); string originalFullPath = context.Request.MapPath(Globals.ApplicationPath + originalSavePath); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail40SavePath), 40, 40); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail60SavePath), 60, 60); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail100SavePath), 100, 100); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail160SavePath), 160, 160); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail180SavePath), 180, 180); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail220SavePath), 220, 220); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail310SavePath), 310, 310); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail410SavePath), 410, 410); string[] parameters = new string[] { "'" + uploadType + "'", "'" + uploaderId + "'", "'" + originalSavePath + "'", "'" + thumbnail40SavePath + "'", "'" + thumbnail60SavePath + "'", "'" + thumbnail100SavePath + "'", "'" + thumbnail160SavePath + "'", "'" + thumbnail180SavePath + "'", "'" + thumbnail220SavePath + "'", "'" + thumbnail310SavePath + "'", "'" + thumbnail410SavePath + "'" }; context.Response.Write("<script type=\"text/javascript\">window.parent.UploadCallback(" + string.Join(",", parameters) + ");</script>"); }
private static string[] ProcessImages(HttpContext context, string originalSavePath) { string fileName = Path.GetFileName(originalSavePath); string str2 = "/Storage/master/product/thumbs40/40_" + fileName; string str3 = "/Storage/master/product/thumbs60/60_" + fileName; string str4 = "/Storage/master/product/thumbs100/100_" + fileName; string str5 = "/Storage/master/product/thumbs160/160_" + fileName; string str6 = "/Storage/master/product/thumbs180/180_" + fileName; string str7 = "/Storage/master/product/thumbs220/220_" + fileName; string str8 = "/Storage/master/product/thumbs310/310_" + fileName; string str9 = "/Storage/master/product/thumbs410/410_" + fileName; string path = context.Request.MapPath(Globals.ApplicationPath + originalSavePath); if (File.Exists(path)) { try { ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str2), 40, 40); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str3), 60, 60); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str4), 100, 100); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str5), 160, 160); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str6), 180, 180); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str7), 220, 220); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str8), 310, 310); ResourcesHelper.CreateThumbnail(path, context.Request.MapPath(Globals.ApplicationPath + str9), 410, 410); } catch { } } return(new string[] { str2, str3, str4, str5, str6, str7, str8, str9 }); }
private void UploadImage(HttpContext context, HttpPostedFile file) { string str = Globals.GetStoragePath() + "/" + this.uploadType; string str2 = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(file.FileName); string str3 = str + "/images/" + str2; string str4 = str + "/thumbs40/40_" + str2; string str5 = str + "/thumbs60/60_" + str2; string str6 = str + "/thumbs100/100_" + str2; string str7 = str + "/thumbs160/160_" + str2; string str8 = str + "/thumbs180/180_" + str2; string str9 = str + "/thumbs220/220_" + str2; string str10 = str + "/thumbs310/310_" + str2; string str11 = str + "/thumbs410/410_" + str2; file.SaveAs(context.Request.MapPath(Globals.ApplicationPath + str3)); string sourceFilename = context.Request.MapPath(Globals.ApplicationPath + str3); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str4), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str5), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str6), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str7), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str8), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str9), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str10), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str11), 410, 410); string[] strArray = new string[] { "'" + this.uploadType + "'", "'" + this.uploaderId + "'", "'" + str3 + "'", "'" + str4 + "'", "'" + str5 + "'", "'" + str6 + "'", "'" + str7 + "'", "'" + str8 + "'", "'" + str9 + "'", "'" + str10 + "'", "'" + str11 + "'" }; context.Response.Write("<script type=\"text/javascript\">window.parent.UploadCallback(" + string.Join(",", strArray) + ");</script>"); }
private ProductImagesInfo SaveGiftImage() { string text = Globals.GetStoragePath() + "/gift/"; if (!Globals.PathExist(text, false)) { Globals.CreatePath(text); } string str = Globals.GetStoragePath() + "/temp/"; string str2 = HttpContext.Current.Server.MapPath(text + "/images/"); string value = this.hidUploadImages.Value; if (value.Trim().Length == 0) { return(null); } value = value.Replace("//", "/"); string text2 = (value.Split('/').Length == 6) ? value.Split('/')[5] : value.Split('/')[4]; if (File.Exists(str2 + text2)) { return(null); } ProductImagesInfo productImagesInfo = new ProductImagesInfo(); File.Copy(HttpContext.Current.Server.MapPath(this.hidUploadImages.Value), str2 + text2); string text3 = text + "thumbs40/40_" + text2; string text4 = text + "thumbs60/60_" + text2; string text5 = text + "thumbs100/100_" + text2; string text6 = text + "thumbs160/160_" + text2; string text7 = text + "thumbs180/180_" + text2; string text8 = text + "thumbs220/220_" + text2; string text9 = text + "thumbs310/310_" + text2; string text10 = text + "thumbs410/410_" + text2; ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text3), 40, 40); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text4), 60, 60); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text5), 100, 100); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text6), 160, 160); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text7), 180, 180); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text8), 220, 220); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text9), 310, 310); ResourcesHelper.CreateThumbnail(str2 + text2, HttpContext.Current.Server.MapPath(text10), 410, 410); productImagesInfo.ImageUrl1 = text + "images/" + text2; productImagesInfo.ThumbnailUrl40 = text3; productImagesInfo.ThumbnailUrl60 = text4; productImagesInfo.ThumbnailUrl100 = text5; productImagesInfo.ThumbnailUrl160 = text6; productImagesInfo.ThumbnailUrl180 = text7; productImagesInfo.ThumbnailUrl220 = text8; productImagesInfo.ThumbnailUrl310 = text9; productImagesInfo.ThumbnailUrl410 = text10; string path = HttpContext.Current.Server.MapPath(str + text2); if (File.Exists(path)) { File.Delete(path); } return(productImagesInfo); }
private void GetImg(string fileName, ref ProductInfo product, int index) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName); string str = System.Guid.NewGuid().ToString("N", System.Globalization.CultureInfo.InvariantCulture) + System.IO.Path.GetExtension(fileName); string text = this.uploadPath + "/images/" + str; string text2 = this.uploadPath + "/thumbs40/40_" + str; string text3 = this.uploadPath + "/thumbs60/60_" + str; string text4 = this.uploadPath + "/thumbs100/100_" + str; string text5 = this.uploadPath + "/thumbs160/160_" + str; string text6 = this.uploadPath + "/thumbs180/180_" + str; string text7 = this.uploadPath + "/thumbs220/220_" + str; string text8 = this.uploadPath + "/thumbs310/310_" + str; string text9 = this.uploadPath + "/thumbs410/410_" + str; fileInfo.CopyTo(base.Request.MapPath(Globals.ApplicationPath + text)); string sourceFilename = base.Request.MapPath(Globals.ApplicationPath + text); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text2), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text3), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text4), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text5), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text6), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text7), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text8), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, base.Request.MapPath(Globals.ApplicationPath + text9), 410, 410); if (index == 1) { product.ImageUrl1 = text; product.ThumbnailUrl40 = text2; product.ThumbnailUrl60 = text3; product.ThumbnailUrl100 = text4; product.ThumbnailUrl160 = text5; product.ThumbnailUrl180 = text6; product.ThumbnailUrl220 = text7; product.ThumbnailUrl310 = text8; product.ThumbnailUrl410 = text9; return; } switch (index) { case 2: product.ImageUrl2 = text; return; case 3: product.ImageUrl3 = text; return; case 4: product.ImageUrl4 = text; return; case 5: product.ImageUrl5 = text; return; default: return; } }
private ProductImagesInfo SaveProductImages() { string text = HiContext.Current.GetStoragePath() + "product/"; if (!Globals.PathExist(text, false)) { Globals.CreatePath(text); } ProductImagesInfo productImagesInfo = new ProductImagesInfo(); string str = HttpContext.Current.Server.MapPath(text + "images/"); string text2 = this.hidUploadImages.Value.Trim(); if (text2.Length == 0) { return(productImagesInfo); } string[] array = text2.Split(','); for (int i = 0; i < array.Length; i++) { string text3 = array[i]; text3 = text3.Replace("//", "/"); if (text3.Length != 0) { string text4 = (text3.Split('/').Length == 6) ? text3.Split('/')[5] : text3.Split('/')[4]; string text5 = text + "thumbs40/40_" + text4; string text6 = text + "thumbs60/60_" + text4; string text7 = text + "thumbs100/100_" + text4; string text8 = text + "thumbs160/160_" + text4; string text9 = text + "thumbs180/180_" + text4; string text10 = text + "thumbs220/220_" + text4; string text11 = text + "thumbs310/310_" + text4; string text12 = text + "thumbs410/410_" + text4; if (File.Exists(str + text4)) { AddProduct.BindProductImageInfo(text, productImagesInfo, i, text4, text5, text6, text7, text8, text9, text10, text11, text12); } else { File.Copy(HttpContext.Current.Server.MapPath(text3), str + text4); if (File.Exists(HttpContext.Current.Server.MapPath(text3))) { File.Delete(HttpContext.Current.Server.MapPath(text3)); } ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text5), 40, 40); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text6), 60, 60); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text7), 100, 100); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text8), 160, 160); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text9), 180, 180); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text10), 220, 220); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text11), 310, 310); ResourcesHelper.CreateThumbnail(str + text4, HttpContext.Current.Server.MapPath(text12), 410, 410); AddProduct.BindProductImageInfo(text, productImagesInfo, i, text4, text5, text6, text7, text8, text9, text10, text11, text12); } } } return(productImagesInfo); }
private string UpdateOnePhoto(string photo) { string text = photo; if (text.Contains("/temp/") && text.Length > 10) { string[] array = photo.Split(new char[] { '.' }); if (array.Length <= 1) { return(""); } string str = array[array.Length - 1].Trim().ToLower(); string str2 = Globals.GetStoragePath() + "/" + this._FlashUploadType; string str3 = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + "." + str; string text2 = text; string[] array2 = photo.Split(new char[] { '/' }); if (text2.StartsWith("http://")) { text2 = text2.Replace("http://" + array2[2], ""); } text2 = this.Context.Server.MapPath(text2); string text3 = str2 + "/images/" + str3; File.Copy(text2, this.Context.Server.MapPath(text3), true); string sourceFilename = this.Context.Request.MapPath(Globals.ApplicationPath + text3); string str4 = str2 + "/thumbs40/40_" + str3; string str5 = str2 + "/thumbs60/60_" + str3; string str6 = str2 + "/thumbs100/100_" + str3; string str7 = str2 + "/thumbs160/160_" + str3; string str8 = str2 + "/thumbs180/180_" + str3; string str9 = str2 + "/thumbs220/220_" + str3; string str10 = str2 + "/thumbs310/310_" + str3; string str11 = str2 + "/thumbs410/410_" + str3; text = text3; ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str4), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str5), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str6), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str7), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str8), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str9), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str10), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str11), 410, 410); } if (text.Length > 10) { text = "," + text; } return(text); }
private string UpdateOnePhoto(string photo) { string str = photo; if (str.Contains("/temp/") && (str.Length > 10)) { string[] strArray = photo.Split(new char[] { '.' }); if (strArray.Length <= 1) { return(""); } string str2 = strArray[strArray.Length - 1].Trim().ToLower(); string str3 = Globals.GetStoragePath() + "/" + this._FlashUploadType; string str4 = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + "." + str2; string path = str; string[] strArray2 = photo.Split(new char[] { '/' }); if (path.StartsWith("http://")) { path = path.Replace("http://" + strArray2[2], ""); } path = this.Context.Server.MapPath(path); string str6 = str3 + "/images/" + str4; File.Copy(path, this.Context.Server.MapPath(str6), true); string sourceFilename = this.Context.Request.MapPath(Globals.ApplicationPath + str6); string str8 = str3 + "/thumbs40/40_" + str4; string str9 = str3 + "/thumbs60/60_" + str4; string str10 = str3 + "/thumbs100/100_" + str4; string str11 = str3 + "/thumbs160/160_" + str4; string str12 = str3 + "/thumbs180/180_" + str4; string str13 = str3 + "/thumbs220/220_" + str4; string str14 = str3 + "/thumbs310/310_" + str4; string str15 = str3 + "/thumbs410/410_" + str4; str = str6; ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str8), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str9), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str10), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str11), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str12), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str13), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str14), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, this.Context.Request.MapPath(Globals.ApplicationPath + str15), 410, 410); } if (str.Length > 10) { str = "," + str; } return(str); }
private void UploadImage(HttpContext context, HttpPostedFile file) { string storageRoot = HiContext.Current.GetStoragePath() + "/" + this.uploadType; string filename = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(file.FileName); string imageFilename = storageRoot + "/images/" + filename; string thumbs40 = storageRoot + "/thumbs40/40_" + filename; string thumbs60 = storageRoot + "/thumbs60/60_" + filename; string thumbs100 = storageRoot + "/thumbs100/100_" + filename; string thumbs160 = storageRoot + "/thumbs160/160_" + filename; string thumbs180 = storageRoot + "/thumbs180/180_" + filename; string thumbs220 = storageRoot + "/thumbs220/220_" + filename; string thumbs310 = storageRoot + "/thumbs310/310_" + filename; string thumbs410 = storageRoot + "/thumbs410/410_" + filename; file.SaveAs(context.Request.MapPath(Globals.ApplicationPath + imageFilename)); string sourceFilename = context.Request.MapPath(Globals.ApplicationPath + imageFilename); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs40), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs60), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs100), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs160), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs180), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs220), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs310), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + thumbs410), 410, 410); string[] value = new string[] { "'" + this.uploadType + "'", "'" + this.uploaderId + "'", "'" + imageFilename + "'", "'" + thumbs40 + "'", "'" + thumbs60 + "'", "'" + thumbs100 + "'", "'" + thumbs160 + "'", "'" + thumbs180 + "'", "'" + thumbs220 + "'", "'" + thumbs310 + "'", "'" + thumbs410 + "'" }; context.Response.Write("<script type=\"text/javascript\">window.parent.UploadCallback(" + string.Join(",", value) + ");</script>"); }
private void DownloadImage(ProductInfo product, string imageUrls, HttpContext context) { imageUrls = HttpUtility.UrlDecode(imageUrls); string[] strArray = imageUrls.Split(new char[] { ';' }); int num = 1; foreach (string str in strArray) { string str2 = string.Format("/Storage/master/product/images/{0}", Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + str.Substring(str.LastIndexOf('.'))); string str3 = str2.Replace("/images/", "/thumbs40/40_"); string str4 = str2.Replace("/images/", "/thumbs60/60_"); string str5 = str2.Replace("/images/", "/thumbs100/100_"); string str6 = str2.Replace("/images/", "/thumbs160/160_"); string str7 = str2.Replace("/images/", "/thumbs180/180_"); string str8 = str2.Replace("/images/", "/thumbs220/220_"); string str9 = str2.Replace("/images/", "/thumbs310/310_"); string str10 = str2.Replace("/images/", "/thumbs410/410_"); string fileName = HttpContext.Current.Request.MapPath(Globals.ApplicationPath + str2); WebClient client = new WebClient(); try { client.DownloadFile(str, fileName); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str3), 40, 40); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str4), 60, 60); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str5), 100, 100); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str6), 160, 160); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str7), 180, 180); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str8), 220, 220); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str9), 310, 310); ResourcesHelper.CreateThumbnail(fileName, context.Request.MapPath(Globals.ApplicationPath + str10), 410, 410); switch (num) { case 1: product.ImageUrl1 = str2; product.ThumbnailUrl40 = str3; product.ThumbnailUrl60 = str4; product.ThumbnailUrl100 = str5; product.ThumbnailUrl160 = str6; product.ThumbnailUrl180 = str7; product.ThumbnailUrl220 = str8; product.ThumbnailUrl310 = str9; product.ThumbnailUrl410 = str10; break; case 2: product.ImageUrl2 = str2; break; case 3: product.ImageUrl3 = str2; break; case 4: product.ImageUrl4 = str2; break; case 5: product.ImageUrl5 = str2; break; } num++; } catch { } } }
private void UpdateStores() { StoresInfo storeById = StoresHelper.GetStoreById(this.storeId); ManagerInfo managerInfo = ManagerHelper.FindManagerByStoreId(this.storeId, SystemRoles.StoreAdmin); if (storeById == null) { base.Response.Redirect("StoresList.aspx"); } double num = 0.0; int num2 = 0; int num3 = 0; decimal num4 = default(decimal); string text = ""; string text2 = ""; string Address = ""; string text3 = Globals.StripAllTags(this.txtStoresName.Text.Trim()); Address = Globals.StripAllTags(this.txtAddress.Text); string text4 = Globals.StripAllTags(this.txtRegionScop.Value.Trim()); string text5 = Globals.StripAllTags(this.txtRegionScopName.Value.Trim()); text = this.txtTel.Text; text2 = this.txtContactMan.Text; string[] array = text4.Split(','); string[] array2 = text5.Split(','); IDictionary <int, DeliveryScopeInfo> dictionary = new Dictionary <int, DeliveryScopeInfo>(); for (int i = 0; i < array.Length; i++) { int num5 = 0; if (int.TryParse(array[i], out num5) && array2.Length >= i && dictionary != null && !dictionary.ContainsKey(num5)) { DeliveryScopeInfo deliveryScopeInfo = new DeliveryScopeInfo(); deliveryScopeInfo.RegionId = num5; deliveryScopeInfo.RegionName = array2[i]; deliveryScopeInfo.FullRegionPath = RegionHelper.GetFullPath(num5, true); dictionary.Add(num5, deliveryScopeInfo); } } if (storeById.StoreName != text3 && StoresHelper.ExistStoreName(text3)) { this.ResetForm(storeById.StoreId); this.ShowMsg("门店名称已经存在,请重新输入!", false); } else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请确保两次输入的密码相同", false); } else if (!this.dropRegion.GetSelectedRegionId().HasValue) { this.ResetForm(storeById.StoreId); this.ShowMsg("请选择店铺所在区域!", false); } else if (text2.Length > 8 || text2.Length < 2) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false); } else if (string.IsNullOrEmpty(this.hfLatitude.Value) || string.IsNullOrEmpty(this.hfLongitude.Value)) { this.ResetForm(storeById.StoreId); this.ShowMsg("请给门店标注定位!", false); } else if (text == "" || !DataHelper.IsTel(text)) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false); } else { if (!string.IsNullOrEmpty(this.txtUserPwd.Text)) { if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20) { this.ResetForm(storeById.StoreId); this.ShowMsg("密码长度必须在6到20个字符之间!", false); return; } managerInfo.Password = Users.EncodePassword(this.txtUserPwd.Text, managerInfo.PasswordSalt); } if (!this.chkIsSupportExpress.Checked && !this.chkIsAboveSelf.Checked && !this.chkIsStoreDelive.Checked) { this.ResetForm(storeById.StoreId); this.ShowMsg("请选择一种配送方式!", false); } else { if (this.chkIsStoreDelive.Checked) { if (!double.TryParse(this.txtServeRadius.Text.Trim(), out num) || num > 10000.0 || num <= 0.0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的配送半径,为大于0至10000之间的数字!", false); return; } if (!int.TryParse(this.txtStoreFreight.Text.Trim(), out num2) || num2 > 99999999 || num2 < 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的配送费", false); return; } if (!int.TryParse(this.txtMinOrderPrice.Text.Trim(), out num3) || num3 > 99999999 || num3 < 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的起送价", false); return; } } if (!decimal.TryParse(this.txtCommissionRate.Text.Trim(), out num4) || num4 > 100m || num4 < decimal.Zero) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的平台抽佣比例", false); } else if (!this.chkOfflinePay.Checked && !this.chkOnlinePay.Checked && !this.chkCashOnDelivery.Checked) { this.ResetForm(storeById.StoreId); this.ShowMsg("支付方式请至少选择一种", false); } else { storeById.IsOfflinePay = this.chkOfflinePay.Checked; storeById.IsOnlinePay = this.chkOnlinePay.Checked; storeById.IsCashOnDelivery = this.chkCashOnDelivery.Checked; if (string.IsNullOrEmpty(this.txtStoreOpenTimeStartH.Text) || this.txtStoreOpenTimeStartH.Text.ToInt(0) < 0 || this.txtStoreOpenTimeStartH.Text.ToInt(0) >= 24) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业起始小时", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeStartM.Text) || this.txtStoreOpenTimeStartM.Text.ToInt(0) < 0 || this.txtStoreOpenTimeStartM.Text.ToInt(0) >= 60) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业起始分钟", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeEndH.Text) || this.txtStoreOpenTimeEndH.Text.ToInt(0) < 0 || this.txtStoreOpenTimeEndH.Text.ToInt(0) >= 24) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业结束小时", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeEndM.Text) || this.txtStoreOpenTimeEndM.Text.ToInt(0) < 0 || this.txtStoreOpenTimeEndM.Text.ToInt(0) >= 60) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业结束分钟", false); } else { string empty = string.Empty; DateTime dateTime = DateTime.Now; string text6 = dateTime.ToString("yyyy-MM-dd"); DateTime?nullable = (text6 + " " + this.txtStoreOpenTimeStartH.Text.ToInt(0) + ":" + this.txtStoreOpenTimeStartM.Text.ToInt(0)).ToDateTime(); DateTime?nullable2 = (text6 + " " + this.txtStoreOpenTimeEndH.Text.ToInt(0) + ":" + this.txtStoreOpenTimeEndM.Text.ToInt(0)).ToDateTime(); dateTime = nullable.Value; string str = dateTime.ToString("HH:mm"); dateTime = nullable2.Value; string text7 = dateTime.ToString("HH:mm"); if (text7 == "00:00") { nullable2 = (text6 + " 23:59").ToDateTime(); text7 = "23:59"; } empty = (storeById.StoreOpenTime = str + "-" + text7); storeById.OpenStartDate = nullable.Value; storeById.OpenEndDate = nullable2.Value; storeById.IsSupportExpress = (this.chkIsSupportExpress.Checked && true); storeById.IsAboveSelf = (this.chkIsAboveSelf.Checked && true); storeById.IsStoreDelive = (this.chkIsStoreDelive.Checked && true); storeById.Introduce = this.editDescription.Text; if (this.chkIsStoreDelive.Checked) { storeById.ServeRadius = num; storeById.MinOrderPrice = num3; storeById.StoreFreight = num2; } else { storeById.ServeRadius = 0.0; storeById.MinOrderPrice = null; storeById.StoreFreight = null; } storeById.CommissionRate = num4; List <string> list = RegionHelper.GetFullRegion(this.dropRegion.GetSelectedRegionId().Value, ",", true, 0).Split(',').Take(3) .ToList(); list.ForEach(delegate(string c) { Address = Address.Replace(c, string.Empty); }); IList <string> list2 = new List <string>(); string text9 = this.hidUploadImages.Value.Trim(); string[] array3 = text9.Split(','); for (int j = 0; j < array3.Length; j++) { if (!string.IsNullOrEmpty(array3[j])) { string text10 = Globals.SaveFile("depot", array3[j], "/Storage/master/", true, false, ""); string text11 = base.Request.MapPath(text10); string virtualPath = HiContext.Current.GetStoragePath() + "/depot/thum_" + text10.Substring(text10.LastIndexOf("/") + 1); if (!File.Exists(text11)) { this.ShowMsg("缩略图文件夹未创建,请联系管理员", false); return; } ResourcesHelper.CreateThumbnail(text11, base.Request.MapPath(virtualPath), 160, 160); list2.Add(text10); } } if (list2.Count == 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("logo已失效或未上传,请上传门店logo", false); } else if (ManagerHelper.Update(managerInfo)) { int value = this.dropRegion.GetSelectedRegionId().Value; storeById.StoreName = text3; storeById.RegionId = value; storeById.TopRegionId = RegionHelper.GetCityId(value); storeById.Tel = text; storeById.Address = Address; storeById.ContactMan = text2; storeById.StoreImages = ((list2.Count == 0) ? string.Empty : string.Join(",", list2.ToArray())); storeById.Longitude = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLongitude.Value) ? "0" : this.hfLongitude.Value), 6); storeById.Latitude = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLatitude.Value) ? "0" : this.hfLatitude.Value), 6); storeById.FullRegionPath = RegionHelper.GetFullPath(value, true); StoresHelper.UpdateStore(storeById); HiCache.Remove("DataCache-StoreInfoDataKey"); if (dictionary.Count > 0 && this.chkIsStoreDelive.Checked) { StoresHelper.AddDeliveryScope(this.storeId, dictionary); } else { StoresHelper.DeleteDevlieryScope(this.storeId); } if (!string.IsNullOrEmpty(this.txtStoreTag.Text.Trim())) { IList <int> list3 = new List <int>(); string text12 = this.txtStoreTag.Text.Trim(); string[] array4 = null; array4 = ((!text12.Contains(",")) ? new string[1] { text12 } : text12.Split(',')); string[] array5 = array4; foreach (string value2 in array5) { list3.Add(Convert.ToInt32(value2)); } StoresHelper.DeleteStoreTags(this.storeId); StoresHelper.BindStoreTags(this.storeId, list3); } else { StoresHelper.DeleteStoreTags(this.storeId); } HiCache.Remove($"DataCache-StoreStateCacheKey-{storeById.StoreId}"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (masterSettings.OpenDadaLogistics) { DataTable dataTable = DepotHelper.SynchroDadaStoreList(this.storeId); if (dataTable != null && dataTable.Rows.Count > 0) { for (int l = 0; l < dataTable.Rows.Count; l++) { string station_name = dataTable.Rows[l]["StoreName"].ToNullString(); int business = 5; string city_name = dataTable.Rows[l]["CityName"].ToNullString().Replace("市", ""); string area_name = dataTable.Rows[l]["RegionName"].ToNullString(); string station_address = dataTable.Rows[l]["Address"].ToNullString(); double lng = dataTable.Rows[l]["Longitude"].ToDouble(0); double lat = dataTable.Rows[l]["Latitude"].ToDouble(0); string contact_name = dataTable.Rows[l]["ContactMan"].ToNullString(); string phone = dataTable.Rows[l]["Tel"].ToNullString(); string text13 = dataTable.Rows[l]["StoreId"].ToNullString(); string text14 = DadaHelper.shopUpdate(masterSettings.DadaSourceID, this.storeId.ToString(), "", station_name, business, city_name, area_name, station_address, lng, lat, contact_name, phone, -1); } } } } } } } } }
private void UploadImage(HttpContext context, HttpPostedFile file, string snailtype) { string str = "/storage/data/grade"; string str2 = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(file.FileName); string str3 = str + "/images/" + str2; if (this.uploadType.ToLower() == UploadType.SharpPic.ToString().ToLower()) { str = "/Storage/data/Sharp/"; str2 = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(file.FileName); str3 = str + str2; } else if (this.uploadType.ToLower() == UploadType.Vote.ToString().ToLower()) { str = "/Storage/master/vote/"; str3 = str + str2; } else if (this.uploadType.ToLower() == UploadType.Topic.ToString().ToLower()) { str = "/Storage/master/topic/"; str3 = str + str2; } else if (this.uploadType.ToLower() == UploadType.Weibo.ToString().ToLower()) { str = "/Storage/master/Weibo/"; str3 = str + str2; } if (this.uploadType.ToLower() == UploadType.Brand.ToString().ToLower()) { str = "/Storage/master/brand/"; str3 = str + str2; } else if (this.uploadType.ToLower() == UploadType.ShopMenu.ToString().ToLower()) { str = "/Storage/master/ShopMenu/"; str3 = str + str2; int result = 0; if (!string.IsNullOrEmpty(this.uploadSize)) { if (!int.TryParse(this.uploadSize, out result)) { this.WriteBackError(context, "UploadSize属性值只能是数字!"); return; } if (file.ContentLength > result) { this.WriteBackError(context, "文件大小不超过10KB!"); return; } } string str4 = Path.GetExtension(file.FileName).ToLower(); if (((!str4.Equals(".gif") && !str4.Equals(".jpg")) && (!str4.Equals(".jpeg") && !str4.Equals(".png"))) && !str4.Equals(".bmp")) { this.WriteBackError(context, "请上传正确的图片文件。"); return; } } string str5 = str + "/thumbs40/40_" + str2; string str6 = str + "/thumbs60/60_" + str2; string str7 = str + "/thumbs100/100_" + str2; string str8 = str + "/thumbs160/160_" + str2; string str9 = str + "/thumbs180/180_" + str2; string str10 = str + "/thumbs220/220_" + str2; string str11 = str + "/thumbs310/310_" + str2; string str12 = str + "/thumbs410/410_" + str2; string imageFilePath = context.Request.MapPath(Globals.ApplicationPath + str3); if (Globals.UploadFileAndCheck(file, imageFilePath) == "1") { string sourceFilename = context.Request.MapPath(Globals.ApplicationPath + str3); if (snailtype == "1") { ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str5), 40, 40); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str6), 60, 60); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str7), 100, 100); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str8), 160, 160); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str9), 180, 180); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str10), 220, 220); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str11), 310, 310); ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str12), 410, 410); } } string[] strArray = new string[] { "'" + this.uploadType + "'", "'" + this.uploaderId + "'", "'" + str3 + "'", "'" + snailtype + "','" + this.uploadSize + "'" }; context.Response.Write("<script type=\"text/javascript\">window.parent.UploadCallback(" + string.Join(",", strArray) + ");</script>"); }
void swfobject_Upload(HttpContext context) { try { string uploadPath = Globals.GetStoragePath() + "/" + uploadType; string newFilename = Guid.NewGuid().ToString("N") + ".jpg"; string originalSavePath = uploadPath + "/images/" + newFilename; CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "images"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs40"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs60"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs100"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs160"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs180"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs220"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs226"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs310"))); CreateDir(context.Request.MapPath(Path.Combine(uploadPath, "thumbs410"))); string thumbnail40SavePath = uploadPath + "/thumbs40/40_" + newFilename; string thumbnail60SavePath = uploadPath + "/thumbs60/60_" + newFilename; string thumbnail100SavePath = uploadPath + "/thumbs100/100_" + newFilename; string thumbnail160SavePath = uploadPath + "/thumbs160/160_" + newFilename; string thumbnail180SavePath = uploadPath + "/thumbs180/180_" + newFilename; string thumbnail220SavePath = uploadPath + "/thumbs220/220_" + newFilename; string thumbnail226SavePath = uploadPath + "/thumbs226/226_" + newFilename; string thumbnail310SavePath = uploadPath + "/thumbs310/310_" + newFilename; string thumbnail410SavePath = uploadPath + "/thumbs410/410_" + newFilename; // file.SaveAs(context.Request.MapPath(Globals.ApplicationPath + originalSavePath)); // System.Drawing.Image image = System.Drawing.Image.FromStream(context.Request.InputStream); // image.Save(context.Request.MapPath(originalSavePath)); #region 读取图片数据 //读取流,并转为byte Stream stream = context.Request.InputStream; byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); //分隔符 byte[] splitStr = System.Text.Encoding.UTF8.GetBytes("--------------------"); //读取分隔符位置 IList <int> points = new List <int>(); for (int i = 0; i < buffer.Length - splitStr.Length; i++) { stream.Position = i; byte[] tempSplitStr = new byte[splitStr.Length]; stream.Read(tempSplitStr, 0, splitStr.Length); if (tempSplitStr.SequenceEqual(splitStr)) { points.Add(i); } } points.Add(buffer.Length); //按分隔符的位置,取出段数据(图片),并存为图片 int curPosition = 0; //foreach (var point in points) //{ // using (FileStream fs = new FileStream("c:\\" + point.GetHashCode() + ".jpg", FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite)) // { // fs.Write(buffer, curPosition, point - curPosition); // curPosition += (splitStr.Length + point); // } //} if (points.Count > 0) { //缩略图 using (FileStream fs = new FileStream(context.Request.MapPath(Globals.ApplicationPath + thumbnail226SavePath), FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite)) { fs.Write(buffer, curPosition, points[0] - curPosition); curPosition += (splitStr.Length + points[0]); } } if (points.Count > 1) { //缩略图 using (FileStream fs = new FileStream(context.Request.MapPath(Globals.ApplicationPath + originalSavePath), FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite)) { fs.Write(buffer, curPosition, points[1] - curPosition); curPosition += (splitStr.Length + points[1]); } } #endregion string originalFullPath = context.Request.MapPath(Globals.ApplicationPath + originalSavePath); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail40SavePath), 40, 40); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail60SavePath), 60, 60); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail100SavePath), 100, 100); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail160SavePath), 160, 160); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail180SavePath), 180, 180); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail220SavePath), 220, 220); //image.Save(context.Request.MapPath(thumbnail226SavePath)); //ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail226SavePath), 226, 340); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail310SavePath), 310, 310); ResourcesHelper.CreateThumbnail(originalFullPath, context.Request.MapPath(Globals.ApplicationPath + thumbnail410SavePath), 410, 410); string[] parameters = new string[] { "'" + uploadType + "'", "'" + uploaderId + "'", "'" + originalSavePath + "'", "'" + thumbnail40SavePath + "'", "'" + thumbnail60SavePath + "'", "'" + thumbnail100SavePath + "'", "'" + thumbnail160SavePath + "'", "'" + thumbnail180SavePath + "'", "'" + thumbnail220SavePath + "'", "'" + thumbnail226SavePath + "'", "'" + thumbnail310SavePath + "'", "'" + thumbnail410SavePath + "'" }; //context.Response.Write("<script type=\"text/javascript\">UploadCallback(" + string.Join(",", parameters) + ");</script>"); StringBuilder json = new StringBuilder(); json.Append("{"); json.AppendFormat("\"uploadType\":\"{0}\",", uploadType); json.AppendFormat("\"uploaderId\":\"{0}\",", uploaderId); json.AppendFormat("\"originalSavePath\":\"{0}\",", originalSavePath); json.AppendFormat("\"thumbnail40SavePath\":\"{0}\",", thumbnail40SavePath); json.AppendFormat("\"thumbnail60SavePath\":\"{0}\",", thumbnail60SavePath); json.AppendFormat("\"thumbnail100SavePath\":\"{0}\",", thumbnail100SavePath); json.AppendFormat("\"thumbnail160SavePath\":\"{0}\",", thumbnail160SavePath); json.AppendFormat("\"thumbnail180SavePath\":\"{0}\",", thumbnail180SavePath); json.AppendFormat("\"thumbnail220SavePath\":\"{0}\",", thumbnail220SavePath); json.AppendFormat("\"thumbnail226SavePath\":\"{0}\",", thumbnail226SavePath); json.AppendFormat("\"thumbnail310SavePath\":\"{0}\",", thumbnail310SavePath); json.AppendFormat("\"thumbnail410SavePath\":\"{0}\"", thumbnail410SavePath); json.Append("}"); context.Response.Write("{\"status\":\"1\",\"callbackdata\":" + json.ToString() + "}"); } catch// (Exception ex) { context.Response.Write("{\"status\":\"-2\"}"); // WriteBackError(context, "应用程序出错"); } }
private void DownloadImage(ProductInfo product, string imageUrls, System.Web.HttpContext context) { imageUrls = System.Web.HttpUtility.UrlDecode(imageUrls); string[] array = imageUrls.Split(new char[] { ';' }); int num = 1; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i]; string text2 = string.Format("/Storage/master/product/images/{0}", System.Guid.NewGuid().ToString("N", System.Globalization.CultureInfo.InvariantCulture) + text.Substring(text.LastIndexOf('.'))); string text3 = text2.Replace("/images/", "/thumbs40/40_"); string text4 = text2.Replace("/images/", "/thumbs60/60_"); string text5 = text2.Replace("/images/", "/thumbs100/100_"); string text6 = text2.Replace("/images/", "/thumbs160/160_"); string text7 = text2.Replace("/images/", "/thumbs180/180_"); string text8 = text2.Replace("/images/", "/thumbs220/220_"); string text9 = text2.Replace("/images/", "/thumbs310/310_"); string text10 = text2.Replace("/images/", "/thumbs410/410_"); string text11 = System.Web.HttpContext.Current.Request.MapPath(Globals.ApplicationPath + text2); System.Net.WebClient webClient = new System.Net.WebClient(); try { webClient.DownloadFile(text, text11); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text3), 40, 40); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text4), 60, 60); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text5), 100, 100); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text6), 160, 160); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text7), 180, 180); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text8), 220, 220); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text9), 310, 310); ResourcesHelper.CreateThumbnail(text11, context.Request.MapPath(Globals.ApplicationPath + text10), 410, 410); switch (num) { case 1: product.ImageUrl1 = text2; product.ThumbnailUrl40 = text3; product.ThumbnailUrl60 = text4; product.ThumbnailUrl100 = text5; product.ThumbnailUrl160 = text6; product.ThumbnailUrl180 = text7; product.ThumbnailUrl220 = text8; product.ThumbnailUrl310 = text9; product.ThumbnailUrl410 = text10; break; case 2: product.ImageUrl2 = text2; break; case 3: product.ImageUrl3 = text2; break; case 4: product.ImageUrl4 = text2; break; case 5: product.ImageUrl5 = text2; break; } num++; } catch { } } }
private List <ProductSpecificationImageInfo> SaveProductAttributeImages() { List <ProductSpecificationImageInfo> list = new List <ProductSpecificationImageInfo>(); string text = HiContext.Current.GetStoragePath() + "sku/"; if (!Globals.PathExist(text, false)) { Globals.CreatePath(text); } string str = HttpContext.Current.Server.MapPath(text + "images/"); string text2 = this.hidSKUUploadImages.Value.Trim(); if (text2.Length == 0) { return(list); } string[] array = text2.Split(','); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('='); string text3 = array2[0]; if (text3.Length != 0) { string text4 = array2[1]; if (text4.Length != 0) { string text5 = array2[2]; text5 = text5.Replace("//", "/"); if (text5.Length != 0) { string text6 = (text5.Split('/').Length == 6) ? text5.Split('/')[5] : text5.Split('/')[4]; string text7 = text + "thumbs40/40_" + text6; string text8 = text + "thumbs410/410_" + text6; ProductSpecificationImageInfo productSpecificationImageInfo = new ProductSpecificationImageInfo(); productSpecificationImageInfo.AttributeId = int.Parse(text3); productSpecificationImageInfo.ValueId = int.Parse(text4); productSpecificationImageInfo.ThumbnailUrl40 = text7; productSpecificationImageInfo.ThumbnailUrl410 = text8; if (File.Exists(str + text6)) { productSpecificationImageInfo.ImageUrl = text + "images/" + text6; list.Add(productSpecificationImageInfo); } else { Globals.CreatePath(HttpContext.Current.Server.MapPath(text5)); File.Copy(HttpContext.Current.Server.MapPath(text5), str + text6); if (File.Exists(HttpContext.Current.Server.MapPath(text5))) { File.Delete(HttpContext.Current.Server.MapPath(text5)); } Globals.CreatePath(HttpContext.Current.Server.MapPath(text7)); Globals.CreatePath(HttpContext.Current.Server.MapPath(text8)); ResourcesHelper.CreateThumbnail(str + text6, HttpContext.Current.Server.MapPath(text7), 40, 40); ResourcesHelper.CreateThumbnail(str + text6, HttpContext.Current.Server.MapPath(text8), 410, 410); productSpecificationImageInfo.ImageUrl = text + "images/" + text6; list.Add(productSpecificationImageInfo); } } } } } return(list); }