public static void SetCultureInfo(string CultureCode) { AppErazer.ClearSysCache(); PageBase.SetCultureInfo(CultureCode, CultureCode); HttpContext.Current.Session["IsCultureChange"] = 1; }
public static int SavePreset(string TemplateName, string ActiveTheme, string ActiveWidth, List <PresetKeyValue> lstLayouts, int portalID) { List <KeyValue> lstLyts = new List <KeyValue>(); foreach (PresetKeyValue kvp in lstLayouts) { lstLyts.Add(new KeyValue(kvp.Key, kvp.Value)); } PresetInfo PresetObj = new PresetInfo(); PresetObj.ActiveTheme = ActiveTheme; PresetObj.ActiveWidth = ActiveWidth; PresetObj.lstLayouts = lstLyts; string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName); string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile; presetPath += "/" + "pagepreset.xml"; int presetstatus = 0; try { PresetHelper.WritePreset(presetPath, PresetObj); return(presetstatus); } catch (Exception) { throw; } finally { AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + portalID); SageFrame.Common.CacheHelper.Clear("PresetList"); } }
private static void ClearOptimizationCache(int PortalID) { AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + PortalID); AppErazer.ClearSysHash(ApplicationKeys.ActiveTemplate + "_" + PortalID); AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + PortalID); AppErazer.ClearSysCache(); string optimized_path = HttpContext.Current.Server.MapPath(SageFrameConstants.OptimizedResourcePath); IOHelper.DeleteDirectoryFiles(optimized_path, ".js,.css"); if (File.Exists(HttpContext.Current.Server.MapPath(SageFrameConstants.OptimizedCssMap))) { SageFrame.Web.XmlHelper.DeleteNodes(HttpContext.Current.Server.MapPath(SageFrameConstants.OptimizedCssMap), "resourcemap/resourcemap"); } if (File.Exists(HttpContext.Current.Server.MapPath(SageFrameConstants.OptimizedJsMap))) { SageFrame.Web.XmlHelper.DeleteNodes(HttpContext.Current.Server.MapPath(SageFrameConstants.OptimizedJsMap), "resourcemap/resourcemap"); } }
protected void imgSave_Click(object sender, ImageClickEventArgs e) { try { bool status = false; foreach (GridViewRow row in gdvPortal.Rows) { LinkButton lnkPortal = row.FindControl("lnkUsername") as LinkButton; if (gdvPortal.DataKeys[row.RowIndex]["PortalID"].ToString() != hdnPortalIndex.Value) { if (lnkPortal.Text.ToLower().Equals(txtPortalName.Text.ToLower())) { status = true; } } } if (!(string.IsNullOrEmpty(txtPortalName.Text))) { if (!status) { SaveProtal(); BindPortalSetting(); HttpRuntime.Cache.Remove(CacheKeys.Portals); SageFrameConfig sf = new SageFrameConfig(); sf.ResetSettingKeys(int.Parse(this.hdnPortalID.Value.ToString())); HttpContext.Current.Session.Remove(SessionKeys.SageFrame_PortalSEOName); AppErazer.ClearSysCache(); BindPortal(); BindSitePortal(); PanelVisibility(false, true); Redirect(GetPortalID); } else { ShowMessage("", GetSageMessage("PortalSettings", "PortalAlreadyExists"), "", SageMessageType.Alert); } } } catch (Exception ex) { ProcessException(ex); } }
protected void btnApply_Click(object sender, EventArgs e) { HttpRuntime.Cache.Remove(CacheKeys.SageFrameJs); HttpRuntime.Cache.Remove(CacheKeys.SageFrameCss); string optimized_path = Server.MapPath(SageFrameConstants.OptimizedResourcePath); IOHelper.DeleteDirectoryFiles(optimized_path, ".js,.css"); if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedCssMap))) { XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedCssMap), "resourcemaps/resourcemap"); } if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedJsMap))) { XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedJsMap), "resourcemap/resourcemap"); } PresetInfo preset = new PresetInfo(); preset = PresetHelper.LoadActivePagePreset(TemplateName, GetPageSEOName(Request.Url.ToString())); if (ddlScreen.SelectedItem.ToString() != string.Empty) { preset.ActiveWidth = ddlScreen.SelectedItem.ToString(); } if (ddlThemes.SelectedItem != null && ddlThemes.SelectedItem.ToString() != string.Empty) { preset.ActiveTheme = ddlThemes.SelectedItem.ToString(); } if (ddlLayout.SelectedItem != null && ddlLayout.SelectedItem.ToString() != string.Empty) { preset.ActiveLayout = Path.GetFileNameWithoutExtension(ddlLayout.SelectedItem.ToString()); } List <KeyValue> lstLayouts = preset.lstLayouts; string pageName = Request.Url.ToString(); SageFrameConfig sfConfig = new SageFrameConfig(); pageName = Path.GetFileNameWithoutExtension(pageName); pageName = pageName.ToLower().Equals("default") ? sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) : pageName; bool isNewLayout = false; int oldPageCount = 0; bool isNewPage = false; bool deleteRepeat = false; bool duplicateLayout = false; List <string> pageList = new List <string>(); foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { duplicateLayout = true; } string[] pages = kvp.Value.Split(','); pageList.Add(string.Join(",", pages)); if (pages.Count() == 1 && pages.Contains(pageName)) // for single pagename and if page = currentpageName { kvp.Key = preset.ActiveLayout; } else if (pages.Count() > 1 && pages.Contains(pageName)) // for multiple pagename and if page = currentpageName { isNewLayout = true; //its because we have to insert another layout List <string> lstnewpage = new List <string>(); foreach (string page in pages) { if (page.ToLower() != pageName.ToLower()) { lstnewpage.Add(page); } } kvp.Value = string.Join(",", lstnewpage.ToArray()); pageList.Add(kvp.Value); } else { oldPageCount++; } if (kvp.Value == "All" && kvp.Key == preset.ActiveLayout) { deleteRepeat = true; } } if (lstLayouts.Count == oldPageCount) { isNewPage = true; } List <KeyValue> lstNewLayouts = new List <KeyValue>(); if (isNewPage) { bool isAppended = false; foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { if (kvp.Value.ToLower() != "all") { kvp.Value += "," + pageName; } isAppended = true; } lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } if (!isAppended) { lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName)); } lstLayouts = lstNewLayouts; } else if (isNewLayout) { bool isAppended = false; bool isAll = false; foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { if (kvp.Value.ToLower() != "all") { kvp.Value += "," + pageName; isAll = true; } isAppended = true; } lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } if (!isAppended && !isAll) { lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName)); } lstLayouts = lstNewLayouts; } else if (deleteRepeat) { foreach (KeyValue kvp in lstLayouts) { if (kvp.Value.ToLower() != pageName.ToLower()) { lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } } lstLayouts = lstNewLayouts; } else if (duplicateLayout) { string key = preset.ActiveLayout; List <string> pages = new List <string>(); foreach (KeyValue kvp in lstLayouts) { if (kvp.Key.ToLower() != preset.ActiveLayout.ToLower()) { lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } else { pages.Add(kvp.Value); } } lstNewLayouts.Add(new KeyValue(key, string.Join(",", pages.ToArray()))); lstLayouts = lstNewLayouts; } preset.lstLayouts = lstLayouts; string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName); string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile; presetPath += "/" + "pagepreset.xml"; AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + GetPortalID); PresetHelper.WritePreset(presetPath, preset); SageFrame.Common.CacheHelper.Clear("PresetList"); Response.Redirect(Request.Url.OriginalString); }
protected void ddlLayout_SelectedIndexChanged(object sender, EventArgs e) { PresetInfo preset = new PresetInfo(); string pageName = ddlPages.SelectedValue; pageName = Regex.Replace(pageName, "--+", ""); preset = PresetHelper.LoadActivePagePreset(TemplateName, GetPageSEOName(Request.Url.ToString())); List <KeyValue> lstLayouts = preset.lstLayouts; preset.ActiveLayout = ddlLayout.SelectedValue; bool isNewLayout = false; int oldPageCount = 0; bool isNewPage = false; bool deleteRepeat = false; bool duplicateLayout = false; List <string> pageList = new List <string>(); foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { duplicateLayout = true; } string[] pages = kvp.Value.Split(','); pageList.Add(string.Join(",", pages)); if (pages.Count() == 1 && pages.Contains(pageName)) // for single pagename and if page = currentpageName { kvp.Key = preset.ActiveLayout; } else if (pages.Count() > 1 && pages.Contains(pageName)) // for multiple pagename and if page = currentpageName { isNewLayout = true; //its because we have to insert another layout List <string> lstnewpage = new List <string>(); foreach (string page in pages) { if (page.ToLower() != pageName.ToLower()) { lstnewpage.Add(page); } } kvp.Value = string.Join(",", lstnewpage.ToArray()); pageList.Add(kvp.Value); } else { oldPageCount++; } if (kvp.Value == "All" && kvp.Key == preset.ActiveLayout) { deleteRepeat = true; } } if (lstLayouts.Count == oldPageCount) { isNewPage = true; } List <KeyValue> lstNewLayouts = new List <KeyValue>(); if (isNewPage) { bool isAppended = false; foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { if (kvp.Value.ToLower() != "all") { kvp.Value += "," + pageName; } isAppended = true; } lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } if (!isAppended) { lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName)); } lstLayouts = lstNewLayouts; } else if (isNewLayout) { bool isAppended = false; bool isAll = false; foreach (KeyValue kvp in lstLayouts) { if (kvp.Key == preset.ActiveLayout) { if (kvp.Value.ToLower() != "all") { kvp.Value += "," + pageName; isAll = true; } isAppended = true; } lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } if (!isAppended && !isAll) { lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName)); } lstLayouts = lstNewLayouts; } else if (deleteRepeat) { foreach (KeyValue kvp in lstLayouts) { if (kvp.Value.ToLower() != pageName.ToLower()) { lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } } lstLayouts = lstNewLayouts; } else if (duplicateLayout) { string key = preset.ActiveLayout; List <string> pages = new List <string>(); foreach (KeyValue kvp in lstLayouts) { if (kvp.Key.ToLower() != preset.ActiveLayout.ToLower()) { lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value)); } else { pages.Add(kvp.Value); } } lstNewLayouts.Add(new KeyValue(key, string.Join(",", pages.ToArray()))); lstLayouts = lstNewLayouts; } preset.lstLayouts = lstLayouts; string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName); string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile; presetPath += "/" + "pagepreset.xml"; AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + GetPortalID); PresetHelper.WritePreset(presetPath, preset); HttpRuntime.Cache.Remove(CacheKeys.SageFrameJs); HttpRuntime.Cache.Remove(CacheKeys.SageFrameCss); SageFrame.Common.CacheHelper.Clear("PresetList"); pageSEOName = ddlPages.SelectedValue.TrimStart('-'); layoutName = ddlLayout.SelectedValue; //BuildLayoutControl(); //BindModuleControls(); string redirectUrl = BuidRedirectURL(pageSEOName); Response.Redirect(redirectUrl); }