Example #1
0
        public void PrintOrders(PrintJob printJob, Ticket ticket)
        {
            ticket = ObjectCloner.Clone2(ticket);
            if (printJob.ExcludeTax)
            {
                ticket.Orders.ToList().ForEach(x => x.TaxIncluded = false);
            }
            IEnumerable <Order> ti;

            switch (printJob.WhatToPrint)
            {
            case (int)WhatToPrintTypes.NewLines:
                ti = ticket.GetUnlockedOrders();
                break;

            case (int)WhatToPrintTypes.GroupedByBarcode:
                ti = GroupLinesByValue(ticket, x => x.Barcode ?? "", "1", true);
                break;

            case (int)WhatToPrintTypes.GroupedByGroupCode:
                ti = GroupLinesByValue(ticket, x => x.GroupCode ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.GroupedByTag:
                ti = GroupLinesByValue(ticket, x => x.Tag ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.LastLinesByPrinterLineCount:
                ti = GetLastOrders(ticket, printJob);
                break;

            case (int)WhatToPrintTypes.LastPaidOrders:
                ti = GetLastPaidOrders(ticket);
                break;

            default:
                ti = ticket.Orders.OrderBy(x => x.Id).ToList();
                break;
            }

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                       new Action(
                                                           delegate
            {
                try
                {
                    InternalPrintOrders(printJob, ticket, ti);
                }
                catch (Exception e)
                {
                    AppServices.LogError(e, "Yazdırma işlemi sırasında bir sorun meydana geldi. Lütfen yazıcı ve şablon ayarlarını kontrol ediniz.\r\n\r\nMesaj:\r\n" + e.Message);
                }
            }));
        }
Example #2
0
        public void PrintOrders(PrintJob printJob, Ticket ticket, Func <Order, bool> orderSelector)
        {
            ticket = ObjectCloner.Clone2(ticket);
            if (printJob.ExcludeTax)
            {
                ticket.TaxIncluded = false;
            }
            IEnumerable <Order> ti;

            switch (printJob.WhatToPrint)
            {
            case (int)WhatToPrintTypes.NewLines:
                ti = ticket.GetUnlockedOrders();
                break;

            case (int)WhatToPrintTypes.GroupedByBarcode:
                ti = GroupLinesByValue(ticket, x => x.Barcode ?? "", "1", true);
                break;

            case (int)WhatToPrintTypes.GroupedByGroupCode:
                ti = GroupLinesByValue(ticket, x => x.GroupCode ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.GroupedByTag:
                ti = GroupLinesByValue(ticket, x => x.Tag ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.LastLinesByPrinterLineCount:
                ti = GetLastOrders(ticket, printJob);
                break;

            case (int)WhatToPrintTypes.LastPaidOrders:
                ti = GetLastPaidOrders(ticket);
                break;

            default:
                ti = ticket.Orders.Where(orderSelector).OrderBy(x => x.Id).ToList();
                break;
            }

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                       new Action(
                                                           delegate
            {
                try
                {
                    InternalPrintOrders(printJob, ticket, ti);
                }
                catch (Exception e)
                {
                    _logService.LogError(e, Resources.PrintErrorMessage + e.Message);
                }
            }));
        }
        public string[] GetFormattedTicket(Ticket ticket, IEnumerable <Order> lines, PrinterTemplate printerTemplate)
        {
            var dataObject = new { Ticket = ObjectCloner.Clone2(ticket) };
            var orders     = printerTemplate.MergeLines ? MergeLines(lines.ToList()) : lines.ToList();

            ticket.Orders.Clear();
            orders.ToList().ForEach(ticket.Orders.Add);
            var content = _ticketValueChanger.GetValue(printerTemplate, ticket);

            content = UpdateExpressions(content, dataObject);
            return(content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToArray());
        }
Example #4
0
        private static IEnumerable <Order> SeparateOrders(Ticket ticket, Func <Order, bool> orderSelector)
        {
            var result = new List <Order>();

            foreach (var order in ticket.Orders.Where(orderSelector))
            {
                if (order.Quantity == 1)
                {
                    result.Add(order);
                }
                else
                {
                    for (int i = 0; i < order.Quantity; i++)
                    {
                        var copiedOrder = ObjectCloner.Clone2(order);
                        copiedOrder.Quantity = 1;
                        result.Add(copiedOrder);
                    }
                }
            }
            return(result);
        }
Example #5
0
        public void PrintTicket(Ticket ticket, PrintJob printJob, Func <Order, bool> orderSelector)
        {
            ticket = ObjectCloner.Clone2(ticket);

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                       new Action(
                                                           delegate
            {
                try
                {
                    LocalSettings.UpdateThreadLanguage();
                    var tasks = _ticketPrintTaskBuilder.GetPrintTasksForTicket(ticket, printJob, orderSelector);
                    foreach (var ticketPrintTask in tasks.Where(x => x != null && x.Printer != null && x.Lines != null))
                    {
                        Print(ticketPrintTask.Printer, ticketPrintTask.Lines);
                    }
                }
                catch (Exception e)
                {
                    _logService.LogError(e, Resources.PrintErrorMessage + e.Message);
                }
            }));
        }
        public void Print()
        {
            var ticket = _highPriority ? _ticket : ObjectCloner.Clone2(_ticket);

            AsyncPrintTask.Exec(_highPriority, () => InternalPrint(ticket, _printJob, _orderSelector), _logService);
        }