本文整理汇总了C#中SageFrame.Web.SageFrameConfig.GetSettingsByKeyIndividual方法的典型用法代码示例。如果您正苦于以下问题:C# SageFrameConfig.GetSettingsByKeyIndividual方法的具体用法?C# SageFrameConfig.GetSettingsByKeyIndividual怎么用?C# SageFrameConfig.GetSettingsByKeyIndividual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SageFrame.Web.SageFrameConfig
的用法示例。
在下文中一共展示了SageFrameConfig.GetSettingsByKeyIndividual方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPreRender
/// <summary>
/// Executes on prerendering of the page
/// </summary>
/// <param name="e">EventArgs e</param>
protected override void OnPreRender(EventArgs e)
{
try
{
ApplicationController objAppController = new ApplicationController();
if (!objAppController.CheckRequestExtension(Request))
{
base.OnPreRender(e);
SetGoogleAnalytics();
SageFrameConfig objSageConfig = new SageFrameConfig();
bool IsCompressCss = bool.Parse(objSageConfig.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeCss));
bool allowOptimization = bool.Parse(objSageConfig.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeJs));
if (!isDefaultAdminPage())
{
if (IsCompressCss)
{
BundleCss();
}
else
{
LoadModuleCss();
}
}
if (!IsAdmin() && allowOptimization)
{
BundleJS();
}
else
{
LoadModuleJs();
}
HttpContext.Current.Session[SessionKeys.ModuleCss] = new List<CssScriptInfo>();
HttpContext.Current.Session[SessionKeys.ModuleJs] = new List<CssScriptInfo>();
HttpContext.Current.Session.Remove(SessionKeys.ModuleJs);
HttpContext.Current.Session.Remove(SessionKeys.ModuleCss);
}
}
catch (Exception ex)
{
ProcessException(ex);
}
}
示例2: LoadModuleCss
//.........这里部分代码省略.........
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/css/{4}",
templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path));
}
}
#endregion
#region "Strategy 2-Priority-2:Check at the template level"
///Strategy 2-Priority-2:Check at the template level
else if (Directory.Exists(fullPath_template))
{
///Check to see if the file exists in the root level
if (File.Exists(string.Format("{0}/{1}", fullPath_template, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path));
}
///Check to see if the file exists in the css folder
else if (File.Exists(string.Format("{0}/css/{1}", fullPath_template, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/css/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path));
}
}
#endregion
}
#endregion
#region "Css Compress"
SageFrameConfig pagebase = new SageFrameConfig();
bool IsCompressCss = bool.Parse(pagebase.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeCss));
if (IsCompressCss && !isAdmin && !IsHandheld())
{
///1.Loop through the list
///2.Read the Css File
///3.Rewrite the Image Paths in Css Files
///4.Compress the Css file
///5.Include it in the Css Literal
string templateTypeName = isAdmin ? "admintemplate" : "template";
lstCss.Insert(0, templateTypeName);
string[] cssArr = lstCss.ToArray().Distinct().ToArray();
#region "Synchronize the cache and the map data in the files"
///Check cache and refresh it if the files optimized folder do not exist
///Synchronize the cache and the map data in the files
Hashtable hst = new Hashtable();
if (HttpRuntime.Cache[CacheKeys.SageFrameCss] != null)
{
hst = (Hashtable)HttpRuntime.Cache[CacheKeys.SageFrameCss];
Hashtable hstNew = new Hashtable();
foreach (string modulekey in hst.Keys)
{
string file = string.Format("{0}.css", hst[modulekey].ToString());
if (File.Exists(Server.MapPath(string.Format("~/Optimized/{0}", file))))
{
hstNew.Add(modulekey, hst[modulekey].ToString());
}
}
HttpRuntime.Cache[CacheKeys.SageFrameCss] = hstNew;
}
#endregion
示例3: LoadModuleCss
//.........这里部分代码省略.........
string fullPath_template = Server.MapPath(string.Format("~/{0}/{1}/modules/{2}",
templatePathFirst, templatePathSecond, css.ModuleName));
string fullPath_module = Server.MapPath(string.Format("~/{0}", css.Path));
#region "Strategy 3-Priority-3:Check at the module level(the default fallback)"
///Strategy 3-Priority-3:Check at the module level(the default fallback)
if (Directory.Exists(fullPath_module))
{
///Check to see if the file exists in the root level
if (File.Exists(string.Format("{0}/{1}", fullPath_module, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path));
}
///Check to see if the file exists in the css folder
else if (File.Exists(string.Format("{0}/css/{1}", fullPath_module, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path));
}
}
#endregion
#region "Strategy 1-Priority-1:Check the themes"
///Strategy 1-Priority-1:Check the themes
if (Directory.Exists(fullPath_theme))
{
///Check to see if the file exists in the root level
if (File.Exists(fullPath_theme + "/" + css.FileName))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/{4}",
templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path));
}
///Check to see if the file exists in the css folder
else if (File.Exists(string.Format("{0}/css/{1}", fullPath_theme, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/css/{4}",
templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path));
}
}
#endregion
#region "Strategy 2-Priority-2:Check at the template level"
///Strategy 2-Priority-2:Check at the template level
else if (Directory.Exists(fullPath_template))
{
///Check to see if the file exists in the root level
if (File.Exists(string.Format("{0}/{1}", fullPath_template, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path));
}
///Check to see if the file exists in the css folder
else if (File.Exists(string.Format("{0}/css/{1}", fullPath_template, css.FileName)))
{
lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/css/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path));
}
}
#endregion
}
#endregion
#region "Css Load"
SageFrameConfig pagebase = new SageFrameConfig();
bool IsCompressCss = bool.Parse(pagebase.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeCss));
Literal SageFrameModuleCSSlinks = this.Page.FindControl("SageFrameModuleCSSlinks") as Literal;
if (SageFrameModuleCSSlinks != null)
{
SageFrameModuleCSSlinks.Text = "";
foreach (KeyValue cssfile in lstCssInclude)
{
AddModuleCssToPage(cssfile.Key, SageFrameModuleCSSlinks);
}
if (IsUserLoggedIn())
{
AddModuleCssToPage("~/js/jquery-ui-1.8.14.custom/css/redmond/jquery-ui-1.8.16.custom.css", SageFrameModuleCSSlinks);
}
SetTemplateCss(SageFrameModuleCSSlinks);
if (isAdmin)
{
string cssColoredTemplate = string.Empty;
SageFrameConfig sageConfig = new SageFrameConfig();
string defaultAdminTheme = sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.DefaultAdminTheme);
cssColoredTemplate = "~/Administrator/Templates/Default/themes/" + defaultAdminTheme + ".css";
AddModuleCssToPage(cssColoredTemplate, SageFrameModuleCSSlinks);
}
}
#endregion
}
}
示例4: OptimizeJs
private void OptimizeJs(List<CssScriptInfo> lstJsColl, int Mode)
{
Literal LitSageScript = Mode == 1 ? Page.Header.FindControl("LitSageScript") as Literal : Page.Header.FindControl("SageFrameModuleCSSlinks") as Literal;
bool isAdmin = IsAdmin();
List<string> lstJs = new List<string>();
foreach (CssScriptInfo js in lstJsColl)
{
lstJs.Add(js.ModuleName);
}
string portalType = isAdmin ? ApplicationKeys.admin.ToLower() : ApplicationKeys.portal;
lstJs.Insert(0, portalType);
SageFrameConfig pagebase = new SageFrameConfig();
bool IsCompressJs = bool.Parse(pagebase.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeJs));
#region "IncludeJs Logic"
if (IsCompressJs && !isAdmin && !IsHandheld())
{
#region "Check cache and refresh it if the files optimized folder do not exist"
Hashtable hst = new Hashtable();
///Check cache and refresh it if the files optimized folder do not exist
if (HttpRuntime.Cache[CacheKeys.SageFrameJs] != null)
{
hst = (Hashtable)HttpRuntime.Cache[CacheKeys.SageFrameJs];
Hashtable hstNew = new Hashtable();
foreach (string modulekey in hst.Keys)
{
string file = string.Format("{0}.js", hst[modulekey].ToString());
if (File.Exists(Server.MapPath(string.Format("~/Optimized/{0}", file))))
{
hstNew.Add(modulekey, hst[modulekey].ToString());
}
}
HttpRuntime.Cache[CacheKeys.SageFrameJs] = hstNew;
}
if (HttpRuntime.Cache[CacheKeys.SageFrameJs] != null)
{
hst = (Hashtable)HttpRuntime.Cache[CacheKeys.SageFrameJs];
}
else
{
XmlDocument doc = SageFrame.Templating.xmlparser.XmlHelper.LoadXMLDocument(Server.MapPath("~/Optimized/map_js.xml"));
XmlNode xnresourcemap = doc.SelectSingleNode("resourcemaps");
XmlNodeList xnlist = xnresourcemap.ChildNodes;
foreach (XmlNode node in xnlist)
{
string modules = node.SelectSingleNode("modules").InnerText;
string map = node.SelectSingleNode("map").InnerText;
if (modules != "" && !hst.Contains(modules))
hst.Add(modules, map);
}
}
#endregion
string[] jsArr = lstJs.ToArray().Distinct().ToArray();
///Read the map file and check if the css for this combination already exists
bool IsExists = false;
string optimizedjs = string.Empty;
#region "Get Optimized Js file name"
foreach (string modulekey in hst.Keys)
{
string modules = modulekey;
string[] modulesArr = modules.Split(',');
if (ArrayHelper.ArraysEqual<string>(jsArr, modulesArr))
{
IsExists = true;
optimizedjs = string.Format("{0}.js", hst[modulekey].ToString());
break;
}
}
#endregion
#region "Optimize JS"
if (IsExists)
{
IsExists = File.Exists(Server.MapPath(string.Format("~/Optimized/{0}", optimizedjs)));
}
if (!IsExists)
{
string uniqueid = GenerateUniqueId();
XmlDocument doc = SageFrame.Templating.xmlparser.XmlHelper.LoadXMLDocument(Server.MapPath("~/Optimized/map_js.xml"));
XmlNode xnresourcemap = doc.SelectSingleNode("resourcemaps");
string optimized_js_path = Server.MapPath(string.Format("~/Optimized/{0}.js", uniqueid));
///Write the combination into the map file
XmlElement resourcemap = doc.CreateElement("resourcemap");
XmlElement modules = doc.CreateElement("modules");
XmlElement map = doc.CreateElement("map");
modules.InnerText = string.Join(",", jsArr);
map.InnerText = uniqueid;
resourcemap.AppendChild(modules);
//.........这里部分代码省略.........