コード例 #1
0
 public PdfPTable SystemUtilization(String path, ViewModels.PollReportViewModel model)
 {
     PdfPTable table = new PdfPTable(4);
     table.WidthPercentage = 100;
     int[] width = new int[] { 1,1,1,2 };
     table.SetWidths(width);
     Phrase phrase = new Phrase("Username", font);
     BaseColor basecolor = new BaseColor(232, 238, 244);
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Access Privileges");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Date Created");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Notifications");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     foreach (var user in model.userList)
     {
         phrase.Clear();
         phrase.Add(user.UserName);
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         foreach (var role in user.Roles)
         {
             phrase.Add(role.RoleName + "\n");
         }
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(user.CreationDate.ToString());
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         if (user.Roles.Contains(new dbPoll_Application.Models.Role("Poll Administrator")) && user.AccountExpiryDate<= DateTime.Now.AddDays(30))
         {
             phrase.Add("This account expires in " + (user.AccountExpiryDate - DateTime.Now).Days + " days.");
         }
         else phrase.Add("");
         table.AddCell(new Phrase(phrase));
     }
     return table;
 }
コード例 #2
0
 public PdfPTable SessionParticipation(String path,ViewModels.PollReportViewModel model)
 {
     PdfPTable table = new PdfPTable(4);
     table.WidthPercentage = 100;
     int[] width = new int[] { 10, 5, 5, 10 };
     table.SetWidths(width);
     Phrase phrase = new Phrase("Participant", font);
     BaseColor basecolor = new BaseColor(232, 238, 244);
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Attended");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Participated (%)");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Points Accumulated");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     foreach (var participant in model.participants)
     {
         phrase.Clear();
         phrase.Add(participant.firstName +" " + participant.lastName);
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(participant.attended.ToString());
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(model.participated(participant));
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(model.points(participant));
         table.AddCell(new Phrase(phrase));
     }
     return table;
 }
コード例 #3
0
        public PdfPTable QuestionReport(String path, ViewModels.PollReportViewModel model,String entity)
        {
            if (model.selectedEntities.Count == 0)
            {
                PdfPTable table = new PdfPTable(4);
                int[] width = new int[4] { 2, 15, 12, 6 };
                table.WidthPercentage = 100;
                table.SetWidths(width);
                Phrase phrase = new Phrase("#", font);
                BaseColor basecolor = new BaseColor(232, 238, 244);
                BaseColor heading = new BaseColor(232, 238, 0);
                heading.Darker();
                heading.Darker();
                if (entity != null)
                {
                    PdfPCell entityline = new PdfPCell(new Phrase("Entity: " + entity, font));
                    entityline.BackgroundColor = heading;
                    entityline.Colspan = 4;
                    table.AddCell(entityline);
                }
                if (model.tick != null)
                {
                    String line;
                    if (model.include) line = "Include ";
                    else line = "Exclude ";
                    line += model.field.name + ", Values: ";
                    foreach (string i in model.tick) line += i + ", ";
                    line = line.Remove(line.Length - 2);
                    PdfPCell demo = new PdfPCell(new Phrase(line + entity, font));
                    demo.BackgroundColor = heading;
                    demo.Colspan = 4;
                    table.AddCell(demo);
                }
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();
                phrase.Add("Question");
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();
                phrase.Add("Answers");
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();
                phrase.Add("Number of Responses");
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                foreach (var question in model.questions)
                {
                    if (question.deletionTime == null)
                    {
                        phrase.Clear();
                        phrase.Add(question.questionNumber.ToString());
                        table.AddCell(new Phrase(phrase));
                        phrase.Clear();
                        phrase.Add(question.question);
                        table.AddCell(new Phrase(phrase));
                        PdfPTable options = new PdfPTable(2);
                        options.SetWidths(new int[2] { 4, 2 });
                        foreach (var answer in model.responses[question])
                        {
                            phrase.Clear();
                            phrase.Add(answer.Key);
                            options.AddCell(new Phrase(phrase));
                            phrase.Clear();
                            phrase.Add(answer.Value.ToString());
                            options.AddCell(new Phrase(phrase));
                        }

                        PdfPCell full = new PdfPCell(options);
                        full.Colspan = 2;
                        table.AddCell(full);
                    }
                }
                return table;
            }
            else
            {
                PdfPTable table = new PdfPTable(3 + model.selectedEntities.Count);
                table.WidthPercentage = 100;
                List<int> widthList = new List<int>();
                widthList.Add(2);
                widthList.Add(15);
                widthList.Add(12);
                widthList.Add(6);
                for (int i = 0; i < model.selectedEntities.Count-1; i++)
                {
                    widthList.Add(6);
                }
                table.SetWidths(widthList.ToArray());
                Phrase phrase = new Phrase("#", font);
                BaseColor basecolor = new BaseColor(232, 238, 244);
                BaseColor heading = new BaseColor(232, 238, 0);
                heading.Darker();
                heading.Darker();
                if (model.selectedEntities.Count > 0)
                {
                    Phrase entities = new Phrase("", new Font(FontFactory.GetFont("Verdana", 14)));
                    int i = 0;
                    if (model.selectedEntities.Count == 1) entities.Add("Entity: ");
                    else entities.Add("Entities: ");
                    foreach (Models.Entity ent in model.selectedEntities)
                    {
                        if (i == model.selectedEntities.Count - 1) entities.Add(ent.name);
                        else entities.Add(ent.name + ", ");
                        i++;
                    }
                    PdfPCell entityline = new PdfPCell(entities);
                    entityline.BackgroundColor = heading;
                    entityline.Colspan = 5;
                    table.AddCell(entityline);
                }
                if (model.tick != null)
                {
                    String line;
                    if (model.include) line = "Include ";
                    else line = "Exclude ";
                    line += model.field.name + ", Values: ";
                    foreach (string i in model.tick) line += i + ", ";
                    line = line.Remove(line.Length - 2);
                    PdfPCell demo = new PdfPCell(new Phrase(line + entity, font));
                    demo.BackgroundColor = heading;
                    demo.Colspan = 5;
                    table.AddCell(demo);
                }
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();
                phrase.Add("Question");
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();
                phrase.Add("Answers");
                table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                phrase.Clear();

                foreach (var e in model.selectedEntities)
                {
                    phrase.Add(e.name);
                    table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
                    phrase.Clear();
                }

                foreach (var question in model.questions)
                {

                    if (question.deletionTime == null)
                    {
                        phrase.Clear();
                        phrase.Add(question.questionNumber.ToString());
                        table.AddCell(new Phrase(phrase));
                        phrase.Clear();
                        phrase.Add(question.question);
                        table.AddCell(new Phrase(phrase));
                        PdfPTable options = new PdfPTable(1 + model.selectedEntities.Count);
                        List<int> widthList2 = new List<int>();
                        widthList2.Add(4);
                        widthList2.Add(2);
                        for (int i = 0; i < model.selectedEntities.Count-1; i++)
                        {
                            widthList2.Add(2);
                        }
                        options.SetWidths(widthList2.ToArray());

                            foreach (var answer in model.filteredResponses[question])
                            {
                                phrase.Clear();
                                phrase.Add(answer.Key);
                                options.AddCell(new Phrase(phrase));
                                foreach (var e in model.selectedEntities)
                                {

                                phrase.Clear();
                                phrase.Add(answer.Value[e.entityID].ToString());
                                options.AddCell(new Phrase(phrase));

                                }

                            }
                        PdfPCell full = new PdfPCell(options);
                        full.Colspan = model.selectedEntities.Count+1;
                        table.AddCell(full);
                    }
                }
                return table;
            }
        }
