Ejemplo n.º 1
0
        /// <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)
        {
            // Write PAF form fields
            XElement job            = root.Element("JobDescription");
            string   assessmentType = root.Element("SelectedPAFType").Value;
            RunFonts checkBoxRun    = new RunFonts {
                Ascii = "Wingdings"
            };
            RunProperties checkBoxRunProperties = new RunProperties();

            checkBoxRunProperties.Append(checkBoxRun);
            switch (assessmentType)
            {
            case "Periodic Performance Assessment":
                PAF_PeriodicPerformanceAssessment.Write("\u2713", true, checkBoxRunProperties);
                break;

            case "Probationary Midpoint":
                PAF_ProbationaryMidpoint.Write("\u2713", true, checkBoxRunProperties);
                break;

            case "Rating Justification":
                PAF_RatingJustification.Write("\u2713", true, checkBoxRunProperties);
                break;
            }

            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.Element("ClassTitle").Value} / {job.Element("Grade").Value}");
            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);
        }
Ejemplo n.º 2
0
        /// <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);
        }