Example #1
0
        /// <summary>
        /// Get a single TODO item by ID.
        /// </summary>
        /// <param name="id">The ID of the item</param>
        /// <returns>A TODO item.</returns>
        public TodoItemDto Get(Guid id)
        {
            var todo = repository.FindBy(t => t.Id == id && t.Owner == User.Identity.Name).FirstOrDefault();

            if (todo == null)
            {
                tracer.TraceEvent(TraceEventType.Error, 1000, "Item not found");
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(todo.Map());
        }
        public LogicalOperationScope(ITraceSource source, object operationId, int startId, int stopId, string startMessage, string stopMessage)
        {
            _source      = source;
            _startId     = startId;
            _stopId      = stopId;
            _operationId = operationId;

            _startMessage = startMessage ?? Resource.LogicalOperationScope_Start;
            _stopMessage  = stopMessage ?? Resource.LogicalOperationScope_Stop;

            // Start Logical Operation
            if (_operationId == null)
            {
                Trace.CorrelationManager.StartLogicalOperation();
            }
            else
            {
                Trace.CorrelationManager.StartLogicalOperation(_operationId);
            }

            // Log Start Message
            if (_source != null)
            {
                _source.TraceEvent(TraceEventType.Start, _startId, _startMessage);
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            var originalPrincipal = Thread.CurrentPrincipal;

            try
            {
                Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("User1"), new string[0]);
                Trace.CorrelationManager.StartLogicalOperation("Started=true");
                Trace.CorrelationManager.StartLogicalOperation("UserId=1");
                Trace.CorrelationManager.ActivityId = Guid.NewGuid();
                // Trace Data
                var data = new object[] { "TraceData", TimeZoneInfo.Local.BaseUtcOffset };
                trace.TraceData(TraceEventType.Verbose, 6001, data);
                // Trace Transfer
                var newActivityId = Guid.NewGuid();
                trace.TraceTransfer(0, "TraceTransfer", newActivityId);
                Trace.CorrelationManager.ActivityId = newActivityId;
                // Trace Event
                Thread.CurrentThread.Name = "MyThread";
                trace.TraceEvent(TraceEventType.Information, 7001, "TraceEvent");
            }
            finally
            {
                Thread.CurrentPrincipal = originalPrincipal;
            }
            Console.ReadLine();
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Log Stop Message
                if (_source != null)
                {
                    _source.TraceEvent(TraceEventType.Stop, _stopId, _stopMessage);
                }

                // Stop Logical Operation
                Trace.CorrelationManager.StopLogicalOperation();
            }
        }
        private void StartScope()
        {
            // Log Transfer In (on original activity)
            Guid newActivity = Guid.NewGuid();

            if (_source != null)
            {
                _source.TraceTransfer(_transferInId, _transferInMessage, newActivity);
            }

            // Change to scope ActivityId
            Trace.CorrelationManager.ActivityId = newActivity;

            // Log Start Message (first message on scope activity)
            if (_source != null)
            {
                if (_activityName == null)
                {
                    _source.TraceEvent(TraceEventType.Start, _startId, _startMessage);
                }
                else
                {
                    //var xml = string.Format(TraceRecordXmlTemplate,
                    //    SecurityElement.Escape(_startMessage),
                    //    SecurityElement.Escape(AppDomain.CurrentDomain.FriendlyName),
                    //    SecurityElement.Escape(_activityName)
                    //);
                    var xml = TraceRecordXmlTemplate;
                    var doc = new XmlDocument();
                    doc.LoadXml(xml);
                    doc.ChildNodes[0].ChildNodes[1].InnerText = _startMessage;
                    doc.ChildNodes[0].ChildNodes[2].InnerText = AppDomain.CurrentDomain.FriendlyName;
                    doc.ChildNodes[0].ChildNodes[3].ChildNodes[0].InnerText = _activityName;
                    _source.TraceData(TraceEventType.Start, _startId, doc.CreateNavigator());
                }
            }
        }
        // Critical

        /// <summary>
        /// Writes a Critical event to the underlying trace source using the specified event identifier, and message.
        /// </summary>
        /// <param name="id">A strongly typed identifier for the event.</param>
        /// <param name="message">The trace message to write.</param>
        public void Critical(TEventId id, string message)
        {
            _traceSource.TraceEvent(TraceEventType.Critical, id.ToInt32(CultureInfo.InvariantCulture), message);
        }
Example #7
0
 public void Run()
 {
     trace.TraceEvent(TraceEventType.Information, 1001, "AbstractionDependency example start.");
     trace.TraceEvent(TraceEventType.Information, 8001, "AbstractionDependency example end.");
 }