Exemple #1
0
        public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery queryOptions)
        {
            var token   = _httpContextAccessor.HttpContext.GetTokenAsync(OpenIdConnectParameterNames.AccessToken).GetAwaiter().GetResult();
            var headers = new Metadata
            {
                { "Authorization", $"Bearer {token}" },
            };

            var client  = new AuditLogClient(ChannelFactory.Create(_configuration["Services:AuditLog:Grpc"]));
            var entries = client.GetAuditLogEntries(new GetAuditLogEntriesRequest
            {
                ObjectId = queryOptions.ObjectId,
            }, headers);

            return(entries.Entries.Select(x => new AuditLogEntryDTO
            {
                Id = Guid.Parse(x.Id),
                ObjectId = x.ObjectId,
                UserId = Guid.Parse(x.UserId),
                Action = x.Action,
                Log = x.Log,
                UserName = x.UserName,
                CreatedDateTime = x.CreatedDateTime.ToDateTimeOffset(),
            }).ToList());
        }
Exemple #2
0
        public void Handle(AddAuditLogEntryCommand command)
        {
            var client = new AuditLogClient(ChannelFactory.Create("https://localhost:5002"));

            client.AddAuditLogEntry(new AuditLog.Grpc.AddAuditLogEntryRequest
            {
                Entry = new AuditLog.Grpc.AuditLogEntryMessage
                {
                    ObjectId        = command.AuditLogEntry.ObjectId,
                    UserId          = command.AuditLogEntry.UserId.ToString(),
                    Action          = command.AuditLogEntry.Action,
                    Log             = command.AuditLogEntry.Log,
                    CreatedDateTime = Timestamp.FromDateTimeOffset(command.AuditLogEntry.CreatedDateTime),
                },
            });
        }
        public void Handle(AddAuditLogEntryCommand command)
        {
            var client = new AuditLogClient(ChannelFactory.Create(_configuration["Services:AuditLog:Grpc"]));

            client.AddAuditLogEntry(new AuditLog.Grpc.AddAuditLogEntryRequest
            {
                Entry = new AuditLog.Grpc.AuditLogEntryMessage
                {
                    ObjectId        = command.AuditLogEntry.ObjectId,
                    UserId          = command.AuditLogEntry.UserId.ToString(),
                    Action          = command.AuditLogEntry.Action,
                    Log             = command.AuditLogEntry.Log,
                    CreatedDateTime = Timestamp.FromDateTimeOffset(command.AuditLogEntry.CreatedDateTime),
                },
            });
        }
Exemple #4
0
        public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery queryOptions)
        {
            var client  = new AuditLogClient(ChannelFactory.Create("https://localhost:5002"));
            var entries = client.GetAuditLogEntries(new GetAuditLogEntriesRequest
            {
                ObjectId = queryOptions.ObjectId,
            });

            return(entries.Entries.Select(x => new AuditLogEntryDTO
            {
                Id = Guid.Parse(x.Id),
                ObjectId = x.ObjectId,
                UserId = Guid.Parse(x.UserId),
                Action = x.Action,
                Log = x.Log,
                UserName = x.UserName,
                CreatedDateTime = x.CreatedDateTime.ToDateTimeOffset(),
            }).ToList());
        }
        public void Handle(AddAuditLogEntryCommand command)
        {
            var token   = _httpContextAccessor.HttpContext.GetTokenAsync(OpenIdConnectParameterNames.AccessToken).GetAwaiter().GetResult();
            var headers = new Metadata
            {
                { "Authorization", $"Bearer {token}" },
            };

            var client = new AuditLogClient(ChannelFactory.Create(_configuration["Services:AuditLog:Grpc"]));

            client.AddAuditLogEntry(new AuditLog.Grpc.AddAuditLogEntryRequest
            {
                Entry = new AuditLog.Grpc.AuditLogEntryMessage
                {
                    ObjectId        = command.AuditLogEntry.ObjectId,
                    UserId          = command.AuditLogEntry.UserId.ToString(),
                    Action          = command.AuditLogEntry.Action,
                    Log             = command.AuditLogEntry.Log,
                    CreatedDateTime = Timestamp.FromDateTimeOffset(command.AuditLogEntry.CreatedDateTime),
                },
            }, headers);
        }
 public AuditLogsModel(AuditLogClient Client)
 {
     _client = Client;
 }