public static bool PrintFinanceDocumentPayment(Window pSourceWindow, sys_configurationprinters pPrinter, fin_documentfinancepayment pDocumentFinancePayment) { bool result = false; if (!LicenceManagement.IsLicensed || !LicenceManagement.CanPrint) { Utils.ShowMessageTouchErrorUnlicencedFunctionDisabled(pSourceWindow, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_printing_function_disabled")); return(false); } sys_configurationprinters printer = (pPrinter != null) ? pPrinter : GlobalFramework.LoggedTerminal.Printer; try { //Notification : Show Message TouchTerminalWithoutAssociatedPrinter and Store user input, to Show Next Time(Yes) or Not (No) if (printer == null) { Utils.ShowMessageTouchTerminalWithoutAssociatedPrinter(pSourceWindow, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_type_title_rc")); } else { //ProtectedFiles Protection bool validFiles = true; string extraMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_protected_files_invalid_files_detected_print_document_ignored"), pDocumentFinancePayment.PaymentRefNo); switch (PrintRouter.GetPrinterToken(printer.PrinterType.Token)) { //ThermalPrinter : Ticket Files case "THERMAL_PRINTER_WINDOWS": case "THERMAL_PRINTER_LINUX": case "THERMAL_PRINTER_SOCKET": break; //FastReport : Report Files case "GENERIC_PRINTER_WINDOWS": case "REPORT_EXPORT_PDF": //validFiles = (IsValidProtectedFile(FrameworkUtils.OSSlash(@"Resources/Reports/UserReports/ReportDocumentFinancePayment.frx"), extraMessage)); break; case "VIRTUAL_SCREEN": break; } //ProtectedFiles Protection if (!validFiles) { return(false); } //Call Print Document result = PrintRouter.PrintFinanceDocumentPayment(printer, pDocumentFinancePayment); } } catch (Exception ex) { Utils.ShowMessageTouchErrorPrintingTicket(pSourceWindow, printer, ex); } return(result); }
public static bool PrintFinanceDocument(Window pSourceWindow, sys_configurationprinters pPrinter, fin_documentfinancemaster pDocumentFinanceMaster) { bool result = false; bool openDrawer = false; PosDocumentFinancePrintDialog.PrintDialogResponse response; if (!LicenceManagement.IsLicensed || !LicenceManagement.CanPrint) { Utils.ShowMessageTouchErrorUnlicencedFunctionDisabled(pSourceWindow, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_printing_function_disabled")); return(false); } //TK016249 - Impressoras - Diferenciação entre Tipos //Deteta janela de origem de forma a escolher qual impressora usar - TicketList -> ThermalPrinter | PosDocumentFinanceDialog -> Printer sys_configurationprinters printer; sys_configurationprinters printerDoc; if (GlobalFramework.UsingThermalPrinter) { //Both printer can be the same, if not Defined in DocumentType //Printer for Drawer and Document, if not defined in DocumentType printer = (pPrinter != null) ? pPrinter : GlobalFramework.LoggedTerminal.ThermalPrinter; printerDoc = (pDocumentFinanceMaster.DocumentType.Printer != null) ? pDocumentFinanceMaster.DocumentType.Printer : printer; } else { //Both printer can be the same, if not Defined in DocumentType //Printer for Drawer and Document, if not defined in DocumentType printer = (pPrinter != null) ? pPrinter : GlobalFramework.LoggedTerminal.Printer; printerDoc = (pDocumentFinanceMaster.DocumentType.Printer != null) ? pDocumentFinanceMaster.DocumentType.Printer : printer; } try { //Overload Management if (printerDoc == null) { //Notification : Show Message TouchTerminalWithoutAssociatedPrinter and Store user input, to Show Next Time(Yes) or Not (No) if (printerDoc == null) { Utils.ShowMessageTouchTerminalWithoutAssociatedPrinter(pSourceWindow, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], pDocumentFinanceMaster.DocumentType.ResourceString)); } else { response = PosDocumentFinancePrintDialog.GetDocumentFinancePrintProperties(pSourceWindow, pDocumentFinanceMaster); //Print with default DocumentFinanceYearSerieTerminal Template if (response.Response == ResponseType.Ok) { result = PrintRouter.PrintFinanceDocument(pDocumentFinanceMaster); } } } else { bool validFiles = true; string extraMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_protected_files_invalid_files_detected_print_document_ignored"), pDocumentFinanceMaster.DocumentNumber); //Printer Drawer : Set openDrawer switch (PrintRouter.GetPrinterToken(printer.PrinterType.Token)) { //ThermalPrinter : Ticket Files case "THERMAL_PRINTER_WINDOWS": case "THERMAL_PRINTER_LINUX": case "THERMAL_PRINTER_SOCKET": openDrawer = true; break; } //Printer Document : Set Valid Files switch (PrintRouter.GetPrinterToken(printerDoc.PrinterType.Token)) { //ThermalPrinter : Ticket Files case "THERMAL_PRINTER_WINDOWS": case "THERMAL_PRINTER_LINUX": case "THERMAL_PRINTER_SOCKET": //validFiles = IsValidProtectedFile(FrameworkUtils.OSSlash(template.FileTemplate), extraMessage); break; //FastReport : Report Files case "GENERIC_PRINTER_WINDOWS": case "REPORT_EXPORT_PDF": //Required both Template Files ReportDocumentFinance and ReportDocumentFinanceWayBill //validFiles = ( // IsValidProtectedFile(FrameworkUtils.OSSlash(@"Resources/Reports/UserReports/ReportDocumentFinance.frx"), extraMessage) && // IsValidProtectedFile(FrameworkUtils.OSSlash(@"Resources/Reports/UserReports/ReportDocumentFinanceWayBill.frx"), extraMessage) //); break; case "VIRTUAL_SCREEN": break; } //ProtectedFiles Protection if (!validFiles) { return(false); } //Call Print Document : Receives ResponseType.Ok without user Confirmation, if Document was never Printer response = PosDocumentFinancePrintDialog.GetDocumentFinancePrintProperties(pSourceWindow, pDocumentFinanceMaster); //Print with Parameters Printer and Template if (response.Response == ResponseType.Ok) { //Print Document use Printer Document result = PrintRouter.PrintFinanceDocument(printerDoc, pDocumentFinanceMaster, response.CopyNames, response.SecondCopy, response.Motive); //OpenDoor use Printer Drawer if (openDrawer && pDocumentFinanceMaster.DocumentType.PrintOpenDrawer && !response.SecondCopy) { PrintRouter.OpenDoor(printer); } } } } catch (Exception ex) { Utils.ShowMessageTouchErrorPrintingTicket(pSourceWindow, printer, ex); } return(result); }