Exemplo n.º 1
0
        protected virtual void OnQueryCompleted(object sender, BrokerCompletedEventArgs e)
        {
            this.InProgress = false;
            var endTime = Environment.TickCount;

            this.ExecutionTime = new TimeSpan(0, 0, 0, 0, endTime - this.startTime);

            if (null != this.Completed)
            {
                this.Completed(sender, e);
            }
        }
Exemplo n.º 2
0
 void queryWatcher_Stopped(object sender, StoppedEventArgs e)
 {
     var args = new BrokerCompletedEventArgs(e.Status == ManagementStatus.NoError, null, e.Status);
     this.OnQueryCompleted(this, args);
 }
Exemplo n.º 3
0
 void queryObserver_Completed(object sender, CompletedEventArgs e)
 {
     var args = new BrokerCompletedEventArgs(e.Status == ManagementStatus.NoError, e.StatusObject, e.Status);
     this.OnQueryCompleted(this, args);
 }
Exemplo n.º 4
0
        protected virtual void OnQueryCompleted(object sender, BrokerCompletedEventArgs e)
        {
            this.InProgress = false;
            var endTime = Environment.TickCount;

            this.ExecutionTime = new TimeSpan(0, 0, 0, 0, endTime - this.startTime);

            if (null != this.Completed)
                this.Completed(sender, e);
        }
Exemplo n.º 5
0
        void queryWatcher_Stopped(object sender, StoppedEventArgs e)
        {
            var args = new BrokerCompletedEventArgs(e.Status == ManagementStatus.NoError, null, e.Status);

            this.OnQueryCompleted(this, args);
        }
Exemplo n.º 6
0
        void queryObserver_Completed(object sender, CompletedEventArgs e)
        {
            var args = new BrokerCompletedEventArgs(e.Status == ManagementStatus.NoError, e.StatusObject, e.Status);

            this.OnQueryCompleted(this, args);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles a Completed event when a WMI query has completed.
        /// </summary>
        /// <param name="sender">The System.Management.ManagementQueryBroker that owns the completed query.</param>
        /// <param name="e">The BrokerCompletedEventArgs for this event.</param>
        private void OnQueryCompleted(object sender, BrokerCompletedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new BrokerCompletedEventHandler(this.OnQueryCompleted), sender, e);
                return;
            }

            var broker = (ManagementQueryBroker)sender;

            this.ToggleQueryUI(false);

            if (e.Success)
            {
                this.Log(LogLevel.Success, String.Format("Query completed in {0} with {1} results.", broker.ExecutionTime, broker.ResultCount));
            }

            else
            {
                var code = (UInt32)e.Status;
                if(Enum.IsDefined(typeof(ManagementError), code))
                {
                    var constant = ((ManagementError)code).ToString();
                    this.Log(LogLevel.Critical, String.Format("Query failed after {0} with {1:G} (0x{1:X}) {2}", broker.ExecutionTime, code, constant));

                    var description = ErrorCodes.ResourceManager.GetString(constant);
                    if (!String.IsNullOrEmpty(description))
                        this.Log(LogLevel.Information, description);
                }

                else
                {
                    this.Log(LogLevel.Critical, String.Format("Query failed after {0} with {1:G} (0x{1:X}).", broker.ExecutionTime, code));
                }
            }
        }