static void Main(string[] args) { const int seconds = 1; var data = LoadData(); ShowData(data, true); while (true) { var nextOffcet = data.NextOffset; Thread.Sleep(seconds * 1000); IAppendOnlyStreamReader reader = new FileAppendOnlyStoreReader(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\Platform.Node\bin\Debug\store")); var records = reader.ReadAll(nextOffcet); bool emptyData = true; foreach (var dataRecord in records) { data.NextOffset = dataRecord.NextOffset; if (data.Distribution.ContainsKey(dataRecord.Data.Length)) data.Distribution[dataRecord.Data.Length]++; else data.Distribution[dataRecord.Data.Length] = 1; emptyData = false; } if (!emptyData) { ShowData(data, false); SaveData(data.ToJson()); } } }
static void Main(string[] args) { const int seconds = 1; var data = LoadData(); ShowData(data, true); while (true) { long nextOffcet = data.NextOffset; Thread.Sleep(seconds * 1000); IAppendOnlyStreamReader reader = new FileAppendOnlyStoreReader(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\Platform.Node\bin\Debug\store")); var records = reader.ReadAll(nextOffcet); bool emptyData = true; foreach (var dataRecord in records) { data.NextOffset = dataRecord.NextOffset; if(dataRecord.Data.Length==0 || dataRecord.Data[0]!=42) continue; var bytes = dataRecord.Data.Skip(1).ToArray(); var json = Encoding.UTF8.GetString(bytes); if(!json.StartsWith("{")) continue; var post = json.FromJson<Post>(); if(post==null) continue; if (data.Distribution.ContainsKey(post.AnswerCount)) data.Distribution[post.AnswerCount]++; else data.Distribution[post.AnswerCount] = 1; emptyData = false; } if (!emptyData) { ShowData(data, false); SaveData(data.ToJson()); } } }
static void Main(string[] args) { const int seconds = 1; var nextOffset = LoadData(); ShowData(nextOffset, true); var path = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\Platform.Node\bin\Debug\store"); IAppendOnlyStreamReader reader = new FileAppendOnlyStoreReader(path); while (true) { var last = reader.ReadAll(nextOffset).LastOrDefault(); if (!last.IsEmpty) { nextOffset = last.NextOffset; ShowData(nextOffset, false); SaveData(nextOffset); } Thread.Sleep(seconds * 1000); } }
private void RegisterCommand() { _commands.Register(new ExitProcessor()); _commands.Register(new WriteEventsFloodProcessor()); _commands.Register(new UsageProcessor(_commands)); _commands.Register(new WriteProccessor()); var reader = new FileAppendOnlyStoreReader(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\Platform.Node\bin\Debug\store")); _commands.Register(new ReadProcessor(reader)); }