public Batch Create(Source source) { Batch batch; using (var dbContext = new TimberMillDbContext()) { batch = new Batch {Source = source}; dbContext.Batchs.Add(batch); dbContext.Entry(batch.Source).State = EntityState.Unchanged; dbContext.SaveChanges(); } return batch; }
private static LogEvent TimberMillEventFactory(Batch batch, LogEventInfo eventInfo) { LogEvent timberMillEvent = new LogEvent(); timberMillEvent.Batch = batch; timberMillEvent.TimeStamp = eventInfo.TimeStamp; timberMillEvent.Level = eventInfo.Level.Name; timberMillEvent.Message = eventInfo.Message; timberMillEvent.Sequence = eventInfo.SequenceID; foreach(KeyValuePair<object, object> property in eventInfo.Properties) { switch(property.Key.ToString()) { case "exception": timberMillEvent.Exception = property.Value.ToString(); break; } } return timberMillEvent; }
private static List<LogEvent> ExtractLogEvents(NLogEvents events, Batch batch) { var logEventInfoList = events.ToEventInfo().ToList(); var timberMillEvents = logEventInfoList.ConvertAll(ei => TimberMillEventFactory(batch, ei)); return timberMillEvents; }