Пример #1
0
 private void JobDone(object sender, CompletedEventArgs obj)
 {
     lock (this.syncObject)
     {
         PSWmiChildJob pSWmiChildJob = this;
         pSWmiChildJob.sinkCompleted = pSWmiChildJob.sinkCompleted - 1;
     }
     if (obj.Status != ManagementStatus.NoError)
     {
         this.bJobFailed = true;
     }
     if (this.sinkCompleted == 0)
     {
         this.helper.RaiseOperationCompleteEvent(null, OperationState.StopComplete);
         if (this.bJobFailed)
         {
             this.helper.State = WmiState.Failed;
             base.SetJobState(JobState.Failed);
         }
         else
         {
             this.helper.State = WmiState.Completed;
             base.SetJobState(JobState.Completed);
             return;
         }
     }
 }
Пример #2
0
        internal PSWmiChildJob(Cmdlet cmds, string computerName, ThrottleManager throttleManager, int count) : base(null, null)
        {
            this.syncObject            = new object();
            this.statusMessage         = "test";
            base.UsesResultsCollection = true;
            this.computerName          = computerName;
            this.throttleManager       = throttleManager;
            this.wmiSinkArray          = new ArrayList();
            ManagementOperationObserver managementOperationObserver = new ManagementOperationObserver();

            this.wmiSinkArray.Add(managementOperationObserver);
            PSWmiChildJob pSWmiChildJob = this;

            pSWmiChildJob.sinkCompleted              = pSWmiChildJob.sinkCompleted + count;
            managementOperationObserver.ObjectReady += new ObjectReadyEventHandler(this.NewObject);
            managementOperationObserver.Completed   += new CompletedEventHandler(this.JobDone);
            this.helper = new WmiAsyncCmdletHelper(this, cmds, computerName, managementOperationObserver, count);
            this.helper.WmiOperationState += new EventHandler <WmiJobStateEventArgs>(this.HandleWMIState);
            this.helper.ShutdownComplete  += new EventHandler <EventArgs>(this.JobDoneForWin32Shutdown);
            base.SetJobState(JobState.NotStarted);
            IThrottleOperation throttleOperation = this.helper;

            throttleOperation.OperationComplete += new EventHandler <OperationStateEventArgs>(this.HandleOperationComplete);
            throttleManager.ThrottleComplete    += new EventHandler <EventArgs>(this.HandleThrottleComplete);
            throttleManager.AddOperation(throttleOperation);
        }
Пример #3
0
 /// <summary>
 /// Internal Constructor
 /// </summary>
 /// <param name="childJob">Job associated with this operation</param>
 /// <param name="wmiObject">object associated with this operation</param>
 /// <param name="computerName"> computer on which the operation is invoked </param>
 /// <param name="results"> sink to get wmi objects </param>
 internal WmiAsyncCmdletHelper(PSWmiChildJob childJob, Cmdlet wmiObject, string computerName, ManagementOperationObserver results)
 {
     _wmiObject = wmiObject;
     _computerName = computerName;
     _results = results;
     this.State = WmiState.NotStarted;
     _job = childJob;
 }
Пример #4
0
 internal WmiAsyncCmdletHelper(PSWmiChildJob childJob, Cmdlet wmiObject, string computerName, ManagementOperationObserver results)
 {
     this.cmdCount     = 1;
     this.wmiObject    = wmiObject;
     this.computerName = computerName;
     this.results      = results;
     this.State        = WmiState.NotStarted;
     this.Job          = childJob;
 }
Пример #5
0
 private void JobDoneForWin32Shutdown(object sender, EventArgs arg)
 {
     lock (this.syncObject)
     {
         PSWmiChildJob pSWmiChildJob = this;
         pSWmiChildJob.sinkCompleted = pSWmiChildJob.sinkCompleted - 1;
     }
     if (this.sinkCompleted == 0)
     {
         this.helper.RaiseOperationCompleteEvent(null, OperationState.StopComplete);
         this.helper.State = WmiState.Completed;
         base.SetJobState(JobState.Completed);
     }
 }
