public void BlueSkyStampMailBook() { var eDeviceData = new Dictionary <string, string>(); eDeviceData.Add("shop_name_shop_no", "Unit Test Shop 1"); eDeviceData.Add("shop_address", "1600 W 7th St."); eDeviceData.Add("shop_city_state_zip", "Fort Worth, TX 76108"); const int numberOfRecords = 8; for (var i = 1; i <= numberOfRecords; i++) { string rowNumKey = string.Format("row{0}_num", i); string rowAddress1Key = string.Format("row{0}_address1", i); string rowAddress2Key = string.Format("row{0}_address2", i); string rowAddress3Key = string.Format("row{0}_address3", i); string rowAddress4Key = string.Format("row{0}_address4", i); eDeviceData.Add(rowNumKey, i.ToString()); eDeviceData.Add(rowAddress1Key, "Name " + i.ToString()); eDeviceData.Add(rowAddress2Key, "Street " + i.ToString()); eDeviceData.Add(rowAddress3Key, "Address1 " + i.ToString()); eDeviceData.Add(rowAddress4Key, "Address2 " + i.ToString()); } eDeviceData.Add("#_mailers_printed", numberOfRecords.ToString()); eDeviceData.Add("page_x_of_x_1", "(Page 1 of 2)"); //eDeviceData.Add("page_x_of_x_2", "(Page 2 of 2)"); PDFITextSharpUtilities.PdfSharpTools tools; PDFITextSharpUtilities.OpenPDFFile(TemplateFilePathPage3, out tools); Assert.IsTrue(PDFITextSharpUtilities.StampSimplePDFWithFormFields(tools, OutputFile, false, eDeviceData)); }
private void PrintPFIMailers(PFIMailerOption pfiMailerOption) { //Create output variables string errorCode; string errorText; var businessRulesProcedures = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession); var pfiMailerAdjustmentDays = businessRulesProcedures.GetNumberOfDaysToAddForPFIMailer(GlobalDataAccessor.Instance.CurrentSiteId); var pfiMailerList = new List <ReportObject.PFIMailer>(); var pfiMailerFilesToDeleteList = new List <String>(); var retVal = false; switch (pfiMailerOption) { case PFIMailerOption.PrintPFIMailers: retVal = PawnProcedures.ExecuteGetPFIMailerData(GlobalDataAccessor.Instance.OracleDA, pfiMailerOption, out pfiMailerList, out errorCode, out errorText, pfiMailerAdjustmentDays, pfiDate: ShopDateTime.Instance.ShopDate); break; case PFIMailerOption.ReprintMailbook: retVal = PawnProcedures.ExecuteGetPFIMailerData(GlobalDataAccessor.Instance.OracleDA, pfiMailerOption, out pfiMailerList, out errorCode, out errorText, pfiDate: Utilities.GetDateTimeValue(this.dateReprintMailbook.SelectedDate)); break; case PFIMailerOption.ReprintPFIMailersByDate: retVal = PawnProcedures.ExecuteGetPFIMailerData(GlobalDataAccessor.Instance.OracleDA, pfiMailerOption, out pfiMailerList, out errorCode, out errorText, pfiDate: Utilities.GetDateTimeValue(this.dateReprintMailers.SelectedDate)); break; case PFIMailerOption.ReprintPFIMailersByTicket: retVal = PawnProcedures.ExecuteGetPFIMailerData(GlobalDataAccessor.Instance.OracleDA, pfiMailerOption, out pfiMailerList, out errorCode, out errorText, startTicketNumber: Utilities.GetIntegerValue(this.txtBeginTicket.Text), endTicketNumber: Utilities.GetIntegerValue(this.txtEndTicket.Text), pfiDate: Utilities.GetDateTimeValue(this.dateTicketRange.SelectedDate)); break; case PFIMailerOption.GetTodaysPrintedPFIMailerTickets: retVal = PawnProcedures.ExecuteGetPFIMailerData( GlobalDataAccessor.Instance.OracleDA, pfiMailerOption, out pfiMailerList, out errorCode, out errorText, pfiDate: Utilities.GetDateTimeValue(this.dateTicketRange.SelectedDate)); break; default: System.Diagnostics.Debug.Assert(false, "Unexpected Default case. Forget to add handler?"); break; } if (retVal) { if (pfiMailerOption == PFIMailerOption.GetTodaysPrintedPFIMailerTickets) { if (pfiMailerList.Count > 0) { txtBeginTicket.Text = pfiMailerList[0].ticketNumber.ToString(); txtEndTicket.Text = pfiMailerList[pfiMailerList.Count - 1].ticketNumber.ToString(); } } else if (pfiMailerOption == PFIMailerOption.ReprintMailbook) { PrintMailingBook(pfiMailerFilesToDeleteList, pfiMailerList); MessageBox.Show(@"PFI Mailbook Printing Complete"); } else { if (DisplayPrintPFIMailersConfirmationBox(pfiMailerList.Count, PFIMailerOption.ReprintPFIMailersByTicket == pfiMailerOption)) { if (pfiMailerList.Count > 0) { var mailFee = businessRulesProcedures.GetPFIMailerFee(GlobalDataAccessor.Instance.CurrentSiteId); var ticketNumberList = new List <int>(); var originalPFINoteList = new List <DateTime>(); var pfiEligibleDateList = new List <DateTime>(); var pfiMailerFileNamesToMerge = new List <String>(); var recordCount = 1; foreach (var pfiMailer in pfiMailerList) { var pfiMailerLocal = pfiMailer; if (pfiMailerOption == PFIMailerOption.PrintPFIMailers) // Spec Change //pfiMailerOption == PFIMailerOption.ReprintPFIMailersByTicket || //pfiMailerOption == PFIMailerOption.ReprintPFIMailersByDate) { // pfiMailerLocal.pfiEligibleDate = GetPFIEligibleDate(); //process pfi eligible date adjustment if (ShopDateTime.Instance.ShopDate > pfiMailerLocal.originalPFINote) { // Special Rule PWN_BR-33 Adjustment pfiMailerLocal.pfiEligibleDate = GetPFIDateAdjustmentRule33(pfiMailerLocal.pfiEligibleDate); } //PawnProcedures.ExecuteUpdatePFIMailerData( // GlobalDataAccessor.Instance.OracleDA, // out errorCode, // out errorText, // pfiMailerLocal.storeNumber, // pfiMailerLocal.ticketNumber, // mailFee, // pfiMailerLocal.originalPFINote, // "Y", // pfiEligibleDate); ticketNumberList.Add(pfiMailerLocal.ticketNumber); originalPFINoteList.Add(pfiMailerLocal.originalPFINote); pfiEligibleDateList.Add(pfiMailerLocal.pfiEligibleDate); } var pfiMailerDocument = new PFIMailerDocument(PdfLauncher.Instance); var pfiMailerFileName = "PFIMailer" + recordCount + ".pdf"; var reportObject = new ReportObject { ReportTempFileFullName = Path.Combine( SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath, pfiMailerFileName) }; pfiMailerDocument.ReportObject = reportObject; pfiMailerDocument.CreateReport(pfiMailerLocal); if (FileLogger.Instance.IsLogInfo) { FileLogger.Instance.logMessage( LogLevel.INFO, "PFI_Mailers", "Creating PFI Mailer {0}, Ticket Number {1}", pfiMailerFileName, pfiMailer.ticketNumber); } //var strReturnMessage = // PrintingUtilities.printDocument( // reportObject.ReportTempFileFullName, // GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, // GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1); // //if (!strReturnMessage.Contains("SUCCESS")) //{ // FileLogger.Instance.logMessage(LogLevel.ERROR, this, "PFI Mailer : " + strReturnMessage); //} pfiMailerFileNamesToMerge.Add(Path.Combine(SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath, pfiMailerFileName)); recordCount++; } // foreach (var pfiMailer in pfiMailerList) // Merge PFIMailerX.pdf doc's var mergedOutputFile = Path.Combine(SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath, "PFIMailer.pdf"); var wasPDFMergeSuccessful = PDFITextSharpUtilities.MergePDFFiles(mergedOutputFile, pfiMailerFileNamesToMerge.ToArray()); if (wasPDFMergeSuccessful) { var strReturnMessage = PrintingUtilities.printDocument( mergedOutputFile, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1); if (FileLogger.Instance.IsLogInfo) { FileLogger.Instance.logMessage( LogLevel.INFO, "PFI_Mailers", "Printing PFI Mailer {0}", mergedOutputFile); } if (!strReturnMessage.Contains("SUCCESS")) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "PFI Mailer : " + strReturnMessage); } } if (pfiMailerOption == PFIMailerOption.PrintPFIMailers) { PawnProcedures.ExecuteAddPFIMailerDataArray( GlobalDataAccessor.Instance.OracleDA, out errorCode, out errorText, int.Parse(GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId.StoreNumber), ticketNumberList, originalPFINoteList, pfiEligibleDateList, mailFee); } // Spec Change //else if (pfiMailerOption == PFIMailerOption.ReprintPFIMailersByDate || // pfiMailerOption == PFIMailerOption.ReprintPFIMailersByTicket) //{ // PawnProcedures.ExecuteAddPFIMailerDataArray( // GlobalDataAccessor.Instance.OracleDA, // out errorCode, // out errorText, // int.Parse(GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId.StoreNumber), // ticketNumberList, // originalPFINoteList, // pfiEligibleDateList, // mailFee); //} // Spec Change //if (pfiMailerOption != PFIMailerOption.ReprintPFIMailersByTicket) { PrintMailingBook(pfiMailerFilesToDeleteList, pfiMailerList); } } } } } else { if (pfiMailerOption == PFIMailerOption.ReprintMailbook) { MessageBox.Show(@"There is no Mail Book for this date."); } //else if (pfiMailerOption == PFIMailerOption.GetTodaysPrintedPFIMailerTickets) //{ // MessageBox.Show(@"There are no PFI Mailers to be printed for this ticket range."); //} else { MessageBox.Show(@"There are no PFI Mailers to be printed for this date."); } } }
private void PrintMailingBook(List <string> pfiMailerFilesToDeleteList, List <ReportObject.PFIMailer> pfiMailerList) { if (pfiMailerList.Count > 0) { PDFITextSharpUtilities.PdfSharpTools tools; var pageCount = 1; if (pfiMailerList.Count > 8) { pageCount++; var remainder = 0; pageCount = Math.DivRem(pfiMailerList.Count, 8, out remainder); if (remainder > 0) { pageCount++; } } pageCount++; var rowCount = 1; var outputFilePageThree = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\ps3877_output_main_page1_" + rowCount + ".pdf"; var outputFilePageFour = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\ps3877_output_last_page_" + rowCount + ".pdf"; var mergedOutputFile = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\PFIMailerMailbook_ps3877_output_" + rowCount + ".pdf"; var pfiData = new Dictionary <string, string> { { "page_x_of_x_1", "(page 1 of " + pageCount + ")" }, { "#_mailers_printed", pfiMailerList.Count.ToString() }, { "shop_name_shop_no", pfiMailerList[0].storeName }, { "shop_address", pfiMailerList[0].storeAddress }, { "shop_city_state_zip", pfiMailerList[0].storeCity + ", " + pfiMailerList[0].storeState + " " + pfiMailerList[0].storeZipCode } }; var pfiOutputFileList = new List <string> { this.pfiMailerTemplateOneTwo }; for (var index = 0; index < pfiMailerList.Count; index++) { pfiData.Add("row" + rowCount + "_num", (index + 1).ToString()); pfiData.Add("row" + rowCount + "_address1", pfiMailerList[index].customerName); pfiData.Add("row" + rowCount + "_address2", pfiMailerList[index].customerAddress); pfiData.Add( "row" + rowCount + "_address3", pfiMailerList[index].customerCity + ", " + pfiMailerList[index].customerState + " " + pfiMailerList[index].customerZipCode); if (index == (pfiMailerList.Count - 1)) { PDFITextSharpUtilities.OpenPDFFile(this.pfiMailerTemplateThree, out tools); PDFITextSharpUtilities.StampSimplePDFWithFormFields(tools, outputFilePageThree, true, pfiData); pfiOutputFileList.Add(outputFilePageThree); pfiMailerFilesToDeleteList.Add(outputFilePageThree); break; } else if (rowCount % 8 == 0) { var pageNumber = GetPageNumberByRowNumber(index + 1).ToString(); PDFITextSharpUtilities.OpenPDFFile(this.pfiMailerTemplateThree, out tools); PDFITextSharpUtilities.StampSimplePDFWithFormFields(tools, outputFilePageThree, true, pfiData); pfiOutputFileList.Add(outputFilePageThree); pfiMailerFilesToDeleteList.Add(outputFilePageThree); outputFilePageThree = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\ps3877_output_main_page" + pageNumber + ".pdf"; pfiData = new Dictionary <string, string> { { "page_x_of_x_1", "(page " + pageNumber + " of " + pageCount + ")" }, { "#_mailers_printed", pfiMailerList.Count.ToString() }, { "shop_name_shop_no", pfiMailerList[index].storeNumber.ToString() }, { "shop_address", pfiMailerList[index].storeAddress }, { "shop_city_state_zip", pfiMailerList[index].storeCity + ", " + pfiMailerList[index].storeState + " " + pfiMailerList[index].storeZipCode } }; rowCount = 1; } else { rowCount++; } } pfiData.Add("page_x_of_x_2", "(page " + pageCount + " of " + pageCount + ")"); PDFITextSharpUtilities.OpenPDFFile(this.pfiMailerTemplateFour, out tools); PDFITextSharpUtilities.StampSimplePDFWithFormFields(tools, outputFilePageFour, true, pfiData); pfiOutputFileList.Add(outputFilePageFour); pfiMailerFilesToDeleteList.Add(outputFilePageFour); var wasPDFMergeSuccessful = PDFITextSharpUtilities.MergePDFFiles(mergedOutputFile, pfiOutputFileList.ToArray()); if (wasPDFMergeSuccessful) { var strReturnMessage = PrintingUtilities.printDocument( mergedOutputFile, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1); if (!strReturnMessage.Contains("SUCCESS")) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "PFI Mailer : " + strReturnMessage); } } else { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "PFI Mailer Merge Failed: " + mergedOutputFile); } } }
public void Print(PawnLoan pawnLoan) { if (pawnLoan != null) { //Get all the data to print from the desktop session CustomerVO currentCust = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer; if (pawnLoan.CustomerNumber != currentCust.CustomerNumber) { currentCust = CustomerProcedures.getCustomerDataByCustomerNumber(GlobalDataAccessor.Instance.DesktopSession, pawnLoan.CustomerNumber); } if (currentCust != null) { //Set all the date for printing transactionDate = ShopDateTime.Instance.ShopDate.FormatDate(); tktNo = pawnLoan.TicketNumber; customerName = currentCust.LastName + "," + currentCust.FirstName; custMiddleInitial = currentCust.MiddleInitial.ToUpper(); loanAmount = pawnLoan.Amount; AddressVO custAddress = currentCust.getHomeAddress(); if (custAddress != null) { custAddr = custAddress.Address1 + " " + custAddress.Address2; custAddrLine2 = custAddress.City + "," + custAddress.State_Code + " " + custAddress.ZipCode; } IdentificationVO custId = currentCust.getFirstIdentity(); if (custId != null) { idData = custId.IdType + "-" + custId.IdIssuerCode + "-" + custId.IdValue; } loanDate = pawnLoan.OriginationDate.FormatDate(); loanDueDate = pawnLoan.DueDate.FormatDate(); lostTktFee = pawnLoan.LostTicketInfo.LostTicketFee; //Get the interest amount decimal interestCharges = 0.0M; var finCharges = (from feeData in pawnLoan.Fees where feeData.FeeType == FeeTypes.INTEREST select feeData).FirstOrDefault(); if (finCharges.Value != 0) { interestCharges = finCharges.Value; } //Get the late fees //If it is negative then it is a refund else it is a late fee var lateFee = (from feeData in pawnLoan.Fees where feeData.FeeType == FeeTypes.LATE select feeData).FirstOrDefault(); if (lateFee.Value < 0) { refundAmt = lateFee.Value; } else { lateCharges = lateFee.Value; } totalPayments = loanAmount + interestCharges + refundAmt + lateCharges + lostTktFee; apr = pawnLoan.InterestRate.ToString(); //Open the pdf file try { var fileName = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseTemplatePath + "\\" + "lostticket.pdf"; if (GlobalDataAccessor.Instance.CurrentSiteId.State.Equals(States.Ohio)) { fileName = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseTemplatePath + "\\" + "lostticketOH.pdf"; } PDFITextSharpUtilities.PdfSharpTools pdfTools;//=new PawnUtilities.ISharp.PDFITextSharpUtilities.PdfSharpTools(fileName); PDFITextSharpUtilities.OpenPDFFile(fileName, out pdfTools); //Generate output file name string timeStamp = DateTime.Now.ToString("yyMMddHHmmssf"); string genDocsDir = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\"; string outputFileName = genDocsDir + "LostTicketStatement" + "-" + timeStamp + ".pdf"; if (pdfTools == null) { if (FileLogger.Instance.IsLogError) { FileLogger.Instance.logMessage(LogLevel.ERROR, "LostTicketStatementPrint", "Could not get PDF tools instance for lost ticket statement"); } return; } pdfTools.PrepForStamping(outputFileName); Dictionary <string, string> lostTicketData = new Dictionary <string, string>(); lostTicketData.Add("TransactionDate", transactionDate); lostTicketData.Add("CustomerName", customerName); lostTicketData.Add("CustomerMiddleInitial", custMiddleInitial); lostTicketData.Add("CustomerAddrLine1", custAddr); lostTicketData.Add("CustomerAddrLine2", custAddrLine2); lostTicketData.Add("CustomerIdData", idData); lostTicketData.Add("DateMade", loanDate); lostTicketData.Add("DateDue", loanDueDate); lostTicketData.Add("TicketNumber", tktNo.ToString()); lostTicketData.Add("VerifyTicketNumber", tktNo.ToString()); lostTicketData.Add("CustomerGender", currentCust.Gender); lostTicketData.Add("CustomerRace", currentCust.Race); lostTicketData.Add("CustomerDOB", currentCust.DateOfBirth.FormatDate()); lostTicketData.Add("CustomerHeight", currentCust.Height); if (currentCust.Weight > 0) { lostTicketData.Add("CustomerWeight", currentCust.Weight.ToString() + " lbs"); } lostTicketData.Add("CustomerHairColor", currentCust.HairColor); lostTicketData.Add("CustomerEyeColor", currentCust.EyeColor); lostTicketData.Add("LostType", Commons.GetLostTicketType(pawnLoan.LostTicketInfo.LSDTicket)); lostTicketData.Add("AmtFinanced", String.Format("{0:C}", pawnLoan.Amount)); lostTicketData.Add("AmtFinanceCharges", String.Format("{0:C}", pawnLoan.InterestAmount)); lostTicketData.Add("AmtLateCharges", String.Format("{0:C}", lateCharges)); lostTicketData.Add("AmtRefunds", String.Format("{0:C}", refundAmt)); lostTicketData.Add("AmtTotalPayments", String.Format("{0:C}", totalPayments)); lostTicketData.Add("APR", apr); lostTicketData.Add("LostTicketFee", String.Format("{0:0.00}", lostTktFee)); if (GlobalDataAccessor.Instance.CurrentSiteId.State.Equals(States.Ohio)) { lostTicketData.Add("CurPrinAmount", pawnLoan.CurrentPrincipalAmount.ToString("c")); } //Add the data to the pdf file if (!(PDFITextSharpUtilities.StampSimplePDFWithFormFields(pdfTools, outputFileName, false, lostTicketData))) { if (FileLogger.Instance.IsLogError) { FileLogger.Instance.logMessage(LogLevel.ERROR, "ProcessTenderController", "Could not stamp PDF document for wipe drive"); } } //Get the printer details for the form string storeNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber; //03/18/2010 GJL - Change for pawn sec to allow development to continue and to facilitate //real machine names in the pawn sec database instead of 47-byte GUID values //Printing lostticket.pdf const string formName = "lostticket.pdf"; if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled && GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid) { if (FileLogger.Instance.IsLogInfo) { FileLogger.Instance.logMessage(LogLevel.INFO, this, "Printing lost ticket statement on: {0}", GlobalDataAccessor.Instance.DesktopSession.LaserPrinter); } if (!(PDFITextSharpUtilities.PrintOutputPDFFile( GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port.ToString(), 1, pdfTools))) { if (FileLogger.Instance.IsLogError) { FileLogger.Instance.logMessage(LogLevel.ERROR, "LostTicketStatement", "Could not print lost ticket statement PDF file"); } } } } catch (Exception ex) { BasicExceptionHandler.Instance.AddException("Error in printing lost ticket statement", new ApplicationException(ex.Message)); return; } } } }