public CreateSession ( IIdentity user, string id, |
||
user | IIdentity | |
id | string | |
interpreter | ||
password | ||
profilePath | string | |
commandLineArguments | string | |
Результат |
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))); } }
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))); } }
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)); }