Пример #6
0
        internal ManagementOperationObserver GetNewSink()
        {
            ManagementOperationObserver managementOperationObserver = new ManagementOperationObserver();

            this.wmiSinkArray.Add(managementOperationObserver);
            lock (this.syncObject)
            {
                PSWmiChildJob pSWmiChildJob = this;
                pSWmiChildJob.sinkCompleted = pSWmiChildJob.sinkCompleted + 1;
            }
            managementOperationObserver.ObjectReady += new ObjectReadyEventHandler(this.NewObject);
            managementOperationObserver.Completed   += new CompletedEventHandler(this.JobDone);
            return(managementOperationObserver);
        }
Пример #7
0
		internal PSWmiJob(Cmdlet cmds, string[] computerName, int throttleLimt, string command) : base(command, null)
		{
			this.throttleManager = new ThrottleManager();
			this.syncObject = new object();
			base.PSJobTypeName = "WmiJob";
			this.throttleManager.ThrottleLimit = throttleLimt;
			for (int i = 0; i < (int)computerName.Length; i++)
			{
				PSWmiChildJob pSWmiChildJob = new PSWmiChildJob(cmds, computerName[i], this.throttleManager);
				pSWmiChildJob.StateChanged += new EventHandler<JobStateEventArgs>(this.HandleChildJobStateChanged);
				pSWmiChildJob.JobUnblocked += new EventHandler(this.HandleJobUnblocked);
				base.ChildJobs.Add(pSWmiChildJob);
			}
			this.CommonInit(throttleLimt);
		}
Пример #8
0
 internal PSWmiJob(Cmdlet cmds, string[] computerName, int throttleLimit, string command, int count) : base(command, null)
 {
     this.throttleManager = new ThrottleManager();
     this.syncObject      = new object();
     base.PSJobTypeName   = "WmiJob";
     this.throttleManager.ThrottleLimit = throttleLimit;
     for (int i = 0; i < (int)computerName.Length; i++)
     {
         PSWmiChildJob pSWmiChildJob = new PSWmiChildJob(cmds, computerName[i], this.throttleManager, count);
         pSWmiChildJob.StateChanged += new EventHandler <JobStateEventArgs>(this.HandleChildJobStateChanged);
         pSWmiChildJob.JobUnblocked += new EventHandler(this.HandleJobUnblocked);
         base.ChildJobs.Add(pSWmiChildJob);
     }
     this.CommonInit(throttleLimit);
 }
Пример #9
0
 /// <summary>
 /// Internal Constructor.  This variant takes a count parameter that determines how many times 
 /// the WMI command is executed.
 /// </summary>
 /// <param name="childJob">Job associated with this operation</param>
 /// <param name="wmiObject">Object associated with this operation</param>
 /// <param name="computerName">Computer on which the operation is invoked</param>
 /// <param name="results">Sink to return wmi objects</param>
 /// <param name="count">Number of times the WMI command is executed</param>
 internal WmiAsyncCmdletHelper(PSWmiChildJob childJob, Cmdlet wmiObject, string computerName, ManagementOperationObserver results, int count)
     : this(childJob, wmiObject, computerName, results)
 {
     _cmdCount = count;
 }
Пример #10
0
        /// <summary>
        /// Internal constructor for initializing WMI jobs, where WMI command is executed a variable
        /// number of times.
        /// </summary>
        internal PSWmiJob(Cmdlet cmds, string[] computerName, int throttleLimit, string command, int count)
            : base(command, null)
        {
            PSJobTypeName = WMIJobType;
            _throttleManager.ThrottleLimit = throttleLimit;
            for (int i = 0; i < computerName.Length; ++i)
            {
                PSWmiChildJob childJob = new PSWmiChildJob(cmds, computerName[i], _throttleManager, count);
                childJob.StateChanged += new EventHandler<JobStateEventArgs>(HandleChildJobStateChanged);
                childJob.JobUnblocked += new EventHandler(HandleJobUnblocked);
                ChildJobs.Add(childJob);
            }

            CommonInit(throttleLimit);
        }
Пример #11
0
 internal WmiAsyncCmdletHelper(PSWmiChildJob childJob, Cmdlet wmiObject, string computerName, ManagementOperationObserver results, int count) : this(childJob, wmiObject, computerName, results)
 {
     this.cmdCount = count;
 }