private async System.Threading.Tasks.Task DownloadRDPFileAsync(ComputeNodeModel computeNode, string localDownloadTargetPath = null)
        {
            string fileName = null;
            bool? result;
            if (string.IsNullOrEmpty(localDownloadTargetPath))
            {
                // Configure save file dialog box
                Microsoft.Win32.SaveFileDialog saveFileDlg = new Microsoft.Win32.SaveFileDialog();
                saveFileDlg.FileName = computeNode.Id; // Default file name
                saveFileDlg.DefaultExt = ".rdp"; // Default file extension.
                saveFileDlg.Filter = "RDP File (.rdp)|*.rdp"; // Filter files by extension

                // Show save file dialog box
                result = saveFileDlg.ShowDialog();
                if (result == true)
                {
                    fileName = saveFileDlg.FileName;
                }
            }
            else
            {
                fileName = Path.Combine(localDownloadTargetPath, Path.GetFileName(computeNode.Id) + ".rdp");
                result = true;
            }

            if (result == true)
            {
                // Save document
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    await computeNode.DownloadRDPAsync(memoryStream);

                    memoryStream.Seek(0, SeekOrigin.Begin);

                    using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
                    {
                        await memoryStream.CopyToAsync(fileStream);
                    }
                }

                // Launch
                // We don't ask for permission to launch here because the process seems
                // to do that for us. The connection is always "untrusted" and,
                // given security settings, it is likely to remain that way.
                Process.Start(fileName);
            }
        }
 private async System.Threading.Tasks.Task<RemoteLoginSettings> GetSSHSettingsAsync(ComputeNodeModel computeNode)
 {
     return await computeNode.GetSSHSettingsAsync();
 }
        private void RegisterMessages()
        {
            Messenger.Default.Register<UpdateWaitSpinnerMessage>(this, ProcessUpdateWaitSpinnerMessage);

            Messenger.Default.Register<RefreshMessage>(this,
                (message) =>
                {
                    switch (message.ItemToRefresh)
                    {
                        case RefreshTarget.Pools:
                            AsyncOperationTracker.Instance.AddTrackedInternalOperation(this.GetDataAsync(dataProvider, false, false, true, false));
                            break;
                        case RefreshTarget.Jobs:
                            AsyncOperationTracker.Instance.AddTrackedInternalOperation(this.GetDataAsync(dataProvider, false, true, false, false));
                            break;
                        case RefreshTarget.JobSchedules:
                            AsyncOperationTracker.Instance.AddTrackedInternalOperation(this.GetDataAsync(dataProvider, true, false, false, false));
                            break;
                        case RefreshTarget.Certificates:
                            AsyncOperationTracker.Instance.AddTrackedInternalOperation(this.GetDataAsync(dataProvider, false, false, false, true));
                            break;
                    }
                }
            );

            Messenger.Default.Register<ModelNotFoundAfterRefresh>(this, (message) =>
                {
                    ModelBase modelBase = message.Model;

                    JobScheduleModel jobScheduleModel = modelBase as JobScheduleModel;
                    if (jobScheduleModel != null)
                    {
                        this.jobSchedules.Remove(jobScheduleModel);
                        FirePropertyChangedEvent("JobScheduleTabTitle");
                        this.SelectedJobSchedule = null;
                    }

                    PoolModel poolModel = modelBase as PoolModel;
                    if (poolModel != null)
                    {
                        this.pools.Remove(poolModel);
                        FirePropertyChangedEvent("PoolTabTitle");
                        SelectedPool = null;
                        this.SelectedComputeNode = null;
                    }

                    JobModel jobModel = modelBase as JobModel;
                    if (jobModel != null)
                    {
                        this.jobs.Remove(jobModel);
                        this.SelectedJob = null;
                        this.FirePropertyChangedEvent("JobTabTitle");
                        this.FirePropertyChangedEvent("TasksTabTitle");
                    }

                    TaskModel taskModel = modelBase as TaskModel;
                    if (taskModel != null)
                    {
                        taskModel.ParentJob.Tasks.Remove(taskModel);
                        taskModel.ParentJob.UpdateTaskView();
                        FirePropertyChangedEvent("TasksTabTitle");
                    }

                    ComputeNodeModel vmModel = modelBase as ComputeNodeModel;
                    if (vmModel != null)
                    {
                        vmModel.ParentPool.ComputeNodes.Remove(vmModel);
                        vmModel.ParentPool.UpdateNodeView();
                        FirePropertyChangedEvent("ComputeNodesTabTitle");
                        this.selectedComputeNode = null;
                    }
                });
        }