public void SetStatusBar() { IPrinterHandler printerHandler = null; try { printerHandler = PrinterController.Instance.GetPrinter(); } catch (Exception) { // ignored } if (printerHandler != null) { statusBarLabel.Text = string.Format("{0} - {1} - {2}", printerHandler.PrinterConfig.Manufacturer, printerHandler.PrinterConfig.Name, printerHandler.PrinterConfig.ConnectionType); statusBarLabel.ForeColor = Color.Black; } else { statusBarLabel.Text = AppStrings.ErrorMessage_Printer_Rule_PrinterNotDefined; statusBarLabel.ForeColor = Color.Red; } }
public void PrintCampaign(Campaign campaign, Enumerations.TriggerType printTriggerType) { try { if (campaign == null) { throw new ArgumentNullException(); } Printer = PrinterController.Instance.GetPrinter(); Voucher voucher; GeneralUtility.DateTime = DateTime.Now; HandleVoucher(campaign, out voucher); HandlePrinting(campaign, voucher); HandleStatistic("Printing", new Dictionary <string, string> { { "CampaignType", campaign.CampaignType.ToString() }, { "Trigger", printTriggerType.ToString() } }); } catch (Exception ex) { LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message); throw; } }
public IPrinterHandler GetPrinter() { try { if (Printer != null) { return(Printer); } var printer = GetList().FirstOrDefault(); Printer = GetPrinterHandlerByPrinter(printer); return(Printer); } catch (Exception ex) { LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message); throw; } }
public void PrintTestPage(IPrinterHandler printerHandler) { try { if (printerHandler == null) { throw new ArgumentNullException(); } printerHandler.InitCommunication(); printerHandler.SetHeader(true); printerHandler.SetText(AppStrings.InfoMessage_Printer_Info_PrintTestPage, 12, FontStyle.Bold, 60, Enumerations.TextAlignmentType.Center); printerHandler.SetText(string.Format("{0} - {1} - {2}", printerHandler.PrinterConfig.Manufacturer, printerHandler.PrinterConfig.Name, printerHandler.PrinterConfig.ConnectionType), 10, FontStyle.Regular, 60, Enumerations.TextAlignmentType.Center); printerHandler.SetFooter(); printerHandler.SetCutPaper(Enumerations.CutType.Completo); printerHandler.CloseCommunication(); printerHandler.ExecuteCommands(); HandleStatistic("TestPrinter", new Dictionary <string, string> { { "Printer", string.Format("{0} - {1} - {2}", printerHandler.PrinterConfig.Manufacturer, printerHandler.PrinterConfig.Name, printerHandler.PrinterConfig.ConnectionType) } }); } catch (Exception ex) { LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message); throw; } }
public new void Load() { IsBusy = true; try { PrinterHandler = PrinterController.Instance.GetPrinter(); } catch (Exception) { // ignored } CompatiblePrintersList = PrinterModelController.Instance.GetList().ToList(); LoadPrinters(); LoadCompatiblePrinters(); gbxPrinterConfig.Visible = true; IsBusy = false; }
public override dynamic Save(Printer entity, int?commandTimeout = null) { try { if (entity == null) { throw new ArgumentNullException(); } Printer = null; var license = AppLicenseController.Instance.ActiveLicense; var licenseKey = license != null ? license.Key : string.Empty; var timeStamp = DateTime.Now; var action = "SetupPrinter"; var value = new Dictionary <string, string> { { "Printer", string.Format("{0} - {1} - {2}", entity.Manufacturer, entity.Name, entity.ConnectionType) } }.ToJSON(); var statistic = new Statistic { License = licenseKey, TimeStamp = timeStamp, Action = action, Value = value }; StatisticController.Instance.Insert(statistic); return(base.Save(entity, commandTimeout)); } catch (Exception ex) { LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message); throw; } }
public static IPrinterHandler GetPrinter() { try { IPrinterHandler oPrinter = null; var sManufacturer = AppConfigUtility.sPrinterManufacturer; var sName = AppConfigUtility.sPrinterName; var sModel = AppConfigUtility.sPrinterModel; var oConnectionType = AppConfigUtility.sPrinterConnectionType.ToEnum <Enumerations.ConnectionType>(); switch (sManufacturer) { case "Bematech": oPrinter = new BematechController(new Printer { Manufacturer = sManufacturer, Name = sName, Model = sModel, ConnectionType = oConnectionType } ); break; } if (oPrinter == null) { throw new ArgumentNullException("PrinterHandler"); } return(oPrinter); } catch (Exception ex) { LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message); throw; } }