示例#1
0
 public IHttpActionResult GetAll()
 {
     try
     {
         CallViewModel        call     = new CallViewModel();
         List <CallViewModel> allCalls = call.GetAll();
         return(Ok(allCalls));
     }
     catch (Exception e)
     {
         return(BadRequest("Retrieve failed - " + e.Message));
     }
 }
示例#2
0
 public IHttpActionResult Get()
 {
     try
     {
         CallViewModel        call     = new CallViewModel();
         List <CallViewModel> allCalls = call.GetAll();
         return(Ok(allCalls));
     }
     catch (Exception ex)
     {
         return(BadRequest("Retrieve Failed - Contact Tech Support"));
     }
 }
        public void callviewmodeltest()
        {
            CallViewModel        cal   = new CallViewModel();
            List <CallViewModel> calls = cal.GetAll();

            //Assert.IsTrue(calls.Count > 0);
            foreach (CallViewModel ca in calls)
            {
                EmployeeModel emp = new EmployeeModel();
                Employee      em  = emp.GetById(ca.EmployeeId);
                ProblemModel  pro = new ProblemModel();
                Problem       pr  = pro.GetById(ca.ProblemId);
            }
        }
 public IHttpActionResult GetAll()
 {
     try
     {
         CallViewModel cvm = new CallViewModel();
         //Use the CallViewModel's GetAll method to fetch and retrieve a list of calls from the server
         List <CallViewModel> allCalls = cvm.GetAll();
         return(Ok(allCalls));
     }
     catch (Exception ex)
     {
         return(BadRequest("Retrieve failed- " + ex.Message));
     }
 }
 public IActionResult GetAll()
 {
     try
     {
         CallViewModel        viewModel = new CallViewModel();
         List <CallViewModel> allCALLS  = viewModel.GetAll();
         return(Ok(allCALLS));
     }
     catch (Exception ex)
     {
         _logger.LogError("Problem in " + GetType().Name + " " +
                          MethodBase.GetCurrentMethod().Name + " " + ex.Message);
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
示例#6
0
        public void getCallReport()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream(mappedPath + "Pdfs/Call.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedPath + IMG);
                image1.SetAbsolutePosition(200f, 640f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;
                addEmptyLine(para, 10);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls"), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;
                para.Add(mainHead);
                addEmptyLine(para, 1);
                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 90.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Fullname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                CallViewModel        call  = new CallViewModel();
                List <CallViewModel> calls = call.GetAll();

                foreach (CallViewModel c in calls)
                {
                    table.AddCell(addCell(c.DateOpened.ToString("MM/dd/yyyy")));
                    table.AddCell(addCell(c.Employee));
                    table.AddCell(addCell(c.Tech));
                    table.AddCell(addCell(c.Problem));
                    if (c.OpenStatus == true)
                    {
                        table.AddCell(addCell("Open"));
                    }
                    else
                    {
                        table.AddCell(addCell("Closed"));
                    }
                    table.AddCell(addCell(c.DateClosed?.ToString("MM/dd/yyyy")));
                }

                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
示例#7
0
        public void doIt()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream(mappedpath + "PDF/Call.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedpath + IMG);
                image1.SetAbsolutePosition(25f, 740f);
                image1.ScalePercent(15f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;
                //Lets write a big header
                addEmptyLine(para, 1);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls"), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;

                para.Add(mainHead);
                addEmptyLine(para, 3);

                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 100.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Lastname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));

                CallViewModel        call  = new CallViewModel();
                List <CallViewModel> calls = call.GetAll();

                foreach (CallViewModel cal in calls)
                {
                    EmployeeModel emp      = new EmployeeModel();
                    Employee      employee = emp.GetById(cal.TechId);
                    table.AddCell(addCell(cal.DateOpened.ToString("MM/dd/yyyy")));
                    table.AddCell(addCell(cal.EmployeeName));
                    table.AddCell(addCell(employee.LastName));
                    table.AddCell(addCell(cal.ProblemDescription));
                    table.AddCell(addCell(cal.OpenStatus?"Open":"Closed"));
                    table.AddCell(addCell((cal.DateClosed == null)?"":((DateTime)cal.DateClosed).ToString("MM-dd-yyyy")));
                }

                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
        public void generateSpecificEmployeeReport(int id)
        {
            try
            {
                /*Retrieve the employee instance associated with the id being passed in to this method*/
                EmployeeViewModel emp = new EmployeeViewModel();
                emp.Id = id;
                emp.GetById();
                Document document = new Document();
                PdfWriter.GetInstance(document,
                                      new FileStream(mappedPath + "Pdfs/EmployeeCall.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedPath + IMG);
                image1.SetAbsolutePosition(10f, 680f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;
                //A big header
                addEmptyLine(para, 3);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls : " + emp.Firstname + " " + emp.Lastname), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;
                para.Add(mainHead);
                addEmptyLine(para, 3);
                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 90.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Lastname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));

                /*Get all the calls and then filter by employee id*/
                CallViewModel        call     = new CallViewModel();
                List <CallViewModel> allCalls = call.GetAll();
                foreach (CallViewModel cll in allCalls)
                {
                    /*Only add calls for that particular employee to the report*/
                    if (cll.EmployeeId == id)
                    {
                        table.AddCell(addCell(cll.DateOpened.ToShortDateString()));
                        table.AddCell(addCell(cll.EmployeeName));
                        table.AddCell(addCell(cll.TechName));
                        table.AddCell(addCell(cll.ProblemDescription));
                        table.AddCell(addCell(cll.OpenStatus == false ? "Closed" : "Open"));
                        if (cll.DateClosed != null)
                        {
                            DateTime closedDate = Convert.ToDateTime(cll.DateClosed);
                            table.AddCell(addCell(closedDate.ToShortDateString()));
                        }
                        else
                        {
                            table.AddCell(addCell(""));
                        }
                    }
                }
                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
        public void doIt()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document,
                                      new FileStream(mappedPath + "Pdfs/Call.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedPath + IMG);
                image1.SetAbsolutePosition(10f, 680f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;
                //A big header
                addEmptyLine(para, 3);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls"), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;
                para.Add(mainHead);
                addEmptyLine(para, 3);

                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 90.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Lastname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));
                CallViewModel        call  = new CallViewModel();
                List <CallViewModel> calls = call.GetAll();

                foreach (CallViewModel cll in calls)
                {
                    table.AddCell(addCell(cll.DateOpened.ToShortDateString()));
                    table.AddCell(addCell(cll.EmployeeName));
                    table.AddCell(addCell(cll.TechName));
                    table.AddCell(addCell(cll.ProblemDescription));
                    table.AddCell(addCell(cll.OpenStatus == false ? "Closed" : "Open"));
                    if (cll.DateClosed != null)
                    {
                        DateTime closedDate = Convert.ToDateTime(cll.DateClosed);
                        table.AddCell(addCell(closedDate.ToShortDateString()));
                    }
                    else
                    {
                        table.AddCell(addCell(""));
                    }
                }
                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
示例#10
0
        public void GenerateCallReport()
        {
            try
            {
                CallViewModel call = new CallViewModel();
                calls = call.GetAll();

                Document document = new Document();
                PdfWriter.GetInstance(document,
                                      new FileStream(mappedPath + "pdfs/CallReport.pdf", FileMode.Create));
                document.Open();

                /* Image */
                Paragraph para1  = new Paragraph();
                Image     image1 = Image.GetInstance(mappedPath + IMG);
                image1.ScaleToFit(150f, 150f);
                image1.Alignment    = Image.ALIGN_CENTER;
                image1.SpacingAfter = 10f;

                document.Add(image1);



                /* Title */
                Paragraph para2 = new Paragraph("Calls", hdgFont);
                para2.Alignment    = Element.ALIGN_CENTER;
                para2.SpacingAfter = 10f;
                document.Add(para2);



                /* Table */
                float[]   widths = { 5f, 5f, 5f, 5f, 5f, 5f };
                PdfPTable table  = new PdfPTable(6);
                table.WidthPercentage = 85.00F;
                PdfPCell cell1 = new PdfPCell(new Phrase("Opened", smallfont));
                cell1.Border = Rectangle.NO_BORDER;
                table.AddCell(cell1);
                PdfPCell cell2 = new PdfPCell(new Phrase("Lastname", smallfont));
                cell2.Border = Rectangle.NO_BORDER;
                table.AddCell(cell2);

                PdfPCell cell3 = new PdfPCell(new Phrase("Tech", smallfont));
                cell3.Border = Rectangle.NO_BORDER;
                table.AddCell(cell3);

                PdfPCell cell4 = new PdfPCell(new Phrase("Problem", smallfont));
                cell4.Border = Rectangle.NO_BORDER;
                table.AddCell(cell4);

                PdfPCell cell5 = new PdfPCell(new Phrase("Status", smallfont));
                cell5.Border = Rectangle.NO_BORDER;
                table.AddCell(cell5);

                PdfPCell cell6 = new PdfPCell(new Phrase("Closed", smallfont));
                cell6.Border = Rectangle.NO_BORDER;
                table.AddCell(cell6);


                foreach (var c in calls)
                {
                    PdfPCell cell7  = new PdfPCell(new Phrase(c.DateOpened.ToString("yyyy-MM-dd"), smallfontNOB));
                    PdfPCell cell8  = new PdfPCell(new Phrase(c.EmployeeName, smallfontNOB));
                    PdfPCell cell9  = new PdfPCell(new Phrase(c.TechName, smallfontNOB));
                    PdfPCell cell10 = new PdfPCell(new Phrase(c.ProblemDescription, smallfontNOB));
                    PdfPCell cell11 = new PdfPCell(new Phrase((c.OpenStatus.ToString() == "True") ? "Open" : "Closed", smallfontNOB));
                    PdfPCell cell12 = new PdfPCell(new Phrase((c.DateClosed != null) ? c.DateClosed.Value.ToString("yyyy-MM-dd") : c.DateClosed.ToString(), smallfontNOB));
                    cell7.Border  = Rectangle.NO_BORDER;
                    cell8.Border  = Rectangle.NO_BORDER;
                    cell9.Border  = Rectangle.NO_BORDER;
                    cell10.Border = Rectangle.NO_BORDER;
                    cell11.Border = Rectangle.NO_BORDER;
                    cell12.Border = Rectangle.NO_BORDER;
                    table.AddCell(cell7);
                    table.AddCell(cell8);
                    table.AddCell(cell9);
                    table.AddCell(cell10);
                    table.AddCell(cell11);
                    table.AddCell(cell12);
                }

                table.SpacingAfter = 30f;
                document.Add(table);

                Paragraph date = new Paragraph("Calls report written on - " + System.DateTime.Now, smallfont);
                date.Alignment = Element.ALIGN_CENTER;
                document.Add(date);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
示例#11
0
        public void do_it()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream(mappedPath + "pdfs/CallPdf.pdf", FileMode.Create));
                document.Open();
                Image image = Image.GetInstance(mappedPath + logo);
                image.ScaleAbsolute(150, 125);
                Paragraph para = new Paragraph("Calls", title_font);
                para.Alignment = iTextSharp.text.Element.ALIGN_CENTER;
                image.SetAbsolutePosition(125f, 710f);
                para.Add(image);


                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 100.00F;
                PdfPCell cell = new PdfPCell(new Phrase("Opened", column_font));
                cell.Border         = Rectangle.NO_BORDER;
                table.SpacingBefore = 100f;
                table.AddCell(cell);
                PdfPCell cell2 = new PdfPCell(new Phrase("Lastname", column_font));
                cell2.Border = Rectangle.NO_BORDER;
                table.AddCell(cell2);
                PdfPCell cell3 = new PdfPCell(new Phrase("Tech", column_font));
                cell3.Border = Rectangle.NO_BORDER;
                table.AddCell(cell3);
                PdfPCell cell4 = new PdfPCell(new Phrase("Problem", column_font));
                cell4.Border = Rectangle.NO_BORDER;
                table.AddCell(cell4);
                PdfPCell cell5 = new PdfPCell(new Phrase("Status", column_font));
                cell5.Border = Rectangle.NO_BORDER;
                table.AddCell(cell5);
                PdfPCell cell6 = new PdfPCell(new Phrase("Closed", column_font));
                cell6.Border = Rectangle.NO_BORDER;
                table.AddCell(cell6);

                CallViewModel        call      = new CallViewModel();
                List <CallViewModel> call_list = call.GetAll();

                foreach (CallViewModel c in call_list)
                {
                    table.AddCell(new PdfPCell(new Phrase(c.DateOpened.ToShortDateString(), list_font))).Border = Rectangle.NO_BORDER;
                    table.AddCell(new PdfPCell(new Phrase(c.employee_last_name, list_font))).Border             = Rectangle.NO_BORDER;
                    table.AddCell(new PdfPCell(new Phrase(c.tech_name, list_font))).Border           = Rectangle.NO_BORDER;
                    table.AddCell(new PdfPCell(new Phrase(c.problem_description, list_font))).Border = Rectangle.NO_BORDER;
                    if (!(c.OpenStatus))
                    {
                        table.AddCell(new PdfPCell(new Phrase("Closed", list_font))).Border = Rectangle.NO_BORDER;
                        table.AddCell(new PdfPCell(new Phrase(c.DateClosed?.ToShortDateString(), list_font))).Border = Rectangle.NO_BORDER;
                    }
                    else
                    {
                        table.AddCell(new PdfPCell(new Phrase("Open", list_font))).Border = Rectangle.NO_BORDER;
                        table.AddCell(new PdfPCell(new Phrase(""))).Border = Rectangle.NO_BORDER;
                    }
                }

                Paragraph date = new Paragraph("Call report written on - " + DateTime.Now.ToString(), date_created_font);
                date.Alignment = iTextSharp.text.Element.ALIGN_CENTER;
                document.Add(para);
                document.Add(table);
                document.Add(date);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }
        public void doIt()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document,
                                      new FileStream(mappedPath + "pdfs/Call.pdf", FileMode.Create));
                document.Open();
                Paragraph para       = new Paragraph();
                PdfPTable titleTable = new PdfPTable(2);
                titleTable.DefaultCell.Border = Rectangle.NO_BORDER;
                // Image Stuff
                Image image1 = Image.GetInstance(mappedPath + IMG);
                image1.SetAbsolutePosition(100f, 100f);
                //image1.Alignment = Image.ALIGN_LEFT | Image.TEXTWRAP;
                image1.ScaleToFit(100, 100);



                // ALign para for image
                //para.Alignment = Element.ALIGN_RIGHT;

                Paragraph mainHead = new Paragraph("Calls", catFont);
                Paragraph imgHead  = new Paragraph();
                //mainHead.Add(logocell);
                mainHead.Alignment = Element.ALIGN_CENTER;
                imgHead.Alignment  = Element.ALIGN_CENTER;
                // mainHead.PaddingTop = Element.

                imgHead.Add(new Chunk(image1, 0, 0, true));

                PdfPCell imgCell  = new PdfPCell(imgHead);
                PdfPCell titlCell = new PdfPCell(mainHead);
                imgCell.Border  = Rectangle.NO_BORDER;
                titlCell.Border = Rectangle.NO_BORDER;
                titleTable.AddCell(imgCell);
                titleTable.AddCell(titlCell);
                // para.Add(imgHead);
                //para.Add(mainHead);
                para.Add(titleTable);


                addEmptyLine(para, 2);
                // Table stuff
                PdfPTable table = new PdfPTable(6);

                table.WidthPercentage = 100.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Lastname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                CallViewModel        callVm = new CallViewModel();
                List <CallViewModel> calls  = callVm.GetAll();

                foreach (CallViewModel call in calls)
                {
                    table.AddCell(addCell(call.DateClosed.ToString()));
                    table.AddCell(addCell(call.DateOpened.ToShortDateString()));

                    table.AddCell(addCell(call.EmployeeName));
                    table.AddCell(addCell(call.TechName));

                    table.AddCell(addCell(call.ProblemDescription));
                    if (call.OpenStatus == true)
                    {
                        table.AddCell(addCell("Open"));
                    }
                    else if (call.OpenStatus == false)
                    {
                        table.AddCell(addCell("Closed"));
                    }
                }

                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call Report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);

                document.Add(para);
                document.Close();
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error: " + e.Message);
            }
        }
示例#13
0
        public void generatedReport(string rootpath)
        {
            PageSize pg        = PageSize.A4.Rotate();
            var      helvetica = PdfFontFactory.CreateFont(StandardFontFamilies.HELVETICA);
            Image    img       = new Image(ImageDataFactory.Create(rootpath + "/img/helpdesk_1.jpg"))
                                 .ScaleAbsolute(150, 100)
                                 .SetFixedPosition(((pg.GetWidth()) / 2) - 85, pg.GetHeight() - 120);


            PdfWriter writer = new PdfWriter(rootpath + "/pdfs/calllist.pdf",
                                             new WriterProperties().SetPdfVersion(PdfVersion.PDF_2_0));

            PdfDocument pdf      = new PdfDocument(writer);
            Document    document = new Document(pdf, pg);

            document.Add(img);
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("Current Calls")
                         .SetFont(helvetica)
                         .SetFontSize(24)
                         .SetBold()
                         .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER));

            Table table = new Table(6);

            table
            .SetWidth(700)
            .SetTextAlignment(TextAlignment.CENTER)
            .SetRelativePosition(0, 0, 0, 0)
            .SetHorizontalAlignment(HorizontalAlignment.CENTER);

            table.AddCell(addCell("Opened", "h", 0));
            table.AddCell(addCell("Lastname", "h", 0));
            table.AddCell(addCell("Tech", "h", 0));
            table.AddCell(addCell("Problem", "h", 0));
            table.AddCell(addCell("Status", "h", 0));
            table.AddCell(addCell("Closed", "h", 0));
            table.AddCell(addCell(" ", "d"));
            table.AddCell(addCell(" ", "d"));
            table.AddCell(addCell(" ", "d"));
            table.AddCell(addCell(" ", "d"));
            table.AddCell(addCell(" ", "d"));
            table.AddCell(addCell(" ", "d"));

            CallViewModel        call  = new CallViewModel();
            List <CallViewModel> calls = call.GetAll();

            foreach (CallViewModel c in calls)
            {
                //table.AddCell(addCell(emp.Title, "d", 8));
                table.AddCell(addCell(c.DateOpened.ToShortDateString(), "d", 8));
                table.AddCell(addCell(c.EmployeeName, "d"));
                table.AddCell(addCell(c.TechName, "d"));
                table.AddCell(addCell(c.ProblemDescription, "d"));

                if (c.OpenStatus == false)
                {
                    table.AddCell(addCell("Open", "d"));
                }
                else
                {
                    table.AddCell(addCell("Closed", "d"));
                }

                if (c.DateClosed == null)
                {
                    table.AddCell(addCell("-", "d"));
                }
                else
                {
                    table.AddCell(addCell(c.DateClosed ? .ToString("MM/dd/yyyy"), "d"));
                }
            }

            document.Add(table);
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("\n"));
            document.Add(new Paragraph("Call report written on - " + DateTime.Now)
                         .SetFontSize(6)
                         .SetTextAlignment(TextAlignment.CENTER));

            document.Close();
        }
