Beispiel #1
0
        public IMarketFileExportResult[] Export(CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var prismPorts   = cspDunsPorts
                               .Where(x => x.ProviderId == 1)
                               .ToArray();

            var context = new Prism650Context();

            foreach (var prismPort in prismPorts)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                var headers = marketDataAccess.ListUnprocessed(prismPort.LdcDuns, prismPort.Duns, 1);
                if (headers.Length == 0)
                {
                    logger.TraceFormat("Zero 650 Prism records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       prismPort.LdcDuns, prismPort.Duns);
                    continue;
                }

                logger.DebugFormat("Exporting {0} unprocessed 650 record(s) for TDSP Duns \"{1}\" and CR Duns \"{2}\".",
                                   headers.Length, prismPort.LdcDuns, prismPort.Duns);

                foreach (var header in headers)
                {
                    if (!header.HeaderKey.HasValue)
                    {
                        continue;
                    }

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    var headerKey = header.HeaderKey.Value;
                    context.Initialize();

                    var identifiedMarket = clientDataAccess.IdentifyMarket(header.TdspDuns);
                    if (identifiedMarket.HasValue)
                    {
                        context.SetMarket(identifiedMarket.Value);
                    }

                    context.SetFileProperties(prismPort, header.TdspDuns, "MTR");
                    context.SetHeaderId(headerKey);
                    context.TransactionSetPurposeCode = header.TransactionSetPurposeCode;

                    WriteHeader(context, header);
                    WriteAccount(context, header);
                    WriteService(context, header);
                }
            }

            return(context.Models);
        }
Beispiel #2
0
        public void Execute(EncryptFileContext context, CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();

            foreach (var port in cspDunsPorts)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                if (!port.EncryptionEnabledFlag)
                {
                    continue;
                }

                logger.TraceFormat(
                    "Identified CSP DUNS Port {0} for LDC \"{1}\" \nDirectory In: \"{2}\" \nDirectory Out: \"{3}\" \n",
                    port.CspDunsPortId, port.LdcShortName, port.DirectoryIn, port.DirectoryOut);

                IPgpEncryption pgpEncryption;

                try
                {
                    pgpEncryption = InfrastructureFactory
                                    .CreatePgpEncryptor(port.PgpEncryptionKey, port.PgpSignatureKey, port.PgpPassphrase);
                }
                catch (IOException ex)
                {
                    logger.ErrorFormat(ex,
                                       "Unable to create PGP Encryption class for Csp Duns Port \"{0}\".", port.CspDunsPortId);
                    continue;
                }

                var identifier = port.TradingPartnerId.Substring(0, 3);

                var ldcId = port.LdcId ?? 0;
                if (ldcId == 0)
                {
                    var clientSearchPattern = string.Format("*{0}*", identifier);
                    EncryptFiles(pgpEncryption, context, clientSearchPattern, token);
                }
                else
                {
                    var fileExtension         = port.ProviderId == 2 ? ".x12" : ".txt";
                    var extendedSearchPattern = string.Format("*{0}*{1}*{2}", identifier, port.LdcShortName, fileExtension);
                    EncryptFiles(pgpEncryption, context, extendedSearchPattern, token);
                }
            }

            MoveFiles(context, "*", token);
        }
