public Task AddLogEntry <T>(AuditLogTypes type, T logData, CancellationToken token) { var datetime = DateTime.UtcNow; var logEntry = new AuditLogEntry <T>(logData, type, datetime); return(_client.IndexAsync(new IndexRequest <AuditLogEntry <T> >( logEntry, BuildIndexName(datetime)), token)); }
/// <summary> /// Stores an AuditLog object for the ongoing transaction /// </summary> public static IAuditLog Logg <T>(IDwarf obj, AuditLogTypes auditLogType, params AuditLogEventTrace[] auditUpdateEvents) { var type = DwarfHelper.DeProxyfy(obj); if (type.Implements <IAuditLogless>() || type.Implements <IAuditLog>()) { return(null); } var al = new AuditLog { ClassType = type.Name, AuditLogType = auditLogType, UserName = DwarfContext <T> .GetConfiguration().UserService.CurrentUser != null ? DwarfContext <T> .GetConfiguration().UserService.CurrentUser.UserName : string.Empty, TimeStamp = DateTime.Now, ObjectValue = obj.ToString(), }; if (!type.Implements <ICompositeId>()) { al.ObjectId = obj.Id.ToString(); } else { foreach (var ep in DwarfHelper.GetPKProperties(type)) { al.ObjectId += string.Format("[{0}: {1}]", ep.Name, ep.GetValue(obj)); } } if (auditLogType != AuditLogTypes.Created) { al.AuditDetails = "<?xml version=\"1.0\"?><Properties>"; foreach (var auditUpdateEvent in auditUpdateEvents) { al.AuditDetails += auditUpdateEvent.ToXml().ToString(); } al.AuditDetails += "</Properties>"; } DwarfContext <T> .GetDatabase().Insert <T, AuditLog>(al); return(al); }
private void CreateAuditLog(AuditLogTypes auditLogType, IEnumerable <AuditLogEventTrace> propertyTraces) { if (DbContextHelper <T> .DbContext.IsAuditLoggingSuspended || DwarfContext <T> .GetConfiguration().AuditLogService == null) { return; } if (auditLogType == AuditLogTypes.Updated) { var traces = propertyTraces.Union(CreateTraceEventsForManyToMany()).ToArray(); if (traces.Length > 0) { DwarfContext <T> .GetConfiguration().AuditLogService.Logg(this, auditLogType, traces); } } else if (auditLogType == AuditLogTypes.Created) { DwarfContext <T> .GetConfiguration().AuditLogService.Logg(this, auditLogType); } }
public string GetAuditLogTypeString(AuditLogTypes logType) { switch (logType) { case AuditLogTypes.DepartmentSettingsChanged: return("Department Settings Changed"); case AuditLogTypes.UserAdded: return("User Added"); case AuditLogTypes.UserRemoved: return("User Removed"); case AuditLogTypes.GroupAdded: return("Group Added"); case AuditLogTypes.GroupRemoved: return("Group Removed"); case AuditLogTypes.GroupChanged: return("Group Changed"); case AuditLogTypes.UnitAdded: return("Unit Added"); case AuditLogTypes.UnitRemoved: return("Unit Removed"); case AuditLogTypes.UnitChanged: return("Unit Changed"); case AuditLogTypes.ProfileUpdated: return("Profile Updated"); case AuditLogTypes.PermissionsChanged: return("Permissions Changed"); } return(""); }
/// <summary> /// Stores an AuditLog object for the ongoing transaction /// </summary> public static IAuditLog Logg <T>(IDwarf obj, AuditLogTypes auditLogType) { return(Logg <T>(obj, auditLogType, new AuditLogEventTrace[] { })); }
/// <summary> /// See base /// </summary> public IAuditLog Logg(IDwarf obj, AuditLogTypes auditLogType, params AuditLogEventTrace[] auditLogEventTraces) { return(AuditLog.Logg <T>(obj, auditLogType, auditLogEventTraces)); }
/// <summary> /// See base /// </summary> public IAuditLog Logg(IDwarf obj, AuditLogTypes auditLogType) { return(AuditLog.Logg <T>(obj, auditLogType)); }