Esempio n. 1
0
        private async Task createNewServerConfiguration(HttpContext context)
        {
            var parsed = await parseRequestBody(context.Request);

            var provider = parsed.SelectToken("databaseProvider")?.Value <string>();

            if (provider == "PostgreSql")
            {
                _configurationApi.CreateServerConfiguration(new CreatePostgresWorkerServer
                {
                    Name                  = parsed.SelectToken("name")?.Value <string>(),
                    Server                = parsed.SelectToken("server").Value <string>(),
                    Database              = parsed.SelectToken("database").Value <string>(),
                    User                  = parsed.SelectToken("user").Value <string>(),
                    Password              = parsed.SelectToken("password").Value <string>(),
                    SchemaName            = parsed.SelectToken("schemaName").Value <string>(),
                    SchemaCreatorUser     = parsed.SelectToken("schemaCreatorUser").Value <string>(),
                    SchemaCreatorPassword = parsed.SelectToken("schemaCreatorPassword").Value <string>(),
                });
                return;
            }

            if (provider == "redis")
            {
                _configurationApi.CreateServerConfiguration(new CreateRedisWorkerServer
                {
                    Name          = parsed.SelectToken("name")?.Value <string>(),
                    Configuration = parsed.SelectToken("server").Value <string>(),
                    Prefix        = parsed.SelectToken("schemaName").Value <string>(),
                });
                return;
            }

            _configurationApi.CreateServerConfiguration(new CreateSqlServerWorkerServer
            {
                Name                  = parsed.SelectToken("name")?.Value <string>(),
                Server                = parsed.SelectToken("server").Value <string>(),
                Database              = parsed.SelectToken("database").Value <string>(),
                User                  = parsed.SelectToken("user").Value <string>(),
                Password              = parsed.SelectToken("password").Value <string>(),
                SchemaName            = parsed.SelectToken("schemaName").Value <string>(),
                SchemaCreatorUser     = parsed.SelectToken("schemaCreatorUser").Value <string>(),
                SchemaCreatorPassword = parsed.SelectToken("schemaCreatorPassword").Value <string>()
            });
        }