Beispiel #3
0
        public void Execute(TransmitFileContext context, CancellationToken token)
        {
            var marketFiles = marketDataAccess.ListEncryptedOutboundMarketFiles()
                              .Where(x => !x.FileType.Equals("CBF", StringComparison.Ordinal))
                              .ToArray();

            if (!marketFiles.Any())
            {
                return;
            }

            logger.DebugFormat("Transmitting {0} encrypted outbound market file(s).", marketFiles.Length);

            var ports = clientDataAccess.ListCspDunsPort();

            foreach (var marketFile in marketFiles)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                var port = IdentifyCspDunsPort(marketFile, ports);
                if (port == null)
                {
                    var message = string.Format("No CspDunsPort found for LDCID: {0} and CSPDUNSID: {1}.",
                                                marketFile.LdcId, marketFile.CspDunsId);

                    logger.Error(message);

                    marketFile.Status       = MarketFileStatusOptions.Error;
                    marketFile.ProcessError = message;
                    marketFile.ProcessDate  = DateTime.Now;
                    marketDataAccess.UpdateMarketFile(marketFile);
                    continue;
                }

                if (!port.TransportEnabledFlag)
                {
                    logger.InfoFormat("CspDunsPort {0} is not enabled for transport.", marketFile.CspDunsId);

                    marketFile.Status       = MarketFileStatusOptions.Error;
                    marketFile.ProcessError = "Transport not enabled.";
                    marketFile.ProcessDate  = DateTime.Now;
                    marketDataAccess.UpdateMarketFile(marketFile);
                    continue;
                }

                logger.TraceFormat("Transmitting file \"{0}\" for CSPDUNS {1}.", marketFile.FileName, port.CspDunsId);
                TransmitMarketFile(context, marketFile, port);
            }
        }
Beispiel #4
0
        public void Execute(ErcotFileContext context, CancellationToken token)
        {
            var marketFiles = marketDataAccess.ListEncryptedOutboundMarketFiles()
                              .Where(x => x.FileType.Equals("CBF", StringComparison.Ordinal))
                              .ToArray();

            if (!marketFiles.Any())
            {
                return;
            }

            logger.DebugFormat("Transmitting {0} Customer Billing File(s).", marketFiles.Length);

            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var grouping     = marketFiles
                               .GroupBy(x => x.CspDunsId ?? 0)
                               .Select(x => new
            {
                CspDunsId   = x.Key,
                MarketFiles = x.ToArray(),
            });

            foreach (var item in grouping)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                var port = IdentifyCspDunsPort(cspDunsPorts, item.CspDunsId);
                if (port == null)
                {
                    var marketFileIds = string.Join(", ", item.MarketFiles.Select(x => x.MarketFileId));

                    logger.InfoFormat(
                        "Unable to find Texas Port for Csp Duns Id {0}. Market Files {1} have been updated to Error status.",
                        item.CspDunsId, marketFileIds);

                    UpdateMarketFilesToError(item.MarketFiles, MissingCspDunsTexasPort);
                    continue;
                }

                if (!port.TransportEnabledFlag)
                {
                    logger.WarnFormat("Csp Duns Port {0} is not enabled for transport.", item.CspDunsId);
                    continue;
                }

                TransportFiles(context, port, item.MarketFiles, token);
            }
        }
Beispiel #5
0
        public void Execute(DecryptFileContext context, CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();

            foreach (var port in cspDunsPorts)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                logger.TraceFormat(
                    "Identified CSP DUNS Port {0} for LDC \"{1}\" \nDirectory In: \"{2}\" \nDirectory Out: \"{3}\" \n",
                    port.CspDunsPortId, port.LdcShortName, port.DirectoryIn, port.DirectoryOut);

                IPgpEncryption pgpEncryption;

                try
                {
                    pgpEncryption = InfrastructureFactory
                                    .CreatePgpEncryptor(port.PgpEncryptionKey, port.PgpSignatureKey, port.PgpPassphrase);
                }
                catch (IOException ex)
                {
                    logger.ErrorFormat(ex,
                                       "Unable to create PGP Encryption class for Csp Duns Port \"{0}\".", port.CspDunsPortId);
                    continue;
                }

                var ldcId = port.LdcId ?? 0;
                if (ldcId == 0)
                {
                    var identifier          = port.TradingPartnerId.Substring(0, 3);
                    var clientSearchPattern = string.Format("*{0}*", identifier);
                    var dunsSearchPattern   = string.Format("*{0}*", port.Duns);

                    DecryptFiles(pgpEncryption, context, clientSearchPattern, token);
                    DecryptFiles(pgpEncryption, context, dunsSearchPattern, token);
                    continue;
                }

                var sourceDirectory = new DirectoryInfo(port.DirectoryIn);
                if (!sourceDirectory.Exists)
                {
                    logger.ErrorFormat("Encryption Directory \"{0}\" was not found or has been deleted.",
                                       sourceDirectory.FullName);
                    continue;
                }

                var sourceFiles = sourceDirectory.GetFiles();
                logger.TraceFormat("Identified {0} file(s) in directory \"{1}\" (all files).",
                                   sourceFiles.Length, sourceDirectory.FullName);

                if (sourceFiles.Length == 0)
                {
                    continue;
                }

                DecryptFiles(pgpEncryption, context, sourceFiles, token);
            }
        }
