private void AddEntryCommand_Execute(object parameter)
        {
            PrintingQueue evmNew = new PrintingQueue();

            this.Entries.Add(evmNew);
            this.SelectedEntry = evmNew;
        }
        private void PrintFaxes(IJobContext context, Operation operation)
        {
            if (!context.Parameters.ContainsKey("ArchivedFilePath") || !context.Parameters.ContainsKey("ImagePath"))
            {
                Logger.Instance.LogFormat(LogType.Trace, this, Resources.NoPrintingPossible);
                return;
            }

            FileInfo sourceImageFile = new FileInfo((string)context.Parameters["ImagePath"]);

            if (!sourceImageFile.Exists)
            {
                Logger.Instance.LogFormat(LogType.Error, this, Resources.FileNotFound, sourceImageFile.FullName);
                return;
            }

            string imagePath = (string)context.Parameters["ImagePath"];

            foreach (string queueName in _settings.GetSetting("AlarmSourcePrinterJob", "PrintingQueueNames").GetStringArray())
            {
                var           queues = _settings.GetSetting(SettingKeys.PrintingQueuesConfiguration).GetValue <PrintingQueuesConfiguration>();
                PrintingQueue pq     = queues.GetPrintingQueue(queueName);
                if (pq == null || !pq.IsEnabled)
                {
                    continue;
                }

                PrintFaxTask task = new PrintFaxTask();
                task.ImagePath = imagePath;
                task.Print(pq);
            }
        }
        private void AddEntryCommand_Execute(object parameter)
        {
            PrintingQueue evmNew = new PrintingQueue();

            this.Entries.Add(evmNew);
            this.SelectedEntry = evmNew;
        }
Esempio n. 4
0
        /// <summary>
        /// Executes a printing operation using a specific <see cref="PrintingQueue"/> and action.
        /// </summary>
        /// <param name="queue">The printing queue to use. Must not be null.</param>
        /// <param name="printAction">The printing action. Must not be null.</param>
        /// <param name="state">An optional, initial user state to hand over to the delegate.</param>
        public static void Print(PrintingQueue queue, PrintDelegate printAction, object state)
        {
            Assertions.AssertNotNull(queue, "queue");
            Assertions.AssertNotNull(printAction, "printAction");

            if (!queue.IsValid)
            {
                Logger.Instance.LogFormat(LogType.Warning, typeof(GdiPrinter), Resources.GdiPrinterPrintingQueueIsNotValid, queue.Name);
                return;
            }

            PrintDocument doc = new PrintDocument();
            if (!queue.IsDefaultPrinter)
            {
                doc.PrinterSettings.PrinterName = queue.GetPrinterName();
            }

            int desiredCopyCount = queue.CopyCount;
            int maxSupportedCopyCount = doc.PrinterSettings.MaximumCopies;
            int requiredPrintIterations = 1;

            if (desiredCopyCount <= maxSupportedCopyCount && !queue.UseAlternativeCopyingMethod)
            {
                doc.PrinterSettings.Copies = (short)desiredCopyCount;
            }
            else
            {
                //Check of the user has requested using this way of printing copies!
                if (!queue.UseAlternativeCopyingMethod)
                {
                    // It appears that some printers don't support the CopyCount-feature (notably Microsoft XPS Writer or perhaps PDF-Writers in general?).
                    // In this case we simply repeat printing until we have reached our copy count.
                    Logger.Instance.LogFormat(LogType.Warning, typeof(GdiPrinter), Resources.UsedPrinterDoesNotSupportThatMuchCopies, maxSupportedCopyCount, desiredCopyCount);
                }

                requiredPrintIterations = desiredCopyCount;
            }

            for (int i = 0; i < requiredPrintIterations; i++)
            {
                Logger.Instance.LogFormat(LogType.Trace, typeof(GdiPrinter), Resources.PrintIterationStart, i + 1, requiredPrintIterations);

                PrintTask task = new PrintTask();
                try
                {
                    task.Print(doc, printAction, state);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, typeof(GdiPrinter), Resources.GdiPrinterPrintTaskException);
                    Logger.Instance.LogException(typeof(GdiPrinter), ex);
                }

                Logger.Instance.LogFormat(LogType.Trace, typeof(GdiPrinter), Resources.PrintIterationEnd);
            }
        }
        private void PrintWithQueue(PrintingQueue pq, Operation operation)
        {
            Thread printThread = new Thread(() => GdiPrinter.Print(pq, GdiPrinterPrintAction));

            // STA needed because of the use of WebBrowser (WinForms).
            printThread.SetApartmentState(ApartmentState.STA);
            printThread.Start();
            // Intentionally synchronize thread until its done.
            printThread.Join();
        }
