public void ParseInit(string initFile) { // Read initialization file ParseContextStack parsingContext = new ParseContextStack(); parsingContext.Push(initFile); parsingContext.GetCurrent().Journal = Session.Journal; parsingContext.GetCurrent().Scope = Report; if (Session.Journal.Read(parsingContext) > 0 || Session.Journal.AutoXacts.Count > 0 || Session.Journal.PeriodXacts.Count > 0) { throw new ParseError(String.Format(ParseError.ParseError_TransactionsFoundInInitializationFile, initFile)); } }
public int ReadTextual(ParseContextStack contextStack) { TextualParser instance = new TextualParser(contextStack, contextStack.GetCurrent(), null, CheckingStyle == JournalCheckingStyleEnum.CHECK_PERMISSIVE); instance.ApplyStack.PushFront("account", contextStack.GetCurrent().Master); instance.Parse(); // Apply any deferred postings at this time Master.ApplyDeferredPosts(); if (contextStack.GetCurrent().Errors > 0) { throw new CountError(contextStack.GetCurrent().Errors); } return(contextStack.GetCurrent().Count); }
/// <summary> /// Ported from global_scope_t::parse_init /// </summary> public void ParseInit(string initFile) { var trace = Logger.Current.TraceContext(TimerName.Init, 1)?.Message("Read initialization file").Start(); // TRACE_START ParseContextStack parsingContext = new ParseContextStack(); parsingContext.Push(initFile); parsingContext.GetCurrent().Journal = Session.Journal; parsingContext.GetCurrent().Scope = Report; if (Session.Journal.Read(parsingContext) > 0 || Session.Journal.AutoXacts.Count > 0 || Session.Journal.PeriodXacts.Count > 0) { throw new ParseError(String.Format(ParseError.ParseError_TransactionsFoundInInitializationFile, initFile)); } trace?.Finish(); // TRACE_FINISH }
/// <summary> /// Ported from void generate_posts_iterator::increment /// </summary> public IEnumerable <Post> Get() { IList <Post> posts = new List <Post>(); int i = 0; while (i < Quantity) { string buf = GenerateXact(); Logger.Current.Debug("generate.post", () => String.Format("The post we intend to parse:\r\n{0}", buf)); try { ParseContextStack parsingContext = new ParseContextStack(); parsingContext.Push(new TextualReader(FileSystem.GetStreamReaderFromString(buf))); parsingContext.GetCurrent().Journal = Session.Journal; parsingContext.GetCurrent().Scope = Session; if (Session.Journal.Read(parsingContext) != 0) { Validator.Verify(() => Session.Journal.Xacts.Last().Valid()); XactPostsIterator iterPosts = new XactPostsIterator(Session.Journal.Xacts.Last()); foreach (Post post in iterPosts.Get()) { if (i++ >= Quantity) { break; } posts.Add(post); } } } catch { ErrorContext.Current.AddErrorContext(String.Format("While parsing generated transaction (seed {0}):", Seed)); ErrorContext.Current.AddErrorContext(buf.ToString()); throw; } } return(posts); }
public static Post GetSampleXact(Report report) { StringBuilder sb = new StringBuilder(); sb.AppendLine("--- Context is first posting of the following transaction ---"); sb.AppendLine(SampleXactStr); report.OutputStream.Write(sb.ToString()); ParseContextStack parsingContext = new ParseContextStack(); parsingContext.Push(new TextualReader(FileSystem.GetStreamReaderFromString(SampleXactStr))); parsingContext.GetCurrent().Journal = report.Session.Journal; parsingContext.GetCurrent().Scope = report.Session; report.Session.Journal.Read(parsingContext); report.Session.Journal.ClearXData(); Xact first = report.Session.Journal.Xacts.First(); return(first.Posts.First()); }