Beispiel #6
0
        public IMarketFileExportResult[] Export(CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var xmlPorts     = cspDunsPorts
                               .Where(x => x.ProviderId == 2)
                               .ToArray();

            var collection = new List <IMarketFileExportResult>();

            foreach (var xmlPort in xmlPorts)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                var model = new Export820Model
                {
                    CspDuns          = xmlPort.Duns,
                    LdcDuns          = xmlPort.LdcDuns,
                    LdcShortName     = xmlPort.LdcShortName,
                    TradingPartnerId = xmlPort.TradingPartnerId,
                };

                var partner = marketDataAccess.LoadCspDunsTradingPartner(xmlPort.Duns, xmlPort.LdcDuns);
                if (partner == null)
                {
                    logger.ErrorFormat(
                        "No CSP DUNS Trading Partner record exists between CR DUNS \"{0}\" and LDC DUNS \"{1}\". 820 Transactions will not be exported.",
                        xmlPort.Duns, xmlPort.LdcDuns);

                    continue;
                }

                marketDataAccess.LoadCspDunsTradingPartnerConfig(partner);
                model.CspDunsTradingPartnerId = partner.CspDunsTradingPartnerId;

                var headers = exportDataAccess.ListUnprocessed(xmlPort.LdcDuns, xmlPort.Duns, 2);
                if (headers.Length == 0)
                {
                    logger.TraceFormat("Zero 820 Xml records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       xmlPort.LdcDuns, xmlPort.Duns);
                    continue;
                }

                logger.DebugFormat("Exporting {0} unprocessed 820 record(s) for TDSP Duns \"{1}\" and CR Duns \"{2}\".",
                                   headers.Length, xmlPort.LdcDuns, xmlPort.Duns);

                XNamespace marketNamespace = "http://CIS.Integration.Schema.Market.Common.Market820";
                var        document        = new XDocument(
                    new XElement(marketNamespace + "Market820",
                                 new XAttribute(XNamespace.Xmlns + "ns0", marketNamespace),
                                 new XElement("TransactionCount", model.HeaderCount),
                                 new XElement("LdcIsaQualifier", partner.GetConfig("TradingPartnerISAQualifier")),
                                 new XElement("LdcIsaIdentifier", partner.GetConfig("TradingPartnerISAIdentifier")),
                                 new XElement("LdcDuns", partner.TradingPartnerDuns),
                                 new XElement("CspIsaQualifier", partner.GetConfig("CspISAQualifier")),
                                 new XElement("CspDuns", partner.CspDuns),
                                 new XElement("MarketFileId", string.Empty),
                                 new XElement("LdcGSIdentifier", partner.GetConfig("TradingPartnerGSIdentifier")),
                                 new XElement("LdcN1Qualifier", partner.GetConfig("TradingPartnerN1Qualifier")),
                                 new XElement("CspN1Qualifier", partner.GetConfig("CspN1Qualifier")),
                                 new XElement("AuthInfoQualifier", string.Empty),
                                 new XElement("AuthInfo", string.Empty),
                                 new XElement("SecurityInfoQualifier", string.Empty),
                                 new XElement("SecurityInfo", string.Empty),
                                 new XElement("InterchangeControlNbr", string.Empty),
                                 new XElement("AckRequested", string.Empty),
                                 new XElement("TestIndicator", string.Empty),
                                 new XElement("SubelementSeparator", partner.GetConfig("TradingPartnerSubElementDelimiter")),
                                 new XElement("FunctionalGroup", "GE"),
                                 new XElement("FunctionalGroupControlNbr", string.Empty),
                                 new XElement("CspIsaIdentifier", partner.GetConfig("CspIsaIdentifier")),
                                 new XElement("CspGSIdentifier", partner.GetConfig("CspGSIdentifier"))));

                if (document.Root == null)
                {
                    logger.Error("Unable to create 820 XML document. Root node element is null.");
                    continue;
                }

                foreach (var header in headers)
                {
                    if (!header.HeaderKey.HasValue)
                    {
                        continue;
                    }

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    var element = new XElement("Transaction",
                                               new XElement("SegmentCount", "0"));

                    WriteHeader(element, header);
                    model.AddHeaderKey(header.HeaderKey.Value);

                    document.Root.Add(element);
                }

                model.Document = document;
                collection.Add(model);
            }

            return(collection.ToArray());
        }
