Example #1
0
 /// <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);
 }
Example #2
0
        /// <summary>
        /// 保存配置到config文件
        /// </summary>
        /// <param name="configinfo"></param>
        /// <returns></returns>
        public static bool SaveConfig(GeneralConfigInfo configinfo)
        {
            bool ret = false;

            lock (lockHelper)
            {
                ret = SerializationHelper.Save(configinfo, GeneralConfigFileManager.ConfigFilePath);
                ResetConfig();
            }
            return(ret);
        }
Example #3
0
        /// <summary>
        /// 获取当前系统常用参数
        /// </summary>
        /// <returns></returns>
        public static GeneralConfigInfo GetConfig()
        {
            string            configid = "generalconfig";
            GeneralConfigInfo config   = AppCtx.Cache.RetrieveObject <GeneralConfigInfo>(configid);

            if (config == null)
            {
                config = GeneralConfigFileManager.LoadConfig();
                AppCtx.Cache.AddObjectWithFileChange(configid, config, ConfigFile);
            }
            return(config);
        }
Example #4
0
        public static GeneralConfigInfo GetConfig()
        {
            //string configid = "generalconfig";
            GeneralConfigInfo config = null;

            if (config == null)
            {
                config = GeneralConfigFileManager.LoadConfig();
            }

            return(config);
        }
 /// <summary>
 /// 返回配置类实例
 /// </summary>
 /// <returns></returns>
 public static GeneralConfigInfo LoadConfig()
 {
     if (ConfigInfo != null)
     {
         m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);
         ConfigInfo      = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, true);
     }
     else
     {
         filename = HttpContext.Current.Server.MapPath("~/Config/general.config");
         if (!File.Exists(filename))
         {
             ConfigInfo = new GeneralConfigInfo();
             SerializationHelper.Save(ConfigInfo, filename);
         }
         ConfigInfo = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, false);
     }
     return(ConfigInfo as GeneralConfigInfo);
 }
Example #6
0
        /// <summary>
        /// 返回配置类实例
        /// </summary>
        /// <returns></returns>
        public static GeneralConfigInfo LoadConfig()
        {
            if (ConfigInfo != null)
            {
                m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);
                ConfigInfo      = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, true);
            }
            else
            {
                filename = HttpContext.Current.Server.MapPath("~/Config/general.config");
                /* 2012/2/14 修改了初始化配置判断逻辑(即使已存在 general.config 文件,ConfigInfo 仍有可能为 null;此处确保其不为空,且在不存在 general.config 时创建之) */
                if (null == ConfigInfo)
                {
                    ConfigInfo = new GeneralConfigInfo();
                }
                if (!File.Exists(filename))
                {
                    SerializationHelper.Save(ConfigInfo, filename);
                }

                ConfigInfo = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, false);
            }
            return(ConfigInfo as GeneralConfigInfo);
        }
Example #7
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     m_configinfo = GeneralConfigFileManager.LoadRealConfig();
 }