public PrinterMapViewModel(PrinterMap model, IMenuService menuService, IPrinterDao printerDao, ICacheService cacheService)
 {
     Model = model;
     _menuService = menuService;
     _printerDao = printerDao;
     _cacheService = cacheService;
 }
 public PrinterMapViewModel(PrinterMap model, IDepartmentService departmentService,
     IMenuService menuService, IPrinterService printerService, ICacheService cacheService)
 {
     Model = model;
     _departmentService = departmentService;
     _menuService = menuService;
     _printerService = printerService;
     _cacheService = cacheService;
 }
        public void CreateData()
        {
            CreateDefaultCurrenciesIfNeeded();

            if (!ShouldCreateData()) return;

            var screen = new ScreenMenu();
            _workspace.Add(screen);

            var ticketNumerator = new Numerator { Name = Resources.TicketNumerator };
            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator { Name = Resources.OrderNumerator };
            _workspace.Add(orderNumerator);

            _workspace.CommitChanges();

            var department = new Department
            {
                Name = Resources.Restaurant,
                ScreenMenuId = screen.Id,
                TicketNumerator = ticketNumerator,
                OrderNumerator = orderNumerator,
                IsAlaCarte = true
            };

            _workspace.Add(department);

            var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 };
            _workspace.Add(role);

            var u = new User("Administrator", "1234") { UserRole = role };
            _workspace.Add(u);

            var ticketTemplate = new PrinterTemplate();
            ticketTemplate.Name = Resources.TicketTemplate;
            ticketTemplate.HeaderTemplate = Resources.TicketTemplateHeaderValue;
            ticketTemplate.LineTemplate = Resources.TicketTempleteLineTemplateValue;
            ticketTemplate.GiftLineTemplate = Resources.TicketTemplateGiftedLineTemplateValue;
            ticketTemplate.FooterTemplate = Resources.TicketTemplateFooterValue;

            var kitchenTemplate = new PrinterTemplate();
            kitchenTemplate.Name = Resources.KitchenOrderTemplate;
            kitchenTemplate.HeaderTemplate = Resources.KitchenTemplateHeaderValue;

            kitchenTemplate.LineTemplate = Resources.KitchenTemplateLineTemplateValue;
            kitchenTemplate.GiftLineTemplate = Resources.KitchenTemplateLineTemplateValue;
            kitchenTemplate.VoidedLineTemplate = Resources.KitchenTemplateVoidedLineTemplateValue;

            kitchenTemplate.FooterTemplate = "<F>-";

            var invoiceTemplate = new PrinterTemplate();
            invoiceTemplate.Name = Resources.InvoicePrinterTemplate;
            invoiceTemplate.HeaderTemplate = Resources.InvoiceTemplateHeaderValue;
            invoiceTemplate.LineTemplate = Resources.InvoiceTemplateLineTemplateValue;
            invoiceTemplate.VoidedLineTemplate = "";
            invoiceTemplate.FooterTemplate = "<F>-";

            _workspace.Add(ticketTemplate);
            _workspace.Add(kitchenTemplate);
            _workspace.Add(invoiceTemplate);

            var printer1 = new Printer { Name = Resources.TicketPrinter };
            var printer2 = new Printer { Name = Resources.KitchenPrinter };
            var printer3 = new Printer { Name = Resources.InvoicePrinter };

            _workspace.Add(printer1);
            _workspace.Add(printer2);
            _workspace.Add(printer3);

            var t = new Terminal
            {
                IsDefault = true,
                Name = Resources.Server,
                SlipReportPrinter = printer1,
            };

            var pm1 = new PrinterMap { Printer = printer1, PrinterTemplate = ticketTemplate };
            _workspace.Add(pm1);

            var pj1 = new PrintJob
            {
                Name = Resources.PrintBill,
                ButtonText = Resources.PrintBill,
                LocksTicket = true,
                Order = 0,
                UseFromPaymentScreen = true,
                UseFromTerminal = true,
                UseFromPos = true,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
                WhenToPrint = (int)WhenToPrintTypes.Manual
            };
            pj1.PrinterMaps.Add(pm1);


            _workspace.Add(pj1);

            var pm2 = new PrinterMap { Printer = printer2, PrinterTemplate = kitchenTemplate };
            var pj2 = new PrintJob
            {
                Name = Resources.PrintOrdersToKitchenPrinter,
                ButtonText = "",
                Order = 1,
                WhatToPrint = (int)WhatToPrintTypes.NewLines,
                WhenToPrint = (int)WhenToPrintTypes.NewLinesAdded
            };
            pj2.PrinterMaps.Add(pm2);

            _workspace.Add(pj2);

            t.PrintJobs.Add(pj1);
            t.PrintJobs.Add(pj2);
            _workspace.Add(t);

            ImportMenus(screen);
            ImportTables(department);

            _workspace.CommitChanges();
            _workspace.Dispose();
        }
 private void PrintOrderLines(Ticket ticket, IEnumerable<Order> lines, PrinterMap p)
 {
     Debug.Assert(lines != null, "lines != null");
     var lns = lines.ToList();
     if (!lns.Any()) return;
     if (p == null)
     {
         MessageBox.Show(Resources.GeneralPrintErrorMessage);
         _logService.Log(Resources.GeneralPrintErrorMessage);
         return;
     }
     var printer = PrinterById(p.PrinterId);
     var prinerTemplate = PrinterTemplateById(p.PrinterTemplateId);
     if (printer == null || string.IsNullOrEmpty(printer.ShareName) || prinerTemplate == null) return;
     var ticketLines = _ticketFormatter.GetFormattedTicket(ticket, lns, prinerTemplate);
     PrintJobFactory.CreatePrintJob(printer).DoPrint(ticketLines);
 }
 public PrinterMapViewModel(PrinterMap model, IWorkspace workspace)
 {
     Model = model;
     _workspace = workspace;
 }