Beispiel #7
0
        public IMarketFileExportResult[] Export(CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var cspDunsPort  = cspDunsPorts
                               .Where(x => x.ProviderId == 3)
                               .ToArray();

            var collection = new List <IMarketFileExportResult>();

            foreach (var port in cspDunsPort)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }


                var partner = marketDataAccess.LoadCspDunsTradingPartner(port.Duns, port.LdcDuns);
                if (partner == null)
                {
                    logger.ErrorFormat(
                        "No CSP DUNS Trading Partner record exists between CR DUNS \"{0}\" and LDC DUNS \"{1}\". 814 Transactions will not be exported.",
                        port.Duns, port.LdcDuns);

                    continue;
                }

                marketDataAccess.LoadCspDunsTradingPartnerConfig(partner);

                var headers = exportDataAccess.ListUnprocessed(port.LdcDuns, port.Duns, 3);
                if (headers.Length == 0)
                {
                    logger.TraceFormat("Zero 814 records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       port.LdcDuns, port.Duns);
                    continue;
                }



                var distinctActionCodes = headers.Select(x => new { x.ActionCode }).Distinct().ToList();


                //we need to loop for each action code and based on that generate a file
                foreach (var uniqueValue in distinctActionCodes)
                {
                    var value = uniqueValue;

                    var headerList = new List <Type814Header>();

                    foreach (var header in headers)
                    {
                        if (header.ActionCode.Trim().ToUpper() == value.ActionCode.Trim().ToUpper())
                        {
                            headerList.Add(header);
                        }
                    }

                    if (headerList.Count <= 0)
                    {
                        continue;
                    }

                    var model = new Export814Model
                    {
                        CspDuns              = port.Duns,
                        LdcDuns              = port.LdcDuns,
                        LdcShortName         = port.LdcShortName,
                        TradingPartnerId     = port.TradingPartnerId,
                        ForSsxContent        = true,
                        UniqueFileNameFiller = string.Format("{0}_SSX", value.ActionCode.Trim())
                    };

                    model.CspDunsTradingPartnerId = partner.CspDunsTradingPartnerId;

                    var fileContentBuilder = BuildFileContent(headerList, port);

                    model.Content = fileContentBuilder.ToString();
                    model.AddHeaderKeys(headerList.Where(x => x.HeaderKey.HasValue).Select(x => x.HeaderKey.Value).ToList().ToArray());

                    collection.Add(model);
                }//loop for each Action Code combination
            }

            return(collection.ToArray());
        }
