Exemplo n.º 1
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            InitializeProfile();
            PromptForDataCollectionProfileIfNotExists();
            InitializeQosEvent();
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName));
            }

            if (Profile != null && Profile.Context != null && Profile.Context.Account != null && Profile.Context.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", Profile.Context.Account.Id));
            }

            _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
            _adalListener           = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            base.BeginProcessing();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            PromptForDataCollectionProfileIfNotExists();
            InitializeQosEvent();
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format("{0} begin processing without ParameterSet.", this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format("{0} begin processing with ParameterSet '{1}'.", this.GetType().Name, ParameterSetName));
            }

            if (DefaultContext != null && DefaultContext.Account != null && DefaultContext.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", DefaultContext.Account.Id));
            }

            _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
            _adalListener           = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue(
                ModuleName, string.Format("v{0}", ModuleVersion));

            AzureSession.ClientFactory.UserAgents.Add(userAgentValue);
            AzureSession.ClientFactory.AddHandler(new CmdletInfoHandler(this.CommandRuntime.ToString(), this.ParameterSetName));
            base.BeginProcessing();
        }
Exemplo n.º 3
0
 protected virtual void TearDownDebuggingTraces()
 {
     RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
     DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
     _azureEventListener?.Dispose();
     _azureEventListener = null;
     FlushDebugMessages();
 }
Exemplo n.º 4
0
 protected virtual void SetupDebuggingTraces()
 {
     _httpTracingInterceptor = _httpTracingInterceptor ?? new
                               RecordingTracingInterceptor(DebugMessages);
     _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
     RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
     DebugStreamTraceListener.AddAdalTracing(_adalListener);
 }
Exemplo n.º 5
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile.
        /// </summary>
        protected override void EndProcessing()
        {
            string message = string.Format(Resources.EndProcessingLog, this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            FlushMessagesFromTracingInterceptor();

            base.EndProcessing();
        }
Exemplo n.º 6
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile.
        /// </summary>
        protected override void EndProcessing()
        {
            LogQosEvent();
            string message = string.Format(Resources.EndProcessingLog, this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
            FlushDebugMessages();

            base.EndProcessing();
        }
Exemplo n.º 7
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile and removes user agent.
        /// </summary>
        protected override void EndProcessing()
        {
            LogQosEvent();
            string message = string.Format("{0} end processing.", this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
            FlushDebugMessages();

            AzureSession.ClientFactory.UserAgents.RemoveWhere(u => u.Product.Name == ModuleName);
            AzureSession.ClientFactory.RemoveHandler(typeof(CmdletInfoHandler));
            base.EndProcessing();
        }
Exemplo n.º 8
0
        protected virtual void SetupDebuggingTraces()
        {
            _httpTracingInterceptor = _httpTracingInterceptor ?? new
                                      RecordingTracingInterceptor(DebugMessages, _matchers);
            _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            if (AzureSession.Instance.TryGetComponent(nameof(IAzureEventListenerFactory), out IAzureEventListenerFactory factory))
            {
                _azureEventListener = factory.GetAzureEventListener(
                    (message) =>
                {
                    DebugMessages.Enqueue(message);
                });
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Cmdlet begin process
        /// </summary>
        protected override void BeginProcessing()
        {
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName));
            }

            if (CurrentContext != null && CurrentContext.Account != null && CurrentContext.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", CurrentContext.Account.Id));
            }

            RecordingTracingInterceptor.AddToContext(httpTracingInterceptor);

            base.BeginProcessing();
        }