예제 #1
0
        /// <summary>
        /// Load settings from one of the default settings locations or file specified
        /// </summary>
        public void LoadSettings()
        {
            var file = new ConverterSettingsFile();

            if (string.IsNullOrEmpty(_processorSettings.SettingsFileToUse) || !File.Exists(ProcessorSettings.SettingsFileToUse))
            {
                if (!string.IsNullOrEmpty(_processorSettings.SettingsFileToUse))
                {
                    Logger.Log.ErrorFormat("LoadSettings - the specified settings file \"{0}\" not found, going to use standard settings file", _processorSettings.SettingsFileToUse);
                }
                string filePath;
                DefaultSettingsLocatorHelper.EnsureDefaultSettingsFilePresent(out filePath, file.Settings);
                _processorSettings.SettingsFileToUse = filePath;
            }
            try
            {
                Logger.Log.InfoFormat("Loading settings from {0}", _processorSettings.SettingsFileToUse);
                file.Load(ProcessorSettings.SettingsFileToUse);
            }
            catch (Exception ex)
            {
                Logger.Log.ErrorFormat("LoadSettings - unable to load file {0} , exception: {1}", _processorSettings.SettingsFileToUse, ex);
            }
            try
            {
                _processorSettings.Settings.CopyFrom(file.Settings);
            }
            catch (Exception ex)
            {
                Logger.Log.ErrorFormat("LoadSettings - unable to copy settings , exception: {0}", ex);
            }
        }
예제 #2
0
 public bool Test()
 {
     try
     {
         ConverterSettingsFile settingsFile = new ConverterSettingsFile();
         string filePath;
         var    settings = new ConverterSettings();
         DefaultSettingsLocatorHelper.EnsureDefaultSettingsFilePresent(out filePath, settings);
         settingsFile.Load(filePath);
         settingsFile.Settings.StandardVersion           = _version;
         settingsFile.Settings.FB2ImportSettings.FixMode = FixOptions.UseFb2Fix;
         IFb2EPubConverterEngine converter = ConvertProcessor.CreateConverterEngine(settingsFile.Settings);
         var path = new StringBuilder();
         path.AppendFormat(@"{0}\TestFiles\Test_001.fb2", Directory.GetCurrentDirectory());
         converter.LoadAndCheckFB2Files(path.ToString());
         string outPath = Path.GetTempPath();
         converter.Save(outPath);
     }
     catch (Exception ex)
     {
         _lastException = ex;
         return(false);
     }
     return(true);
 }