List <ProcessListEntry> GetProcessList(IProcessListRequest request) { // TODO: Use single cancelable task for both actions try { var enableSshAction = _actionRecorder.CreateToolAction(ActionType.GameletEnableSsh); if (!_cancelableTaskFactory .Create(TaskMessages.EnablingSSH, async _ => await _sshManager.EnableSshAsync(Gamelet, enableSshAction)) .RunAndRecord(enableSshAction)) { return(new List <ProcessListEntry>()); } } catch (Exception e) when(e is SshKeyException || e is CloudException) { Trace.WriteLine(e.ToString()); _dialogUtil.ShowError(ErrorStrings.FailedToEnableSsh(e.Message), e.ToString()); return(new List <ProcessListEntry>()); } // TODO: Handle ProcessException var processListAction = _actionRecorder.CreateToolAction(ActionType.ProcessList); var queryProcessesTask = _cancelableTaskFactory.Create( "Querying instance processes...", async() => await request.GetBySshAsync(new SshTarget(Gamelet))); queryProcessesTask.RunAndRecord(processListAction); return(queryProcessesTask.Result); }
/// <summary> /// Enable SSH for communication with the gamelet. /// </summary> bool EnableSsh(Gamelet gamelet) { try { IAction action = _actionRecorder.CreateToolAction(ActionType.GameletEnableSsh); ICancelableTask enableSshTask = _cancelableTaskFactory.Create(TaskMessages.EnablingSSH, async _ => { await _sshManager.EnableSshAsync(gamelet, action); }); return(enableSshTask.RunAndRecord(action)); } catch (Exception e) when(e is CloudException || e is SshKeyException) { Trace.Write($"Received exception while enabling ssh.\n{e}"); _dialogUtil.ShowError(ErrorStrings.FailedToEnableSsh(e.Message), e.ToString()); return(false); } }
bool EnableSsh() { try { var action = _actionRecorder.CreateToolAction(ActionType.GameletEnableSsh); var enableSshTask = _cancelableTaskFactory.Create( TaskMessages.EnablingSSH, async _ => { await _sshManager.EnableSshAsync(_instance, action); }); if (!enableSshTask.RunAndRecord(action)) { return(false); } } catch (Exception e) when(e is CloudException || e is SshKeyException) { Trace.Write("An exception was thrown while enabling ssh." + Environment.NewLine + e); GameletMessageTextBox.Text = ErrorStrings.FailedToEnableSsh(e.Message); return(false); } return(true); }