Exemplo n.º 1
0
        public bool PrintReport(PrinterJob printerJob)
        {
            Logger.LogInfo(Message.PrintingPrintReport, printerJob.ReportType);
            var eventArgs = new PrintReportEventArgs(printerJob);

            try
            {
                PrintReportStarting.RaiseEvent(this, eventArgs);
                ExecutePrinterJob(printerJob);
                return(true);
            }
            catch (ThreadAbortException)
            {
                return(false);
            }
            catch (Exception ex)
            {
                if (ex is CupsFailureException)
                {
                    CancelJobs(_findPrinterName);
                    EnablePrinter(_findPrinterName);
                }
                Logger.LogError(Message.PrintingError, ex, printerJob.FilePath);
                return(false);
            }
            finally
            {
                PrintReportFinished.RaiseEvent(this, eventArgs);
            }
        }
Exemplo n.º 2
0
 public bool PrintReport(PrinterJob printerJob)
 {
     Logger.LogInfo(Message.PrintingPrintReport, printerJob.ReportType);
     var eventArgs = new PrintReportEventArgs(printerJob);
     try
     {
         PrintReportStarting.RaiseEvent(this, eventArgs);
         ExecutePrinterJob(printerJob);
         return true;
     }
     catch (ThreadAbortException)
     {
         return false;
     }
     catch (Exception ex)
     {
         if (ex is CupsFailureException)
         {
             CancelJobs(_findPrinterName);
             EnablePrinter(_findPrinterName);
         }
         Logger.LogError(Message.PrintingError, ex, printerJob.FilePath);
         return false;
     }
     finally
     {
         PrintReportFinished.RaiseEvent(this, eventArgs);
     }
 }