示例#1
0
文件: ServerMain.cs 项目: Rai/aura
        /// <summary>
        /// Loads system and user localization files.
        /// </summary>
        public void LoadLocalization(BaseConf conf)
        {
            var language = conf.Localization.Language;
            var path     = Path.Combine("localization", language + ".po");

            Log.Info("Loading localization ({0})...", language);

            // Try user first
            try
            {
                Localization.Load(Path.Combine("user", path));
            }
            catch (FileNotFoundException)
            {
                // Try system second, if the file wasn't in user
                try
                {
                    Localization.Load(Path.Combine("system", path));
                }
                catch (FileNotFoundException)
                {
                    // Warn if language wasn't the default
                    if (language != "en-US")
                    {
                        Log.Warning("Localization file '{0}.po' not found.", language);
                    }
                }
            }
        }
示例#2
0
        public override void InitDatabase(AuraDb db, BaseConf conf)
        {
            base.InitDatabase(db, conf);

            // If items end up with temp ids in the db we'd get entity ids
            // that exist twice, when creating new temps later on.
            if (ChannelServer.Instance.Database.TmpItemsExist())
            {
                Log.Warning("InitDatabase: Found items with temp entity ids.");
                // TODO: clean up dbs
            }
        }
示例#3
0
        /// <summary>
        /// Load config file from the path stated in BaseConf
        /// </summary>
        /// <param name="conf">Config File containing the path of every file that need to be loaded</param>
        private static void LoadConf(BaseConf conf)
        {
            Log.Info("Reading configuration...");

            try
            {
                conf.Load();
            }
            catch (Exception ex)
            {
                Log.Exception(ex, "Unable to read configuration. ({0})", ex.Message);
            }
        }
示例#4
0
        /// <summary>
        /// Tries to initialize database with the information from conf,
        /// exits on error.
        /// </summary>
        public virtual void InitDatabase(AuraDb db, BaseConf conf)
        {
            Log.Info("Initializing database...");

            try
            {
                db.Init(conf.Database.Host, conf.Database.User, conf.Database.Pass, conf.Database.Db);
            }
            catch (Exception ex)
            {
                Log.Error("Unable to open database connection. ({0})", ex.Message);
                CliUtil.Exit(1);
            }
        }
示例#5
0
        /// <summary>
        /// Initialize the Database using parameters retrieved from BaseConf
        /// </summary>
        /// <param name="db">Database Connection</param>
        /// <param name="conf">Config File</param>
        protected static void InitDatabase(GameDatabase db, BaseConf conf)
        {
            Log.Info("Initializing database...");

            try
            {
                db.Init(conf.Database.Host, conf.Database.Port, conf.Database.User, conf.Database.Pass, conf.Database.Db);
            }
            catch (Exception ex)
            {
                db = null;
                Log.Error("Unable to open database connection. ({0})", ex.Message);
            }
        }
示例#6
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="conf"></param>
        public void LoadConf(BaseConf conf)
        {
            Log.Info("读取配置...");

            try
            {
                conf.Load();
            }
            catch (Exception ex)
            {
                Log.Exception(ex, "读取错误. ({0})", ex.Message);
                CliUtil.Exit(1);
            }
        }
示例#7
0
        /// <summary>
        ///     Tries to call conf's load method, exits on error.
        /// </summary>
        protected static void LoadConf(BaseConf conf)
        {
            Log.Info("Reading configuration...");

            try
            {
                conf.Load();
            }
            catch (Exception ex)
            {
                Log.Exception(ex, "Unable to read configuration. ({0})", ex.Message);
                ConsoleUtil.Exit(1);
            }
        }
示例#8
0
文件: CommConf.cs 项目: fkdl/OpenLIS
        static CommConf()
        {
            const string configName = "CommConf";

            FormText    = BaseConf.ConfigStrR("conf/ui/form_text", configName);
            TrayText    = BaseConf.ConfigStrR("conf/ui/tray_text", configName);
            BallonTitle = BaseConf.ConfigStrR("conf/ui/ballon_title", configName);
            BallonText  = BaseConf.ConfigStrR("conf/ui/ballon_text", configName);
            HideOnLoad  = BaseConf.ConfigBoolR("conf/ui/hide_on_load", configName);

            DllFileName = BaseConf.ConfigStrR("conf/model/dll_file_name", configName);
            NameSpace   = BaseConf.ConfigStrR("conf/model/name_space", configName);
            ClassName   = BaseConf.ConfigStrR("conf/model/class_name", configName);
        }
示例#9
0
 /// <summary>
 /// Tries to call conf's load method, exits on error.
 /// </summary>
 public void LoadConf(BaseConf conf)
 {
     using (var t = new ChangingOutput("Reading Configuration..."))
     {
         try
         {
             Log.ToFile("Reading Configuration...", LogLevel.Info);
             conf.Load();
             t.PrintResult(true);
         }
         catch (Exception ex)
         {
             t.PrintResult(false);
             Log.Exception(ex, "Unable to read configuration. ({0})", ex.Message);
             CliUtil.Exit(1);
         }
     }
 }
示例#10
0
 /// <summary>
 /// Tries to initialize database with the information from conf,
 /// exits on error.
 /// </summary>
 public virtual void InitDatabase(PastorsDeskDb db, BaseConf conf)
 {
     using (var t = new ChangingOutput("Initializing database..."))
     {
         try
         {
             Log.ToFile("Initializing database...", LogLevel.Info);
             db.Init(conf.Database.Host, conf.Database.User, conf.Database.Pass, conf.Database.Db);
             t.PrintResult(true);
         }
         catch (Exception ex)
         {
             t.PrintResult(false);
             Log.Error("Unable to open database connection. ({0})", ex.Message);
             CliUtil.Exit(1);
         }
     }
 }
示例#11
0
        /// <summary>
        /// Loads system and user localization files.
        /// </summary>
        public void LoadLocalization(BaseConf conf)
        {
            var language = conf.Localization.Language;
            var path     = Path.Combine("localization", language + ".po");

            Log.Info("Loading localization ({0})...", language);

            // Try user first
            try
            {
                Localization.Load(Path.Combine("user", path));
            }
            catch (FileNotFoundException)
            {
                // Try system second, if the file wasn't in user
                try
                {
                    Localization.Load(Path.Combine("system", path));
                }
                catch (FileNotFoundException)
                {
                    // Warn if language wasn't the default
                    if (language != "en-US")
                    {
                        Log.Warning("Localization file '{0}.po' not found.", language);
                    }
                }
            }

            ErinnTime.SetMonthNames(
                Localization.Get("Imbolic"),
                Localization.Get("Alban Eiler"),
                Localization.Get("Baltane"),
                Localization.Get("Alban Heruin"),
                Localization.Get("Lughnasadh"),
                Localization.Get("Alban Elved"),
                Localization.Get("Samhain")
                );
        }
示例#12
0
        /// <summary>
        /// Loads system and user localization files.
        /// </summary>
        public void LoadLocalization(BaseConf conf)
        {
            Log.Info("Loading localization ({0})...", conf.Localization.Language);

            // System
            try
            {
                Localization.Parse("system/localization/" + conf.Localization.Language);
            }
            catch (FileNotFoundException ex)
            {
                Log.Warning("Unable to load localization: " + ex.Message);
            }

            // User
            try
            {
                Localization.Parse("user/localization/" + conf.Localization.Language);
            }
            catch (FileNotFoundException)
            {
            }
        }