Пример #1
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();

            settings = new ModuleSettings();

            LoggingConfiguration loggingConfiguration = new LoggingConfiguration();
            FileTarget           target = new FileTarget(settings.LogFileTarget)
            {
                FileName = settings.LogFilePath
            };

            loggingConfiguration.AddRule(LogLevel.Debug, LogLevel.Fatal, target, "*");
            LogManager.Configuration = loggingConfiguration;

            try
            {
                if (BaseSettingsProvider.Instance != null)
                {
                    Log.Info("Module intialization | Settings initialized sucessfully. Using MCM Config.");
                    settings = ModuleSettings.Instance;
                    SerializeSettings(settings.SettingsFilePath);
                }
                else
                {
                    if (!File.Exists(settings.SettingsFilePath))
                    {
                        SerializeSettings(settings.SettingsFilePath);
                    }

                    settings = DeserializeSettings(settings.SettingsFilePath);
                    Log.Info("Module intialization | Settings initialized sucessfully. Using XML Config.");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to Serialize/Deserialize for " + settings.SettingsFilePath);;
            }
        }