Esempio n. 1
0
        void fsw_Changed(object sender, FileSystemEventArgs e)
        {
            //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.f**k));
            var hf = AppCtx.Cache.RetrieveObject <HelperFactory>(HelperFactory.CacheKey);

            if (hf != null)
            {
                MoudelMonitoring.SetModelDataDic(hf.Assistant);
                //更新缓存
                AppCtx.Cache.RemoveObject(HelperFactory.CacheKey);
                AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf);
                //更新Application
                if (WatcherTimer.context != null)
                {
                    WatcherTimer.context.Application.Remove(HelperFactory.ApplicationID);
                    WatcherTimer.context.Application.Add(HelperFactory.ApplicationID, hf);
                }
            }
        }
Esempio n. 2
0
        /// <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();  //监控内容模型
                }
            }
        }