Esempio n. 1
0
        public async Task GetAllEnvironments()
        {
            var(environments, error) = await EnvsSvc.GetAllEnvironments().ConfigureAwait(false);

            if (error != null)
            {
                await SendErrorToCaller(error).ConfigureAwait(false);

                return;
            }

            await DispatchToCaller(MessageTypes.ENV_RECV_ALL, environments).ConfigureAwait(false);
        }
Esempio n. 2
0
        private async Task UpdateAvailableEnvironments()
        {
            var(environments, error) = await EnvsSvc.GetAllEnvironments().ConfigureAwait(false);

            if (error != null)
            {
                // Since this is a global update for anyone connected to the server, we don't
                // need to notify everyone when it fails. For now, we'll let the underlying
                // service log the error then not do anything for the clients.
                return;
            }

            Log.LogTrace("Updating all clients with {count} environments.", environments.Count);
            await DispatchToAll(MessageTypes.ENV_RECV_ALL, environments).ConfigureAwait(false);
        }
Esempio n. 3
0
        public async Task RemoveEnvironment(long id)
        {
            Log.LogInformation("Removing existing environment with ID {id}", id);

            var error = await EnvsSvc.DeleteEnvironment(id).ConfigureAwait(false);

            if (error != null)
            {
                await SendErrorToCaller(error).ConfigureAwait(false);

                return;
            }

            await UpdateAvailableEnvironments().ConfigureAwait(false);
        }
Esempio n. 4
0
        public async Task CreateNewEnvironment(string envName)
        {
            var env = new Environment
            {
                Name = envName,
            };

            Log.LogInformation("Adding new environment with name {name}", env.Name);

            var error = await EnvsSvc.AddNewEnvironment(env).ConfigureAwait(false);

            if (error != null)
            {
                await SendErrorToCaller(error).ConfigureAwait(false);

                return;
            }

            await UpdateAvailableEnvironments().ConfigureAwait(false);
        }