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

            var context = new Prism820Context();

            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 820 Prism records found to export for TDSP Duns \"{0}\" and CR Duns \"{1}\".",
                                       prismPort.LdcDuns, prismPort.Duns);
                    continue;
                }

                logger.DebugFormat("Exporting {0} unprocessed 820 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, "PYM");
                    context.SetHeaderId(headerKey);

                    WriteHeader(context, header);
                    WritePayment(context, header);
                    WriteDetail(context, header);
                }
            }

            return(context.Models);
        }
示例#2
0
        public void ParseLine(Prism820Context 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++;
                break;

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

            case "20":
                ParseDetail(context, marketFields);
                break;

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