Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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;
                    }
                }
            }
        }