Esempio n. 6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            using (ApplicationDbContext appc = new ApplicationDbContext())
            {
                Queue = new PrintingQueue(appc.Prints.Where(x => !x.Stopped && !x.Finished), new PrintComparer());
            }
        }
        private void PrintOperation(Operation operation)
        {
            foreach (string queueName in _settings.GetSetting(SettingKeysJob.PrintingQueueNames).GetStringArray())
            {
                PrintingQueuesConfiguration queues = _settings.GetSetting(SettingKeys.PrintingQueuesConfiguration).GetValue <PrintingQueuesConfiguration>();

                PrintingQueue pq = queues.GetPrintingQueue(queueName);
                if (pq == null || !pq.IsEnabled)
                {
                    continue;
                }

                PrintWithQueue(pq, operation);
            }
        }
Esempio n. 8
0
        private void ImportEntryCommand_Execute(object parameter)
        {
            SystemPrintingQueues dialog = new SystemPrintingQueues();

            dialog.ShowDialog();
            var dataModel = (dialog.DataContext as SystemPrintingQueuesViewModel);

            if (dataModel == null || !dataModel.Ok)
            {
                return;
            }
            var           item   = dataModel.Selection;
            PrintingQueue evmNew = new PrintingQueue
            {
                PrinterName = item,
                Name        = item
            };

            Entries.Add(evmNew);
            SelectedEntry = evmNew;
        }
            internal void Print(PrintingQueue queue)
            {
                _pages = SplitMultipageTiff(ImagePath);

                ThreadPool.QueueUserWorkItem(w => GdiPrinter.Print(queue, GdiPrinterPrintAction));
            }
Esempio n. 10
0
 /// <summary>
 /// Executes a printing operation using a specific <see cref="PrintingQueue"/> and action.
 /// </summary>
 /// <param name="queue">The printing queue to use. Must not be null.</param>
 /// <param name="printAction">The printing action. Must not be null.</param>
 public static void Print(PrintingQueue queue, PrintDelegate printAction)
 {
     Print(queue, printAction, null);
 }
 private void PrintWithQueue(PrintingQueue pq, Operation operation)
 {
     Thread printThread = new Thread(() => GdiPrinter.Print(pq, GdiPrinterPrintAction));
     // STA needed because of the use of WebBrowser (WinForms).
     printThread.SetApartmentState(ApartmentState.STA);
     printThread.Start();
     // Intentionally synchronize thread until its done.
     printThread.Join();
 }
Esempio n. 12
0
            internal void Print(PrintingQueue queue)
            {
                _pages = SplitMultipageTiff(ImagePath);

                ThreadPool.QueueUserWorkItem(w => GdiPrinter.Print(queue, GdiPrinterPrintAction));
            }
        void IStringSettingConvertible.Convert(string settingValue)
        {
            XDocument doc = XDocument.Parse(settingValue);

            foreach (XElement pqe in doc.Root.Elements("PrintingQueue"))
            {
                // Sanity-check name first to avoid exception.
                string pqName = pqe.TryGetAttributeValue("Name", null);
                if (string.IsNullOrWhiteSpace(pqName))
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, Resources.PrintingQueueParseErrorNameIsInvalid);
                    continue;
                }

                PrintingQueue pq = new PrintingQueue();
                pq.Name = pqName;

                pq.PrintServer = pqe.TryGetAttributeValue("PrintServer", null);
                pq.PrinterName = pqe.TryGetAttributeValue("PrinterName", null);
                pq.IsEnabled = pqe.TryGetAttributeValue("IsEnabled", true);
                pq.UseAlternativeCopyingMethod = pqe.TryGetAttributeValue("UseAlternativeCopyingMethod", false);

                // Sanity-check copy count to avoid exception.
                int pqCopyCount = pqe.TryGetAttributeValue("CopyCount", 1);
                if (pqCopyCount < 1)
                {
                    pqCopyCount = 1;
                    Logger.Instance.LogFormat(LogType.Warning, this, Resources.PrintingQueueCopyCountMustBeGreaterThanZero, pqCopyCount);
                }
                pq.CopyCount = pqCopyCount;

                this.Entries.Add(pq);
            }
        }