/// <summary>
 /// 序列化配置信息为XML
 /// </summary>
 /// <param name="configinfo">配置信息</param>
 /// <param name="configFilePath">配置文件完整路径</param>
 public static GeneralConfigInfo Serialiaze(GeneralConfigInfo configinfo, string configFilePath)
 {
     lock (lockHelper)
     {
         SerializationHelper.Save(configinfo, configFilePath);
     }
     return configinfo;
 }
        /// <summary>
        /// 静态构造函数初始化相应实例和定时器
        /// </summary>
        static GeneralConfigs()
        {
            m_configinfo = GeneralConfigFileManager.LoadConfig();

            generalConfigTimer.AutoReset = true;
            generalConfigTimer.Enabled = true;
            generalConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
            generalConfigTimer.Start();
        }
        /// <summary>
        /// 初始化文件修改时间和对象实例
        /// </summary>
        static GeneralConfigFileManager()
        {
            m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);

            try
            {
                m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
            }
            catch
            {
                if (File.Exists(ConfigFilePath))
                {
                    m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
                }
            }
        }
        public ActionResult AdminBaseConfig(GeneralConfigInfo model)
        {
            try
            {
                GeneralConfigInfo config = configinfo;
                config.Weburl = model.Weburl;
                config.Webtitle = model.Webtitle;
                //config.WebPath = string.IsNullOrEmpty(model.WebPath) ? "/" : model.WebPath;
                config.Icp = model.Icp;
                config.IndexPagerCount = model.IndexPagerCount;
                config.CatePagerCount = model.CatePagerCount;
                config.CommentPagerCount = model.CommentPagerCount;
                config.NotePagerCount = model.NotePagerCount;
                config.WebDescription = model.WebDescription;
                config.ThumbnailInfo = model.ThumbnailInfo;
                config.Theme = model.Theme;
                config.DefaultLang = model.DefaultLang;
                config.ContributorCateIds = model.ContributorCateIds;
                config.MaxSummaryCharCount = model.MaxSummaryCharCount;
                config.AdminEmail = model.AdminEmail;
                config.SmtpServer = model.SmtpServer;
                config.SmtpUser = model.SmtpUser;
                config.SmtpPass = model.SmtpPass;
                config.SmtpPort = model.SmtpPort;
                config.IfSendReplyEmail = model.IfSendReplyEmail;

                WebUtils.ChangeTheme(model.Theme);
                CultureInfo cultureinfo = new CultureInfo(model.DefaultLang == "zh-cn" ? "" : configinfo.DefaultLang);
                System.Web.HttpContext.Current.Session["CurrentLanguage"] = cultureinfo;
                GeneralConfigs.Serialiaze(config, Server.MapPath(WebUtils.GetWebConfigPath()));
            }
            catch (Exception)
            {
                return Content(res.ModifyFailed + " <a href=\"/QAAdmin/admin/AdminBaseConfig\">" + res.ContinueModify + "</a>", "text/html;charset=UTF-8");
            }
            return Content(res.ModifiedSuccessfully + " <a href=\"/QAAdmin/admin/AdminBaseConfig\">" + res.ContinueModify + "</a>", "text/html;charset=UTF-8");
        }
 /// <summary>
 /// 保存配置类实例
 /// </summary>
 /// <param name="generalconfiginfo"></param>
 /// <returns></returns>
 public static bool SaveConfig(GeneralConfigInfo generalconfiginfo)
 {
     GeneralConfigFileManager gcf = new GeneralConfigFileManager();
     GeneralConfigFileManager.ConfigInfo = generalconfiginfo;
     return gcf.SaveConfig();
 }
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     m_configinfo = GeneralConfigFileManager.LoadConfig();
 }