Exemple #6
0
 private static void PrintOrderLines(Ticket ticket, IEnumerable<TicketItem> lines, PrinterMap p)
 {
     if (p == null)
     {
         MessageBox.Show("Yazdırma sırasında bir problem tespit edildi: Yazıcı Haritası null");
         AppServices.Log("Yazıcı Haritası NULL problemi tespit edildi.");
         return;
     }
     if (!string.IsNullOrEmpty(p.PrinterTemplate.LineTemplate) && lines.Count() <= 0) return;
     if (p.Printer == null || string.IsNullOrEmpty(p.Printer.ShareName) || p.PrinterTemplate == null) return;
     var ticketLines = TicketFormatter.GetFormattedTicket(ticket, lines, p.PrinterTemplate);
     PrintJobFactory.CreatePrintJob(p.Printer).DoPrint(ticketLines);
 }
 private TicketPrintTask GetPrintTask(Ticket ticket, IEnumerable<Order> orders, PrinterMap map)
 {
     Debug.Assert(orders != null, "orders != null");
     var lns = orders.ToList();
     if (map == null)
     {
         MessageBox.Show(Resources.GeneralPrintErrorMessage);
         _logService.Log(Resources.GeneralPrintErrorMessage);
         return null;
     }
     var printer = PrinterById(map.PrinterId);
     var prinerTemplate = PrinterTemplateById(map.PrinterTemplateId);
     if (printer == null || string.IsNullOrEmpty(printer.ShareName) || prinerTemplate == null) return null;
     if (!printer.IsCustomPrinter && !lns.Any()) return null;
     var ticketLines = _ticketFormatter.GetFormattedTicket(ticket, lns, prinerTemplate);
     return new TicketPrintTask { Lines = ticketLines, Printer = printer };
 }
 private TicketPrintTask GetPrintTask(Ticket ticket, IEnumerable<Order> orders, PrinterMap map)
 {
     Debug.Assert(orders != null, "orders != null");
     var lns = orders.ToList();
     if (map == null)
     {
         MessageBox.Show(Resources.GeneralPrintErrorMessage);
         _logService.Log(Resources.GeneralPrintErrorMessage);
         return null;
     }
     var printer = PrinterById(map.PrinterId);
     var prinerTemplate = PrinterTemplateById(map.PrinterTemplateId);
     if (ShouldSkipPrint(printer, lns, prinerTemplate)) return null;
     var ticketLines = _ticketFormatter.GetFormattedTicket(ticket, lns, prinerTemplate);
     return new TicketPrintTask { Lines = ticketLines, Printer = printer };
 }