Exemplo n.º 1
0
        public override ExitCode Run()
        {
            _logger.Info("Launched printjob with PrintFile command.");

            if (string.IsNullOrEmpty(PrintFile))
            {
                _logger.Error("PrintFile Parameter has no argument");
                return(ExitCode.PrintFileParameterHasNoArgument);
            }

            if (!File.Exists(PrintFile))
            {
                _logger.Error("The file \"{0}\" does not exist!", PrintFile);
                return(ExitCode.PrintFileDoesNotExist);
            }

            _settingsManager.LoadAllSettings();

            _printFileHelper.PdfCreatorPrinter = GetValidPrinterName();

            if (!_printFileHelper.AddFile(PrintFile))
            {
                _logger.Warn("The file \"{0}\" is not printable!", PrintFile);
                return(ExitCode.PrintFileNotPrintable);
            }

            //todo: Test
            // Ignore Profile if Printer is set.
            // After the printing we can't determine if the printer was selected by the user or was the primary printer
            var profile = "";

            if (string.IsNullOrWhiteSpace(AppStartParameters.Printer))
            {
                profile = AppStartParameters.Profile;
            }
            _storedParametersManager.SaveParameterSettings(AppStartParameters.OutputFile, profile, PrintFile);

            if (!_printFileHelper.PrintAll())
            {
                _logger.Error("The file \"{0}\" could not be printed!", PrintFile);
                return(ExitCode.PrintFileCouldNotBePrinted);
            }

            return(ExitCode.Ok);
        }
Exemplo n.º 2
0
        public override ExitCode Run()
        {
            _logger.Info("Launched printjob with PrintFile command.");

            if (string.IsNullOrEmpty(PrintFile))
            {
                _logger.Error("PrintFile Parameter has no argument");
                return(ExitCode.PrintFileParameterHasNoArgument);

                ;
            }

            if (!File.Exists(PrintFile))
            {
                _logger.Error("The file \"{0}\" does not exist!", PrintFile);
                return(ExitCode.PrintFileDoesNotExist);
            }

            _settingsManager.LoadPdfCreatorSettings();

            _printFileHelper.PdfCreatorPrinter = GetValidPrinterName();

            if (!_printFileHelper.AddFile(PrintFile))
            {
                _logger.Warn("The file \"{0}\" is not printable!", PrintFile);
                return(ExitCode.PrintFileNotPrintable);
            }

            if (!_printFileHelper.PrintAll())
            {
                _logger.Error("The file \"{0}\" could not be printed!", PrintFile);
                return(ExitCode.PrintFileCouldNotBePrinted);
            }

            return(ExitCode.Ok);
        }