void processLog(Log log) { using (var stream = new FileStream(log.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var reader = new StreamReader(stream)) { processLines(log, reader); } } }
void processFile(string path) { using (var session = _documentStore.OpenSession()) { var log = session.Load<Log>(path.GetHashCode()); if (log == null) { log = new Log(path); session.Store(log); } processLog(log); session.SaveChanges(); } }
void processLines(Log log, StreamReader reader) { using (var bulk = _documentStore.BulkInsert()) { var index = 0; while (reader.Peek() >= 0) { index++; var line = reader.ReadLine(); if (index > log.LastLineNumber) { bulk.Store(log.CreateLine(line, index)); } } } }