private void btnDelete_Click(object sender, System.EventArgs e) { bool flag = true; string[] array = this.hdfSelIDList.Value.Trim(new char[] { ',' }).Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; try { int photoId = Globals.ToNum(s); if (!GalleryHelper.DeletePhoto(photoId)) { flag = false; } } catch { this.ShowMsg("删除文件错误", false); this.BindImageData(); } } if (flag) { this.ShowMsg("删除图片成功", true); } this.BindImageData(); }
private void btnDelete_Click(object sender, EventArgs e) { if (moduleId > -1) { if (itemId > -1) { GalleryImage galleryImage = new GalleryImage(moduleId, itemId); if (galleryImage.ModuleId != moduleId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } galleryImage.ContentChanged += new ContentChangedEventHandler(galleryImage_ContentChanged); GalleryHelper.DeleteImages(galleryImage, fileSystem, imageFolderPath); galleryImage.Delete(); CurrentPage.UpdateLastModifiedTime(); CacheHelper.ClearModuleCache(moduleId); SiteUtils.QueueIndexing(); } } if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); }
protected void Page_Load(object sender, System.EventArgs e) { System.Collections.Hashtable hashtable = new System.Collections.Hashtable(); base.Response.AddHeader("Content-Type", "application/json; charset=UTF-8"); IUser user = Users.GetUser(0, Users.GetLoggedOnUsername(), true, true); if (user.UserRole != UserRole.SiteManager) { base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); return; } System.Collections.Generic.List <System.Collections.Hashtable> list = new System.Collections.Generic.List <System.Collections.Hashtable>(); hashtable["category_list"] = list; System.Data.DataTable photoCategories = GalleryHelper.GetPhotoCategories(); foreach (System.Data.DataRow dataRow in photoCategories.Rows) { System.Collections.Hashtable hashtable2 = new System.Collections.Hashtable(); hashtable2["cId"] = dataRow["CategoryId"]; hashtable2["cName"] = dataRow["CategoryName"]; list.Add(hashtable2); } base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); }
protected void Page_Load(object sender, EventArgs e) { Hashtable hashtable = new Hashtable(); base.Response.AddHeader("Content-Type", "application/json; charset=UTF-8"); if (Globals.GetCurrentManagerUserId() == 0) { base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); } else { List <Hashtable> list = new List <Hashtable>(); hashtable["category_list"] = list; foreach (DataRow row in GalleryHelper.GetPhotoCategories().Rows) { Hashtable item = new Hashtable(); item["cId"] = row["CategoryId"]; item["cName"] = row["CategoryName"]; list.Add(item); } base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); } }
private void LoadSettings() { appRoot = WebUtils.GetApplicationRoot(); moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new GalleryConfiguration(moduleSettings); lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl(); //if (WebConfigSettings.ImageGalleryUseMediaFolder) //{ imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/"; thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/"; //} //else //{ // imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/"; // thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/"; //} fullSizeImageFolderPath = VirtualPathUtility.Combine(imageFolderPath, "FullSizeImages/"); edDescription.WebEditor.ToolBar = ToolBar.Full; AddClassToBody("galleryeditimage"); FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { return; } fileSystem = p.GetFileSystem(); GalleryHelper.VerifyGalleryFolders(fileSystem, imageFolderPath); uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(SiteUtils.ImageFileExtensions()); uploader.ServiceUrl = SiteRoot + "/ImageGallery/upload.ashx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&ItemID=" + itemId.ToInvariantString(); // itemid will be returned into this field uploader.ReturnValueFormFieldClientId = hdnState.ClientID; uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form string refreshFunction = "function refresh" + moduleId.ToInvariantString() + " () { $('#" + btnUpdate.ClientID + "').click(); } "; uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString(); ScriptManager.RegisterClientScriptBlock( this, this.GetType(), "refresh" + moduleId.ToInvariantString(), refreshFunction, true); }
public void Save() { GalleryHelper gh = new GalleryHelper(this.SiteID); Dictionary <int, string> lstImages = ParseGalleryImages(); int iPos = 0; foreach (var img in lstImages) { if (!string.IsNullOrEmpty(img.Value)) { var theImg = gh.GalleryImageEntryGetByFilename(this.GalleryID, img.Value); if (theImg == null) { theImg = new GalleryImageEntry(); theImg.GalleryImage = img.Value; theImg.GalleryImageID = Guid.NewGuid(); theImg.GalleryID = this.GalleryID; } theImg.ImageOrder = iPos; theImg.Save(); } iPos++; List <string> lst = (from l in lstImages select l.Value.ToLower()).ToList(); gh.GalleryImageCleanup(this.GalleryID, lst); } }
private void btnSaveImageType_Click(object sender, System.EventArgs e) { string text = this.AddImageTypeName.Text; if (text.Length == 0) { this.ShowMsg("分类名称不能为空", false); } else { if (text.Length > 20) { this.ShowMsg("分类名称长度限在20个字符以内", false); } else { if (GalleryHelper.AddPhotoCategory(Globals.HtmlEncode(text))) { this.ShowMsg("添加成功!", true); this.GetImageType(); } else { this.ShowMsg("添加失败", false); } } } }
protected override void OnPreRender(EventArgs e) { int id = 1; int.TryParse(this.Request.QueryString["id"], out id); int page = 1; int.TryParse(this.Request.QueryString["page"], out page); if (id <= 0) { id = 1; } if (page <= 0) { page = 1; } string callBack = this.Request.QueryString["callBack"]; if (string.IsNullOrEmpty(callBack)) { return; } string lstString = JSON2.Serialize(GalleryHelper.GetPagedCategory(id, page, false)); this.Response.Write(callBack + "(" + lstString + ")"); this.Response.ContentType = "application/json"; base.OnPreRender(e); }
protected void Page_Load(object sender, EventArgs e) { if (Globals.RequestFormStr("posttype") == "togallery") { base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; string str3 = Globals.RequestFormStr("photourl"); if (!string.IsNullOrEmpty(str3)) { Bitmap bitmap = new Bitmap(base.Server.MapPath(str3)); MemoryStream stream = new MemoryStream(); bitmap.Save(stream, ImageFormat.Jpeg); GalleryHelper.AddPhote(0, "wb" + DateTime.Now.ToString("yyyyMMddHHmmss"), str3, (int)stream.Length); s = "{\"type\":\"1\",\"tips\":\"操作成功\"}"; stream.Dispose(); } base.Response.Write(s); base.Response.End(); } else { this.btnImagetSearch.Click += new EventHandler(this.btnImagetSearch_Click); if (!base.IsPostBack) { this.LoadParameters(); this.BindImageData(); } } }
private void BindImageData() { int type = Globals.RequestQueryNum("type"); this.pageIndex = this.pager.PageIndex; this.orderby = Globals.RequestQueryNum("orderby"); switch (this.orderby) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: this.ImageOrder.SelectedValue = new int?(this.orderby); break; } PhotoListOrder order = (PhotoListOrder)Enum.ToObject(typeof(PhotoListOrder), this.orderby); DbQueryResult result = GalleryHelper.GetPhotoList(this.keyWordIName, this.typeId, this.pageIndex, order, type, 0x12); this.rptList.DataSource = result.Data; this.rptList.DataBind(); this.pager.TotalRecords = result.TotalRecords; this.lblImageData.Text = this.pager.TotalRecords.ToString(); }
public string GetListJson(HttpContext context) { int pagesize = 0x15; StringBuilder builder = new StringBuilder(); builder.Append("{\"status\":1,"); builder.Append("\"data\":["); int type = Globals.RequestFormNum("type"); int maincategoryid = Globals.RequestFormNum("id"); string keyword = Globals.RequestFormStr("file_name"); int pageCount = 0; if (type == 3) { DbQueryResult goodsTable = this.GetGoodsTable(context, pagesize, keyword, maincategoryid); pageCount = TemplatePageControl.GetPageCount(goodsTable.TotalRecords, pagesize); builder.Append(this.GetGoodsListJson(goodsTable)); } else { DbQueryResult mamagerRecordset = GalleryHelper.GetPhotoList(keyword, new int?(maincategoryid), Convert.ToInt32(context.Request.Form["p"]), pagesize, PhotoListOrder.UploadTimeDesc, type); pageCount = TemplatePageControl.GetPageCount(mamagerRecordset.TotalRecords, pagesize); builder.Append(this.GetImgItemsJson(mamagerRecordset, context)); } return(((builder.ToString().TrimEnd(new char[] { ',' }) + "],") + "\"page\": \"" + this.GetPageHtml(pageCount, context) + "\",") + "\"msg\": \"\"" + "}"); }
/// <summary> /// 微商城模板管理 /// </summary> /// <returns></returns> public ActionResult VHomepage() { string crrentTemplateName = "t1"; var curr = _iTemplateSettingsService.GetCurrentTemplate(0); if (null != curr) { crrentTemplateName = curr.CurrentTemplateName; } var helper = new GalleryHelper(); var themes = helper.LoadThemes(); var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower())); if (CurTemplateObj == null) { CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1")); } if (CurTemplateObj == null) { throw new HimallException("错误的模板:" + crrentTemplateName); } ViewBag.CurrentTemplate = CurTemplateObj; ViewBag.CurUrl = Request.Url.Scheme + "://" + Request.Url.Authority; return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList())); }
private void GetImageType() { int type = Globals.RequestQueryNum("type"); this.ImageTypeList.DataSource = GalleryHelper.GetPhotoCategories(type); this.ImageTypeList.DataBind(); }
private void btnDelete_Click(object sender, EventArgs e) { bool flag = true; foreach (string str in this.hdfSelIDList.Value.Trim(new char[] { ',' }).Split(new char[] { ',' })) { try { if (!GalleryHelper.DeletePhoto(Globals.ToNum(str))) { flag = false; } } catch { this.ShowMsg("删除文件错误", false); this.BindImageData(); } } if (flag) { this.ShowMsg("删除图片成功", true); } this.BindImageData(); }
public string GetListJson(HttpContext context) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"status\":1,"); stringBuilder.Append("\"data\":["); int num = 1; PhotoListOrder order = PhotoListOrder.UpdateTimeDesc; if (!string.IsNullOrEmpty(context.Request.Form["sortby"])) { order = (PhotoListOrder)Enum.Parse(typeof(PhotoListOrder), context.Request.Form["sortby"]); } int supplierId = 0; if (!string.IsNullOrEmpty(context.Request.Form["supplierId"])) { supplierId = context.Request.Form["supplierId"].ToInt(0); } DbQueryResult photoList = GalleryHelper.GetPhotoList(context.Request.Form["file_Name"], context.Request.Form["id"].ToInt(0), context.Request.Form["p"].ToInt(0), 36, order, supplierId); int pageCount = TemplatePageControl.GetPageCount(photoList.TotalRecords, 36); stringBuilder.Append(this.GetImgItemsJson(photoList, context)); string str = stringBuilder.ToString().TrimEnd(','); str += "],"; str = str + "\"page\": \"" + this.GetPageHtml(pageCount, context) + "\","; str += "\"msg\": \"\""; return(str + "}"); }
private void ImageTypeEdit_Click(object sender, EventArgs e) { Dictionary <int, string> photoCategorys = new Dictionary <int, string>(); for (int i = 0; i < this.ImageTypeList.Rows.Count; i++) { GridViewRow row = this.ImageTypeList.Rows[i]; string text = ((TextBox)row.Cells[1].FindControl("ImageTypeName")).Text; if (text.Length > 20) { this.ShowMsg("分类长度限在20个字符以内", false); return; } int key = Convert.ToInt32(this.ImageTypeList.DataKeys[i].Value); photoCategorys.Add(key, Globals.HtmlEncode(text.ToString())); } try { if (GalleryHelper.UpdatePhotoCategories(photoCategorys) > 0) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", false); } } catch { this.ShowMsg("保存失败!", false); } }
protected void Page_Load(object sender, System.EventArgs e) { string a = Globals.RequestFormStr("posttype"); if (a == "togallery") { base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; string text = Globals.RequestFormStr("photourl"); if (!string.IsNullOrEmpty(text)) { System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(base.Server.MapPath(text)); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); GalleryHelper.AddPhote(0, "wb" + System.DateTime.Now.ToString("yyyyMMddHHmmss"), text, (int)memoryStream.Length); s = "{\"type\":\"1\",\"tips\":\"操作成功\"}"; memoryStream.Dispose(); } base.Response.Write(s); base.Response.End(); return; } this.btnImagetSearch.Click += new System.EventHandler(this.btnImagetSearch_Click); if (!base.IsPostBack) { this.LoadParameters(); this.BindImageData(); } }
protected void btnSaveImageData_Click(object sender, EventArgs e) { string str = this.RePlaceImg.Value; int photoId = Convert.ToInt32(this.RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string str3 = photoPath.Substring(photoPath.LastIndexOf(".")); string extension = string.Empty; string str5 = string.Empty; try { HttpPostedFile postedFile = base.Request.Files[0]; extension = Path.GetExtension(postedFile.FileName); if (str3 != extension) { this.ShowMsgToTarget("上传图片类型与原文件类型不一致!", false, "parent"); } else { string str6 = Globals.GetStoragePath() + "/gallery"; str5 = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string str7 = str.Substring(str.LastIndexOf("/") - 6, 6); string virtualPath = string.Empty; if (str7.ToLower().Contains("weibo")) { virtualPath = Globals.GetStoragePath() + "/weibo/"; } else { virtualPath = str6 + "/" + str7 + "/"; } int contentLength = postedFile.ContentLength; string path = base.Request.MapPath(virtualPath); string text1 = str7 + "/" + str5; DirectoryInfo info = new DirectoryInfo(path); if (!info.Exists) { info.Create(); } if (!ResourcesHelper.CheckPostedFile(postedFile, "image")) { this.ShowMsgToTarget("文件上传的类型不正确!", false, "parent"); } else if (contentLength >= 0x1f4000) { this.ShowMsgToTarget("图片文件已超过网站限制大小!", false, "parent"); } else { postedFile.SaveAs(base.Request.MapPath(virtualPath + str5)); GalleryHelper.ReplacePhoto(photoId, contentLength); this.CloseWindow(); } } } catch { this.ShowMsgToTarget("替换文件错误!", false, "parent"); } }
public ActionResult GalleryDatabase() { List <string> lst = new List <string>(); DatabaseUpdate du = new DatabaseUpdate(); DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse(); string sqlUpdate = ""; string sqlTest = ""; try { sqlUpdate = GalleryHelper.ReadEmbededScript("CarrotCake.CMS.Plugins.PhotoGallery.tblGallery.sql"); sqlTest = "select * from [information_schema].[columns] where table_name in('tblGalleryImageMeta')"; dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false); if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) { lst.Add(dbRes.LastException.Message); } else { lst.Add(dbRes.Response); } } catch (Exception ex) { lst.Add(ex.ToString()); } return(View(lst)); }
private void ImageTypeEdit_Click(object sender, System.EventArgs e) { System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); for (int i = 0; i < this.ImageTypeList.Rows.Count; i++) { System.Web.UI.WebControls.GridViewRow gridViewRow = this.ImageTypeList.Rows[i]; string text = ((System.Web.UI.WebControls.TextBox)gridViewRow.Cells[1].FindControl("ImageTypeName")).Text; if (text.Length > 20) { this.ShowMsg("分类长度限在20个字符以内", false); return; } int key = System.Convert.ToInt32(this.ImageTypeList.DataKeys[i].Value); dictionary.Add(key, Globals.HtmlEncode(text.ToString())); } try { int num = GalleryHelper.UpdatePhotoCategories(dictionary); if (num > 0) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", false); } } catch { this.ShowMsg("保存失败!", false); } }
public string GetImgTypeJson(int type) { StringBuilder builder = new StringBuilder(); DataTable photoCategories = null; if (type == 3) { IList <CategoryInfo> mainCategories = CatalogHelper.GetMainCategories(); for (int i = 0; i < mainCategories.Count; i++) { builder.Append("{"); builder.Append("\"name\":\"" + mainCategories[i].Name + "\","); builder.Append("\"parent_id\":" + mainCategories[i].ParentCategoryId + ","); builder.Append("\"id\":" + mainCategories[i].CategoryId + ","); builder.Append("\"picNum\":" + ProductHelper.GetProductsImgList(this.GetProductQuery(mainCategories[i].CategoryId)).TotalRecords); builder.Append("},"); } } else { photoCategories = GalleryHelper.GetPhotoCategories(type); for (int j = 0; j < photoCategories.Rows.Count; j++) { builder.Append("{"); builder.Append("\"name\":\"" + photoCategories.Rows[j]["CategoryName"] + "\","); builder.Append("\"parent_id\":0,"); builder.Append("\"id\":" + photoCategories.Rows[j]["CategoryId"] + ","); builder.Append("\"picNum\":" + GalleryHelper.GetPhotoList("", new int?(Convert.ToInt32(photoCategories.Rows[j]["CategoryId"])), 10, PhotoListOrder.UploadTimeDesc, type, 20).TotalRecords); builder.Append("},"); } } return(builder.ToString().TrimEnd(new char[] { ',' })); }
public string GetTreeListJson(HttpContext context) { try { int supplierId = 0; if (!string.IsNullOrEmpty(context.Request.Form["supplierId"])) { supplierId = context.Request.Form["supplierId"].ToInt(0); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"status\":1,"); stringBuilder.Append("\"data\":{"); stringBuilder.Append("\"total\":" + GalleryHelper.GetPhotoList("", 0, 10, PhotoListOrder.UploadTimeDesc, supplierId).TotalRecords + ","); stringBuilder.Append("\"tree\":["); stringBuilder.Append(this.GetImgTypeJson(supplierId)); stringBuilder.Append("]"); stringBuilder.Append("},"); stringBuilder.Append("\"msg\":\"\""); stringBuilder.Append("}"); return(stringBuilder.ToString()); } catch (Exception ex) { NameValueCollection param = new NameValueCollection { context.Request.Form, context.Request.QueryString }; Globals.WriteExceptionLog_Page(ex, param, "GetTreeListJson"); return(""); } }
protected void Page_Load(object sender, EventArgs e) { Hashtable hashtable = new Hashtable(); Response.AddHeader("Content-Type", "application/json; charset=UTF-8"); if (Users.GetUser(0, Users.GetLoggedOnUsername(), true, true).UserRole != UserRole.SiteManager) { Response.Write(JsonMapper.ToJson(hashtable)); Response.End(); } else { List <Hashtable> list = new List <Hashtable>(); hashtable["category_list"] = list; foreach (DataRow row in GalleryHelper.GetPhotoCategories().Rows) { Hashtable item = new Hashtable(); item["cId"] = row["CategoryId"]; item["cName"] = row["CategoryName"]; list.Add(item); } Response.Write(JsonMapper.ToJson(hashtable)); Response.End(); } }
private void btnMoveImageData_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>(); int pTypeId = Globals.ToNum(this.dropImageFtp.SelectedItem.Value); string[] array = this.hdfSelIDList.Value.Trim(new char[] { ',' }).Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; int num = Globals.ToNum(s); if (num > 0) { list.Add(num); } } if (GalleryHelper.MovePhotoType(list, pTypeId) > 0) { this.ShowMsg("图片移动成功!", true); } this.BindImageData(); }
public string GetListJson(System.Web.HttpContext context) { int num = 21; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{\"status\":1,"); stringBuilder.Append("\"data\":["); int num2 = Globals.RequestFormNum("type"); int num3 = Globals.RequestFormNum("id"); string keyword = Globals.RequestFormStr("file_name"); int pageCount; if (num2 == 3) { DbQueryResult goodsTable = this.GetGoodsTable(context, num, keyword, num3); pageCount = TemplatePageControl.GetPageCount(goodsTable.TotalRecords, num); stringBuilder.Append(this.GetGoodsListJson(goodsTable)); } else { DbQueryResult photoList = GalleryHelper.GetPhotoList(keyword, new int?(num3), System.Convert.ToInt32(context.Request.Form["p"]), num, PhotoListOrder.UploadTimeDesc, num2); pageCount = TemplatePageControl.GetPageCount(photoList.TotalRecords, num); stringBuilder.Append(this.GetImgItemsJson(photoList, context)); } string str = stringBuilder.ToString().TrimEnd(new char[] { ',' }); str += "],"; str = str + "\"page\": \"" + this.GetPageHtml(pageCount, context) + "\","; str += "\"msg\": \"\""; return(str + "}"); }
private void MovePhoto(HttpContext context) { string text = context.Request["PhotoId"]; string obj = context.Request["ImageFtp"]; string text2 = text.Trim(); if (!string.IsNullOrEmpty(text2)) { int item = 0; List <int> list = new List <int>(); string[] array = text2.Split(','); foreach (string text3 in array) { if (!string.IsNullOrEmpty(text3) && int.TryParse(text3, out item)) { list.Add(item); } } if (GalleryHelper.MovePhotoType(list, obj.ToInt(0)) > 0) { base.ReturnResult(context, true, "图片移动成功!", 0, true); } return; } throw new HidistroAshxException("请至少选择一项"); }
private void DeleteImage(HttpContext context) { string text = context.Request["PhotoIdStr"]; int photoId = 0; string text2 = text.Trim(); if (!string.IsNullOrEmpty(text2)) { string[] array = text2.Split(','); foreach (string text3 in array) { if (!string.IsNullOrEmpty(text3)) { string[] array2 = text3.Split(':'); if (int.TryParse(array2[0], out photoId)) { StoreHelper.DeleteImage(array2[1]); if (!GalleryHelper.DeletePhoto(photoId)) { throw new HidistroAshxException("请至少选择一项"); } } } } base.ReturnResult(context, true, text2, 0, true); return; } throw new HidistroAshxException("请至少选择一项"); }
private void btn_AddImageType_Click(object sender, System.EventArgs e) { string text = this.txt_AddImageTypeName.Text; if (text.Length == 0) { this.ShowMsg("分类名称不能为空", false); return; } if (text.Length > 20) { this.ShowMsg("分类名称长度限在20个字符以内", false); return; } bool flag = GalleryHelper.AddPhotoCategory(Globals.HtmlEncode(text)); if (flag) { this.txt_AddImageTypeName.Text = ""; this.ShowMsg("添加成功!", true); this.GetImageType(); return; } this.ShowMsg("添加失败", false); }
public string DelFolder(HttpContext context) { if (GalleryHelper.DeletePhotoCategory(Convert.ToInt32(context.Request["id"]))) { return("{\"status\":1,\"msg\":\"\"}"); } return("{\"status\":0,\"msg\":\"请选择一个分类\"}"); }
private int GetImgCount(int type) { if (type == 3) { return(ProductHelper.GetProductsImgList(this.GetProductQuery(0)).TotalRecords); } return(GalleryHelper.GetPhotoList("", 0, 10, PhotoListOrder.UploadTimeDesc, type, 20).TotalRecords); }
public ActionResult EditGallery(GalleryGroup model) { if (ModelState.IsValid) { GalleryHelper gh = new GalleryHelper(this.SiteID); GalleryGroup m = gh.GalleryGroupGetByID(model.GalleryID); if (m == null) { m = new GalleryGroup(); m.SiteID = this.SiteID; } m.GalleryTitle = model.GalleryTitle; m.Save(); return RedirectToAction("Index"); } else { return View("EditGallery", model); } }
public ActionResult EditImageMetaData(string path) { GalleryHelper gh = new GalleryHelper(this.SiteID); string imageFile = String.Empty; if (!String.IsNullOrEmpty(path)) { imageFile = CMSConfigHelper.DecodeBase64(path); } GalleryMetaData model = gh.GalleryMetaDataGetByFilename(imageFile); if (model == null) { model = new GalleryMetaData(); model.SiteID = this.SiteID; model.GalleryImageMetaID = Guid.Empty; model.GalleryImage = imageFile; } return View(model); }
public ActionResult Index(PagedData<GalleryGroup> model) { GalleryHelper gh = new GalleryHelper(this.SiteID); model.ToggleSort(); var srt = model.ParseSort(); List<GalleryGroup> lst = gh.GalleryGroupListGetBySiteID(); IQueryable<GalleryGroup> query = lst.AsQueryable(); query = query.SortByParm<GalleryGroup>(srt.SortField, srt.SortDirection); model.DataSource = query.Skip(model.PageSize * model.PageNumberZeroIndex).Take(model.PageSize).ToList(); model.TotalRecords = lst.Count(); ModelState.Clear(); return View(model); }
public PartialViewResult ShowPrettyPhotoGallery() { GallerySettings settings = new GallerySettings(); if (WidgetPayload is GallerySettings) { settings = (GallerySettings)WidgetPayload; settings.LoadData(); } GalleryModel model = new GalleryModel(); if (settings != null) { model.GalleryID = settings.GalleryID; model.ShowHeading = settings.ShowHeading; model.ScaleImage = settings.ScaleImage; model.ThumbSize = settings.ThumbSize; model.PrettyPhotoSkin = settings.PrettyPhotoSkin; model.InstanceId = settings.WidgetClientID; GalleryHelper gh = new GalleryHelper(settings.SiteID); var gal = gh.GalleryGroupGetByID(model.GalleryID); if (gal != null) { model.Gallery = gal; model.Images = (from g in gal.GalleryImages where g.GalleryID == model.GalleryID orderby g.ImageOrder ascending select g).ToList(); } else { model.Gallery = new GalleryGroup(); model.Images = new List<GalleryImageEntry>(); } } if (String.IsNullOrEmpty(settings.AlternateViewFile)) { return PartialView(model); } else { return PartialView(settings.AlternateViewFile, model); } }
public ActionResult EditImageMetaData(GalleryMetaData model) { GalleryHelper gh = new GalleryHelper(this.SiteID); GalleryMetaData meta = gh.GalleryMetaDataGetByFilename(model.GalleryImage); if (meta == null) { meta = new GalleryMetaData(); meta.GalleryImageMetaID = Guid.Empty; meta.SiteID = this.SiteID; meta.GalleryImage = model.GalleryImage.ToLower(); } meta.ImageMetaData = model.ImageMetaData; meta.ImageTitle = model.ImageTitle; meta.Save(); return RedirectToAction("EditImageMetaData", new { @path = CMSConfigHelper.EncodeBase64(meta.GalleryImage) }); }
public ActionResult Index() { GalleryHelper gh = new GalleryHelper(this.SiteID); PagedData<GalleryGroup> model = new PagedData<GalleryGroup>(); model.InitOrderBy(x => x.GalleryTitle, true); model.PageSize = 25; model.PageNumber = 1; var srt = model.ParseSort(); return Index(model); }
public ActionResult EditGallery(Guid id) { GalleryHelper gh = new GalleryHelper(this.SiteID); return View("EditGallery", gh.GalleryGroupGetByID(id)); }
public void LoadGallery() { GalleryHelper gh = new GalleryHelper(this.SiteID); this.Gallery = gh.GalleryGroupGetByID(this.GalleryID); }
public void Save() { GalleryHelper gh = new GalleryHelper(this.SiteID); Dictionary<int, string> lstImages = ParseGalleryImages(); int iPos = 0; foreach (var img in lstImages) { if (!string.IsNullOrEmpty(img.Value)) { var theImg = gh.GalleryImageEntryGetByFilename(this.GalleryID, img.Value); if (theImg == null) { theImg = new GalleryImageEntry(); theImg.GalleryImage = img.Value; theImg.GalleryImageID = Guid.NewGuid(); theImg.GalleryID = this.GalleryID; } theImg.ImageOrder = iPos; theImg.Save(); } iPos++; List<string> lst = (from l in lstImages select l.Value.ToLower()).ToList(); gh.GalleryImageCleanup(this.GalleryID, lst); } }