コード例 #1
0
ファイル: Settings.cs プロジェクト: liuyanchen1994/cms
 public static void TurnOffDebug()
 {
     Opti_Debug = !true;
     WebConfig.SetDebug(!true);
 }
コード例 #2
0
ファイル: Settings.cs プロジェクト: liuyanchen1994/cms
 public static void TurnOnDebug()
 {
     Opti_Debug = true;
     WebConfig.SetDebug(true);
 }
コード例 #3
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>返回加载消息,如成功返回空</returns>
        private static void Load(string filePath)
        {
            cmsConfFile = filePath;
            //从配置文件中加载
            SettingFile sf = new SettingFile(cmsConfFile);

            Settings.loaded = true;
            bool settingChanged = false;

            //try
            // {
            Settings.LICENSE_NAME            = sf.Contains("license_name") ? sf["license_name"] : "评估用户";
            Settings.LICENSE_KEY             = sf.Contains("license_key") ? sf["license_key"] : String.Empty;
            Settings.SYS_WWW_RD              = GetInt(sf, "sys_www_rd");
            Settings.SYS_FORCE_HTTPS         = CheckTrueValue(sf, "sys_force_https");
            Settings.SYS_USE_UPLOAD_RAW_NAME = CheckTrueValue(sf, "sys_use_upload_raw_path");

            #region 读取模板选项

            Settings.TPL_FULL_URL_PATH = !sf.Contains("tpl_full_url_path") || sf["tpl_full_url_path"] == "true";
            Settings.TPL_USE_COMPRESS  = sf.Contains("tpl_use_compress") && sf["tpl_use_compress"] == "true";
            Settings.TPL_USE_CACHE     = !sf.Contains("tpl_use_cache") || sf["tpl_use_cache"] == "true";

            #endregion

            Settings.DB_TYPE   = sf["db_type"];
            Settings.DB_CONN   = sf["db_conn"];
            Settings.DB_PREFIX = sf["db_prefix"];

            Settings.MM_AVATAR_PATH = sf["mm_avatar_path"];


            /**************** 优化项 ******************/
            Settings.OPTI_DEBUG_MODE = WebConfig.IsDebug();

            //缓存项
            if (sf.Contains("perm_index_cache_second"))
            {
                Int32.TryParse(sf["perm_index_cache_second"], out Settings.PERM_INDEX_CACHE_SECOND);
            }

            if (sf.Contains("opti_client_cache_seconds"))
            {
                Int32.TryParse(sf["opti_client_cache_seconds"], out Settings.Opti_ClientCacheSeconds);
            }

            if (sf.Contains("opti_gc_collect_interval"))
            {
                Int32.TryParse(sf["opti_gc_collect_interval"], out Settings.opti_gc_collect_interval);
            }


            /**************** 静态服务器 ******************/

            if (sf.Contains("server_static"))
            {
                Settings.SERVER_STATIC = sf["server_static"];
                if (Settings.SERVER_STATIC.Length == 0)
                {
                    Settings.SERVER_STATIC = Server.DefaultStaticServer;
                }
            }
            else
            {
                sf.Set("server_static", Server.DefaultStaticServer);
                Settings.SERVER_STATIC = Server.DefaultStaticServer;
                settingChanged         = true;
            }


            if (sf.Contains("server_upgrade"))
            {
                Settings.SERVER_UPGRADE = sf["server_upgrade"];
                if (Settings.SERVER_UPGRADE.Length == 0)
                {
                    Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                }
            }
            else
            {
                sf.Set("server_upgrade", Server.DefaultUpgradeServer);
                Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                settingChanged          = true;
            }

            if (sf.Contains("server_static_enabled"))
            {
                Settings.SERVER_STATIC_ENABLED = sf["server_static_enabled"] == "true";
            }
            else
            {
                sf.Set("server_static_enabled", "false");
                settingChanged = true;
            }

            if (sf.Contains("sys_encode_conf"))
            {
                Settings.SYS_ENCODE_CONF_FILE = sf["sys_encode_conf"] == "true";
            }
            else
            {
                sf.Set("sys_encode_conf", Settings.SYS_ENCODE_CONF_FILE ? "true" : "false");
                settingChanged = true;
            }

            if (sf.Contains("sql_profile_trace"))
            {
                Settings.SQL_PROFILE_TRACE = sf["sql_profile_trace"] == "true";
            }
            else
            {
                sf.Set("sql_profile_trace", Settings.SQL_PROFILE_TRACE ? "true" : "false");
                settingChanged = true;
            }
            if (sf.Contains("sys_admin_tag"))
            {
                Settings.SYS_ADMIN_TAG = sf["sys_admin_tag"];
            }
            else
            {
                sf.Set("sys_admin_tag", Settings.SYS_ADMIN_TAG);
                settingChanged = true;
            }

            if (sf.Contains("sys_site_map_path"))
            {
                Settings.SYS_SITE_MAP_PATH = sf["sys_site_map_path"];
            }
            else
            {
                sf.Set("sys_site_map_path", "");
                settingChanged = true;
            }

            if (settingChanged)
            {
                sf.Flush();
            }
        }
