Exemplo n.º 1
0
        private async Task RaiseIntegrationPushEvent(Integration integration, WorkerJobResponse workerResponse)
        {
            var integrationEvent = new IntegrationPushEvent()
            {
                ResultStatus = workerResponse.ResultStatus == WorkerJobResultStatus.Successful
                    ? ResultStatus.Successful
                    : ResultStatus.Failed,
                IntegrationGuid = integration.Guid,
                ResultMessage   = workerResponse.ResultMessage,
                Details         = workerResponse.JobOutput
            };

            await _communicator.Bus.PublishAsync(integrationEvent);
        }
Exemplo n.º 2
0
        private async Task OnIntegrationPushEvent(IntegrationPushEvent @event)
        {
            try
            {
                _logger.LogInformation($"IntegrationPushEvent received. Guid:{@event.EventGuid}");

                ValidateReceivedIntegrationEvent(@event);

                using (var scope = _scopeFactory.CreateScope())
                {
                    var uof = scope.ServiceProvider.GetService <IUnitOfWork>();


                    var deployment =
                        await uof.Deployments.GetAsync(@event.IntegrationGuid) ??
                        throw new Exception($"Deployment {@event.IntegrationGuid} not found in db");

                    deployment.Logs.Add(new DeploymentLog()
                    {
                        Description   = @event.Details,
                        Status        = @event.ResultStatus,
                        DateTime      = @event.DateTime,
                        EventType     = "push",
                        ResultMessage = @event.ResultMessage,
                    });

                    await uof.CompleteAsync();

                    _logger.LogInformation($"Deployment {deployment.Guid} received push.");
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.ToString());
            }
        }