Beispiel #1
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 #2
0
        public void ParseLine(Prism814Context context, string line)
        {
            if (string.IsNullOrWhiteSpace(line))
            {
                return;
            }

            if (line.Length < 2)
            {
                return;
            }

            var indicator    = line.Substring(0, 2);
            var marketFields = line.Split('|');

            switch (indicator)
            {
            case "SH":
                context.ResolveToHeader();
                context.Initialize();
                context.TransactionActualCount++;
                marketFields.TryAtIndex(3, x => context.Alias = x);
                break;

            case "01":
                ParseHeader(context, marketFields);
                break;

            case "05":
                ParseName(context, marketFields);
                break;

            case "10":
                context.RevertToHeader();
                ParseService(context, marketFields);
                break;

            case "11":
                ParseServiceDate(context, marketFields);
                break;

            case "12":
                ParseServiceRate(context, marketFields);
                break;

            case "15":
                ParseServiceReject(context, marketFields);
                break;

            case "16":
                ParseServiceStatus(context, marketFields);
                break;

            case "30":
                context.RevertToService();
                context.InitializeMeter();
                ParseServiceMeter(context, marketFields);
                break;

            case "35":
                ParseServiceMeterType(context, marketFields);
                break;

            case "38":
                ParseServiceMeterChange(context, marketFields);
                break;

            case "40":
                context.RevertToService();
                ParseServiceStatus(context, marketFields);
                break;

            case "TL":
                context.ResolveToHeader();
                marketFields.TryAtIndexInt(1, x => context.TransactionAuditCount = x);
                break;
            }
        }