コード例 #4
0
 public static void TurnOffDebug()
 {
     OPTI_DEBUG_MODE = !true;
     WebConfig.SetDebug(!true);
 }
コード例 #5
0
 public static void TurnOnDebug()
 {
     OPTI_DEBUG_MODE = true;
     WebConfig.SetDebug(true);
 }
コード例 #6
0
ファイル: Configuration.cs プロジェクト: liuyanchen1994/cms
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>返回加载消息,如成功返回空</returns>
        internal static string Load(string filePath)
        {
            CmsConfigFile = filePath;


            //从配置文件中加载
            SettingFile sf = new SettingFile(CmsConfigFile);

            Settings.loaded = true;
            bool settingChanged = false;

            //try
            // {
            Settings.License_NAME = sf.Contains("license_name") ? sf["license_name"] : "评估用户";
            Settings.License_KEY  = sf.Contains("license_key") ? sf["license_key"] : String.Empty;
            Settings.SYS_AUTOWWW  = sf.Contains("sys_autowww") && sf["sys_autowww"] == "true";        //自动WWW

            #region 读取模板选项

            Settings.TPL_UseFullPath = sf.Contains("tpl_usefullpath") ? sf["tpl_usefullpath"] == "true" : true;
            Settings.TPL_UseCompress = sf.Contains("tpl_usecompress") ? sf["tpl_usecompress"] == "true" : false;


            #endregion

            Settings.DB_TYPE   = sf["db_type"];
            Settings.DB_CONN   = sf["db_conn"];
            Settings.DB_PREFIX = sf["db_prefix"];

            Settings.MM_AVATAR_PATH = sf["mm_avatar_path"];


            /**************** 优化项 ******************/
            Settings.Opti_Debug = WebConfig.IsDebug();

            //缓存项
            if (sf.Contains("opti_IndexCacheSeconds"))
            {
                Int32.TryParse(sf["opti_IndexCacheSeconds"], out Settings.Opti_IndexCacheSeconds);
            }

            if (sf.Contains("opti_ClientCacheSeconds"))
            {
                Int32.TryParse(sf["opti_ClientCacheSeconds"], out Settings.Opti_ClientCacheSeconds);
            }

            if (sf.Contains("Opti_GC_Collect_Interval"))
            {
                Int32.TryParse(sf["Opti_GC_Collect_Interval"], out Settings.Opti_GC_Collect_Interval);
            }


            /**************** 静态服务器 ******************/

            if (sf.Contains("server_static"))
            {
                Settings.SERVER_STATIC = sf["server_static"];
                if (Settings.SERVER_STATIC.Length == 0)
                {
                    Settings.SERVER_STATIC = Server.DefaultStaticServer;
                }
            }
            else
            {
                sf.Set("server_static", Server.DefaultStaticServer);
                Settings.SERVER_STATIC = Server.DefaultStaticServer;
                settingChanged         = true;
            }


            if (sf.Contains("server_upgrade"))
            {
                Settings.SERVER_UPGRADE = sf["server_upgrade"];
                if (Settings.SERVER_UPGRADE.Length == 0)
                {
                    Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                }
            }
            else
            {
                sf.Set("server_upgrade", Server.DefaultUpgradeServer);
                Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                settingChanged          = true;
            }

            if (sf.Contains("server_static_enabled"))
            {
                Settings.SERVER_STATIC_ENABLED = sf["server_static_enabled"] == "true";
            }
            else
            {
                sf.Set("server_static_enabled", "false");
                settingChanged = true;
            }



            if (sf.Contains("sys_encode_conf"))
            {
                Settings.SYS_ENCODE_CONF_FILE = sf["sys_encode_conf"] == "true";
            }
            else
            {
                sf.Set("sys_encode_conf", Settings.SYS_ENCODE_CONF_FILE ? "true" : "false");
                settingChanged = true;
            }

            if (sf.Contains("sql_profile_trace"))
            {
                Settings.SQL_PROFILE_TRACE = sf["sql_profile_trace"] == "true";
            }
            else
            {
                sf.Set("sql_profile_trace", Settings.SQL_PROFILE_TRACE ? "true" : "false");
                settingChanged = true;
            }


            if (sf.Contains("sys_admin_tag"))
            {
                Settings.SYS_ADMIN_TAG = sf["sys_admin_tag"];
            }
            else
            {
                sf.Set("sys_admin_tag", Settings.SYS_ADMIN_TAG);
                settingChanged = true;
            }

            if (settingChanged)
            {
                sf.Flush();
            }


            return(String.Empty);

            /*
             * }
             * catch (Exception ex)
             * {
             * const string strtpl = "配置文件不正确,请检查!位置:{0}。{1}";
             * string _file = filePath.Replace("/", "\\").Replace("\\\\", "\\");
             *
             * return string.Format(strtpl, _file,
             * ex.GetType() == typeof(ArgumentOutOfRangeException) ? "此错误可能因为缺少系统所需的配置而引发。" :
             * string.Empty
             * );
             * }*/
        }