コード例 #1
0
        public void ParseHeader(Prism820Context context, string[] marketFields)
        {
            var model = new Type820Header
            {
                TotalAmount       = marketFields.AtIndex(4),
                PaymentMethodCode = marketFields.AtIndex(5),
                TransactionDate   = marketFields.AtIndex(13),
                TraceReferenceNbr = marketFields.AtIndex(14),
                TdspName          = marketFields.AtIndex(15),
                TdspDuns          = marketFields.AtIndex(16),
                CrName            = marketFields.AtIndex(17),
                CrDuns            = marketFields.AtIndex(18),
                CreditDebitFlag   = marketFields.AtIndex(19),
            };

            var identifiedMarket = clientDataAccess.IdentifyMarket(model.TdspDuns);

            if (identifiedMarket.HasValue)
            {
                context.SetMarket(identifiedMarket.Value);
            }

            model.MarketId   = context.MarketId;
            model.ProviderId = 1;

            context.PushModel(model);
        }
コード例 #2
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);
        }