コード例 #1
0
 /// <summary>
 /// Handles config view request
 /// </summary>
 /// <param name="parameters">Request parameters</param>
 /// <param name="requestContext">Request Context</param>
 /// <returns></returns>
 public async Task HandleServerConfigViewRequest(ServerConfigViewRequestParams parameters, RequestContext <ServerConfigViewResponseParams> requestContext)
 {
     Logger.Write(TraceEventType.Verbose, "HandleServerConfigViewRequest");
     try
     {
         ConnectionInfo connInfo;
         ConnectionServiceInstance.TryFindConnection(
             parameters.OwnerUri,
             out connInfo);
         if (connInfo == null)
         {
             await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
         }
         else
         {
             var serverConnection = ConnectionService.OpenServerConnection(connInfo);
             ServerConfigProperty serverConfig = GetConfig(serverConnection, parameters.ConfigNumber);
             await requestContext.SendResult(new ServerConfigViewResponseParams
             {
                 ConfigProperty = serverConfig
             });
         }
     }
     catch (Exception e)
     {
         // Exception related to run task will be captured here
         await requestContext.SendError(e);
     }
 }
コード例 #2
0
        /// <summary>
        /// Returns current value of external script config
        /// </summary>
        /// <param name="serverConnection"></param>
        /// <returns></returns>
        private ServerConfigProperty GetConfig(ServerConnection serverConnection, int configNumber)
        {
            Server         server       = new Server(serverConnection);
            ConfigProperty serverConfig = GetSmoConfig(server, configNumber);

            return(serverConfig != null?ServerConfigProperty.ToServerConfigProperty(serverConfig) : null);
        }
コード例 #3
0
        private List <ServerConfigProperty> GetConfigs(ServerConnection serverConnection)
        {
            Server server = new Server(serverConnection);
            List <ServerConfigProperty> list = new List <ServerConfigProperty>();

            foreach (ConfigProperty serverConfig in server.Configuration.Properties)
            {
                list.Add(serverConfig != null ? ServerConfigProperty.ToServerConfigProperty(serverConfig) : null);
            }
            return(list);
        }
コード例 #4
0
        public async void VerifyUpdatingConfigs()
        {
            using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
            {
                var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);

                List <ServerConfigProperty> configs = await GetAllConfigs();

                Assert.NotNull(configs);
                Assert.True(configs.Count > 0);
                ServerConfigProperty sampleConfig = configs[0];

                ServerConfigViewResponseParams   result       = null;
                ServerConfigUpdateResponseParams updateResult = null;
                int newValue = sampleConfig.ConfigValue == sampleConfig.Minimum ? sampleConfig.Maximum : sampleConfig.Minimum;

                var requestContext       = RequestContextMocks.Create <ServerConfigViewResponseParams>(r => result = r).AddErrorHandling(null);
                var updateRequestContext = RequestContextMocks.Create <ServerConfigUpdateResponseParams>(r => updateResult = r).AddErrorHandling(null);

                ServerConfigViewRequestParams requestParams = new ServerConfigViewRequestParams
                {
                    OwnerUri     = connectionResult.ConnectionInfo.OwnerUri,
                    ConfigNumber = sampleConfig.Number
                };
                ServerConfigUpdateRequestParams updateRequestParams = new ServerConfigUpdateRequestParams
                {
                    OwnerUri     = connectionResult.ConnectionInfo.OwnerUri,
                    ConfigNumber = sampleConfig.Number,
                    ConfigValue  = newValue
                };

                await ServerConfigService.Instance.HandleServerConfigViewRequest(requestParams, requestContext.Object);

                Assert.NotNull(result);
                Assert.Equal(result.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
                await ServerConfigService.Instance.HandleServerConfigUpdateRequest(updateRequestParams, updateRequestContext.Object);

                Assert.NotNull(updateResult);
                Assert.Equal(updateResult.ConfigProperty.ConfigValue, newValue);
                updateRequestParams.ConfigValue = sampleConfig.ConfigValue;
                await ServerConfigService.Instance.HandleServerConfigUpdateRequest(updateRequestParams, updateRequestContext.Object);

                Assert.NotNull(updateResult);
                Assert.Equal(updateResult.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
                ServerConfigService.Instance.ConnectionServiceInstance.Disconnect(new DisconnectParams
                {
                    OwnerUri = queryTempFile.FilePath,
                    Type     = ServiceLayer.Connection.ConnectionType.Default
                });
            }
        }