Example #1
0
        private void WriteMessageCallback(uint channel, string message)
        {
            this.ExceptionSafeWrapper(() => {
                CimChildJobBase <T> .MessageChannel messageChannel = (CimChildJobBase <T> .MessageChannel)channel;
                switch (messageChannel)
                {
                case (CimChildJobBase <T> .MessageChannel)CimChildJobBase <T> .MessageChannel.Warning:
                    {
                        this.WriteWarning(message);
                        return;
                    }

                case (CimChildJobBase <T> .MessageChannel)CimChildJobBase <T> .MessageChannel.Verbose:
                    {
                        this.WriteVerbose(message);
                        return;
                    }

                case (CimChildJobBase <T> .MessageChannel)CimChildJobBase <T> .MessageChannel.Debug:
                    {
                        this.WriteDebug(message);
                        return;
                    }

                default:
                    {
                        return;
                    }
                }
            }
                                      );
        }
Example #2
0
        internal override void WriteObject(object outputObject)
        {
            CimInstance baseObject;
            PSObject    pSObject = null;

            if (outputObject as PSObject == null)
            {
                baseObject = outputObject as CimInstance;
            }
            else
            {
                pSObject   = PSObject.AsPSObject(outputObject);
                baseObject = pSObject.BaseObject as CimInstance;
            }
            if (baseObject != null)
            {
                CimCmdletAdapter.AssociateSessionOfOriginWithInstance(baseObject, this.JobContext.Session);
                CimCustomOptionsDictionary.AssociateCimInstanceWithCustomOptions(baseObject, this.GetJobSpecificCustomOptions());
                if (this.JobContext.ShowComputerName)
                {
                    if (pSObject == null)
                    {
                        pSObject = PSObject.AsPSObject(outputObject);
                    }
                    CimChildJobBase <T> .AddShowComputerNameMarker(pSObject);
                }
            }
            base.WriteObject(outputObject);
        }
Example #3
0
        private CimResponseType PromptUserCallback(string message, CimPromptType promptType)
        {
            Action    action  = null;
            Action    action1 = null;
            string    str     = this.JobContext.PrependComputerNameToMessage(message);
            Exception obj     = null;
            int       num     = 0;

            this._userWasPromptedForContinuationOfProcessing = true;
            CimPromptType cimPromptType = promptType;

            switch (cimPromptType)
            {
            case CimPromptType.None:
            {
                CimChildJobBase <T> cimChildJobBase = this;
                if (action1 == null)
                {
                    action1 = () => num = (int)this.ShouldProcess(message, null, null);
                }
                cimChildJobBase.ExceptionSafeWrapper(action1);
                break;
            }

            case CimPromptType.Critical:
            {
                CimChildJobBase <T> cimChildJobBase1 = this;
                if (action == null)
                {
                    action = () => {
                        if (!this.ShouldContinue(str, (string)null, out obj))
                        {
                            num = (int)CimResponseType.None;
                            return;
                        }
                        else
                        {
                            num = (int)CimResponseType.Yes;
                            return;
                        }
                    }
                    ;
                }
                cimChildJobBase1.ExceptionSafeWrapper(action);
                break;
            }
            }
            if (obj != null)
            {
                num = 2;
            }
            if (num == 1 || num == 3)
            {
                this._userRespondedYesToAtLeastOneShouldProcess = true;
            }
            return((CimResponseType)num);
        }
Example #4
0
 internal override void WriteObject(object outputObject)
 {
     if (CimChildJobBase <CimInstance> .IsShowComputerNameMarkerPresent(this.associatedObject))
     {
         PSObject pSObject = PSObject.AsPSObject(outputObject);
         CimChildJobBase <CimInstance> .AddShowComputerNameMarker(pSObject);
     }
     base.WriteObject(outputObject);
 }
Example #5
0
 public virtual void OnError(Exception exception)
 {
     this.ExceptionSafeWrapper(() => {
         if (!CimChildJobBase <T> .IsWsManQuotaReached(exception))
         {
             CimJobException cimJobException = CimJobException.CreateFromAnyException(this.GetDescription(), this.JobContext, exception);
             this.ReportJobFailure(cimJobException);
             return;
         }
         else
         {
             this.SleepAndRetry();
             return;
         }
     }
                               );
 }
Example #6
0
        private void SleepAndRetry()
        {
            int num  = this._random.Next(0, this._sleepAndRetryDelayRangeMs);
            int num1 = 100 + this._sleepAndRetryExtraDelayMs + num;

            this._sleepAndRetryExtraDelayMs = this._sleepAndRetryDelayRangeMs - num;
            if (this._sleepAndRetryDelayRangeMs < 0x3a98)
            {
                CimChildJobBase <T> cimChildJobBase = this;
                cimChildJobBase._sleepAndRetryDelayRangeMs = cimChildJobBase._sleepAndRetryDelayRangeMs * 2;
            }
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;
            string      cimJobSleepAndRetryVerboseMessage = CmdletizationResources.CimJob_SleepAndRetryVerboseMessage;

            object[] invocationName = new object[3];
            invocationName[0] = this.JobContext.CmdletInvocationInfo.InvocationName;
            object[] objArray     = invocationName;
            int      num2         = 1;
            string   computerName = this.JobContext.Session.ComputerName;
            object   obj          = computerName;

            if (computerName == null)
            {
                obj = "localhost";
            }
            objArray[num2]    = obj;
            invocationName[2] = (double)num1 / 1000;
            string str = string.Format(invariantCulture, cimJobSleepAndRetryVerboseMessage, invocationName);

            this.WriteVerbose(str);
            lock (this._jobStateLock)
            {
                if (!this._jobWasStopped)
                {
                    object obj1 = null;
                    int    num3 = num1;
                    int    num4 = -1;
                    this._sleepAndRetryTimer = new Timer(new TimerCallback(this.SleepAndRetry_OnWakeup), obj1, num3, num4);
                }
                else
                {
                    this.SetCompletedJobState(JobState.Stopped, null);
                }
            }
        }
Example #7
0
        internal CimChildJobBase(CimJobContext jobContext) : base(Job.GetCommandTextFromInvocationInfo(jobContext.CmdletInvocationInfo), " ")
        {
            this._myJobNumber = Interlocked.Increment(ref CimChildJobBase <T> ._globalJobNumberCounter);
            this._sleepAndRetryDelayRangeMs = 0x3e8;
            this._cancellationTokenSource   = new CancellationTokenSource();
            this._jobStateLock = new object();
            this._activityIdToLastProgressRecord = new ConcurrentDictionary <int, ProgressRecord>();
            this._jobContext           = jobContext;
            base.PSJobTypeName         = "CimJob";
            base.Name                  = string.Concat(base.GetType().Name, this._myJobNumber.ToString(CultureInfo.InvariantCulture));
            base.UsesResultsCollection = true;
            lock (CimChildJobBase <T> .GlobalRandom)
            {
                this._random = new Random(CimChildJobBase <T> .GlobalRandom.Next());
            }
            CimChildJobBase <T> cimChildJobBase = this;

            this._jobSpecificCustomOptions = new Lazy <CimCustomOptionsDictionary>(new Func <CimCustomOptionsDictionary>(cimChildJobBase.CalculateJobSpecificCustomOptions));
        }