Exemplo n.º 1
0
        private void GetAudiRecords()
        {
            AuditDetailsClient auditClient = new AuditDetailsClient();
            var auditRecords = auditClient.GetAllAuditRecords();

            foreach (var item in auditRecords)
            {
                AuditModel audit = new AuditModel();
                audit.AuditId        = item.AuditId;
                audit.ClientId       = item.ClientId;
                audit.TuronOverMoney = item.TuronOverMoney;
                audit.AuditRequired  = item.AuditRequired;
                audit.AuditStartDate = item.AuditStartDate;
                audit.AuditEndDate   = item.AuditEndDate;
                audit.AuditBy        = item.AuditBy.ToString();
                audit.AuditFee       = item.AuditFee;
                AuditRecords.Add(audit);
            }
        }
Exemplo n.º 2
0
        private void _TrackUpdated(DateTime now)
        {
            var entities = ChangeTracker.Entries().Where(p => p.State == EntityState.Modified).ToList();

            foreach (var entity in entities)
            {
                var primaryKey     = GetPrimaryKeyValue(entity);
                var entityName     = entity.Entity.GetType().Name;
                var databaseValues = entity.GetDatabaseValues();

                foreach (var propName in entity.OriginalValues.PropertyNames)
                {
                    if (propName == "DateCreated" || propName == "LastUpdated")
                    {
                        continue;
                    }

                    var currentValue  = getStringValue(entity.CurrentValues[propName]);
                    var originalValue = getStringValue(databaseValues.GetValue <object>(propName));

                    if (originalValue != currentValue)
                    {
                        var auditRecord = new AuditRecord()
                        {
                            EntityName      = entityName,
                            PrimaryKeyValue = primaryKey.ToString(),
                            Action          = "Updated",
                            PropertyName    = propName,
                            OldValue        = originalValue,
                            NewValue        = currentValue,
                            DateChanged     = now,
                            UserName        = this.UserName,
                            Operator        = this.Operator
                        };

                        AuditRecords.Add(auditRecord);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void _TrackDeleted(DateTime now)
        {
            var entities = ChangeTracker.Entries().Where(p => p.State == EntityState.Deleted).ToList();

            foreach (var entity in entities)
            {
                var primaryKey = GetPrimaryKeyValue(entity);
                var entityName = entity.Entity.GetType().Name;

                var auditRecord = new AuditRecord()
                {
                    EntityName      = entityName,
                    PrimaryKeyValue = primaryKey.ToString(),
                    Action          = "Deleted",
                    DateChanged     = now,
                    UserName        = this.UserName,
                    Operator        = this.Operator
                };

                AuditRecords.Add(auditRecord);
            }
        }