Ejemplo n.º 1
0
        protected void Audit <TEntity>(string associationPropertyPath, AuditTypes auditType, int?tableIdValue, int?relatedKeyValue, int auditUserId,
                                       dynamic oldData, dynamic newData, Func <int> save)
            where TEntity : class, new()
        {
            var auditLog = new AuditLog
            {
                AuditTypeID    = (byte)auditType,
                AuditDate      = DateTime.Now,
                UserID         = auditUserId,
                TableName      = _auditLogFactory.GetTableName(new TEntity(), associationPropertyPath),
                TableIDValue   = tableIdValue,
                RelatedKeyName = relatedKeyValue != null?_auditLogFactory.GetPrimaryKeyName(new TEntity()) : null,
                                     RelatedKeyValue                     = relatedKeyValue,
                                     OldData                             = oldData != null?JsonConvert.SerializeObject(oldData, Formatting.Indented) : null,
                                                                 NewData = newData != null?JsonConvert.SerializeObject(newData, Formatting.Indented) : null
            };

            var retVal = save();

            // Don't log if no records were updated or audit log indicates no changes exist
            if (retVal <= 0 || !auditLog.ChangesExist)
            {
                return;
            }

            // Assume save returns new identity when tableIdValue <= 0
            if (tableIdValue <= 0)
            {
                auditLog.TableIDValue = retVal;
            }

            Add(auditLog);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        protected async Task LogAudit(AuditTypes auditType, string username, string service)
        {
            var audit = new Audit
            {
                User      = username,
                Type      = auditType.ToString(),
                Service   = service,
                AuditDate = DateTime.UtcNow
            };

            await _auditRepository.Create(audit);
        }
Ejemplo n.º 3
0
        public void Init()
        {
            cbCompanies.Items.AddRange(Companies.GetCompaniesComboboxItemsList(companiesList).ToArray <ComboboxItem>());
            cbAuditTypes.Items.AddRange(AuditTypes.GetAuditTypesComboboxItemsList(auditTypesList).ToArray <ComboboxItem>());

            //List<Users> auditorsList = usersList;
            //List<Users> auditorsList = new List<Users>();

            cbAuditor1.Items.AddRange(Users.GetUsersComboboxItemsList(usersList).ToArray <ComboboxItem>());
            cbAuditor2.Items.AddRange(Users.GetUsersComboboxItemsList(usersList).ToArray <ComboboxItem>());
            cbSupervisor.Items.AddRange(Users.GetUsersComboboxItemsList(usersList).ToArray <ComboboxItem>());
            cbRating.Items.AddRange(AuditRating.GetAuditRatingComboboxItemsList(auditRatingList).ToArray <ComboboxItem>());
        }
Ejemplo n.º 4
0
        public DomainAuditProcessor(IRepository <DomainObjectLifeCycle> repository)
        {
            _Repository = repository;

            var types = AppRuntimeContext.Current.TypeFinder.ClassesOfType <IEntity>();

            foreach (var type in types)
            {
                if (type.GetCustomAttributes(typeof(AuditAttribute), true).Length > 0)
                {
                    AuditTypes.Add(type);
                }
            }
        }
Ejemplo n.º 5
0
        public void AddAudit(AuditTypes type, string username, string data)
        {
            Exception e;

            Task.Run(() => LunaLogic.Current.DatabaseProvider.Audits.Insert(new Audit
            {
                ActionTaken = type.ToString(),
                ActionData = data,
                Time = DateTime.UtcNow,
                UserId = LunaLogic.Current.DatabaseProvider.Users.Get(username).UserId
            }, out e));
            
            //TODO: Logging
        }
Ejemplo n.º 6
0
 protected void Audit <TEntity>(AuditTypes auditType, int?tableIdValue, int auditUserId, dynamic oldData, dynamic newData, Func <int> save)
     where TEntity : class, new()
 {
     Audit <TEntity>(null, auditType, tableIdValue, null, auditUserId, oldData, newData, save);
 }
Ejemplo n.º 7
0
 public void AddEntry(AuditTypes type, string comment, int userId, int objectId)
 {
     WriteProvider.WriteEntry(objectId, userId, DateTime.Now, type.ToString(), comment);
 }
Ejemplo n.º 8
0
 public void AddEntry(AuditTypes type, string comment, int userId, int objectId)
 {
     WriteProvider.WriteEntry(objectId, userId, DateTime.Now, type.ToString(), comment);
 }
Ejemplo n.º 9
0
 public static void Add(AuditTypes type, string comment, int userId, int objectId)
 {
     AuditTrail.Current.AddEntry(type, comment, userId, objectId);
 }
Ejemplo n.º 10
0
 public static void Add(AuditTypes type, string comment, int userId, int objectId)
 {
     AuditTrail.Current.AddEntry(type, comment, userId, objectId);
 }