// For help with how to work with OpenXml documents:
        // https://docs.microsoft.com/en-us/office/open-xml/how-do-i

        public void Generate(SubmittedPreKApplicationForm Form, TimeZoneInfo TimeZone, string FileName)
        {
            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }

            using (WordprocessingDocument document = WordprocessingDocument.Create(FileName, WordprocessingDocumentType.Document)) {
                // Create the main document part
                MainDocumentPart mainPart = document.AddMainDocumentPart();
                LSSDDocumentStyles.AddStylesToDocument(document);

                mainPart.Document = GenerateBody(Form, TimeZone);
            }
        }
        private Document GenerateBody(SubmittedPreKApplicationForm Form, TimeZoneInfo TimeZone)
        {
            List <OpenXmlElement> pageParts = new List <OpenXmlElement>();

            // Now add all the generated parts
            // The code for these parts is in /FormSections
            pageParts.AddRange(PageTitleSection.GetSection(Form, TimeZone));
            pageParts.AddRange(SchoolPreferencesSection.GetSection(Form.Form.SchoolPreferences));
            pageParts.AddRange(StudentInfoSection.GetSection(Form.Form.Student, TimeZone, true));
            pageParts.AddRange(SubmittedBySection.GetSection(Form.Form.SubmittedBy));
            pageParts.AddRange(SiblingSection.GetSection(Form.Form.Siblings));
            pageParts.AddRange(PreKInfoSection.GetSection(Form.Form.PreKInfo));
            pageParts.AddRange(ContactsSection.GetSection(Form.Form.Contacts));
            pageParts.AddRange(FormEndSection.GetSection(Form, TimeZone));
            return(new Document(new Body(pageParts)));
        }
示例#3
0
        // TODO: Improve resuablility of the following two methods
        public string GenerateForm(SubmittedPreKApplicationForm Form, TimeZoneInfo TimeZone)
        {
            if (Form == null)
            {
                throw new Exception("Form cannot be null");
            }

            string filename = Path.Combine(_tempDirPath, genFilename(Form));

            PreKApplicationFormGenerator generator = new PreKApplicationFormGenerator();

            // Generate the file
            generator.Generate(Form, TimeZone, filename);

            // Store the filename in the tracking list
            _generatedFileNames.Add(filename);

            // Return the filename
            return(filename);
        }
示例#4
0
 public static IEnumerable <OpenXmlElement> GetSection(SubmittedPreKApplicationForm Form, TimeZoneInfo timezone)
 {
     return(GetSection(Form, timezone, "LSSD Pre-Kindergarten Application Form", Form.Id.ToString()));
 }
 public PreKEmailNotification(SubmittedPreKApplicationForm Form, FormFactory Factory, TimeZoneInfo TimeZone)
 {
     this._form     = Form;
     this._timeZone = TimeZone;
     this._factory  = Factory;
 }