示例#1
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]);
     }
 }
示例#2
0
 private void WriteJobStateInformationIfRequired(System.Management.Automation.Job job, JobStateEventArgs args = null)
 {
     if (this._writeStateChangedEvents && job.IsPersistentState(job.JobStateInfo.State))
     {
         this.WriteJobStateInformation(job, args);
     }
     this.AutoRemoveJobIfRequired(job);
 }
示例#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 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));
         }
     }
 }