コード例 #4
0
 public PdfPTable SessionHistory(IList<Models.Poll> polls, String locations)
 {
     var userRepository = new UserRepository(NHibernateHelper.GetCurrentSession());
     string[] location = locations.Split('|');
     PdfPTable table = new PdfPTable(8);
     table.WidthPercentage = 100;
     int[] width = new int[] { 3,8,6,14,6,6,8,8 };
     table.SetWidths(width);
     Phrase phrase = new Phrase("Poll #", font);
     BaseColor basecolor = new BaseColor(232, 238, 244);
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Poll Name");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Attendance");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Location");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Opening Time");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Closing Time");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Poll Masters");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     phrase.Clear();
     phrase.Add("Poll Creators");
     table.AddCell(new PdfPCell(new PdfPCell(new Phrase(phrase)) { BackgroundColor = basecolor }));
     var i = 0;
     foreach (var poll in polls)
     {
         phrase.Clear();
         phrase.Add(poll.pollID.ToString());
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(poll.name);
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         int attendance = 0;
         foreach (var participant in poll.participants)
         {
             if (participant.attended)
             {
                 attendance += 1;
             }
         }
         phrase.Add(attendance.ToString());
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(location[i]);
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         if (poll.pollStart.HasValue) phrase.Add(poll.pollStart.Value.ToString());
         else phrase.Add("");
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         phrase.Add(poll.pollClose.ToString());
         table.AddCell(new Phrase(phrase));
         phrase.Clear();
         PdfPCell masters = new PdfPCell();
         foreach (Models.User master in poll.pollMasters) masters.AddElement(new Paragraph(master.FirstName + " " + master.LastName, font));
         table.AddCell(masters);
         PdfPCell creators = new PdfPCell();
         creators.BorderWidthLeft = 0;
         creators.BorderWidthTop = 0;
         foreach (Models.User creator in userRepository.GetCreatorsOfPoll(poll)) creators.AddElement(new Paragraph(creator.FirstName + " " + creator.LastName, font));
         table.AddCell(creators);
         i++;
     }
     return table;
 }
