Beispiel #1
0
        public void PrintAccountTransactions(Account account, WorkPeriod workPeriod, Printer printer, string filter)
        {
            var range = _accountService.GetDateRange(filter, workPeriod);
            var summary = _accountService.GetAccountTransactionSummary(account, workPeriod, range.Start, range.End);

            var totalBalance = summary.Transactions.Sum(x => x.Debit - x.Credit).ToString(LocalSettings.ReportCurrencyFormat);

            var report = new SimpleReport("");
            report.AddParagraph("Header");
            report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo);
            report.AddParagraphLine("Header", Resources.AccountTransaction, true);
            report.AddParagraphLine("Header", "");
            report.AddParagraphLine("Header", string.Format("{0}: {1}", string.Format(Resources.Name_f, Resources.Account), account.Name));
            report.AddParagraphLine("Header", string.Format("{0}: {1}", Resources.Balance, totalBalance));
            report.AddParagraphLine("Header", "");

            report.AddColumnLength("Transactions", "15*", "35*", "15*", "15*", "20*");
            report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right);
            report.AddTable("Transactions", Resources.Date, Resources.Description, Resources.Debit, Resources.Credit, Resources.Balance);

            foreach (var ad in summary.Transactions)
            {
                report.AddRow("Transactions", ad.Date.ToShortDateString(), ad.Name, ad.DebitStr, ad.CreditStr, ad.BalanceStr);
            }

            foreach (var sum in summary.Summaries)
            {
                report.AddBoldRow("Transactions", "", sum.Caption, sum.Debit, sum.Credit, sum.Balance);
            }

            _printerService.PrintReport(report.Document, printer);
        }
Beispiel #2
0
        public void Process(Printer printer, string document)
        {
            // https://www.voipbuster.com/myaccount/sendsms.php?username=USERNAME&password=PASS&from=FROM&to=@nummer@&text=@SMS@
            var settingsObject = GetSettingsObject(printer.CustomPrinterData) as UrlPrinterSettings;
            if (settingsObject == null) return;
            var tokenChar = !string.IsNullOrEmpty(settingsObject.TokenChar) ? settingsObject.TokenChar : "@";
            var url = ReplaceValues(document, settingsObject.UrlFormat, tokenChar);
            if (url.Contains(tokenChar)) return;
            url = Uri.UnescapeDataString(url);

            var data = "";
            if (!string.IsNullOrEmpty(settingsObject.DataFormat))
            {
                data = ReplaceValues(document, settingsObject.DataFormat, tokenChar);
                if (data.Contains(tokenChar)) return;
                data = Uri.UnescapeDataString(data);
            }

            if (settingsObject.LiveMode)
            {
                var c = new WebClient();
                if (!string.IsNullOrEmpty(data))
                {
                    c.UploadDataAsync(new Uri(url), Encoding.GetEncoding(printer.CodePage).GetBytes(data));
                }
                else
                    c.DownloadDataAsync(new Uri(url));
            }
            else MessageBox.Show(url);
        }
Beispiel #3
0
 public void Process(Printer printer, string document)
 {
     var settings = GetSettingsObject(printer.CustomPrinterData) as SaveToFileSettings;
     if (settings == null) return;
     if (!string.IsNullOrEmpty(settings.FileName))
     {
         File.WriteAllText(settings.FileName, document, Encoding.GetEncoding(printer.CodePage));
     }
 }
Beispiel #4
0
 public static AbstractPrintJob CreatePrintJob(Printer printer)
 {
     if (printer.PrinterType == 1)
         return new TextPrinterJob(printer);
     if (printer.PrinterType == 2)
         return new HtmlPrinterJob(printer);
     if (printer.PrinterType == 3)
         return new PortPrinterJob(printer);
     if (printer.PrinterType == 4)
         return new DemoPrinterJob(printer);
     return new SlipPrinterJob(printer);
 }
Beispiel #5
0
 public void Process(Printer printer, string document)
 {
     var settings = GetSettingsObject(printer.CustomPrinterData) as SettingPrinterSettings;
     if (settings == null) return;
     if (!string.IsNullOrEmpty(settings.SettingName))
     {
         var setting = settings.IsLocal
             ? _settingService.ReadLocalSetting(settings.SettingName)
             : _settingService.ReadGlobalSetting(settings.SettingName);
         setting.StringValue = document;
         if (!settings.IsLocal) _settingService.SaveProgramSettings();
     }
 }