Beispiel #8
0
        public IMarketFileExportResult[] Export(CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var prismPorts   = cspDunsPorts
                               .Where(x => x.ProviderId == 1)
                               .ToArray();

            var context = new Prism814Context();

            foreach (var prismPort in prismPorts)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                var headers = exportDataAccess.ListUnprocessed(prismPort.LdcDuns, prismPort.Duns, 1);
                if (headers.Length == 0)
                {
                    logger.TraceFormat("Zero 814 Prism records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       prismPort.LdcDuns, prismPort.Duns);
                    continue;
                }

                logger.DebugFormat("Exporting {0} unprocessed 814 record(s) for TDSP Duns \"{1}\" and CR Duns \"{2}\".",
                                   headers.Length, prismPort.LdcDuns, prismPort.Duns);

                foreach (var header in headers)
                {
                    if (!header.HeaderKey.HasValue)
                    {
                        continue;
                    }

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    var headerKey = header.HeaderKey.Value;

                    context.Initialize();
                    context.ActionCode = header.ActionCode;

                    var identifiedMarket = clientDataAccess.IdentifyMarket(header.TdspDuns);
                    if (identifiedMarket.HasValue)
                    {
                        context.SetMarket(identifiedMarket.Value);
                    }

                    if (context.ActionCode.Equals("PC", StringComparison.Ordinal) ||
                        context.ActionCode.Equals("PD", StringComparison.Ordinal) ||
                        context.Market != MarketOptions.Texas)
                    {
                        context.SetFileProperties(prismPort, header.TdspDuns, "ENR");
                    }
                    else
                    {
                        context.SetFileProperties(prismPort, "183529049", "ENR");
                    }

                    context.SetHeaderId(headerKey);
                    var services = exportDataAccess.ListServices(headerKey);
                    WriteHeader(context, header, services);
                    WriteAccount(context, header);
                    WriteName(context, header);
                    WriteService(context, header, services);
                }
            }

            return(context.Models);
        }
