Exemplo n.º 1
0
        private async Task RaiseIntegrationPingEvent(Integration integration)
        {
            try
            {
                _logger.LogInformation($"Ping received for integration: [{integration.Guid}] " +
                                       $"{integration.GitUrl} => {integration.FtpUsername}@{integration.FtpHostname}");

                var integrationEvent = new IntegrationPingEvent()
                {
                    IntegrationGuid = integration.Guid
                };

                await _communicator.Bus.PublishAsync(integrationEvent);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private async Task OnIntegrationPingEvent(IntegrationPingEvent @event)
        {
            try
            {
                _logger.LogInformation($"IntegrationPingEvent 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.State = DeploymentState.Verified;
                    deployment.Logs.Add(new DeploymentLog()
                    {
                        Description = "PingEvent received",
                        Status      = ResultStatus.Successful,
                        DateTime    = @event.DateTime,
                        EventType   = "ping",
                    });

                    await uof.CompleteAsync();

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