/// <summary> /// generates xml file(s) and archives it using gzip library /// </summary> /// <param name="catalog">catalog from which data is retrieved</param> /// <param name="reader">datareader</param> /// <param name="identifier">feed identifier used for file name</param> /// <param name="configSection">name of the configuration section containing catalog attributes</param> private void WriteFeedFiles(string catalog, IDataReader reader, string identifier, string configSection) { var dict = ConfigurationManager.GetSection(configSection) as StringDictionary; var feedFilePath = PlaRelatedFeedUtils.GetFeedFilePath(identifier, false, OutputFolderPath); Log.DebugFormat("[WriteFeedFile] {0} start", feedFilePath); //create gzip archive stream if (GzipFiles) { var gZipStream = new GZipStream(File.Create(feedFilePath + ".gz"), CompressionMode.Compress); var xmlWriter = XmlWriter.Create(gZipStream, new XmlWriterSettings { Indent = true }); FeedXmlElement(xmlWriter, reader, dict, catalog, identifier, feedFilePath); xmlWriter.Close(); gZipStream.Close(); } else { var xmlWriter = XmlWriter.Create(feedFilePath, new XmlWriterSettings { Indent = true }); FeedXmlElement(xmlWriter, reader, dict, catalog, identifier, feedFilePath); xmlWriter.Close(); } }
/// <summary> /// generates xml file(s) and archives it using gzip library /// </summary> /// <param name="catalog">catalog from which data is retrieved</param> /// <param name="reader">datareader</param> /// <param name="identifier">feed identifier used for file name</param> /// <param name="configSection">name of the configuration section containing catalog attributes</param> private void WriteFeedFiles(string catalog, IDataReader reader, string identifier, string configSection) { var dict = ConfigurationManager.GetSection(configSection) as StringDictionary; var feedFilePath = PlaRelatedFeedUtils.GetFeedFilePath(identifier, false, OutputFolderPath); var feedFilePathSecondary = (HasTwoGenerators()) ? PlaRelatedFeedUtils.GetFeedFilePath(identifier, true, AncillaryOutputFolderPath) : string.Empty; Log.DebugFormat("[WriteFeedFile] {0} start", feedFilePath); var countRec = new Tuple <int, int, int>(0, 0, 0); //create gzip archive stream if (GzipFiles) { var gZipStream = new GZipStream(File.Create(feedFilePath + ".gz"), CompressionMode.Compress); var xmlWriter = XmlWriter.Create(gZipStream, new XmlWriterSettings { Indent = true }); GZipStream gZipStreamSecondary = null; XmlWriter xmlWriterSecondary = null; if (HasTwoGenerators()) { gZipStreamSecondary = new GZipStream(File.Create(feedFilePathSecondary + ".gz"), CompressionMode.Compress); xmlWriterSecondary = XmlWriter.Create(gZipStreamSecondary, new XmlWriterSettings { Indent = true }); } FeedXmlElement(xmlWriter, xmlWriterSecondary, reader, dict, catalog, identifier, feedFilePath, ref countRec); xmlWriter.Close(); if (xmlWriterSecondary != null) { xmlWriterSecondary.Close(); } gZipStream.Close(); if (gZipStreamSecondary != null) { gZipStreamSecondary.Close(); } } else { var xmlWriter = XmlWriter.Create(feedFilePath, new XmlWriterSettings { Indent = true }); XmlWriter xmlWriterSecondary = null; if (HasTwoGenerators()) { xmlWriterSecondary = XmlWriter.Create(feedFilePathSecondary, new XmlWriterSettings { Indent = true }); } FeedXmlElement(xmlWriter, xmlWriterSecondary, reader, dict, catalog, identifier, feedFilePath, ref countRec); xmlWriter.Close(); if (xmlWriterSecondary != null) { xmlWriterSecondary.Close(); } } Log.DebugFormat("[WriteFeedFile] {0} complete. Total written records: {1}; Error records: {2}, skipped records: {3}.", feedFilePath, countRec.Item1, countRec.Item2, countRec.Item3); }