示例#14
0
        public void doIt()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream(mappedPath + "Pdfs/Calls.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedPath + IMG);
                image1.SetAbsolutePosition(245f, 740f);
                image1.ScaleAbsoluteHeight(90f);
                image1.ScaleAbsoluteWidth(120f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;

                // Lets write a big header
                addEmptyLine(para, 3);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls"), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;
                para.Add(mainHead);
                addEmptyLine(para, 1);

                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 96.00F;
                float[] widths = new float[] { 16f, 16f, 16f, 18f, 30f, 40f };
                table.SetWidths(widths);
                table.AddCell(addCell("Date Opened", "h"));
                table.AddCell(addCell("Date Closed", "h"));
                table.AddCell(addCell("Employee", "h"));
                table.AddCell(addCell("Technician", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Notes", "h"));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                CallViewModel        call  = new CallViewModel();
                List <CallViewModel> calls = call.GetAll();

                foreach (CallViewModel callVm in calls)
                {
                    table.AddCell(addCell(callVm.DateOpened.ToString()));
                    table.AddCell(addCell(callVm.DateClosed.ToString()));
                    table.AddCell(addCell(callVm.EmployeeName));
                    table.AddCell(addCell(callVm.TechName));
                    table.AddCell(addCell(callVm.ProblemDescription));
                    table.AddCell(addCell(callVm.Notes));
                }

                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }