// Job done! private void handle_SubmitSasProgramComplete(object sender, SubmitCompleteEventArgs args) { // use BeginInvoke to move processing back to UI thread BeginInvoke(new MethodInvoker( delegate() { // Close progress dialog if needed if (progressdlg != null && progressdlg.Visible) { progressdlg.Close(); progressdlg = null; } sasJobId = -1; Cursor.Current = _savedCursor; if (args.Success) { SaveSettings(); AddProcesses(); UpdateKillButton(); } else { // ERROR - provide option to show the SAS log if (DialogResult.Yes == MessageBox.Show("An error occurred while trying to retrieve the list of processes. Would you like to view the error log?", "Error", MessageBoxButtons.YesNo)) { SAS.Tasks.Toolkit.Controls.SASLogViewDialog logView = new SASLogViewDialog("Error log", "PROC IOMOPERATE log:", args.Log); logView.ShowDialog(this); }; } } )); }
private void btnKill_Click(object sender, EventArgs e) { if (listProcesses.SelectedItems.Count == 1) { SasServer serv = new SasServer(Consumer.AssignedServer); string thisProcess = serv.GetSasMacroValue("SYSJOBID"); SasProcess proc = (listProcesses.SelectedItems[0].Tag as SasProcess); if (proc.PID.Trim() == thisProcess.Trim()) { // confirm before killing the current active SAS session if (DialogResult.No == MessageBox.Show("The selected process is your active SAS session. Do you still want to stop it?", "Warning", MessageBoxButtons.YesNo)) return; } string log = ""; string UUID = (listProcesses.SelectedItems[0].Tag as SasProcess).UUID; string program = string.Format(killProgram, UUID ); SasSubmitter s = new SasSubmitter(Consumer.AssignedServer); if (s.IsServerBusy()) { MessageBox.Show(string.Format("The server {0} is busy; cannot end selected process.", Consumer.AssignedServer)); // bail out, return control to UI return; } // server is available, so submit code synchronously bool success = s.SubmitSasProgramAndWait(program, out log); if (success) RefreshProcesses(); else { // ERROR - provide option to show the SAS log if (DialogResult.Yes == MessageBox.Show("An error occurred while trying to end the selected process. Would you like to view the error log?", "Error", MessageBoxButtons.YesNo)) { SAS.Tasks.Toolkit.Controls.SASLogViewDialog logView = new SASLogViewDialog("Error log", "PROC IOMOPERATE log:", log); logView.ShowDialog(this); }; } } }