public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); context.Application["We7.Application.OnlinePeople.Key"] = 0; if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistant = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistant.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistant.LoadDataSource(dataPath); } catch (DataException ex) { Debug.WriteLine(ex.ToString()); string s = string.Format("注意检查:/app_data/xml目录下的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}", ex.Errorcode, ex.Message); LogHelper.WriteLog(typeof(ApplicationHelper), s); throw ex; } HelperFactory factory = new HelperFactory(); factory.Assistant = assistant; factory.Root = root; factory.Initialize(); context.Application["We7.HelperFactory"] = factory; } } }
/// <summary> /// 重启网站 /// </summary> public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); PluginManager.LoadPlugins(); context.Application["We7.Application.OnlinePeople.Key"] = 0; //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString. Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); string msg = string.Format("注意检查:/app_data/xml里的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}" , ex.ErrorCode, ex.Message); We7.Framework.LogHelper.WriteLog(typeof(ApplicationHelper), msg); throw ex; } HelperFactory hf = new HelperFactory(); /* * 添加内容模型表结构(系统内置字段已在LoadDataSource里添加) * author:丁乐 */ ModelHelper.ReCreateModelIndex(); MoudelMonitoring.SetModelDataDic(assistat); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); context.Application.Add("We7.HelperFactory", hf); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); MoudelMonitoring ml = new MoudelMonitoring(); //监控内容模型 } } }