/// <summary>
        /// Populates manifest xml rootXmlObject object tree from the database via a ManifestPopulater instance, and serializes
        /// the xml to disk in the location specified in the xmlFilePath parameter.
        /// </summary>
        /// <param name="manifestXmlFilepath">Fully qualified path where the manifist XML will be written to disk.</param>
        /// <param name="manifestFile">Output.  A refernce to the manifest xml object tree.</param>
        /// <returns></returns>
        public bool GenerateXmlFile(string manifestXmlFilepath, out IRootXmlClass manifestFile)
        {
            //Populate in memory.
            var manifestPopulator = new ManifestPopulator(_currentContext, _formDataRootXmlObj);

            manifestFile = manifestPopulator.GetXmlRootClassPopulated();

            //Write to xml to disk.
            return(Helper.WriteXmlFileToDisk(manifestFile, this.GetNamespaces(), manifestXmlFilepath));
        }
Beispiel #2
0
        public bool GenerateXmlFile(string xmlFilepath, out IRootXmlClass formDataFile)
        {
            var formDataPopulator = new FormDataPopulator(
                pr1094HeaderRow:               employerInfoToTransmit,
                pr1095HeaderRows:              employeesToTransmit,
                pr1095CoveredRows:             dependentsToTransmit,
                pr1094OtherAleMembers:         employerSubsidiariesToTransmit,
                prACAEFileTransmissionHistory: correctedTransmissionInfo,
                isTest:                        isTest,
                generateXmlOnSchemaError:      generateXmlOnSchemaError);

            formDataFile = formDataPopulator.GetXmlRootClassPopulated();

            return(Helper.WriteXmlFileToDisk(formDataFile, this.GetNamespaces(), xmlFilepath));
        }
Beispiel #3
0
        internal static bool WriteXmlFileToDisk(IRootXmlClass rootXmlObj, XmlSerializerNamespaces nmSpaces,
                                                string xmlFilepath)
        {
            try
            {
                var serializer = new XmlSerializer(rootXmlObj.GetType());
                Directory.CreateDirectory(Path.GetDirectoryName(xmlFilepath));

                using (TextWriter writer = new StreamWriter(xmlFilepath, true, UpperCaseUTF8.UpperCaseUtf8Encoding))
                    serializer.Serialize(writer, rootXmlObj, nmSpaces);
            }
            catch (Exception e)
            {
                throw new Exception(string.IsNullOrWhiteSpace(e.Message)
                    ? "An unknown error occurred while writing to disk.  Please try again."
                    : e.Message);
            }

            return(true);
        }
 /// <summary>
 /// Sets readonly TransmissionContext and IRootXmlClass instance variables.
 /// </summary>
 /// <param name="currentContext">Contains form instance variables/properties for the current context.</param>
 /// <param name="formDataRootXmlObj">A refernce to the form data xml object tree.</param>
 public ManifestExporter(TransmissionContext currentContext, IRootXmlClass formDataRootXmlObj)
 {
     _currentContext     = currentContext;
     _formDataRootXmlObj = formDataRootXmlObj as Form109495CTransmittalUpstreamType;
 }