예제 #1
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);
 }
예제 #2
0
        private void backgroundWorkerProcess_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            object[]         parameters = (object[])e.Argument;
            ConvertProcessor processor  = (ConvertProcessor)parameters[0];

            processor.PerformConvertOperation((List <string>)parameters[1], null);
        }
예제 #3
0
 /// <summary>
 /// Processes single option command like settings ort registration that does not require actual converting
 /// </summary>
 /// <param name="singleOptionCommand">the option command to process</param>
 /// <returns>true if proper known command was processed, false if unrecognized command</returns>
 private static bool ProcessSingleOptionCommand(string singleOptionCommand)
 {
     if ((singleOptionCommand.ToLower() == "/settings") || singleOptionCommand.ToLower() == "-settings")
     {
         ConvertProcessor.ShowSettingsDialog(null);
         return(true);
     }
     return(false);
 }
예제 #4
0
        private void ConvertFiles(string[] files)
        {
            _processor.LoadSettings();
            _processor.ProcessorSettings.Settings.OutPutPath    = comboBoxDestination.Text;
            _processor.ProcessorSettings.Settings.ResourcesPath = ConvertProcessor.GetResourcesPath();
            _processor.ProcessorSettings.ProgressCallbacks      = new ProgressUpdater(this);
            List <string> allFiles = SelectValidFiles(files);

            backgroundWorkerProcess.RunWorkerAsync(new object[] { _processor, allFiles, this });
        }
예제 #5
0
 static void Main(string[] args)
 {
     SetupLogAndData();
     if (args.Length > 0)
     {
         List <string> options    = new List <string>();
         List <string> fileParams = new List <string>();
         foreach (var param in args)
         {
             if (IsOptionParameter(param))
             {
                 options.Add(param);
             }
             else
             {
                 fileParams.Add(param);
             }
         }
         if (fileParams.Count == 0)
         {
             if (options.Count == 1)
             {
                 // Process single option command (registration etc.) , exit if it's a valid command
                 if (ProcessSingleOptionCommand(options[0]))
                 {
                     return;
                 }
             }
             Console.WriteLine(@"Input file name missing. Exiting.");
             _log.Error("Input file name missing.");
             if (_log.IsInfoEnabled)
             {
                 _log.Info("Application [FB2EPUB] End");
             }
             return;
         }
         var processor = new ConvertProcessor();
         PreProcessParameters(options, processor.ProcessorSettings);
         ProcessSettings(processor);
         ProcessParameters(options, processor.ProcessorSettings);
         Console.WriteLine(@"Loading {0}...", fileParams[0]);
         var filesInMask = new List <string>();
         processor.DetectFilesToProcess(fileParams, ref filesInMask);
         string outputFileName = (fileParams.Count > 1)?fileParams[1]:null;
         processor.PerformConvertOperation(filesInMask, outputFileName);
         Console.WriteLine(@"Done.");
     }
     else
     {
         ShowHelp();
     }
     _log.Debug("Application [FB2EPUB] End");
 }
예제 #6
0
        private void toolStripMenuItemConvSettings_Click(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                OnButtonPressedCallback d = toolStripMenuItemConvSettings_Click;
                Invoke(d, new object[] { sender, e });
                return;
            }

            if (ConvertProcessor.ShowSettingsDialog(this))
            {
                LoadPaths();
                comboBoxDestination.SelectedIndex = 0;
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Console.WriteLine(@"  _____                     _     _____           _           ");
            Console.WriteLine(@" / ____|   Sitecore        | |   |_   _|         | |          ");
            Console.WriteLine(@"| (___   ___  __ _ _ __ ___| |__   | |  _ __   __| | _____  _ ");
            Console.WriteLine(@" \___ \ / _ \/ _` | '__/ __| '_ \  | | | '_ \ / _` |/ _ \ \/ /");
            Console.WriteLine(@" ____) |  __/ (_| | | | (__| | | |_| |_| | | | (_| |  __/>  < ");
            Console.WriteLine(@"|_____/ \___|\__,_|_|  \___|_| |_|_____|_| |_|\__,_|\___/_/\_\");
            Console.WriteLine(@"                                                   Builder    ");

            var parser = new Parser(s => {
                s.HelpWriter    = Console.Error;
                s.CaseSensitive = false;
            });

            parser
            .ParseArguments <DeployOptions, SetupOptions, ConvertOptions, IndexingOptions, RetryOptions, RemoveOptions>(args)
            .WithParsed <DeployOptions>(o => DeployProcessor.RunProcess(o))
            .WithParsed <SetupOptions>(o => SetupProcessor.RunProcess(o))
            .WithParsed <ConvertOptions>(o => ConvertProcessor.RunProcess(o))
            .WithParsed <IndexingOptions>(o => IndexingProcessor.RunProcess(o))
            .WithParsed <RetryOptions>(o => RetryProcessor.RunProcess(o))
            .WithParsed <RemoveOptions>(o => RemoveProcessor.RunProcess(o));
        }
예제 #8
0
 private static void ProcessSettings(ConvertProcessor processor)
 {
     processor.LoadSettings();
     processor.ProcessorSettings.Settings.ResourcesPath = ConvertProcessor.GetResourcesPath();
 }