/// <summary>
        /// Operations that happen before the cmdlet is invoked.
        /// </summary>
        protected override void BeginProcessing()
        {
            string commandAlias = GetType().Name;

            if (cancellationSource == null)
            {
                cancellationSource = new CancellationTokenSource();
            }

            httpTracingInterceptor ??= new RecordingTracingInterceptor(PartnerSession.Instance.DebugMessages);

            ServiceClientTracing.IsEnabled = true;
            ServiceClientTracing.AddTracingInterceptor(httpTracingInterceptor);

            if (MyInvocation != null && MyInvocation.MyCommand != null)
            {
                commandAlias = MyInvocation.MyCommand.Name;
            }

            qosEvent = new PartnerQosEvent
            {
                CommandName      = commandAlias,
                IsSuccess        = true,
                ModuleVersion    = GetType().Assembly.GetName().Version.ToString(),
                ParameterSetName = ParameterSetName
            };

            if (MyInvocation != null && MyInvocation.BoundParameters != null && MyInvocation.BoundParameters.Keys != null)
            {
                qosEvent.Parameters = string.Join(" ", MyInvocation.BoundParameters.Keys.Select(
                                                      s => string.Format(CultureInfo.InvariantCulture, "-{0} ***", s)));
            }

            ProcessBreakingChangeAttributesAtRuntime(GetType(), MyInvocation, WriteWarning);
        }
예제 #2
0
        /// <summary>
        /// Operations that happen before the cmdlet is invoked.
        /// </summary>
        protected override void BeginProcessing()
        {
            string commandAlias = GetType().Name;

            if (cancellationSource == null)
            {
                cancellationSource = new CancellationTokenSource();
            }

            if (correlationId == default)
            {
                correlationId = Guid.NewGuid();
            }

            httpTracingInterceptor ??= new RecordingTracingInterceptor(PartnerSession.Instance.DebugMessages);

            ServiceClientTracing.IsEnabled = true;
            ServiceClientTracing.AddTracingInterceptor(httpTracingInterceptor);

            if (MyInvocation != null && MyInvocation.MyCommand != null)
            {
                commandAlias = MyInvocation.MyCommand.Name;
            }

            qosEvent = new PartnerQosEvent
            {
                CommandName      = commandAlias,
                IsSuccess        = true,
                ModuleVersion    = GetType().Assembly.GetName().Version.ToString(),
                ParameterSetName = ParameterSetName,
                SessionId        = sessionId.ToString(),
            };

            if (!string.IsNullOrEmpty(PartnerSession.Instance?.Context?.Account?.Identifier))
            {
                qosEvent.UserId = GenerateSha256HashString(PartnerSession.Instance.Context.Account.Identifier)?.Replace("-", string.Empty)?.ToLowerInvariant();
            }

            if (MyInvocation != null && MyInvocation.BoundParameters != null && MyInvocation.BoundParameters.Keys != null)
            {
                qosEvent.Parameters = string.Join(" ", MyInvocation.BoundParameters.Keys.Select(
                                                      s => string.Format(CultureInfo.InvariantCulture, "-{0} ***", s)));
            }

            ProcessBreakingChangeAttributesAtRuntime(GetType(), MyInvocation, WriteWarning);
        }