public static ChartSkin GetChartConfigFile(ChartConfig chartConfig, string source) { string skinFile; chartConfig.SkinFiles.TryGetValue(source, out skinFile); if (string.IsNullOrEmpty(skinFile)) { return null; } var _cacheKey = skinFile; var chartSkin = Cache.Get(_cacheKey) as ChartSkin; if (chartSkin == null) { lock (_chartLock) { chartSkin = Cache.Get(_cacheKey) as ChartSkin; if (chartSkin == null) { var file = AppSettings.PhysicalAppPath + "//" + skinFile.Replace("/", "//"); var doc = new XmlDocument(); doc.Load(file); chartSkin = new ChartSkin(skinFile) {XmlSource = doc}; Cache.Insert(_cacheKey, chartSkin, new System.Web.Caching.CacheDependency(file)); } } } return chartSkin; }
public static ChartConfig GetChartConfig() { string _cacheKey = "ChartConfig"; var chartConfig = Cache.Get(_cacheKey) as ChartConfig; if (chartConfig == null) { lock (_chartLock) { chartConfig = Cache.Get(_cacheKey) as ChartConfig; if (chartConfig == null) { var parms = Thinkgate.Base.Classes.DistrictParms.LoadDistrictParms(); var file = AppSettings.PhysicalAppPath + "\\Config\\" + parms.ChartConfigFile; try { var doc = XDocument.Load(file); chartConfig = new ChartConfig(doc); } catch (System.IO.FileNotFoundException ex) { // hopefully the base config file exists, otherwise, not sure what to do string errorMessage = "Chart config file specified in Parms, " + file + ", does not exist. Attempting to load base configuration."; ThinkgateEventSource.Log.ApplicationError(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "->" + MethodBase.GetCurrentMethod().Name, errorMessage, ex.ToString()); var doc = XDocument.Load(AppSettings.PhysicalAppPath + "\\Config\\chart_config1.xml"); chartConfig = new ChartConfig(doc); } Cache.Insert(_cacheKey, chartConfig, new System.Web.Caching.CacheDependency(file)); } } } return chartConfig; }