コード例 #1
0
 private void CheckIfMonitoredJobIsComplete(Job job, JobState jobState)
 {
     if (job.IsFinishedState(jobState))
     {
         lock (this._myLock)
         {
             this.StopMonitoringJob(job);
         }
     }
 }
コード例 #2
0
 private void HandleJobStateChangedEvent(object source, JobStateEventArgs eventArgs)
 {
     System.Management.Automation.Job item = (System.Management.Automation.Job)source;
     lock (this._jobTrackingLock)
     {
         if (eventArgs.JobStateInfo.State == JobState.Blocked)
         {
             this._blockedJobs.Add(item);
         }
         else
         {
             this._blockedJobs.Remove(item);
         }
         if (((this.Force == 0) && item.IsPersistentState(eventArgs.JobStateInfo.State)) || ((this.Force != 0) && item.IsFinishedState(eventArgs.JobStateInfo.State)))
         {
             if (!item.IsFinishedState(eventArgs.JobStateInfo.State))
             {
                 this._warnNotTerminal = true;
             }
             this._finishedJobs.Add(item);
         }
         else
         {
             this._finishedJobs.Remove(item);
         }
         if (this.Any.IsPresent)
         {
             if (this._finishedJobs.Count > 0)
             {
                 this.SetEndProcessingAction(new Action(this.EndProcessingOutputSingleFinishedJob));
             }
             else if (this._blockedJobs.Count == this._jobsToWaitFor.Count)
             {
                 this.SetEndProcessingAction(new Action(this.EndProcessingBlockedJobsError));
             }
         }
         else if (this._finishedJobs.Count == this._jobsToWaitFor.Count)
         {
             this.SetEndProcessingAction(new Action(this.EndProcessingOutputAllFinishedJobs));
         }
         else if (this._blockedJobs.Count > 0)
         {
             this.SetEndProcessingAction(new Action(this.EndProcessingBlockedJobsError));
         }
     }
 }
コード例 #3
0
 private void AggregateResultsFromJob(System.Management.Automation.Job job)
 {
     if (((this.Force != false) || !job.IsPersistentState(job.JobStateInfo.State)) && ((this.Force == false) || !job.IsFinishedState(job.JobStateInfo.State)))
     {
         job.StateChanged += new EventHandler <JobStateEventArgs>(this.HandleJobStateChanged);
         if (((this.Force == false) && job.IsPersistentState(job.JobStateInfo.State)) || ((this.Force != false) && job.IsFinishedState(job.JobStateInfo.State)))
         {
             job.StateChanged -= new EventHandler <JobStateEventArgs>(this.HandleJobStateChanged);
         }
         else
         {
             this._tracer.WriteMessage("ReceiveJobCommand", "AggregateResultsFromJob", Guid.Empty, job, "BEGIN Adding job for aggregation", null);
             this._jobsBeingAggregated.Add(job);
             if (job.UsesResultsCollection)
             {
                 job.Results.SourceId   = job.InstanceId;
                 job.Results.DataAdded += new EventHandler <DataAddedEventArgs>(this.ResultsAdded);
             }
             else
             {
                 job.Output.SourceId     = job.InstanceId;
                 job.Error.SourceId      = job.InstanceId;
                 job.Progress.SourceId   = job.InstanceId;
                 job.Verbose.SourceId    = job.InstanceId;
                 job.Warning.SourceId    = job.InstanceId;
                 job.Debug.SourceId      = job.InstanceId;
                 job.Output.DataAdded   += new EventHandler <DataAddedEventArgs>(this.Output_DataAdded);
                 job.Error.DataAdded    += new EventHandler <DataAddedEventArgs>(this.Error_DataAdded);
                 job.Progress.DataAdded += new EventHandler <DataAddedEventArgs>(this.Progress_DataAdded);
                 job.Verbose.DataAdded  += new EventHandler <DataAddedEventArgs>(this.Verbose_DataAdded);
                 job.Warning.DataAdded  += new EventHandler <DataAddedEventArgs>(this.Warning_DataAdded);
                 job.Debug.DataAdded    += new EventHandler <DataAddedEventArgs>(this.Debug_DataAdded);
             }
             this._tracer.WriteMessage("ReceiveJobCommand", "AggregateResultsFromJob", Guid.Empty, job, "END Adding job for aggregation", null);
         }
     }
 }
コード例 #4
0
 private void AutoRemoveJobIfRequired(System.Management.Automation.Job job)
 {
     if ((this._autoRemoveJob && this._jobsSpecifiedInParameters.Contains(job.InstanceId)) && job.IsFinishedState(job.JobStateInfo.State))
     {
         if (job.HasMoreData)
         {
             this._tracer.WriteMessage("ReceiveJobCommand", "AutoRemoveJobIfRequired", Guid.Empty, job, "Job has data and is being removed.", new string[0]);
         }
         Job2 job2 = job as Job2;
         if (job2 != null)
         {
             try
             {
                 base.JobManager.RemoveJob(job2, this, false, true);
                 job.Dispose();
             }
             catch (Exception exception)
             {
                 this.AddRemoveErrorToResults(job2, exception);
             }
         }
         else
         {
             try
             {
                 base.JobRepository.Remove(job);
                 job.Dispose();
             }
             catch (ArgumentException exception2)
             {
                 this.AddRemoveErrorToResults(job, exception2);
             }
         }
     }
 }
コード例 #5
0
 private void HandleJobStateChanged(object sender, JobStateEventArgs e)
 {
     System.Management.Automation.Job job = sender as System.Management.Automation.Job;
     this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "BEGIN wait for write existing data", null);
     if (e.JobStateInfo.State != JobState.Running)
     {
         this._writeExistingData.WaitOne();
     }
     this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "END wait for write existing data", null);
     lock (this._syncObject)
     {
         if (!this._jobsBeingAggregated.Contains(job))
         {
             this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "Returning because job is not in _jobsBeingAggregated", null);
             return;
         }
     }
     if (e.JobStateInfo.State == JobState.Blocked)
     {
         DoUnblockJob(job);
     }
     if (((this.Force == 0) && job.IsPersistentState(e.JobStateInfo.State)) || ((this.Force != 0) && job.IsFinishedState(e.JobStateInfo.State)))
     {
         this.WriteReasonError(job);
         this.WriteJobStateInformationIfRequired(job, e);
         this.StopAggregateResultsFromJob(job);
     }
     else
     {
         this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "Returning because job state does not meet wait requirements (continue aggregating)", new string[0]);
     }
 }