Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TraceInfo"/> class.
 /// </summary>
 /// <param name="dataConnection"><see cref="DataConnection"/> instance, generated this trace.</param>
 /// <param name="traceInfoStep">Trace execution step.</param>
 /// <param name="operation">Operation associated with trace event.</param>
 /// <param name="isAsync">Flag indicating whether operation was executed asynchronously.</param>
 public TraceInfo(DataConnection dataConnection, TraceInfoStep traceInfoStep, TraceOperation operation, bool isAsync)
 {
     DataConnection = dataConnection;
     TraceInfoStep  = traceInfoStep;
     Operation      = operation;
     IsAsync        = isAsync;
 }
 public override void AmqpLogOperationVerbose(object source, TraceOperation operation, object detail)
 {
     if (Logging.IsEnabled)
     {
         Logging.Info(source, "AmqpLogOperationVerbose:", $"{" source:"}{source}.{" operation:"}.{operation}.{" detail:"}.{detail}");
     }
     base.AmqpLogOperationVerbose(source, operation, detail);
 }
Ejemplo n.º 3
0
        public override void AmqpLogOperationInformational(object source, TraceOperation operation, object detail)
        {
            if (Logging.IsEnabled)
            {
                Logging.Info(source, "AmqpLogOperationInformational:", $"source:{source}.operation:{operation}.detail:{detail}");
            }

            base.AmqpLogOperationInformational(source, operation, detail);
        }
Ejemplo n.º 4
0
        private async Task ReceiveMessage(CancellationTokenSource cancellation)
        {
            using (TraceOperation.Start())
                using (this.logger.BeginRequestScope(this.Options.NextScopeId()))
                    using (var stream = new NetworkStream(this.socket, ownsSocket: false))
                    {
                        var receiveTimeout = this.Options.Configuration.KdcDefaults.ReceiveTimeout;

                        stream.ReadTimeout = (int)receiveTimeout.TotalMilliseconds / 2;

                        await this.ProcessMessage(stream, cancellation.Token, receiveTimeout).ConfigureAwait(false);
                    }
        }
        public void Start()
        {
            using (var trace = new TraceOperation("Update item references"))
            {
                if (ShouldProcessField == null)
                {
                    //Default if not supplied from outside.
                    ShouldProcessField = ExcludeStandardSitecoreFieldsExceptLayout;
                }

                if (_startItem != null && _roots != null)
                {
                    _masterDb = _startItem.Database;
                    FixReferences(_startItem, _roots, _deep);
                }
            }
        }
        public void Process(GetCanonicalUrlArgs args)
        {
            if (!string.IsNullOrWhiteSpace(args.CanonicalUrl))
            {
                return;
            }

            using (var trace = new TraceOperation("GetCanonicalUrlForAlias"))
            {
                if (!Sitecore.Configuration.Settings.AliasesActive)
                {
                    trace.Debug("Skipping because AliasesActive = false");
                    return;
                }
                if (!Sitecore.Context.Database.Aliases.Exists(args.RawUrl))
                {
                    trace.Debug(string.Format("Skipping because alias not found in database '{0}' for raw url '{1}'", Sitecore.Context.Database.Name, args.RawUrl));
                    return;
                }

                var targetId   = Sitecore.Context.Database.Aliases.GetTargetID(args.RawUrl);
                var targetItem = Sitecore.Context.Database.GetItem(targetId);
                if (targetItem == null)
                {
                    trace.Warning(string.Format("Unable to find the item '{0}' defined in the alias.", targetId));
                    return;
                }

                if (HttpContext.Current != null)
                {
                    const string href = "{0}://{1}{2}";
                    args.CanonicalUrl =
                        string.Format(href,
                                      HttpContext.Current.Request.Url.Scheme,
                                      HttpContext.Current.Request.Url.Host,
                                      LinkManager.GetItemUrl(targetItem));
                }
                else
                {
                    args.CanonicalUrl = LinkManager.GetItemUrl(targetItem);
                }
                trace.Info(string.Format("Setting canonical url to '{0}'", args.CanonicalUrl));
            }
        }
Ejemplo n.º 7
0
        protected static async Task <TResult> TraceActionAsync <TContext, TResult>(
            DataConnection dataConnection,
            TraceOperation traceOperation,
            Func <TContext, string?>?commandText,
            TContext context,
            Func <DataConnection, TContext, CancellationToken, Task <TResult> > action,
            CancellationToken cancellationToken)
        {
            var       now = DateTime.UtcNow;
            Stopwatch?sw  = null;
            var       sql = dataConnection.TraceSwitchConnection.TraceInfo ? commandText?.Invoke(context) : null;

            if (dataConnection.TraceSwitchConnection.TraceInfo)
            {
                sw = Stopwatch.StartNew();
                dataConnection.OnTraceConnection(new TraceInfo(dataConnection, TraceInfoStep.BeforeExecute, traceOperation, true)
                {
                    TraceLevel  = TraceLevel.Info,
                    CommandText = sql,
                    StartTime   = now,
                });
            }

            try
            {
                var actionResult = await action(dataConnection, context, cancellationToken).ConfigureAwait(Configuration.ContinueOnCapturedContext);

                if (dataConnection.TraceSwitchConnection.TraceInfo)
                {
                    dataConnection.OnTraceConnection(new TraceInfo(dataConnection, TraceInfoStep.AfterExecute, traceOperation, true)
                    {
                        TraceLevel    = TraceLevel.Info,
                        CommandText   = sql,
                        StartTime     = now,
                        ExecutionTime = sw !.Elapsed
                    });
                }
Ejemplo n.º 8
0
 public virtual void AmqpLogOperationVerbose(object source, TraceOperation operation, object detail)
 {
 }
Ejemplo n.º 9
0
 public virtual void AmqpLogOperationInformational(object source, TraceOperation operation, object detail)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 ///   Invoked when the service starts.
 /// </summary>
 /// <param name="args">
 ///   Arguments passed by the Service Control Manager Start command.
 /// </param>
 protected sealed override void OnStart(string[] args)
 {
     TraceOperation.Do("Service Start", StartCore);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///   Invoked when the service stops as a result of system shutdown (if
 ///   running as a Windows service).
 /// </summary>
 protected sealed override void OnShutdown()
 {
     TraceOperation.Do("Service Stop (Shutdown)", StopCore);
 }
Ejemplo n.º 12
0
 /// <summary>
 ///   Invoked when the service stops as a result of a Service Control
 ///   Manager Stop command (if running as a Windows service) or when the
 ///   application exits (if running as a console application).
 /// </summary>
 protected sealed override void OnStop()
 {
     TraceOperation.Do("Service Stop", StopCore);
 }
Ejemplo n.º 13
0
 public virtual void AmqpLogOperationVerbose(object source, TraceOperation operation, object detail)
 {
 }
Ejemplo n.º 14
0
 public virtual void AmqpLogOperationInformational(object source, TraceOperation operation, object detail)
 {
 }