Esempio n. 1
0
    protected void PopulatePDF(ref iTextSharp.text.Document doc)
    {
        PRMS controller = new PRMS();

        List <UserJobPosting> userJobPostingList = new List <UserJobPosting>();

        userJobPostingList = controller.GetUserJobPostingByStatus(Request["status"]);

        JobPosting            aJobPosting = new JobPosting();
        List <UserJobPosting> refinedList = new List <UserJobPosting>();
        User       aUser         = new User();
        List <int> idTrackerList = new List <int>();
        bool       exists        = false;

        doc.Add(new Paragraph("\n\n"));
        doc.Add(new Chunk("Candidate Status Report (" + Request["status"] + ")", FontFactory.GetFont("arial", 22f)).SetUnderline(1f, -1.5f));
        doc.Add(new Paragraph("Date: " + DateTime.Now.ToString() + "\n\n"));

        PdfPTable table;

        foreach (var userJobPostingItem in userJobPostingList)
        {
            table = new PdfPTable(5);
            table.AddCell("First Name");
            table.AddCell("Last Name");
            table.AddCell("Email");
            table.AddCell("Phone");
            table.AddCell("Date");

            int    searchJobPostingID = userJobPostingItem.JobPostingID;
            string statusDate         = userJobPostingItem.StatusDate.ToString("MMM dd, yyyy");

            aJobPosting = controller.GetJobPostingDetails(searchJobPostingID);
            foreach (var idTrackerItem in idTrackerList)
            {
                if (idTrackerItem == searchJobPostingID)
                {
                    exists = true;
                    break;
                }
                else
                {
                    exists = false;
                }
            }

            if (exists == false)
            {
                doc.Add(new Chunk(aJobPosting.CompanyName + " - " + aJobPosting.Description, FontFactory.GetFont("arial", 14f)));
                //Get UserID by JobPostingID and Status
                refinedList = controller.GetUserIDByJobPostingStatus(searchJobPostingID, Request["status"]);

                foreach (var refinedListItem in refinedList)
                {
                    int searchUserID = refinedListItem.UserID;

                    aUser = controller.GetUserDetails(searchUserID);

                    table.AddCell(aUser.FirstName);
                    table.AddCell(aUser.LastName);
                    table.AddCell(aUser.UserEmail);
                    table.AddCell(aUser.Phone);
                    table.AddCell(GetStatusDate(searchUserID, searchJobPostingID, Request["Status"]));
                }
                doc.Add(table);
                doc.Add(new Paragraph("\n"));

                idTrackerList.Add(searchJobPostingID);
            }
        }
    }