Exemple #1
0
        public async Task AddActivity(AuditActivity auditActivity)
        {
            switch (auditActivity.GetActivityType())
            {
            case AuditActivityType.Login:
            case AuditActivityType.Heartbeat:
                await ProcessLogin(auditActivity);

                break;

            case AuditActivityType.Permission:
                await ProcessPermissionIssue(auditActivity);

                break;

            case AuditActivityType.Create:
            case AuditActivityType.Update:
            case AuditActivityType.Delete:
            case AuditActivityType.Info:
            case AuditActivityType.Access:
            default:
                await ProcessActivity(auditActivity);

                break;
            }
        }
Exemple #2
0
        async Task ProcessActivity(AuditActivity auditActivity)
        {
            var activityUser = new AuditUserActivity(auditActivity.On, auditActivity.ById, auditActivity.ByName)
            {
                AuditType          = auditActivity.AuditType,
                EntityPartitionKey = auditActivity.PartitionKey,
                EntityRowKey       = auditActivity.RowKey,
                EntityType         = auditActivity.EntityType,
                EntityId           = auditActivity.EntityId
            };
            var auditUserHistoryActivity = new AuditUserHistoryActivity(auditActivity.On, auditActivity.ById, auditActivity.ByName);
            var activityHistory          = new AuditActivityHistory(TimeZoneHelper.GetDate(auditActivity.On), auditActivity.ById, auditActivity.ByName, auditActivity.PartitionKey, auditActivity.RowKey)
            {
                EntityType = auditActivity.EntityType,
                EntityId   = auditActivity.EntityId,
                On         = auditActivity.On,
                AuditType  = auditActivity.AuditType
            };

            await ExecuteAsync(ServiceManager.GetTableClient().GetTableReference(TableAssist.AuditActivities()), TableOperation.Insert(auditActivity));
            await ExecuteAsync(ServiceManager.GetTableClient().GetTableReference(TableAssist.AuditUsers()), TableOperation.Insert(activityUser));
            await ExecuteAsync(ServiceManager.GetTableClient().GetTableReference(TableAssist.AuditUsers()), TableOperation.InsertOrReplace(auditUserHistoryActivity));
            await ExecuteAsync(ServiceManager.GetTableClient().GetTableReference(TableAssist.AuditActivityHistories()), TableOperation.InsertOrReplace(activityHistory));

            if (auditActivity.GetActivityType() == AuditActivityType.Delete)
            {
                var deletion = new AuditDeletion(auditActivity.EntityType, auditActivity.EntityId)
                {
                    Entity = auditActivity.Entity,
                    ById   = auditActivity.ById,
                    ByName = auditActivity.ByName,
                    On     = auditActivity.On
                };
                await ExecuteAsync(ServiceManager.GetTableClient().GetTableReference(TableAssist.AuditDeletions()), TableOperation.Insert(deletion));
            }
            ;
        }