Beispiel #6
0
 public static AbstractPrintJob CreatePrintJob(Printer printer, IPrinterService printerService)
 {
     if (printer.IsTextPrinter)
         return new TextPrinterJob(printer);
     if (printer.IsHtmlPrinter)
         return new HtmlPrinterJob(printer);
     if (printer.IsPortPrinter)
         return new PortPrinterJob(printer);
     if (printer.IsDemoPrinter)
         return new DemoPrinterJob(printer);
     if (printer.IsWindowsPrinter)
         return new WindowsPrinterJob(printer);
     if (printer.IsCustomPrinter)
         return new CustomPrinterJob(printer, printerService);
     return new SlipPrinterJob(printer);
 }
        private static void SendToNotepad(Printer printer, string text)
        {
            var pcs = printer.ShareName.Split('#');
            var wname = "Edit";
            if (pcs.Length > 1) wname = pcs[1];

            var notepads = Process.GetProcessesByName(pcs[0]);

            if (notepads.Length == 0)
                notepads = Process.GetProcessesByName("notepad");

            if (notepads.Length == 0) return;

            if (notepads[0] != null)
            {
                IntPtr child = FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), wname, null);
                SendMessage(child, 0x000C, 0, text);
            }
        }
Beispiel #8
0
        public void PrintAccountScreen(AccountScreen accountScreen, WorkPeriod workperiod, Printer printer)
        {
            var accounts = _accountService.GetAccountScreenRows(accountScreen, workperiod);
            var report = new SimpleReport("");
            report.AddParagraph("Header");
            report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo);
            report.AddParagraphLine("Header", string.Format(accountScreen.Name), true);
            report.AddParagraphLine("Header", "");

            report.AddColumnLength("Transactions", "60*", "40*");
            report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Right);
            report.AddTable("Transactions", string.Format(Resources.Name_f, Resources.Account), Resources.Balance);

            foreach (var ad in accounts)
            {
                report.AddRow("Transactions", ad.Name, ad.BalanceStr);
            }

            _printerService.PrintReport(report.Document, printer);
        }
Beispiel #9
0
 public SlipPrinterJob(Printer printer)
     : base(printer)
 {
 }
Beispiel #10
0
 public PortPrinterJob(Printer printer)
     : base(printer)
 { }
Beispiel #11
0
 public ReportPrinter WithPrinter(Printer printer)
 {
     _printer = printer;
     return this;
 }
 private static bool ShouldSkipPrint(Printer printer, IEnumerable<Order> lns, PrinterTemplate prinerTemplate)
 {
     if (printer == null || string.IsNullOrEmpty(printer.ShareName) || prinerTemplate == null) return true;
     if (printer.IsCustomPrinter) return false;
     return (!lns.Any() && prinerTemplate.Template.Contains("{ORDERS}"));
 }
Beispiel #13
0
 protected AbstractPrintJob(Printer printer)
 {
     Printer = printer;
 }
        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();
        }
Beispiel #15
0
 public DemoPrinterJob(Printer printer)
     : base(printer)
 {
 }
Beispiel #16
0
 public CustomPrinterJob(Printer printer, IPrinterService printerService)
     : base(printer)
 {
     _printerService = printerService;
 }
Beispiel #17
0
 public TextPrinterJob(Printer printer)
     : base(printer)
 {
 }
Beispiel #18
0
 public void PrintObject(object item, Printer printer, PrinterTemplate printerTemplate)
 {
     var formatter = DocumentFormatters.FirstOrDefault(x => x.ObjectType == item.GetType());
     if (formatter != null)
     {
         var lines = formatter.GetFormattedDocument(item, printerTemplate);
         if (lines != null)
         {
             Print(printer, lines);
         }
     }
 }
Beispiel #19
0
        public RawPrinterJob(Printer printer)
            : base(printer)
        {

        }
Beispiel #20
0
 public void PrintReport(FlowDocument document, Printer printer)
 {
     if (printer == null || string.IsNullOrEmpty(printer.ShareName)) return;
     Print(printer, document);
 }
Beispiel #21
0
 private void Print(Printer printer, string[] document)
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
         new Action(
             delegate
             {
                 try
                 {
                     LocalSettings.UpdateThreadLanguage();
                     PrintJobFactory.CreatePrintJob(printer, this).DoPrint(document);
                 }
                 catch (Exception e)
                 {
                     _logService.LogError(e, Resources.PrintErrorMessage + e.Message);
                 }
             }));
 }
Beispiel #22
0
 public void PrintReport(FlowDocument document, Printer printer)
 {
     if (printer == null || string.IsNullOrEmpty(printer.ShareName)) return;
     PrintJobFactory.CreatePrintJob(printer).DoPrint(document);
 }
Beispiel #23
0
 public HtmlPrinterJob(Printer printer)
     : base(printer)
 {
 }
 public WindowsPrinterJob(Printer printer)
     : base(printer)
 {
 }