Пример #1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BatchScripter.ScriptingArgs args = e.Argument as BatchScripter.ScriptingArgs;
            _isScripting = true;

            ScripterResult result = new ScripterResult();

            try
            {
                result.Content = _scripter.ScriptObjects(args);
            }
            catch (Exception ex)
            {
                result.Error = ex;
            }
            finally
            {
                e.Cancel            = _scripter.CancelRequested;
                result.RecentErrors = _scripter.RecentErrors;
                e.Result            = result;
            }
        }
Пример #2
0
        private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress, this.Handle);
                TaskbarManager.Instance.SetProgressValue(0, 100, this.Handle);
            }
            ResetWizardState();

            if (e.Cancelled)
            {
                ResetProgressInfo("Scripting was cancelled by the user.");
                return;
            }

            if (e.Error != null)
            {
                ResetProgressInfo("Scripting completed with errors.");
                CheckAndShowErrors(e.Error, String.Empty, true);
                return;
            }

            ScripterResult result    = e.Result as ScripterResult;
            bool           hasErrors = !String.IsNullOrEmpty(result.RecentErrors) || result.Error != null;

            if (hasErrors)
            {
                ResetProgressInfo("Scripting completed with errors.");
                CheckAndShowErrors(result.Error, result.RecentErrors, true);
            }
            else
            {
                ResetProgressInfo("Scripting completed succesfully.");
                OutputScript(result.Content);
                NotifyUserOrClose();
            }
            this.BringToFront();
        }