Exemple #1
0
        public bool Run()
        {
            _logger.Info("Launched printjob with PrintFile command.");

            if (String.IsNullOrEmpty(PrintFile))
            {
                _logger.Error("PrintFile Parameter has no argument");
                return(false);
            }

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

            var printFileAssistant = new PrintFileAssistant(PrinterName);

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

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

            return(true);
        }
Exemple #2
0
        /// <summary>
        ///     Launches a print job for all dropped files that can be printed.
        /// </summary>
        public static void PrintPrintableFiles(IEnumerable <string> droppedFiles)
        {
            var launchPrintAll     = false;
            var printFileAssistant = new PrintFileAssistant();

            foreach (var file in droppedFiles)
            {
                if (!IsPrintFile(file))
                {
                    continue;
                }

                if (!printFileAssistant.AddFile(file))
                {
                    Logger.Warn("The file " + file + " is not printable.");
                    continue;
                }

                launchPrintAll = true;
            }

            if (launchPrintAll)
            {
                printFileAssistant.PrintAll();
            }
        }