Example #1
0
        //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);
        }
Example #2
0
        private bool ProcessingPrint(string printerName, ICashVoucherItem item)
        {
            //var barcode = PrepareBarcode(CurrentTicketNumber);
            var barcode = BarcodeHelper.GetBarcode(CurrentTicketNumber, CurrentRollInfo);
            var printed = SendToPrint(printerName, item, barcode);

            CreateChequeRow(printed.IsSuccess, DateTime.Now, barcode, item.AttractionInfo);
            if (item.Count > 1)
            {
                item.Count--;
            }
            else
            {
                item.IsPrinted = printed.IsSuccess;
            }

            var isSuccessStr = printed.IsSuccess ? "успешна" : "не успешна";
            var isErrorStr   = printed.HasError ? "Были ошибки" : "Ошибок не было";
            var isChangeStr  = printed.IsNeedNewTicketRoll ? "требовалась" : "не требовалась";

            Log.Debug("Печать {0}; {1}; Смена рулона билетов {2}.", isSuccessStr, isErrorStr, isChangeStr);

            if (!printed.IsNeedNewTicketRoll)
            {
                return(!printed.HasError);
            }

            NeedChangeRoll();
            return(false);
        }