CreateSession() public méthode

public CreateSession ( IIdentity user, string id, Interpreter interpreter, SecureString password, string profilePath, string commandLineArguments ) : Session
user IIdentity
id string
interpreter Microsoft.R.Host.Broker.Interpreters.Interpreter
password System.Security.SecureString
profilePath string
commandLineArguments string
Résultat Session
Exemple #1
0
        public Task <IActionResult> PutAsync(string id, [FromBody] SessionCreateRequest request)
        {
            if (!_interpManager.Interpreters.Any())
            {
                return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.NoRInterpreters)));
            }

            Interpreter interp;

            if (!string.IsNullOrEmpty(request.InterpreterId))
            {
                interp = _interpManager.Interpreters.FirstOrDefault(ip => ip.Id == request.InterpreterId);
                if (interp == null)
                {
                    return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.InterpreterNotFound)));
                }
            }
            else
            {
                interp = _interpManager.Interpreters.First();
            }

            try {
                var session = _sessionManager.CreateSession(User, id, interp, request.CommandLineArguments, request.IsInteractive);
                return(Task.FromResult <IActionResult>(new ObjectResult(session.Info)));
            } catch (Exception ex) {
                return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.UnableToStartRHost, ex.Message)));
            }
        }
Exemple #2
0
        public Task <IActionResult> PutAsync(string id, [FromBody] SessionCreateRequest request)
        {
            if (!_interpManager.Interpreters.Any())
            {
                return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.NoRInterpreters)));
            }

            string profilePath = User.FindFirst(Claims.RUserProfileDir)?.Value;
            var    password    = User.FindFirst(Claims.Password)?.Value.ToSecureString();

            Interpreter interp;

            if (!string.IsNullOrEmpty(request.InterpreterId))
            {
                interp = _interpManager.Interpreters.FirstOrDefault(ip => ip.Id == request.InterpreterId);
                if (interp == null)
                {
                    return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.InterpreterNotFound)));
                }
            }
            else
            {
                interp = _interpManager.Interpreters.First();
            }

            try {
                var session = _sessionManager.CreateSession(User.Identity, id, interp, password, profilePath, request.CommandLineArguments);
                return(Task.FromResult <IActionResult>(new ObjectResult(session.Info)));
            } catch (BrokerMaxedUsersException ex) {
                return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.BrokerMaxUsers, ex.Message)));
            } catch (Exception ex) {
                return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.UnableToStartRHost, ex.Message)));
            }
        }
 public Task <IActionResult> PutAsync(string id, [FromBody] SessionCreateRequest request)
 {
     try {
         var session = _sessionManager.CreateSession(id, request.InterpreterPath, request.InterpreterArchitecture, request.CommandLineArguments, request.IsInteractive);
         return(Task.FromResult <IActionResult>(new ObjectResult(session.Info)));
     } catch (Exception ex) {
         return(Task.FromResult <IActionResult>(new ApiErrorResult(BrokerApiError.UnableToStartRHost, ex.Message)));
     }
 }
Exemple #4
0
        public Task <SessionInfo> PutAsync(string id, [FromBody] SessionCreateRequest request)
        {
            SecureString securePassword = null;
            string       password       = User.FindFirst(Claims.Password)?.Value;

            if (password != null)
            {
                securePassword = new SecureString();
                foreach (var ch in password)
                {
                    securePassword.AppendChar(ch);
                }
            }

            var interp  = _interpManager.Interpreters.First(ip => ip.Info.Id == request.InterpreterId);
            var session = _sessionManager.CreateSession(User.Identity, id, interp, securePassword, request.CommandLineArguments);

            return(Task.FromResult(session.Info));
        }