public void SaveAuditEvent(AuditLoggingEvent info) { try { EventTypes type = (EventTypes)Enum.Parse(typeof(EventTypes), info.Level.ToString()); using (var unit = ServiceLocator.Current.GetInstance <IUnitOfWork>()) { Event evt = new Event() { TypeID = (int)type, ProcessName = info.FriendlyProcessName, Message = info.Message.ToString(), ExceptionMessage = info.ExceptionObject == null ? string.Empty : info.ExceptionObject.Message, StackTrace = info.ExceptionObject == null ? string.Empty : info.ExceptionObject.StackTrace }; unit.Scope.Repository <Event>().Add(evt); unit.Save(); } } catch (Exception) { Console.WriteLine("Could not log exception to db. Exception was @0", info.Message.ToString()); } }
public void SaveAuditEvent(AuditLoggingEvent info) { EventTypes type = (EventTypes)Enum.Parse(typeof(EventTypes), info.Level.ToString()); //using (ConcentratorDataContext context = new ConcentratorDataContext()) //{ // Event evt = new Event() // { // TypeID = (int)type, // ProcessName = info.FriendlyProcessName, // Message = info.Message.ToString(), // ExceptionMessage = info.ExceptionObject == null ? string.Empty : info.ExceptionObject.Message, // StackTrace = info.ExceptionObject == null ? string.Empty : info.ExceptionObject.StackTrace // }; // context.Events.InsertOnSubmit(evt); // context.SubmitChanges(); //} }