/// <summary> /// 更新模版 /// </summary> /// <param name="templateName"></param> /// <param name="ItemValues"></param> public void UpdateTemplate(string templateName) { //以当前模版文件的参数为主,将当前接受的参数对比,有的就更新。 List <SettingEntity> x_OptionList = _OptionList(templateName); List <KeyValueEntity> x_ItemValues = _ItemValues(templateName); Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.ItemValues = x_ItemValues; xf.OptionList = x_OptionList; Puts.Add("ItemValues", x_ItemValues); Puts.Add("OptionList", x_OptionList); Puts.Add("SkinName", SkinName); Puts.Add("SkinFileName", templateName); //更新模版 String ascxFileName = String.Format("{0}.ascx", templateName); String ascxContent = HttpUtility.HtmlDecode(ViewTemplate(ascxFileName, Puts, xf)); WriteTemplate(ascxFileName, ascxContent); //更新CSS String cssFileName = String.Format("{0}.css", templateName); string cssContent = HttpUtility.HtmlDecode(ViewTemplate(cssFileName, Puts, xf)); WriteTemplate(cssFileName, cssContent); }
public void BulkResetTemplate(String templateName) { List <KeyValueEntity> list = new List <KeyValueEntity>(); List <SettingEntity> ItemSettingDB = _OptionList(templateName); if (templateName == "Global") { WriteTextToFile(_ItemValueXmlPath(templateName), ResetItemSettings(ref list, ItemSettingDB)); } else { Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.ItemValues = list; xf.OptionList = ItemSettingDB; xf.GlobalValues = GlobalValues; xf.GlobalOptionList = GlobalOptionList; Puts.Add("ItemValues", list); Puts.Add("OptionList", ItemSettingDB); Puts.Add("SkinName", SkinName); Puts.Add("SkinFileName", templateName); Puts.Add("GlobalValues", GlobalValues); Puts.Add("GlobalOptionList", GlobalOptionList); //更新模版 String ascxFileName = String.Format("{0}.ascx", templateName); String ascxContent = HttpUtility.HtmlDecode(ViewTemplate(ascxFileName, Puts, xf)); WriteTemplate(ascxFileName, ascxContent); //更新CSS String cssFileName = String.Format("{0}.css", templateName); string cssContent = HttpUtility.HtmlDecode(ViewTemplate(cssFileName, Puts, xf)); WriteTemplate(cssFileName, cssContent); } }
public void Execute(BasePage Context) { QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_ThemePlugin_Multimedia._.ID; qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Context.Request, "PageSize", Int32.MaxValue); qp.Where.Add(new SearchParam(DNNGo_ThemePlugin_Multimedia._.Status, (Int32)EnumFileStatus.Approved, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_ThemePlugin_Multimedia._.PortalId, Context.PortalId, SearchType.Equal)); int RecordCount = 0; List <DNNGo_ThemePlugin_Multimedia> fileList = DNNGo_ThemePlugin_Multimedia.FindAll(qp, out RecordCount); Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>(); TemplateFormat xf = new TemplateFormat(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); foreach (var fileItem in fileList) { int index = fileList.IndexOf(fileItem); //index 为索引值 Dictionary <String, Object> jsonPicture = new Dictionary <String, Object>(); jsonPicture.Add("Pages", qp.Pages); jsonPicture.Add("ID", fileItem.ID); jsonPicture.Add("CreateTime", fileItem.LastTime); jsonPicture.Add("Name", WebHelper.leftx(fileItem.Name, 20, "...")); jsonPicture.Add("Extension", fileItem.FileExtension); String ThumbnailUrl = Context.ViewLinkUrl(String.Format("MediaID={0}", fileItem.ID)); jsonPicture.Add("ThumbnailUrl", ThumbnailUrl); jsonPicture.Add("FileUrl", Context.GetPhotoPath(fileItem.FilePath)); jsonPicture.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\" src=\"{0}\" /> ", ThumbnailUrl)); //判断当前文件是否为图片 if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("gif,jpg,jpeg,bmp,png").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsVideo", false); jsonPicture.Add("IsPicture", true); } else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("mp4,mkv,avi,ogv,webm,m4v").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsVideo", true); jsonPicture.Add("IsPicture", false); switch (fileItem.FileExtension) { case "mp4": jsonPicture.Add("IsMp4", true); break; case "m4v": jsonPicture.Add("IsM4v", true); break; case "ogv": jsonPicture.Add("IsOgv", true); break; case "webm": jsonPicture.Add("IsWebm", true); break; default: break; } } else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("flv,swf").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsFlash", true); jsonPicture.Add("IsPicture", false); jsonPicture.Add("Guid", Guid.NewGuid().ToString()); } else { jsonPicture.Add("IsVideo", false); jsonPicture.Add("IsPicture", false); } jsonPicture.Add("Json", jsSerializer.Serialize(jsonPicture)); jsonPictures.Add(index.ToString(), jsonPicture); } //转换数据为json ResponseString = jsSerializer.Serialize(jsonPictures); }
/// <summary> /// 批量更新模版 /// </summary> /// <param name="templateName">模版名称</param> public void BulkUpdateTemplate(string templateName, List <KeyValueEntity> objItemValues) { if (templateName == "Global") { //以当前模版文件的参数为主,将当前接受的参数对比,有的就更新。 List <KeyValueEntity> new_ItemValues = new List <KeyValueEntity>(); List <SettingEntity> x_OptionList = _OptionList(templateName); List <KeyValueEntity> x_ItemValues = _ItemValues(templateName); foreach (SettingEntity item in x_OptionList) { KeyValueEntity new_Value = x_ItemValues.Find(r => r.Key == item.Name); if (!(new_Value != null && !String.IsNullOrEmpty(new_Value.Key))) { new_Value = new KeyValueEntity(); new_Value.Key = item.Name; new_Value.Value = item.DefaultValue; } if (objItemValues.Exists(r => r.Key == item.Name)) { KeyValueEntity old_value = objItemValues.Find(r => r.Key == item.Name); if (old_value != null && !String.IsNullOrEmpty(old_value.Key)) { new_Value.Value = old_value.Value; } } new_ItemValues.Add(new_Value); } GlobalValues = new_ItemValues; //保存参数到XML WriteTextToFile(_ItemValueXmlPath(templateName), ConvertTo.Serialize <List <KeyValueEntity> >(new_ItemValues)); } else { Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.GlobalValues = GlobalValues; xf.GlobalOptionList = GlobalOptionList; xf.ItemValues = ItemValues; xf.OptionList = OptionList; Puts.Add("ItemValues", ItemValues); Puts.Add("OptionList", OptionList); Puts.Add("SkinName", SkinName); Puts.Add("SkinFileName", templateName); Puts.Add("GlobalValues", GlobalValues); Puts.Add("GlobalOptionList", GlobalOptionList); //更新模版 String ascxFileName = String.Format("{0}.ascx", templateName); String ascxContent = HttpUtility.HtmlDecode(ViewTemplate(ascxFileName, Puts, xf)); WriteTemplate(ascxFileName, ascxContent); //更新CSS String cssFileName = String.Format("{0}.css", templateName); string cssContent = HttpUtility.HtmlDecode(ViewTemplate(cssFileName, Puts, xf)); WriteTemplate(cssFileName, cssContent); } }
/// <Description> /// 绑定页面项 /// </Description> private void BindPageItem() { //链接 String Element_UrlLink = FieldItem != null ? FieldItem.DefaultValue : String.Empty; //imgUrlLink.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/1-1.png'", ModulePath)); WebHelper.BindList <TabInfo>(ddlUrlLink, TabController.GetPortalTabs(PortalId, Null.NullInteger, true, true, false, false), "IndentedTabName", "TabId"); List <EnumEntity> EnumList = EnumHelper.GetEnumList(typeof(EnumUrlControls)); //设置和选择哪些类型可以显示出来 if (!String.IsNullOrEmpty(FieldItem.ListContent)) { if (!FindUrlType(FieldItem.ListContent, "U")) { EnumList.RemoveAll(r => r.Value == 1); } if (!FindUrlType(FieldItem.ListContent, "P")) { EnumList.RemoveAll(r => r.Value == 2); } if (!FindUrlType(FieldItem.ListContent, "F")) { EnumList.RemoveAll(r => r.Value == 3); } if (EnumList.Count == 1) { rblUrlLink.Visible = false; } WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value"); String defaultType = WebHelper.leftx(FieldItem.ListContent, 1).ToUpper(); if (!String.IsNullOrEmpty(defaultType)) { ShowHideControl(defaultType); } } else { WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value"); ShowHideControl("U"); } if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) == 0) { WebHelper.SelectedListByValue(ddlUrlLink, Element_UrlLink.Replace("TabID=", "")); //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Page); //txtUrlLink.Attributes.Add("style", "display:none"); //panUrlLink.Attributes.Add("style", "display:none"); ShowHideControl("P"); } else if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) == 0) { TemplateFormat xf = new TemplateFormat(this); hfUrlLink.Value = Element_UrlLink; //imgUrlLink.ImageUrl = xf.ViewLinkUrl(Element_UrlLink); div_Image.Attributes.Add("data-MediaID", Element_UrlLink); ShowHideControl("F"); //hlRemoveUrlLink.Attributes.Add("style", "display:;"); //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Files); //txtUrlLink.Attributes.Add("style", "display:none"); //ddlUrlLink.Attributes.Add("style", "display:none"); } else { if (!String.IsNullOrEmpty(Element_UrlLink)) { if (Element_UrlLink.IndexOf("FileID=", StringComparison.CurrentCultureIgnoreCase) == 0) { int FileID = 0; if (int.TryParse(Element_UrlLink.Replace("FileID=", ""), out FileID) && FileID > 0) { var fi = FileManager.Instance.GetFile(FileID); if (fi != null && fi.FileId > 0) { txtUrlLink.Text = string.Format("{0}{1}{2}", PortalSettings.HomeDirectory, fi.Folder, Server.UrlPathEncode(fi.FileName)); } } } else { txtUrlLink.Text = Element_UrlLink; } ShowHideControl("U"); } //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Url); //ddlUrlLink.Attributes.Add("style", "display:none"); //panUrlLink.Attributes.Add("style", "display:none"); } }
/// <summary> /// 更新内容 /// </summary> protected void cmdUpdate_Click(object sender, EventArgs e) { try { //演示站点需要锁定功能 if (IsAdministrator || !DemoLock) { //保存参数到XML List <KeyValueEntity> list = new List <KeyValueEntity>(); String ItemSettings = SetItemSettings(ref list); WriteTextToFile(ItemValueXmlPath, ItemSettings); Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); List <KeyValueEntity> ItemValues = xf.ItemValues = list; xf.OptionList = OptionList; xf.GlobalOptionList = GlobalOptionList; xf.GlobalValues = GlobalValues; Puts.Add("ItemValues", list); Puts.Add("OptionList", OptionList); Puts.Add("SkinName", SkinName); Puts.Add("SkinFileName", SkinFileName); Puts.Add("GlobalValues", GlobalValues); Puts.Add("GlobalOptionList", GlobalOptionList); //更新模版 String ascxFileName = String.Format("{0}.ascx", SkinFileName); String ascxContent = HttpUtility.HtmlDecode(ViewTemplate(ascxFileName, Puts, xf)); WriteTemplate(ascxFileName, ascxContent); //更新CSS String cssFileName = String.Format("{0}.css", SkinFileName); string cssContent = HttpUtility.HtmlDecode(ViewTemplate(cssFileName, Puts, xf)); WriteTemplate(cssFileName, cssContent); if (Settings_Scope == EnumScope.Global) { //批量更新模版 BulkUpdateTemplate(ItemValues); } //更新引用文件版本 IncrementCrmVersion(); ////复制文件 //FileSystemUtils.CopyTemplate(MapPath(SkinPath), SkinFileName); } mTips.LoadMessage("SaveOptionsSuccess", EnumTips.Success, this, new String[] { }); Response.Redirect(WebHelper.GetScriptUrl, false); //String GoUrl = String.Format("{0}?PortalId={1}&TabID={2}&Token={3}&SkinFileName={4}#tabs-box-{3}", "Resource_Options.aspx", PortalId, TabId, "Options", ""); //Response.Redirect(GoUrl,false); } catch (Exception exc) { ProcessModuleLoadException(exc); } }