Beispiel #9
0
        public IMarketFileExportResult[] Export(CancellationToken token)
        {
            var cspDunsPorts = clientDataAccess.ListCspDunsPort();
            var prismPorts   = cspDunsPorts
                               .Where(x => x.ProviderId == 1)
                               .ToArray();

            var context = new Prism810Context();

            foreach (var prismPort in prismPorts)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                var headers = marketDataAccess.ListUnprocessed(prismPort.LdcDuns, prismPort.Duns, 1);
                if (headers.Length == 0)
                {
                    logger.TraceFormat("Zero 810 Prism records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       prismPort.LdcDuns, prismPort.Duns);
                    continue;
                }

                logger.DebugFormat("Exporting {0} unprocessed 810 record(s) for TDSP Duns \"{1}\" and CR Duns \"{2}\".",
                                   headers.Length, prismPort.LdcDuns, prismPort.Duns);

                var cspDuns = clientDataAccess.LoadDunsByCspDunsId(prismPort.CspDunsId);

                foreach (var header in headers)
                {
                    if (!header.HeaderKey.HasValue)
                    {
                        continue;
                    }

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    var headerKey = header.HeaderKey.Value;
                    context.Initialize();

                    var ldcModel = clientDataAccess.LoadLdcByTdspDuns(header.TdspDuns);
                    if (ldcModel == null)
                    {
                        logger.ErrorFormat("Failed to load LDC for DUNS \"{0}\".", header.TdspDuns);
                        return(context.Models);
                    }

                    context.SetMarket(ldcModel.MarketId);
                    context.SetFileProperties(prismPort, header.TdspDuns, "INV");
                    context.IsCustomerInvoice = false;
                    context.BillFromName      = header.TdspName;
                    context.BillFromDuns      = header.TdspDuns;

                    if (!string.IsNullOrWhiteSpace(cspDuns) && cspDuns.Equals("RYDER0000", StringComparison.Ordinal))
                    {
                        context.SetFileNamePrefix("ECPCUSTINVRYDER");
                    }

                    if (!string.IsNullOrEmpty(header.CustomerDUNS))
                    {
                        var seekDuns = header.TdspDuns;
                        if (seekDuns.Length > 9)
                        {
                            seekDuns = seekDuns.Substring(0, 9);
                        }

                        var partnerId = context.TradingPartnerId.Replace(seekDuns, header.CustomerDUNS);
                        context.SetTradingPartnerId(partnerId);

                        var cspDunsList = clientDataAccess.ListCspDuns();
                        if (cspDunsList == null || cspDunsList.Length == 0)
                        {
                            logger.Error("No CSP DUNS exist or none could be found.");
                            return(context.Models);
                        }

                        var cspDunsItem = cspDunsList.First();
                        context.IsCustomerInvoice = true;
                        context.BillFromName      = cspDunsItem.Description;
                        context.BillFromDuns      = cspDunsItem.Duns;

                        if (header.CustomerDUNS.Equals("055458350"))
                        {
                            var crdPartnerId      = context.TradingPartnerId;
                            var fixedCrdPartnerId = string.Concat("CRD",
                                                                  crdPartnerId.Substring(3, crdPartnerId.Length - 3));

                            context.SetTradingPartnerId(fixedCrdPartnerId);
                        }

                        if (header.CustomerDUNS.Equals("PROKARMAI", StringComparison.Ordinal))
                        {
                            var lptPartnerId      = context.TradingPartnerId;
                            var fixedLptPartnerId = string.Concat("LPT",
                                                                  lptPartnerId.Substring(3, lptPartnerId.Length - 3));

                            var zzDuns = string.Concat("ZZ", header.CustomerDUNS);
                            context.SetFileProperties(prismPort, zzDuns, fixedLptPartnerId, header.CustomerDUNS, string.Empty);
                        }
                    }

                    context.SetHeaderId(headerKey);

                    var invoiceConfig = clientDataAccess
                                        .LoadCustomerInvoiceConfig(header.CustomerDUNS, ldcModel.LdcId);

                    if (invoiceConfig != null)
                    {
                        var zzPartnerId      = context.TradingPartnerId;
                        var fixedZzPartnerId = string.Concat(zzPartnerId.Substring(0, 3), "ZZ",
                                                             zzPartnerId.Substring(5, zzPartnerId.Length - 5));

                        context.SetTradingPartnerId(fixedZzPartnerId);

                        var shouldSkipMeterReads   = false;
                        var configuredCustomerDuns = clientDataAccess
                                                     .LoadParameterConfigurationValue("CustomerDunsConfiguredForSkip30Record");
                        if (!string.IsNullOrWhiteSpace(configuredCustomerDuns))
                        {
                            shouldSkipMeterReads = configuredCustomerDuns.Equals(invoiceConfig.CustomerDuns);
                        }

                        WriteCustInvHeader(context, invoiceConfig, header);
                        WriteCustInvAccount(context, invoiceConfig, header);
                        WriteCustInvAddress(context, invoiceConfig, header);
                        WriteCustInvRemitanceAddress(context, invoiceConfig, header);
                        WriteCustInvDetail(context, invoiceConfig, header);
                        WriteCustInvAccountTaxCharges(context, invoiceConfig, header);
                        if (!shouldSkipMeterReads)
                        {
                            WriteCustInvMeterReads(context, invoiceConfig, header);
                        }
                        WriteCustInvCharges(context, invoiceConfig, header);
                        WriteCustInvTax(context, invoiceConfig, header);
                        WriteCustInvSummary(context, invoiceConfig, header);
                    }
                    else
                    {
                        if (context.TradingPartnerId.Equals("CRDTX055458350INV", StringComparison.Ordinal))
                        {
                            var txPartnerId      = context.TradingPartnerId;
                            var fixedTxPartnerId = txPartnerId.Replace("CRDTX", "CRDZZ");

                            context.SetTradingPartnerId(fixedTxPartnerId);

                            WriteNiscHeader(context, header);
                            WriteNiscAccount(context, header);
                            WriteNiscRemitanceAddress(context, header);
                            WriteNiscDetail(context, header);
                            WriteNiscAccountTaxCharges(context, header);
                            WriteNiscMeterReads(context, header);
                            WriteNiscCharges(context, header);
                            WriteNiscTax(context, header);
                            WriteNiscSummary(context, header);
                        }
                        else
                        {
                            WriteHeader(context, header);
                            WriteAccount(context, header);
                            WriteRemitanceAddress(context, header);
                            WriteDetail(context, header);
                            WriteMeterReads(context, header);
                            WriteCharges(context, header);
                            WriteTax(context, header);
                            WriteSummary(context, header);
                        }
                    }
                }
            }

            return(context.Models);
        }