Exemplo n.º 1
0
 public ActionResult CreateLetter()
 {
     try
     {
         string path = HttpContext.Server.MapPath(".");
         var createPdf = new CreatePdf();
         var parametersInfo = (ParametersViewModel)Session["ParametersSelected"];
         if (createPdf.WritePdf(path, parametersInfo,
             CustomerInfoAcc().FirstOrDefault(),
             GlnodesAcc(), FacilitiesAcc(), MmContractAcc(), GuarantorAcc(), (string[])Session["AccValues"],
             LdKenAcc(), SecuritiesAcc(), User.Identity.GetUserName(), Request.ServerVariables["REMOTE_ADDR"], (string)Session["AccountCharge"]))
         {
             ViewBag.Message = "Report Generated Awaiting Approval";
             getVals.LogAudit(User.Identity.GetUserName(), "Created", Request.UserHostName, "Created Audit Letter Of Date:" + parametersInfo.ReportDate + " and BaseNos:" +
             string.Join(",", parametersInfo.BaseNumberList), "Created", "AuditLetters");
             return RedirectToAction("ReportLogIndex");
         }
         ModelState.AddModelError("", "Report Not Generated Properly:: ");
         return View();
     }
     catch (Exception ex)
     {
         //Clean All sessions
         Session["ParametersSelected"] = null;
         Session["AccValues"] = null;
         Session["Glnodes"] = null;
         Session["BaseValues"] = null;
         _logs.LogError(User.Identity.GetUserName(), "CreateLetter", "Error: " + ex.Message,
        Request.ServerVariables["REMOTE_ADDR"], HttpContext.Server.MapPath("."), "AuditLetters");
         return RedirectToAction("AuditorSelectIndex");
     }
 }
Exemplo n.º 2
0
        // write on top of document
        public override void OnEndPage(PdfWriter writer, Document document)
        {
            base.OnEndPage(writer, document);
            var page = document.PageSize;
            float cellHeight = document.TopMargin;

            string imageFilePath = HttpContext.Current.Server.MapPath(".") + "/Images/Contacts.jpg";
            string image3 = HttpContext.Current.Server.MapPath(".") + "/Images/citi_sm-header.jpg";

            Image jpg = Image.GetInstance(imageFilePath);
            jpg.ScaleToFit(360f, 480f);
            jpg.Alignment = Image.ALIGN_LEFT;
            Image jpg3 = Image.GetInstance(image3);
            jpg3.ScaleToFit(80f, 60f);
            jpg3.Alignment = Image.ALIGN_RIGHT;

            PdfPTable table1 = new PdfPTable(2);
            table1.SpacingAfter = 10F;
            table1.TotalWidth = 560f;
            //table1.WidthPercentage = 100;

            PdfPCell cell11 = new PdfPCell();
            cell11.Border = PdfPCell.NO_BORDER;
            cell11.AddElement(jpg);

            //PdfPCell cell10 = new PdfPCell(new Phrase("                         "));
            //cell10.Border = PdfPCell.NO_BORDER;

            PdfPCell cell12 = new PdfPCell();
            cell12.Border = PdfPCell.NO_BORDER;
            cell12.AddElement(jpg3);

            PdfPCell cell13 = new PdfPCell(new Phrase("\n"));
            cell13.Border = PdfPCell.NO_BORDER;

            PdfPCell cell14 = new PdfPCell(new Phrase("\n"));
            cell14.Border = PdfPCell.NO_BORDER;

            //PdfPCell cell15 = new PdfPCell(new Phrase("\n"));
            //cell15.Border = PdfPCell.NO_BORDER;

            table1.AddCell(cell11);
            //table1.AddCell(cell10);
            table1.AddCell(cell12);
            table1.AddCell(cell13);
            table1.AddCell(cell14);
            //table1.AddCell(cell15);

            table1.WriteSelectedRows(0, -1, 10, page.Height - cellHeight + table1.TotalHeight, writer.DirectContent);//WriteSelectedRows(0, -1, 5, document.Top, writer.DirectContent);

            var normalFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 7);
            PdfPTable tabFot = new PdfPTable(new float[] { 1F });
            tabFot.SpacingAfter = 10F;
            CreatePdf getParams = new CreatePdf();
            var myParams = getParams.Parameters("FOOTER");
            string[] footerLines = myParams.Paramvalue.Replace("||","|").Split('|');

            PdfPCell cell;
            tabFot.TotalWidth = 600F;
            cell = new PdfPCell(new Phrase("\n"));
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.Border = PdfPCell.NO_BORDER;
            tabFot.AddCell(cell);
            foreach (var  n in footerLines)
            {
                cell = new PdfPCell(new Phrase(n =="" ? "\n" : n , normalFont));
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                cell.Border = PdfPCell.NO_BORDER;
                tabFot.AddCell(cell);
            }

            //cell = new PdfPCell(new Phrase("Incorporated in the USA under the National Banking Act Charter No. 1481", normalFont));
            //cell.HorizontalAlignment = Element.ALIGN_LEFT;
            //cell.Border = PdfPCell.NO_BORDER;
            //tabFot.AddCell(cell);
            //cell = new PdfPCell(new Phrase("Local Manager: Joyce-Ann Wainaina", normalFont));
            //cell.HorizontalAlignment = Element.ALIGN_LEFT;
            //cell.Border = PdfPCell.NO_BORDER;
            //tabFot.AddCell(cell);
            //cell = new PdfPCell(new Phrase("Directors: Barbara J. Desoer, Duncan P. Hennes, Eugene M. McQuade, Gary M. Reiner, Robert L. Ryan, Anthony M. Santomero, Joan E. Spero, Diana L. Taylor, James S. Turley (US Citizens) ", normalFont));
            //cell.HorizontalAlignment = Element.ALIGN_LEFT;
            //cell.Border = PdfPCell.NO_BORDER;
            //tabFot.AddCell(cell);
            //cell = new PdfPCell(new Phrase("\n"));
            //cell.HorizontalAlignment = Element.ALIGN_LEFT;
            //cell.Border = PdfPCell.NO_BORDER;
            //tabFot.AddCell(cell);
            //cell = new PdfPCell(new Phrase("Citibank, N.A. Kenya Branch is licensed and regulated by the Central Bank of Kenya", normalFont));
            //cell.HorizontalAlignment = Element.ALIGN_LEFT;
            //cell.Border = PdfPCell.NO_BORDER;
            //tabFot.AddCell(cell);

            cell = new PdfPCell(new Phrase("\n"));
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.Border = PdfPCell.NO_BORDER;
            tabFot.AddCell(cell);
            tabFot.WriteSelectedRows(0, -1, 20, document.Bottom, writer.DirectContent);
        }
Exemplo n.º 3
0
 public ClsEmail()
 {
     getParams = new CreatePdf();
     getVals = new ClsDatabase();
 }