コード例 #5
0
        /*createReport()
        * Generates a .pdf document of the report based on the items selected. It requires that all fields have an item
        * selected or text entered. Once completed, it'll place the document on the user's Desktop. The following does
        * require the iTextSharp extension.
        */
        private void createReport()
        {
            try
            {
                //The following makes sure that all items are entered.
                if (clientName == null)
                {
                    MessageBox.Show("Client Name Cannot Be Empty", "Empty");
                }
                else if (clientStatus == null)
                {
                    MessageBox.Show("Client Status Cannot Be Empty", "Empty");
                }
                else if (clientPOC == null)
                {
                    MessageBox.Show("Client POC Cannot Be Empty", "Empty");
                }
                else if (clientArcVersion == null)
                {
                    MessageBox.Show("Client Arc Version Cannot Be Empty", "Empty");
                }
                else if (issuesTextBox.Text == "")
                {
                    MessageBox.Show("Open Issues Cannot Be Empty", "Empty");
                }
                else if (oppTextBox.Text == "")
                {
                    MessageBox.Show("Opportunities Cannot Be Empty", "Empty");
                }
                else if (summaryTextBox.Text == "")
                {
                    MessageBox.Show("Summary Cannot Be Empty", "Empty");
                }
                else
                {
                    //CSets the file path to the user's desktop
                    var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                    filename = Path.Combine(desktopFolder, reportAuthor + "_" + clientName + ".pdf");
                    var fullFileName = filename;
                    FileStream fileStream = new FileStream(fullFileName, FileMode.Create, FileAccess.Write, FileShare.None);
                    Document doc = new Document();
                    PdfWriter writer = PdfWriter.GetInstance(doc, fileStream);
                    doc.Open();

                    Chunk glue = new Chunk(new VerticalPositionMark());

                    Paragraph header = new Paragraph("Client Tune Up Report - " + reportAuthor, FontFactory.GetFont(FontFactory.TIMES_BOLD, 16));
                    header.Alignment = Element.ALIGN_CENTER;
                    doc.Add(header);

                    doc.Add(Chunk.NEWLINE);

                    Phrase clientPhrase = new Phrase();
                    clientPhrase.Add(new Chunk("Client: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    clientPhrase.Add(new Chunk(clientName, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    Paragraph clientP = new Paragraph(clientPhrase);
                    doc.Add(clientP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase pocPhrase = new Phrase();
                    pocPhrase.Add(new Chunk("Client POC: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    pocPhrase.Add(new Chunk(clientPOC, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    Paragraph pocP = new Paragraph(pocPhrase);
                    doc.Add(pocP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase datePhrase = new Phrase();
                    datePhrase.Add(new Chunk("Date: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    datePhrase.Add(new Chunk(reportDate, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    Paragraph dateP = new Paragraph(datePhrase);
                    doc.Add(dateP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase softPhrase = new Phrase();
                    softPhrase.Add(new Chunk("Software: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    Paragraph softP = new Paragraph(softPhrase);
                    doc.Add(softP);
                    softPhrase.Clear();
                    for (int i = 0; i < assetData.RowCount - 1; i++)
                    {
                        for (int j = 0; j < assetData.ColumnCount; j++)
                        {
                            softPhrase.Add(new Chunk(assetData.Rows[i].Cells[j].Value.ToString(), FontFactory.GetFont(FontFactory.TIMES, 12)));
                            softPhrase.Add(new Chunk("    "));
                        }
                        softP = new Paragraph(softPhrase);
                        doc.Add(softP);
                        softPhrase.Clear();
                    }

                    doc.Add(Chunk.NEWLINE);

                    Phrase gisPhrase = new Phrase();
                    gisPhrase.Add(new Chunk("GIS Platform: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    gisPhrase.Add(new Chunk(clientArcVersion, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    Paragraph gisP = new Paragraph(gisPhrase);
                    doc.Add(gisP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase issuesPhrase = new Phrase();
                    issuesPhrase.Add(new Chunk("Open Issues: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    Paragraph issuesP = new Paragraph(issuesPhrase);
                    doc.Add(issuesP);
                    issuesPhrase.Clear();
                    issuesPhrase.Add(new Chunk(clientIssues, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    issuesP = new Paragraph(issuesPhrase);
                    doc.Add(issuesP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase oppPhrase = new Phrase();
                    oppPhrase.Add(new Chunk("Opportunities: ", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    Paragraph oppP = new Paragraph(oppPhrase);
                    doc.Add(oppP);
                    oppPhrase.Clear();
                    oppPhrase.Add(new Chunk(clientOpportunites, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    oppP = new Paragraph(oppPhrase);
                    doc.Add(oppP);

                    doc.Add(Chunk.NEWLINE);

                    Phrase sumPhrase = new Phrase();
                    sumPhrase.Add(new Chunk("Summary: " + "  (" + clientStatus + ")", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                    Paragraph sumP = new Paragraph(sumPhrase);
                    doc.Add(sumP);
                    sumPhrase.Clear();
                    sumPhrase.Add(new Chunk(clientSummary, FontFactory.GetFont(FontFactory.TIMES, 12)));
                    sumP = new Paragraph(sumPhrase);
                    doc.Add(sumP);

                    doc.Add(Chunk.NEWLINE);

                    doc.Close();
                }
            }
            catch (Exception reportGen_ex)
            {
                MessageBox.Show(reportGen_ex.ToString(), "Error Generating Report");
            }
        }