コード例 #1
0
        public void Export()
        {
            TrainingServiceClient tsc = new TrainingServiceClient();

            try
            {
                tsc.Export();
            }
            catch (FaultException fex)
            {
                throw new ApplicationException(fex.Message);
            }
            finally
            {
                tsc.Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Calls the GetTraining operation method in the TrainingService.
        /// </summary>
        /// <param name="tRequestID">A tRequestID value.</param>
        /// <returns>Returns a TrainingRequest object.</returns>
        public TrainingRequest GetTraining(string tRequestID)
        {
            TrainingRequest result = default(TrainingRequest);
            var             proxy  = new TrainingServiceClient();

            try
            {
                result = proxy.GetTraining(tRequestID);
            }
            catch (FaultException fex)
            {
                // TODO: Handle your exception here or raise it to the UI.
                //		 Do not display sensitive information to the UI.
                throw new ApplicationException(fex.Message);
            }
            finally
            {
                proxy.Close();
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Calls the ListTraining operation method in the TrainingService.
        /// </summary>
        /// <param name="currentPage">A currentPage value.</param>
        /// <returns>Returns a List<TrainingRequest> object.</returns>
        public List <TrainingRequest> ListTraining(int currentPage)
        {
            List <TrainingRequest> result = default(List <TrainingRequest>);
            var proxy = new TrainingServiceClient();

            try
            {
                result = proxy.ListTraining(currentPage);
            }
            catch (FaultException fex)
            {
                // TODO: Handle your exception here or raise it to the UI.
                //		 Do not display sensitive information to the UI.
                throw new ApplicationException(fex.Message);
            }
            finally
            {
                proxy.Close();
            }
            return(result);
        }
コード例 #4
0
    {       /// <summary>
            /// Calls the LoginVerify operation method in the TrainingService.
            /// </summary>
            /// <param name="Username">A Username value.</param>
            /// <param name="Password">A Password value.</param>
            /// <returns>Returns a User object.</returns>
        public User LoginVerify(string Username, string Password)
        {
            User result = default(User);
            var  proxy  = new TrainingServiceClient();

            try
            {
                result = proxy.LoginVerify(Username, Password);
            }
            catch (FaultException fex)
            {
                // TODO: Handle your exception here or raise it to the UI.
                //		 Do not display sensitive information to the UI.
                throw new ApplicationException(fex.Message);
            }
            finally
            {
                proxy.Close();
            }
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Calls the GetUserPermission operation method in the TrainingService.
        /// </summary>
        /// <param name="userID">A userID value.</param>
        /// <param name="policyId">A policyId value.</param>
        /// <returns>Returns a AccessPolicy object.</returns>
        public AccessPolicy GetUserPermission(long userID, string policyId)
        {
            AccessPolicy result = default(AccessPolicy);
            var          proxy  = new TrainingServiceClient();

            try
            {
                result = proxy.GetUserPermission(userID, policyId);
            }
            catch (FaultException fex)
            {
                // TODO: Handle your exception here or raise it to the UI.
                //		 Do not display sensitive information to the UI.
                throw new ApplicationException(fex.Message);
            }
            finally
            {
                proxy.Close();
            }
            return(result);
        }
コード例 #6
0
        private async Task CallServer(string projectName)
        {
            this.logger.Info($"Running retraining of project '{projectName}' on R Server.");

            using (TrainingServiceClient client = new TrainingServiceClient(new Uri(this.serviceConfiguration.RServerUrl, UriKind.RelativeOrAbsolute)))
            {
                client.HttpClient.Timeout = this.serviceConfiguration.RServerClientTimeout;

                var loginParameters = new LoginRequest(this.serviceConfiguration.RServerUserName, this.serviceConfiguration.RServerPassword);

                var loginResult = await client.LoginWithHttpMessagesAsync(loginParameters);

                if (string.IsNullOrWhiteSpace(loginResult?.Body?.AccessToken))
                {
                    throw new SecurityException("Could not log in to prediction service.");
                }

                var headers     = client.HttpClient.DefaultRequestHeaders;
                var accessToken = loginResult.Body.AccessToken;
                headers.Remove("Authorization");
                headers.Add("Authorization", $"Bearer {accessToken}");

                var result = await client.TrainAsync(new InputParameters(projectName));

                var consoleOutput = result?.ConsoleOutput;
                if (!string.IsNullOrWhiteSpace(consoleOutput))
                {
                    this.logger.Info($"Training project '{projectName}'. Console output: {consoleOutput}");
                }

                if (!(result?.Success).GetValueOrDefault())
                {
                    var message = result?.ErrorMessage ?? "R Server returned not a success or null.";
                    this.logger.Error(message);

                    throw new Exception(message);
                }
            }
        }