//private static String PrepareBarcode(long num) //{ // var curTicketNum = num.ToString(CultureInfo.InvariantCulture); // var curTicketLength = curTicketNum.Length; // return curTicketLength > 13 // ? curTicketNum.Remove(13, curTicketLength) // : curTicketNum.Insert(curTicketLength - 1, "0000000000000".Remove(0, 13 - curTicketLength)); //} private PrintResult SendToPrint(String printerName, ICashVoucherItem item, String barcode) { IsShowErrorMessage = false; try { #if !DEBUG || PRINT_DEBUG if (!PrinterDeviceHelper.IsPlug(printerName)) { throw new Exception("Принтер {0} не подключен!".F(printerName)); } var pathToTemplate = SettingsStore.Load().PathToTemplate; RawPrinterHelper.SendStringToPrinter(printerName, ZebraHelper.LoadAndFillTemplate(pathToTemplate, CurrentDateTime.ToString("dd.MM.yyyy HH:mm:ss"), item.Price.ToString(CultureInfo.InvariantCulture), item.PrintTitle, "", barcode)); #endif } catch (Exception e) { PrintTroubleToLog(e); IsShowErrorMessage = true; RightErrorMessage = e.Message; return(PrintResult.Failure); } finally { CurrentTicketNumber++; TicketsLeft--; } if (TicketsLeft <= 25) { RightErrorMessage = "Заканчиваются билеты! Осталось: {0}".F(TicketsLeft); IsShowErrorMessage = true; } return(TicketsLeft > 0 ? PrintResult.Success : PrintResult.SuccessAndNeedNewTicketRoll); }
private void ResolvePaymentViewModel() { IsShowErrorMessage = false; #if !DEBUG || PRINT_DEBUG if (!PrinterDeviceHelper.IsPlug(PrinterName)) { var message = "Принтер {0} не подключен!".F(PrinterName); Log.Debug(message); RightErrorMessage = message; IsShowErrorMessage = true; return; } #endif IsEnabled = false; var paymentViewModel = ObserveWrapperHelper.GetInstance().Resolve <PaymentViewModel>(); paymentViewModel.Total = Total; paymentViewModel.Show(); paymentViewModel.PaymentReached += delegate(object sender, PaymentEventArgs args) { IsEnabled = true; if (!args.PaymentType.HasValue) { return; } _cheque.MoneyType = (short)args.PaymentType.Value; Log.Debug("Чек оплачен {0}.", args.PaymentType.Value.DescriptionOf()); _chequeRows = new List <ChequeRow>(); PrintCashVoucherToLog(_cashVoucherToPrint); PrintTickets(PrinterName); }; }