コード例 #1
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;
            }
        }
コード例 #2
0
        public IMarketFileParseResult Parse(Stream stream)
        {
            var context = new Prism820Context();

            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 820. Transactions may not be completed.");
                context.ResolveToHeader();
            }

            return(context.Results);
        }