示例#1
0
        /// <summary>
        /// Writes an event to the audit log using the specified parameters.
        /// </summary>
        /// <param name="eventType">The type of the audit event</param>
        /// <param name="successful">Indicates whether the event was successful</param>
        /// <param name="comment">A brief explanation of the event</param>
        /// <param name="userId">The user causing the audit event</param>
        /// <param name="relatedId">A related ID to the event, if applicable</param>
        /// <param name="remoteIP">IP of the remote system causing the event</param>
        public static void Audit(AuditEventType eventType, bool successful, string comment, int userId, int relatedId, string remoteIP)
        {
            AuditEvent logEntry = new AuditEvent();

            logEntry.EventDate  = DateTime.UtcNow;
            logEntry.EventType  = eventType;
            logEntry.Successful = successful;
            logEntry.UserId     = userId;
            logEntry.RelatedId  = relatedId;
            logEntry.RemoteIP   = StringHelper.Truncate(remoteIP, 39);
            logEntry.Comment    = comment;
            logEntry.Save();
        }