public Task <AuditLogItem> FindLastItemAsync(long userId, AuditLogType type) { return(GetBaseQuery(true) .Where(o => o.Type == type && o.UserId == userId) .OrderByDescending(o => o.Id) .FirstOrDefaultAsync()); }
public string Format(IRpcContext context, AuditLogType logType, AmpMessage req, AmpMessage rsp, long elapsedMS) { string log = string.Empty; if (req == null || rsp == null) { return(log); } var reqParser = GetMessageParser(req.ServiceId, req.MessageId, 1); var resParser = GetMessageParser(rsp.ServiceId, rsp.MessageId, 2); if (reqParser == null || resParser == null) { Console.WriteLine("{0},{1} ,错误的服务ID和消息ID", req.ServiceId, req.MessageId); return(null); } if (logType == AuditLogType.CACAduit) { log = FormatCACLog(req, rsp, elapsedMS, reqParser, resParser); } else if (logType == AuditLogType.RequestAudit) { log = FormatRequestLog(context, req, rsp, elapsedMS, reqParser, resParser); } return(log); }
/// <summary> /// Creates new <see cref="AuditLogDetails" /> object for this <see cref="AuditLog" /> object /// and fills it with provided data (which can be formatted). /// </summary> /// <param name="auditType">Audit Type (<see cref="AuditLogType" /> constants can be used).</param> /// <param name="description">Audit Log Details description.</param> /// <param name="args"><paramref name="description" /> formatting arguments.</param> /// <returns>Newly created <see cref="AuditLogDetails" /> object or null if object creation failed.</returns> virtual public AuditLogDetails AddLogDetailsFormat(AuditLogType auditType, string description, params object[] args) { if (IsNewObject) { return(null); } return(AddLogDetails(auditType, String.Format(description, args))); }
public string Format(IRpcContext context, AuditLogType logType, string methodName, object req, RpcResult <object> res, long elapsedMs) { if (req == null || res == null) { return(string.Format("req or res is null ------------,reqType={0},resType = {1}", req?.GetType().Name, res?.Data?.GetType().Name)); } return(string.Format("logType={0},methodName={1}, elapsedMs={2}", logType, methodName, elapsedMs)); }
/// <summary> /// Creates new <see cref="AuditLogDetails" /> object for this <see cref="AuditLog" /> object and fills it with provided data. /// </summary> /// <param name="auditType">Audit Type (<see cref="AuditLogType" /> constants can be used).</param> /// <param name="description">Audit Log Details description.</param> /// <returns>Newly created <see cref="AuditLogDetails" /> object or null if object creation failed.</returns> virtual public AuditLogDetails AddLogDetails(AuditLogType auditType, string description) { if (IsNewObject) { return(null); } return(AddLogDetails(Id, auditType, description)); }
public IQueryable <string> GetLastAuditLogIdsQuery(ulong guildId, AuditLogType type) { var halfYearBack = DateTime.Now.AddMonths(-6); return(Context.AuditLogs.AsQueryable() .Where(o => o.DcAuditLogId != null && o.CreatedAt >= halfYearBack && o.GuildId == guildId.ToString() && o.Type == type) .Select(o => o.DcAuditLogId)); }
public IEnumerable<AuditLog> GetLog(AuditLogType logType, DateTime? sinceDate) { if (sinceDate == null) sinceDate = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0, 0)); return Mapper.Map<IEnumerable<AuditLog>>( Log.Instance.GetLogItems(Enum<LogTypes>.Parse(logType.ToString()), sinceDate.Value)); }
/// <summary> /// Creates new <see cref="AuditLogDetails" /> object and fills it with provided data (which can be formatted). /// </summary> /// <param name="auditLogId">Parent Audit Log entry ID.</param> /// <param name="auditType">Audit Type (<see cref="AuditLogType" /> constants can be used).</param> /// <param name="description">Audit Log Details description.</param> /// <param name="args"><paramref name="description" /> formatting arguments.</param> /// <returns>Newly created <see cref="AuditLogDetails" /> object or null if object creation failed.</returns> /// <exception cref="ArgumentNullException"><paramref name="description" /> is a null reference.</exception> static public AuditLogDetails AddLogDetailsFormat(int auditLogId, AuditLogType auditType, string description, params object[] args) { // Exceptions if (description == null) { throw new ArgumentNullException("description"); } return(AddLogDetails(auditLogId, auditType, string.Format(description, args))); }
public IEnumerable <AuditLog> GetLog(AuditLogType logType, DateTime?sinceDate) { if (sinceDate == null) { sinceDate = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0, 0)); } return(Mapper.Map <IEnumerable <AuditLog> >( Log.Instance.GetLogItems(Enum <LogTypes> .Parse(logType.ToString()), sinceDate.Value))); }
public AuditLogItem() { this._user = RafyEnvironment.Identity.Name; if (string.IsNullOrEmpty(this._user)) { this._user = "******"; } this._title = string.Empty; this._privateContent = string.Empty; this._moduleName = string.Empty; this._machineName = Environment.MachineName; this._type = AuditLogType.None; this._logTime = DateTime.Now; }
internal static AuditLogRecord CreateNew(object entity, object id, AuditLogType logType, ISession session) { AuditLogRecord log = new AuditLogRecord(); log.EntityId = id == null ? string.Empty : id.ToString(); log.EntityName = entity == null ? string.Empty : session.GetEntityName(entity); log.LogType = logType.ToString(); log.Created = DateTime.Now; log.CreatedBy = SystemConfiguration.UserName; log.ClientId = SystemConfiguration.ClientId; log.OrgId = SystemConfiguration.OrgId; log.IsActive = true; return(log); }
/// <summary> /// Creates new <see cref="AuditLogDetails" /> object and fills it with provided data. /// </summary> /// <param name="auditLogId">Parent Audit Log entry ID.</param> /// <param name="auditType">Audit Type (<see cref="AuditLogType" /> constants can be used).</param> /// <param name="description">Audit Log Details description.</param> /// <returns>Newly created <see cref="AuditLogDetails" /> object or null if object creation failed.</returns> /// <exception cref="ArgumentNullException"><paramref name="description" /> is a null reference.</exception> static public AuditLogDetails AddLogDetails(int auditLogId, AuditLogType auditType, string description) { // Exceptions if (description == null) { throw new ArgumentNullException("description"); } // Create and fill new AuditLog object AuditLogDetails newAuditLogDetails = (AuditLogDetails)AuditLogDetailsManager.CreateObject(); newAuditLogDetails.AuditLogId = auditLogId; newAuditLogDetails.AuditLogType = auditType; newAuditLogDetails.Description = description; // Return newly created object if it was saved in the DB return(newAuditLogDetails.Save() ? newAuditLogDetails : null); }
public void Create(string description, AuditLogType type) { var log = new AuditLog { Description = description, CreatorId =_userManager.GetCurrentUserId(), Type = type }; switch (type) { case AuditLogType.JustDescription: break; case AuditLogType.Serialize: log.NewValue = _unitOfWork.AuditNewValue; log.OldValue = _unitOfWork.AuditOldValue; log.RecordedEntityId = _unitOfWork.RecordedEntityKey; break; } _logs.Add(log); _unitOfWork.SaveChanges(); }
public static DataTable InsertAuditLog(SqlConnection Connection, SqlTransaction Transaction, Guid? AuditID, string AuditSource, Guid?AuditKey, string AuditName, AuditLogType AuditLogType, AuditLog.AuditAction AuditAction, string AuditContent, string ReferenceTable, Guid?ReferenceID, string LogXML, Guid?AuditGroupID, Guid?UserID, string Username) { using (SqlCommand cmd = new SqlCommand("", Connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) { StringBuilder sql = new StringBuilder(); sql.AppendLine("INSERT INTO AuditLog (AuditID, AuditSource, AuditKey, AuditName, AuditLogType, AuditAction, AuditContent, ReferenceTable, ReferenceID, LogXML, AuditGroupID, CreatedBy, CreatedByName, ModifiedBy, ModifiedByName) "); sql.AppendLine("VALUES (@AuditID, @AuditSource, @AuditKey, @AuditName, @AuditLogType, @AuditAction, @AuditContent, @ReferenceTable, @ReferenceID, @LogXML, @AuditGroupID, @UserID, @Username, @UserID, @Username) "); cmd.CommandText = sql.ToString(); cmd.Transaction = Transaction; cmd.CommandTimeout = int.MaxValue; cmd.Parameters.AddWithValue("@AuditID", AuditID); cmd.Parameters.AddWithValue("@AuditSource", AuditSource); cmd.Parameters.AddWithValue("@AuditKey", AuditKey); cmd.Parameters.AddWithValue("@AuditName", AuditName); cmd.Parameters.AddWithValue("@AuditLogType", AuditLogType); cmd.Parameters.AddWithValue("@AuditAction", AuditAction); cmd.Parameters.AddWithValue("@AuditContent", AuditContent); cmd.Parameters.AddWithValue("@ReferenceTable", ConvertToNull(ReferenceTable)); cmd.Parameters.AddWithValue("@ReferenceID", ConvertToNull(ReferenceID)); cmd.Parameters.AddWithValue("@LogXML", LogXML); cmd.Parameters.AddWithValue("@AuditGroupID", AuditGroupID); cmd.Parameters.AddWithValue("@UserID", UserID); cmd.Parameters.AddWithValue("@Username", Username); DataTable dataTable = new DataTable(); adapter.Fill(dataTable); return(dataTable); } } }
private static void AddAuditLog(ILogger writer, IAuditLoggerFormat <AmpMessage> format, AuditLogType logType, IRpcContext context, AmpMessage req, AmpMessage rsp, long elapsedMS) { if (writer == null || format == null) { return; } var entity = new AuditLogEntity() { Context = context, Request = req, Response = rsp, ElapsedMS = elapsedMS, Writer = writer, Formater = format, LogType = logType }; logDict.Enqueue(entity); StartWrite(); }
private AuditLogRecord CreateNew(object entity, object id, AuditLogType logType) { return CreateNew(entity, id, logType, m_session); }
private static void AddAuditLog(IRpcContext context, ILogger writer, IAuditLoggerFormat format, AuditLogType logType, string methodName, object req, object rsp, long elapsedMS) { if (writer == null || format == null) { return; } var entity = new AuditLogEntity { MethodFullName = methodName, Request = req, Response = rsp, ElapsedMS = elapsedMS, Writer = writer, Context = context, Formatter = format, LogType = logType }; logDict.Enqueue(entity); StartWrite(); }
public IQueryable <AuditLogItem> GetAuditLogsByType(AuditLogType type) { return(GetBaseQuery(false) .Where(o => o.Type == type)); }
private AuditLogRecord CreateNew(object entity, object id, AuditLogType logType) { return(CreateNew(entity, id, logType, m_session)); }
internal static AuditLogRecord CreateNew(object entity, object id, AuditLogType logType, ISession session) { AuditLogRecord log = new AuditLogRecord(); log.EntityId = id == null ? string.Empty : id.ToString(); log.EntityName = entity == null ? string.Empty : session.GetEntityName(entity); log.LogType = logType.ToString(); log.Created = DateTime.Now; log.CreatedBy = SystemConfiguration.UserName; log.ClientId = SystemConfiguration.ClientId; log.OrgId = SystemConfiguration.OrgId; log.IsActive = true; return log; }