protected override Boolean BlockRemoved() { try { DisplayAdapter.Cashier.Show(PosMessage.CONNECTING_TO_PRINTER); String port = PosConfiguration.Get("PrinterComPort"); cr.SetPrinterPort(port); if (cr.State is PrinterConnectionError) { return(false); } cr.Log.Success("Connected to printer. {0}", port); cr.CheckDocumentAfterReConnected(); return(true); } catch (BlockingException) { cr.State = PrinterBlockingError.Instance(); return(false); } catch (PowerFailureException) { cr.Void(); } catch (EJException ej) { cr.State = ElectronicJournalError.Instance(ej); } catch (Exception e) { errorMessage = new Error(e).Message; DisplayAdapter.Cashier.Show(errorMessage); cr.Log.Error("Error in PrinterConnectionError: {0}", errorMessage); } return(false); }
private static IState AcceptManager(String mngrPwd) { DisplayAdapter.Cashier.Show("YÖNETÝCÝ GÝRÝÞÝ\nYAPILIYOR..."); System.Threading.Thread.Sleep(500); try { manager = cr.Printer.SignInCashier(managerId, mngrPwd); cr.CurrentManager = manager; //Settings should be reloaded on first cashier login on if (totalLogins++ == -1 || manager.AuthorizationLevel == AuthorizationLevel.P) { //compare currents settings file with printer CashRegister.LoadCurrentSettings(); //and check new settings try { cr.LastZReportDate = cr.Printer.LastZReportDate; CashRegister.LoadNewSettings(); } catch (FileNotFoundException) { //this is not a problem } catch (Exception) { //but think about this: //if new program file is invalid when program starts, what should be done? } //program start and after on each Z report ReportMenu.OnZReportComplete += new ZEventHandler(ResetLoginCount); } cr.State = InstanceAfterMngr(); } catch (FMNewException fmne) { cr.Log.Error(fmne); int fiscalId = int.Parse(PosConfiguration.Get("FiscalId").Substring(2, 8)); cr.State = States.EnterInteger.Instance(PosMessage.START_FM, fiscalId, new StateInstance <int>(AcceptFiscalId), new StateInstance(Instance)); } catch (MissingCashierException mce) { cr.Log.Error(mce); int loginAttemptCount = int.Parse(mce.Message); if (loginAttemptCount == cr.MAX_PASSWORD_TRY) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.MANAGER_LOGIN_LOCKED, new StateInstance(Instance))); } else { cr.State = States.ConfirmCashier.Instance(new Confirm(String.Format("{0}\n{1}: {2}", PosMessage.INVALID_PASS_ENTRY, PosMessage.RIGHT_TO_REST, (5 - loginAttemptCount).ToString()), new StateInstance(Instance))); } } catch (CashierAutorizeException cae) { cr.Log.Error(cae); cr.State = States.ConfirmCashier.Instance(new Confirm(PosMessage.NO_AUTHORIZATION_FOR_LOAD_SETTINGS, new StateInstance(LogoutManager), new StateInstance(Instance))); } catch (LimitExceededOrZRequiredException lzre) { cr.Log.Error(lzre); cr.State = States.ConfirmCashier.Instance(new Error( lzre, new StateInstance(PrintZReport), new StateInstance(EscapeZReport) )); } catch (BlockingException be) { cr.Log.Error(be); cr.State = PrinterBlockingError.Instance(new Error(be)); } catch (ZRequiredException zre) { cr.Log.Error(zre); if (zre.ErrorCode == 134) { cr.State = States.ConfirmCashier.Instance(new Error( zre, new StateInstance(SendInterrupt), new StateInstance(EscapeZReport) )); } else { cr.State = States.ConfirmCashier.Instance(new Error( zre, new StateInstance(PrintZReport), new StateInstance(EscapeZReport) )); } } catch (Exception ex) { if (tryCount == 0) { tryCount++; return(Instance()); } cr.Log.Error(ex); cr.State = States.ConfirmCashier.Instance(new Error(ex, new StateInstance(Instance))); } finally { managerId = -1; } return(cr.State); }
protected override Boolean BlockRemoved() { IPrinterResponse response; try { response = cr.Printer.CheckPrinterStatus(); //if (Str.Contains(response.Detail, PosMessage.EJ_FULL)) //{ // throw new EJFullException(); //} DisplayAdapter.Cashier.Show(PosMessage.CONNECTING_TO_PRINTER); String port = PosConfiguration.Get("ReceiptPrinterComPort"); cr.SetPrinterPort(port); response = cr.Printer.CheckPrinterStatus(); //if (Str.Contains(response.Detail, PosMessage.EJ_FULL)) //{ // throw new EJFullException(); //} cr.Log.Success("Connected to printer. {0}", port); if (cr.Document.Items.Count > 0 && activeEJ != "") { throw EJEXCEPTION; } return(true); } catch (EJFullException) { throw new EJFullException(); } catch (BlockingException) { cr.State = PrinterBlockingError.Instance(); return(false); } catch (EJException eje) { cr.State = Instance(eje); } catch (PowerFailureException pfe) { try { Recover.RecoverPowerFailure(pfe); return(true); } catch (EJException eje) { cr.State = Instance(eje); } } catch (PrinterException pe) { Error e = new Error(pe); DisplayError(e.Message); cr.Log.Error(e.Message); } catch (Exception e) { DisplayError(PosMessage.EJ_ERROR_OCCURED); cr.Log.Error(e.Message); } return(false); }