internal static void Initialize(FileImporter fileImporter) { if (fileImporter.Initialized) return; try { fileImporter.LogMessages = new LogMessagesQueue(); fileImporter.MediaProfilesProvider = MediaLocations.GetInstance(); fileImporter.GlobalPluginProperties = new GlobalPluginProperties(); fileImporter.ImageLinker = new ImageLinker(fileImporter.LogMessages); fileImporter.DataPath = FolderLocations.Data; fileImporter.FileImporterDataPath = fileImporter.DataPath + "FileImporter\\"; if (!String.IsNullOrEmpty(fileImporter.DataPath)) { if (fileImporter.IsFirstLoad) { if (!Directory.Exists(fileImporter.FileImporterDataPath)) { Directory.CreateDirectory(fileImporter.FileImporterDataPath); } } } else { fileImporter .LogMessages.Enqueue (new LogMessage("Warn", "Invalid DataPath")); } TranslationExtension.Plugin = fileImporter; fileImporter.ImporterSettings = new ImporterPropertiesCore .FileImporterProperties(fileImporter); } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw new FileImporter.FileImporterInitializationException(ex); } fileImporter.Initialized = true; }
internal static void SetupLogging(FileImporter fileImporter) { if (fileImporter.DebugLevel == "Off") return; if (!String.IsNullOrEmpty(fileImporter.DataPath) && Directory.Exists(fileImporter.DataPath)) { fileImporter.Log = LogManager.GetLogger(typeof(FileImporter)); string logConfigFilename = fileImporter.FileImporterDataPath + "LoggerConfig_" + fileImporter.Section.Name + ".xml"; LogConfigCreator.CreateLogConfig(fileImporter, logConfigFilename); fileImporter.LogConfig = new FileInfo(logConfigFilename); XmlConfigurator.Configure(fileImporter.LogConfig); fileImporter.LogConfig = null; fileImporter.LogMessages.Log = fileImporter.Log; } else { const string logMessage1 = "DataPath wasn't retrieved correctly preventing logging in the logs folder."; fileImporter.LogMessages.Enqueue(new LogMessage("Warn", logMessage1)); } }
public FileImporterProperties(CORE.FileImporter fileImporter) : base(false, ";;;", "|||", ":::") { this.fileImporter = fileImporter; this.Plugin = fileImporter; string fileImporterDataPath = this.fileImporter.DataPath + "FileImporter\\"; if (File.Exists(fileImporterDataPath + "TVShowsReplacementRules.txt")) { try { this.tvShowsReplacements = File.ReadAllText(fileImporterDataPath + "TVShowsReplacementRules.txt"); } catch (Exception ex) { this.fileImporter.LogMessages.Enqueue( new LogMessage( "Warn", "Unable to load the default TVShowsTagValueReplacementRules." + Environment.NewLine + ex)); } } if (File.Exists(fileImporterDataPath + "TVShowsRegex.txt")) { try { this._tvShowsRegex = File.ReadAllText(fileImporterDataPath + "TVShowsRegex.txt"); } catch (Exception ex) { this.fileImporter.LogMessages.Enqueue( new LogMessage( "Warn", "Unable to load the default TVShowsRegex." + Environment.NewLine + ex)); } } if (File.Exists(fileImporterDataPath + "MoviesRegex.txt")) { try { moviesRegex = File.ReadAllText(fileImporterDataPath + "MoviesRegex.txt"); } catch (Exception ex) { this.fileImporter.LogMessages.Enqueue( new LogMessage("Warn", "Unable to load the default MoviesRegex." + Environment.NewLine + ex)); } } if (File.Exists(fileImporterDataPath + "MusicRegex.txt")) { try { musicRegex = File.ReadAllText(fileImporterDataPath + "MusicRegex.txt"); } catch (Exception ex) { this.fileImporter.LogMessages.Enqueue( new LogMessage("Warn", "Unable to load the default MusicRegex." + Environment.NewLine + ex)); } } InitializeOptionSettings(); }