public ActionResult testCopy() { BlobStorageService svBlob = new BlobStorageService(); svBlob.CopyBlob("Manual/mail-month.txt", "Manual/mail-month-copy.txt"); return(Json(new { IsSuccess = svBlob.IsSuccess }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditArticle(FormCollection form) { var Articles = new b2bArticle(); var emArticles = new emArticle(); int ArticleTypeID = DataManager.ConvertToInteger(form["ArticleTypeID"]); int CompID = DataManager.ConvertToInteger(form["hideCompID"]); int OldCompID = DataManager.ConvertToInteger(form["OldCompID"]); Articles = svArticle.SelectData <b2bArticle>("*", " ArticleID = " + form["ArticleID"] + " AND RowVersion = " + form["RowVersion"]).First(); #region set ค่า b2bArticle // set Value var ArticleImgPath = Articles.ImgPath; var a = form["ImgPath"]; Articles.ArticleName = form["ArticleName"]; Articles.ArticleTypeID = ArticleTypeID; Articles.Description = ReplaceText(form["Description"]); Articles.ShortDescription = ReplaceText(form["ShortDescription"]); if (!string.IsNullOrEmpty(form["ImgPath"]) && form["ImgPath"] != ArticleImgPath) { Articles.ImgPath = form["ImgPath"]; } else { Articles.ImgPath = Articles.ImgPath; } Articles.PageTitle = form["PageTitle"]; Articles.Owner = form["Owner"]; Articles.Position = form["Position"]; Articles.IsHot = DataManager.ConvertToBool(form["IsHot"]); if (ArticleTypeID == 7) { Articles.CompID = CompID; } else { Articles.CompID = DataManager.ConvertToInteger(Articles.CompID); } #endregion Articles.ModifiedDate = DateTime.Now; Articles.RowVersion = DataManager.ConvertToShort(Articles.RowVersion + 1); emArticles.RowVersion = DataManager.ConvertToShort(emArticles.RowVersion + 1); #region Save b2bArticle Articles = svArticle.SaveData <b2bArticle>(Articles, "ArticleID"); if (svArticle.IsResult) { emArticles.ModifiedDate = DateTime.Now; emArticles.RowVersion = Articles.RowVersion; #region Save emArticle emArticles = svArticle.SaveData <emArticle>(emArticles, "ArticleID"); #endregion if (svArticle.IsResult && svArticle.IsResult) { #region SaveArticleImg if (!string.IsNullOrEmpty(form["ImgPath"])) { /* Check New Company */ if (OldCompID != CompID) { /* New Img */ if (Articles.ImgPath != ArticleImgPath) { imgManager = new FileHelper(); imgManager.DirPath = "Article/" + Articles.CompID + "/" + Articles.ArticleID; imgManager.DirTempPath = "Temp/Article/" + LogonCompID; imgManager.ImageName = form["ImgPath"]; imgManager.FullHeight = 0; imgManager.FullWidth = 0; imgManager.ThumbHeight = 150; imgManager.ThumbWidth = 150; imgManager.SaveImageFromTemp(); } /* Old Img */ else { var svBlobStorage = new BlobStorageService(); string fromFilePath = "Article/" + OldCompID + "/" + Articles.ArticleID + "/" + form["ImgPath"]; string descFilePath = "Article/" + Articles.CompID + "/" + Articles.ArticleID + "/" + form["ImgPath"]; svBlobStorage.CopyBlob(fromFilePath, descFilePath); } } /* Check Old Company */ else { if (Articles.ImgPath != ArticleImgPath) { imgManager = new FileHelper(); imgManager.DirPath = "Article/" + Articles.CompID + "/" + Articles.ArticleID; imgManager.DirTempPath = "Temp/Article/" + LogonCompID; imgManager.ImageName = form["ImgPath"]; imgManager.FullHeight = 0; imgManager.FullWidth = 0; imgManager.ThumbHeight = 150; imgManager.ThumbWidth = 150; imgManager.SaveImageFromTemp(); } } } #endregion } } #endregion return(Redirect("~/Admin/Article/list")); }