Пример #1
0
        private void _ScriptManager_OnScriptAborted(object sender, Common.ScriptEventArgs e)
        {
            DebugEx.WriteLine("COnfigurationManager : OnScriptAborted - " + e.Reason, DebugLevel.Informational);
            SNGScriptManager thisManager = null;

            if (sender is ScriptExecutor)
            {
                thisManager = ScriptingFormManager.GetScriptManager(sender as ScriptExecutor);
            }
            else if (sender is ScriptingForm)
            {
                thisManager = (sender as ScriptingForm).ScriptManager;
            }
            if (ScriptManagers.Contains(thisManager))
            {
                lock (_lckObject) // locking is required to synchronize potential parallel calls
                {
                    Invoke(new MethodInvoker(delegate
                    {
                        if (pbPullProgress.Value < pbPullProgress.Maximum)
                        {
                            pbPullProgress.Value += 1;
                        }
                        if (ScriptManagers.Count == 0)
                        {
                            EnableControls();
                            btnPullConfig.Enabled       = true;
                            lblOperationInProgress.Text = "Operation completed";
                            RefreshScriptManagers();
                        }
                        btnCancelPull.Visible = !btnPullConfig.Enabled;
                    }));
                }
            }
        }
Пример #2
0
        private void _ScriptManager_OnScriptFinished(object sender, Common.ScriptEventArgs e)
        {
            DebugEx.WriteLine("ConfigurationManager : OnScriptFinished - " + e.Reason.ToString(), DebugLevel.Informational);
            SNGScriptManager thisManager = null;

            if (sender is ScriptExecutor)
            {
                thisManager = ScriptingFormManager.GetScriptManager(sender as ScriptExecutor);
            }
            else if (sender is ScriptingForm)
            {
                thisManager = (sender as ScriptingForm).ScriptManager;
            }
            if (ScriptManagers.Contains(thisManager))
            {
                lock (_lckObject) // locking is required to synchronize potential parallel calls
                {
                    ScriptManagers.Remove(thisManager);
                    if (e.Reason != ScriptEventReason.UserAborted)
                    {
                        Invoke(new MethodInvoker(delegate()
                        {
                            if (pbPullProgress.Value < pbPullProgress.Maximum)
                            {
                                pbPullProgress.Value += 1;
                            }
                            DialogResult saveConfig = DialogResult.Yes;
                            if (cbAutoSave.Checked || (saveConfig = MessageBox.Show(String.Format("Script <{0}> finished. Do you want to auto-save script results to database ?", thisManager.GetScriptName()), "Auto-save", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) == System.Windows.Forms.DialogResult.Yes)
                            {
                                SaveScriptResults(thisManager);
                            }
                            if (saveConfig == DialogResult.Yes)
                            {
                                thisManager.CloseForm();
                            }
                            if (ScriptManagers.Count == 0)
                            {
                                EnableControls();
                                btnPullConfig.Enabled       = true;
                                lblOperationInProgress.Text = "Operation completed";
                                RefreshScriptManagers();
                            }
                            btnCancelPull.Visible = !btnPullConfig.Enabled;
                        }));
                    }
                    else
                    {
                        Invoke(new MethodInvoker(delegate() { if (!IsDisposed && pbPullProgress.Value < pbPullProgress.Maximum)
                                                              {
                                                                  pbPullProgress.Value += 1;
                                                              }
                                                 }));
                    }
                }
            }
        }