コード例 #1
0
        public Task GetTestSqlConnection()
        {
            try
            {
                var factoryName      = GetStringQueryString("factoryName");
                var connectionString = new StreamReader(HttpContext.Request.Body).ReadToEnd();
                RelationalDatabaseWriter.TestConnection(factoryName, connectionString);
                NoContentStatus();
            }
            catch (Exception ex)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; // Bad Request

                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Error occurred during sql replication connection test", ex);
                }

                using (ContextPool.AllocateOperationContext(out JsonOperationContext context))
                {
                    using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                    {
                        context.Write(writer, new DynamicJsonValue
                        {
                            ["Error"]     = "Connection failed",
                            ["Exception"] = ex.ToString()
                        });
                    }
                }
            }

            return(Task.CompletedTask);
        }
コード例 #2
0
 public Task <HttpResponseMessage> TestSqlReplicationConnection(string factoryName, string connectionString)
 {
     try
     {
         RelationalDatabaseWriter.TestConnection(factoryName, connectionString);
         return(GetEmptyMessageAsTask(HttpStatusCode.NoContent));
     }
     catch (Exception ex)
     {
         return(GetMessageWithObjectAsTask(new
         {
             Error = "Connection failed",
             Exception = ex
         }, HttpStatusCode.BadRequest));
     }
 }
コード例 #3
0
        public Task GetTestSqlConnection()
        {
            try
            {
                var factoryName      = GetStringQueryString("factoryName");
                var connectionString = new StreamReader(HttpContext.Request.Body).ReadToEnd();
                RelationalDatabaseWriter.TestConnection(factoryName, connectionString);

                DynamicJsonValue result = new DynamicJsonValue
                {
                    [nameof(NodeConnectionTestResult.Success)] = true,
                };

                using (ContextPool.AllocateOperationContext(out JsonOperationContext context))
                    using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                    {
                        context.Write(writer, result);
                    }
            }
            catch (Exception ex)
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Error occurred during sql replication connection test", ex);
                }

                using (ContextPool.AllocateOperationContext(out JsonOperationContext context))
                {
                    using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                    {
                        context.Write(writer, new DynamicJsonValue
                        {
                            [nameof(NodeConnectionTestResult.Success)] = false,
                            [nameof(NodeConnectionTestResult.Error)]   = ex.ToString()
                        });
                    }
                }
            }

            return(Task.CompletedTask);
        }