Esempio n. 1
0
            /// <summary>
            /// Stop the Job
            /// </summary>
            /// <param name="actions">Actions collection</param>
            /// <param name="index">this actions index into the actions collection</param>
            /// <returns></returns>
            public ProgressStatus DoAction(ProgressItemCollection actions, int index)
            {
                //parameter check
                if (actions == null)
                {
                    throw new ArgumentNullException("actions");
                }

                // in progress
                actions.Progress.UpdateActionStatus(index, ProgressStatus.InProgress);
                actions.Progress.AddActionInfoString(index, "AgentActionSR.StoppingJob(this.job.Name)");
                job.Stop();

                // done
                actions.Progress.AddActionInfoString(index, "AgentActionSR.StoppedJob(this.job.Name)");
                actions.Progress.UpdateActionStatus(index, ProgressStatus.Success);
                return(ProgressStatus.Success);
            }
Esempio n. 2
0
            /// <summary>
            /// Enable the alert
            /// </summary>
            /// <param name="actions">Actions collection</param>
            /// <param name="index">this actions index into the actions collection</param>
            /// <returns></returns>
            public ProgressStatus DoAction(ProgressItemCollection actions, int index)
            {
                //parameter check
                if (actions == null)
                {
                    throw new ArgumentNullException("actions");
                }

                // in progress
                actions.Progress.UpdateActionStatus(index, ProgressStatus.InProgress);
                actions.Progress.AddActionInfoString(index, "AgentActionSR.EnablingAlert(this.alert.Name)");

                this.alert.IsEnabled = true;
                this.alert.Alter();

                // done
                actions.Progress.AddActionInfoString(index, "AgentActionSR.EnabledAlert(this.alert.Name)");
                actions.Progress.UpdateActionStatus(index, ProgressStatus.Success);
                return(ProgressStatus.Success);
            }
Esempio n. 3
0
            /// <summary>
            /// Start the Job
            /// </summary>
            /// <param name="actions">Actions collection</param>
            /// <param name="index">this actions index into the actions collection</param>
            /// <returns></returns>
            public ProgressStatus DoAction(ProgressItemCollection actions, int index)
            {
                ProgressStatus status = ProgressStatus.Success;

                //parameter check
                if (actions == null)
                {
                    throw new ArgumentNullException("actions");
                }

                // in progress
                actions.Progress.UpdateActionStatus(index, ProgressStatus.InProgress);

                // perform an enumerator query to get the steps. We could use the
                // SMO step object but this is too inefficient as it generates a batch
                // per step.
                Request request = new Request();

                request.Fields      = new string[] { "Name", "ID", "SubSystem" };
                request.Urn         = this.job.Urn + "/Step";
                request.OrderByList = new OrderBy[] { new OrderBy("ID", OrderBy.Direction.Asc) };

                if (this.currentJobStep != null)
                {
                    actions.Progress.AddActionInfoString(index,
                                                         "AgentActionSR.StartJobWithStep(this.job.Name, this.currentJobStep)");
                    this.job.Start(this.currentJobStep);
                }
                else
                {
                    actions.Progress.AddActionInfoString(index, "AgentActionSR.StartingJob(this.job.Name)");
                    this.job.Start();
                }

                // done
                actions.Progress.UpdateActionStatus(index, status);
                return(status);
            }
Esempio n. 4
0
            /// <summary>
            /// Perform the action for this class
            /// </summary>
            /// <param name="actions">Actions collection</param>
            /// <param name="index">array index of this particular action</param>
            /// <returns></returns>
            public ProgressStatus DoAction(ProgressItemCollection actions, int index)
            {
                ProgressStatus status = ProgressStatus.Error;

                bool jobFinished = false;

                JobServer   jobServer = job.Parent;
                JobCategory category  = jobServer.JobCategories[job.Category];

                if (category.CategoryType == CategoryType.MultiServerJob)
                {
                    actions.Progress.UpdateActionDescription(index, "AgentActionSR.RequestPostedToTargetServers");
                    actions.Progress.UpdateActionStatus(index, ProgressStatus.Success);
                    return(ProgressStatus.Success);
                }

                status = ProgressStatus.Aborted;

                // now wait for job to finish...
                while (!this.abortEvent.WaitOne(WaitForJobToFinishAction.ServerPollingInterval))
                {
                    if (actions.Progress.IsAborted)
                    {
                        break;
                    }

                    this.job.Refresh();
                    // If this job hasn't started yet then don't check for its status
                    if (this.prevRunTime != job.LastRunDate)
                    {
                        switch (this.job.CurrentRunStatus)
                        {
                        case JobExecutionStatus.Idle:
                            actions.Progress.UpdateActionProgress(index, 100);

                            // see if the job succeeded.
                            if (this.job.LastRunOutcome == CompletionResult.Failed)
                            {
                                actions.Progress.UpdateActionStatus(index, ProgressStatus.Error);
                                actions.Progress.AddActionException(index,
                                                                    new Exception("AgentActionSR.JobFailed(job.Name)"));
                                status = ProgressStatus.Error;
                            }
                            else
                            {
                                actions.Progress.UpdateActionDescription(index, "AgentActionSR.ExecuteJob(job.Name)");
                                actions.Progress.UpdateActionStatus(index, ProgressStatus.Success);
                                status = ProgressStatus.Success;
                            }

                            jobFinished = true;
                            break;

                        case JobExecutionStatus.Suspended:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.Suspended");
                            break;

                        case JobExecutionStatus.BetweenRetries:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.BetweenRetries");
                            break;

                        case JobExecutionStatus.Executing:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.Executing");
                            break;

                        case JobExecutionStatus.PerformingCompletionAction:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.PerformingCompletionAction");
                            break;

                        case JobExecutionStatus.WaitingForStepToFinish:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.WaitingForStepToFinish");
                            break;

                        case JobExecutionStatus.WaitingForWorkerThread:
                            actions.Progress.UpdateActionProgress(index, "AgentActionSR.WaitingForWorkerThread");
                            break;

                        default:
                            // unknown JobExecutionStatus, keep waiting.
                            System.Diagnostics.Debug.Assert(false,
                                                            "Unknown JobExecutionStatus found while waiting for job execution to finish");
                            break;
                        }
                    }

                    if (jobFinished)
                    {
                        break;
                    }

                    actions.Progress.UpdateActionStatus(index, ProgressStatus.InProgress);
                }

                return(status);
            }