示例#1
0
        public void WriteXMLToFields(XElement root)
        {
            JobDescription job = ExtractJobDescriptionFromXMLFormData(root);

            foreach (JobDescriptionCategory category in job.Categories)
            {
                JobDescriptionTable.Append(category.GetCategoryHeaderRow());
                JobDescriptionTable.Append(category.GenerateDetailsRow());
            }
            // Write Job Description Fields
            JOB_EmployeeName.Write($"{root.Element("LastName").Value}, {root.Element("FirstName").Value}", true, new RunProperties(new FontSize()
            {
                Val = "28"
            }));
            JOB_DistrictDivision.Write(root.Element("DepartmentDivision").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_AgencyActivity.Write(root.Element("DepartmentDivisionCode").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_PositionNumber.Write(root.Element("PositionNumber").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_ClassTitle.Write(job.ClassTitle, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_Grade.Write(job.Grade, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_WorkingTitle.Write(job.WorkingTitle, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_WorkAddress.Write(root.Element("WorkPlaceAddress").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_WorkingHours.Write(job.WorkingHours, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_Supervisor.Write(root.Element("AuthorName").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
            JOB_Supervises.Write(root.Element("SupervisedByEmployee").Value, true, new RunProperties(new FontSize()
            {
                Val = "20"
            }));
        }
        /// <summary>
        /// Method that writes the XML data to the template
        /// </summary>
        /// <param name="root">A <see cref="XElement"/> containing the XML form field data.</param>
        public void WriteXMLToFields(XElement root)
        {
            JobDescription job = ExtractJobDescriptionFromXMLFormData(root);

            // Write PPA Fields
            PPA_EmployeeName.Write($"{root.Element("LastName").Value}, {root.Element("FirstName").Value}");
            PPA_PayrollId.Write(root.Element("PayrollIdNumber").Value);
            // attempt to append newline subtext for Working Title

            PPA_ClassTitle.Write(job.ClassTitle);
            Run           titleRun           = new Run();
            RunProperties titleRunProperties = new RunProperties();
            FontSize      titleRunFontSize   = new FontSize()
            {
                Val = "16"
            };

            titleRunProperties.Append(titleRunFontSize);
            titleRun.Append(titleRunProperties);
            Text titleRunText = new Text(job.WorkingTitle);

            titleRun.Append(titleRunText);

            PPA_ClassTitle.Paragraph.InsertAfterSelf(new Paragraph(titleRun));
            PPA_Grade.Write(job.Grade);
            PPA_PositionNumber.Write(root.Element("PositionNumber").Value);
            PPA_StartDate.Write(DateTime.Parse(root.Element("StartDate").Value).ToString("MM/dd/yy"));
            PPA_EndDate.Write(DateTime.Parse(root.Element("EndDate").Value).ToString("MM/dd/yy"));
            PPA_DistrictDivision.Write(root.Element("DepartmentDivision").Value);
            PPA_AgencyActivity.Write(root.Element("DepartmentDivisionCode").Value);


            // Write Job Categories and Details
            int i = 0;

            foreach (JobDescriptionCategory category in job.Categories)
            {
                PPA_Categories[i].Write(category.Title, category.Weight, category.SelectedScore, category.GetCategoryRatedScore());
                JobDescriptionTable.Append(category.GetCategoryHeaderRow());
                JobDescriptionTable.Append(category.GenerateDetailsRow());
                i++;
            }
            PPA_TotalRatingValue.Write(job.GetOverallScore().ToString());
            RunFonts checkBoxRun = new RunFonts {
                Ascii = "Wingdings"
            };
            RunProperties checkBoxRunProperties = new RunProperties();

            checkBoxRunProperties.Append(checkBoxRun);
            RunFonts checkBoxRun1 = new RunFonts {
                Ascii = "Wingdings"
            };
            RunProperties checkBoxRunProperties1 = new RunProperties();

            checkBoxRunProperties1.Append(checkBoxRun1);
            switch (job.GetOverallRating())
            {
            case "Unsatisfactory":
                PPA_UnsatisfactoryRatingCheckBox.Write("\u2713", true, checkBoxRunProperties);
                PPA_MeritNotApprovedCheckBox.Write("\u2713", true, checkBoxRunProperties1);
                break;

            case "Improvement Needed":
                PPA_NeedsImprovementRatingCheckBox.Write("\u2713", true, checkBoxRunProperties);
                PPA_MeritNotApprovedCheckBox.Write("\u2713", true, checkBoxRunProperties1);
                break;

            case "Satisfactory":
                PPA_SatisfactoryRatingCheckBox.Write("\u2713", true, checkBoxRunProperties);
                PPA_MeritApprovedCheckBox.Write("\u2713", true, checkBoxRunProperties1);
                break;

            case "Exceeds Satisfactory":
                PPA_ExceedsSatisfactoryRatingCheckBox.Write("\u2713", true, checkBoxRunProperties);
                PPA_MeritApprovedCheckBox.Write("\u2713", true, checkBoxRunProperties1);
                break;

            case "Outstanding":
                PPA_OutstandingRatingCheckBox.Write("\u2713", true, checkBoxRunProperties);
                PPA_MeritApprovedCheckBox.Write("\u2713", true, checkBoxRunProperties1);
                break;
            }

            // Write PAF form fields
            PAF_EmployeeName.Write($"{root.Element("LastName").Value}, {root.Element("FirstName").Value}");
            PAF_PayrollId.Write(root.Element("PayrollIdNumber").Value);
            PAF_StartDate.Write(DateTime.Parse(root.Element("StartDate").Value).ToString("MM/dd/yy"));
            PAF_EndDate.Write(DateTime.Parse(root.Element("EndDate").Value).ToString("MM/dd/yy"));
            PAF_ClassGrade.Write($"{job.ClassTitle} - {job.Grade}");
            PAF_DistrictDivision.Write(root.Element("DepartmentDivision").Value);
            // HTML from the RTF Textarea needs to be chunked.
            using (Stream chunkStream = PAF_Assessment_Chunk.GetStream(FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter stringStream = new StreamWriter(chunkStream))
                {
                    stringStream.Write($"<html>{root.Element("Assessment").Value}</html>");
                }
            }
            AltChunk assessmentChunk = new AltChunk
            {
                Id = "assessmentChunk"
            };

            PAF_Assessment.Paragraph.InsertBeforeSelf(assessmentChunk);
            using (Stream chunkStream = PAF_Recommendations_Chunk.GetStream(FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter stringStream = new StreamWriter(chunkStream))
                {
                    stringStream.Write($"<html>{root.Element("Recommendation").Value}</html>");
                }
            }
            AltChunk recommendationsChunk = new AltChunk
            {
                Id = "recommendationsChunk"
            };

            PAF_Recommendations.Paragraph.InsertBeforeSelf(recommendationsChunk);

            // Write Job Description Fields
            JOB_EmployeeName.Write($"{root.Element("LastName").Value}, {root.Element("FirstName").Value}");
            JOB_DistrictDivision.Write(root.Element("DepartmentDivision").Value);
            JOB_AgencyActivity.Write(root.Element("DepartmentDivisionCode").Value);
            JOB_PositionNumber.Write(root.Element("PositionNumber").Value);
            JOB_ClassTitle.Write(job.ClassTitle);
            JOB_Grade.Write(job.Grade);
            JOB_WorkingTitle.Write(job.WorkingTitle);
            JOB_WorkAddress.Write(root.Element("WorkPlaceAddress").Value);
            JOB_WorkingHours.Write(job.WorkingHours);
            JOB_Supervisor.Write(root.Element("AuthorName").Value);
            JOB_Supervises.Write(root.Element("SupervisedByEmployee").Value);
        }