Esempio n. 1
0
        public void ParseLine(Prism810Context 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 "10":
                context.RevertToHeader();
                context.FirstCharge = true;
                ParseDetail(context, marketFields);
                break;

            case "40":
                if (context.FirstCharge)
                {
                    ParseDetailItem(context, marketFields);
                    context.FirstCharge = false;
                }
                ParseCharge(context, marketFields);
                break;

            case "45":
                ParseTax(context, marketFields);
                break;

            case "60":
                ParseSummary(context, marketFields);
                break;

            case "TL":
                context.ResolveToHeader();
                marketFields.TryAtIndexInt(1, x => context.TransactionAuditCount = x);
                break;
            }
        }
Esempio n. 2
0
        public IMarketFileParseResult Parse(Stream stream)
        {
            var context = new Prism810Context();

            using (var reader = new StreamReader(stream))
            {
                string marketFileLine;
                while ((marketFileLine = reader.ReadLine()) != null)
                {
                    ParseLine(context, marketFileLine);
                }
            }

            if (context.ShouldResolve)
            {
                logger.Warn("Unresolved data identified after parsing 810. Transactions may not be completed.");
                context.ResolveToHeader();
            }

            return(context.Results);
        }