public ComplexTraceMessage(string message, int severity, string source, TraceMessage innerMessage) { this.message = message; this.severity = severity; this.source = source; this.innerMessage = innerMessage; }
private void ForwardMessage(TraceMessage message) { if (message.IsToolMessage) traceListener.WriteToolOutput(message.Message); else traceListener.WriteTestOutput(message.Message); }
public void AddEvent(GameEvent gameEvent) { gameEvent.Turn = Turn + 1; Logger.Info(TraceMessage.Execute(this, $"Add event.Turn = {gameEvent.Turn} Turn = {Turn}")); GameEvents.Add(gameEvent); }
private void Node_NewTraceMessageAdded(object sender, TraceMessage e) { if (TraceLevelActive(e.TraceLevel) == false) { return; } TraceTerminal.AddMessage(e); }
public override async void OnEntry(MethodExecutionArgs args) { var traceId = GetTraceId(args.Instance); var methodId = Guid.NewGuid().ToString(); var parentMethodId = PeekAndPushParentMethodId(methodId, args.Instance); var windowsUser = System.Security.Principal.WindowsIdentity.GetCurrent(); var message = new TraceMessage { TraceId = traceId, MethodId = methodId, ParentMethodId = parentMethodId, TraceEvent = TraceEvent.OnMethodEntry, Timestamp = DateTime.Now, MethodName = _methodName, Arguments = args.GetMethodArguments(), MachineName = Environment.MachineName, WindowsUsername = windowsUser != null ? windowsUser.Name : "Unknown", }; message.Broadcast(); // ensure TraceId and ParentMethodId are passed across http boundaries foreach (var argument in args.Arguments.Where(a => a is HttpRequestMessage)) { var httpRequest = argument as HttpRequestMessage; if (httpRequest == null) { continue; } if (!httpRequest.Headers.Contains(TraceIdHeaderKey)) { httpRequest.Headers.Add(TraceIdHeaderKey, traceId); } if (!httpRequest.Headers.Contains(ParentMethodHeaderKey)) { httpRequest.Headers.Add(ParentMethodHeaderKey, methodId); } var httpBoundaryRequestMessage = new TraceHttpBoundaryRequestMessage { TraceId = traceId, MethodId = methodId, Uri = httpRequest.RequestUri.ToString(), HttpMethod = httpRequest.Method.ToString(), Timestamp = DateTime.Now, MachineName = Environment.MachineName, Headers = httpRequest.Headers.GetHeaders(), Content = (httpRequest.Content != null) ? await httpRequest.Content.ReadAsStringAsync() : "", }; httpBoundaryRequestMessage.Broadcast(); } args.MethodExecutionTag = new TraceAttributeContext(traceId, methodId, parentMethodId); }
/// <summary> /// General Method to validate Data. /// </summary> /// <param name="traceData">Data created using trace class.</param> /// <param name="traceMessageData">Data created using trace message class.</param> private static void ValidateTraceMessages(TraceMessage traceMessageData, TraceMessage traceData) { PrivateObject readTrace = new PrivateObject(traceData); PrivateObject readTraceMessage = new PrivateObject(traceMessageData); Assert.AreEqual(readTrace.GetField(Constants.MessageNode), readTraceMessage.GetField(Constants.MessageNode)); Assert.AreEqual(readTrace.GetField(Constants.ContextParameterNode), readTraceMessage.GetField(Constants.ContextParameterNode)); Assert.AreEqual(readTrace.GetField(Constants.DataParameterNode), readTraceMessage.GetField(Constants.DataParameterNode)); }
internal static void TraceDiagnostic(TraceMessage msg, List <TraceMessage> errors, ref int diagnosticCounter) { Console.WriteLine(msg.ToString()); diagnosticCounter++; if (msg.BuildError.Focus != Focus.Diagnostic) { errors.Add(msg); } }
public void WriteTraceMessage([FromBody] TraceMessage traceMessage) { if (traceMessage == null) { return; } LoggingHubContext.Instance.Pend(traceMessage); }
public void TraceDiagnosticTestMethod2() { List <TraceMessage> _listOfTraceMessage = new List <TraceMessage>(); int _diagnosticCounter = 0; TraceHelper.TraceDiagnostic(TraceMessage.DiagnosticTraceMessage("Test string"), _listOfTraceMessage, ref _diagnosticCounter); Assert.AreEqual <int>(0, _listOfTraceMessage.Count); Assert.AreEqual <int>(1, _diagnosticCounter); }
public void UploadTrace(TraceMessage traceMessage) { if (traceMessage == null) { return; } Clients.All.WriteTrace(traceMessage); // LoggingHubContext.Instance.Pend(traceMessage); }
public void TraceDiagnosticTestMethod3() { List <TraceMessage> _listOfTraceMessage = new List <TraceMessage>(); int _diagnosticCounter = 0; TraceHelper.TraceDiagnostic(TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdInvalidSyntax, "NodeIdInvalidSyntax"), _listOfTraceMessage, ref _diagnosticCounter); Assert.AreEqual <int>(1, _listOfTraceMessage.Count); Assert.AreEqual <int>(0, _diagnosticCounter); }
public void Pend(TraceMessage tm) { if (pendingQueue.Count >= maxBufferedTraces) { return; } pendingQueue.Enqueue(tm, tm.TimeUtc.Ticks); }
public void TraceDiagnosticTestMethod2() { List <TraceMessage> _listOfTraceMessage = new List <TraceMessage>(); int _diagnosticCounter = 0; TraceHelper.TraceDiagnostic(TraceMessage.BuildErrorTraceMessage(BuildError.NonCategorized, "Test string"), _listOfTraceMessage, ref _diagnosticCounter); Assert.AreEqual <int>(1, _listOfTraceMessage.Count); Assert.AreEqual <int>(1, _diagnosticCounter); }
private void DataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { TraceMessage msg = (TraceMessage)mDataGridView.Rows[e.RowIndex].DataBoundItem; if (msg == null) { return; } TraceMessageDialog.Show(this, msg); }
/// <summary> /// Serializes the already generated model using the interface <see cref="IModelFactory"/> and writes the XML document to a file. /// </summary> /// <param name="stylesheetName">Name of the stylesheet document.</param> public void ExportToXMLFile(string stylesheetName) { if (m_Model == null) { throw new ArgumentNullException("UAModelDesign", "The model must be generated first."); } XML.ModelDesign _model = m_Model.Export(); XML.XmlFile.WriteXmlFile <XML.ModelDesign>(_model, m_OutputPath, FileMode.Create, stylesheetName); m_traceEvent(TraceMessage.DiagnosticTraceMessage($"The ModelDesign XML has been saved to file {m_OutputPath} and decorated with the stylesheet {stylesheetName}")); }
/// <summary> /// Parses a node id string and returns a node id object. /// </summary> /// <remarks> /// Parses a NodeId String and returns a NodeId object /// </remarks> /// <param name="text">The NodeId value as a string.</param> /// <exception cref="ServiceResultException">Thrown under a variety of circumstances, each time with a specific message.</exception> public static NodeId Parse(string text) { try { if (String.IsNullOrEmpty(text)) { return(NodeId.Null); } ushort namespaceIndex = 0; // parse the namespace index if present. if (text.StartsWith("ns=", StringComparison.Ordinal)) { int index = text.IndexOf(';'); if (index == -1) { throw new ServiceResultException (TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdInvalidSyntax, String.Format("Cannot parse node id text: '{0}'", text)), "BuildError_BadNodeIdInvalid"); } namespaceIndex = Convert.ToUInt16(text.Substring(3, index - 3), CultureInfo.InvariantCulture); text = text.Substring(index + 1); } // parse numeric node identifier. if (text.StartsWith("i=", StringComparison.Ordinal)) { return(new NodeId(Convert.ToUInt32(text.Substring(2), CultureInfo.InvariantCulture), namespaceIndex)); } // parse string node identifier. if (text.StartsWith("s=", StringComparison.Ordinal)) { return(new NodeId(text.Substring(2), namespaceIndex)); } // parse guid node identifier. if (text.StartsWith("g=", StringComparison.Ordinal)) { return(new NodeId(new System.Guid(text.Substring(2)), namespaceIndex)); } // parse opaque node identifier. if (text.StartsWith("b=", StringComparison.Ordinal)) { return(new NodeId(Convert.FromBase64String(text.Substring(2)), namespaceIndex)); } // treat as a string identifier if a namespace was specified. if (namespaceIndex != 0) { return(new NodeId(text, namespaceIndex)); } // treat as URI identifier. return(new NodeId(text, 0)); } catch (Exception e) { throw new ServiceResultException (TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdInvalidSyntax, String.Format("Cannot parse node id text: '{0}'", text)), "BuildError_BadNodeIdInvalid", e); } }
private void Execute(IList <IRule <T> > rules) { foreach (var rule in OrderByExecutionOrder(rules)) { InvokeNestedRules(rule.Configuration.InvokeNestedRulesFirst, rule); if (rule.CanInvoke(_model, _ruleEngineConfiguration.IsRuleEngineTerminated())) { InvokeProactiveRules(rule); try { TraceMessage.Verbose(rule, TraceMessage.BeforeInvoke); rule.BeforeInvoke(); TraceMessage.Verbose(rule, TraceMessage.Invoke); var ruleResult = rule.Invoke(); TraceMessage.Verbose(rule, TraceMessage.AfterInvoke); rule.AfterInvoke(); AddToRuleResults(ruleResult, rule.GetType().Name); } catch (Exception exception) { rule.UnhandledException = exception; if (_rxRuleService.GetExceptionRules().ContainsKey(rule.GetType())) { InvokeExceptionRules(rule); } else { var globalExceptionHandler = _rules.GetGlobalExceptionHandler(); if (globalExceptionHandler is IRule <T> ) { globalExceptionHandler.UnhandledException = exception; Execute(new List <IRule <T> > { (IRule <T>)globalExceptionHandler }); } throw; } } rule.UpdateRuleEngineConfiguration(_ruleEngineConfiguration); InvokeReactiveRules(rule); } InvokeNestedRules(!rule.Configuration.InvokeNestedRulesFirst, rule); } }
private void ExecuteModuleForSelectSelectObject(IModule arg1, Func <GameSession, List <ICelestialObject> > getObjects) { if (_gameSession is null) { return; } var objects = getObjects(_gameSession); Logger.Info(TraceMessage.Execute(this, $"ExecuteModuleForSelectSelectObject {arg1.Name} execute. Objects cont is {objects.Count}.")); }
private void ForwardMessage(TraceMessage message) { if (message.IsToolMessage) { _traceListener.WriteToolOutput(message.Message); } else { _traceListener.WriteTestOutput(message.Message); } }
internal static void TraceDiagnostic(TraceMessage msg, List<TraceMessage> errors, ref int diagnosticCounter) { if (errors == null) throw new ArgumentNullException("errors"); Console.WriteLine(msg.ToString()); if (msg.BuildError.Focus == Focus.Diagnostic) { diagnosticCounter++; } else errors.Add(msg); }
public async Task SendMessages([Default("Sender1")] string sender, int count) { var runtime = _senders[sender]; for (int i = 0; i < count; i++) { var msg = new TraceMessage { Name = Guid.NewGuid().ToString() }; await runtime.Messaging.Send(msg); } }
/// <summary> /// Gets the supports events. /// </summary> /// <param name="eventNotifier">The event notifier. The EventNotifier represents the mandatory EventNotifier attribute of the Object NodeClass and identifies whether /// the object can be used to subscribe to events or to read and write the history of the events.</param> /// <param name="traceEvent">The trace event.</param> /// <returns><c>true</c> if supports events, <c>false</c> otherwise.</returns> internal static bool?GetSupportsEvents(this byte eventNotifier, Action <TraceMessage> traceEvent) { if (eventNotifier > EventNotifiers.SubscribeToEvents + EventNotifiers.HistoryRead + EventNotifiers.HistoryWrite) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.WrongEventNotifier, String.Format("EventNotifier value: {0}", eventNotifier))); } else if (eventNotifier > EventNotifiers.SubscribeToEvents) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.EventNotifierValueNotSupported, String.Format("EventNotifier value: {0}", eventNotifier))); } return(eventNotifier != 0 ? (eventNotifier & EventNotifiers.SubscribeToEvents) != 0 : new Nullable <bool>()); }
internal static QualifiedName Parse(this string qualifiedName, Action <TraceMessage> traceEvent) { try { return(QualifiedName.Parse(qualifiedName)); } catch (ServiceResultException _sre) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.QualifiedNameInvalidSyntax, String.Format("Error message: {0}", _sre.Message))); return(QualifiedName.Null); } }
public async Task SendMessages([Default("Sender1")] string sender, int count) { var runtime = _senders[sender]; for (var i = 0; i < count; i++) { var msg = new TraceMessage { Name = Guid.NewGuid().ToString() }; await runtime.Services.GetService <IMessageContext>().Send(msg); } }
void ReproduceTrace(TraceMessage tm) { if (loggingSource.Listeners.Count == 0) { return; } foreach (var listener in loggingSource.Listeners.OfType <TraceListener>()) { listener.TraceEvent(new TraceEventCache(), tm.Source, tm.EventType, tm.Id, FormatTraceMessage(tm)); } }
private void TraceDiagnostic(TraceMessage msg, List <TraceMessage> errors, ref int diagnosticCounter) { Console.WriteLine(msg.ToString()); if (msg.BuildError.Focus == Focus.Diagnostic) { diagnosticCounter++; } else { errors.Add(msg); } }
public static void Build() { var trace = new TraceMessage { Id = Guid.NewGuid().ToString(), EventDate = DateTime.UtcNow, TenantCode = "MaritzCX", ApplicationSource = "Pledge", Content = "Trace", TotalFail = 3, TotalPass = 3, FileName = "Trace file.txt", JobId = Guid.NewGuid().ToString() }; var incidence = new IncidenceMessage { Id = Guid.NewGuid().ToString(), EventDate = DateTime.Now, TenantCode = "MaritzCX", ApplicationSource = "Pledge", Content = $"Incidence", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow, MachineName = "incidence Machine" }; var invoice = new InvoiceMessage { Id = Guid.NewGuid().ToString(), EventDate = DateTime.UtcNow, TenantCode = "MaritzCX", ApplicationSource = "Pledge", Content = $"Invoice", RecordsProcessed = 343, Country = "Japan", Dealer = "Nissan" }; var traceContent = Build(trace, "cx_trace", "trace"); var incidenceContent = Build(incidence, "cx_incidence", "incidence"); var invoiceContent = Build(invoice, "cx_invoice", "invoice"); System.Console.WriteLine("Trace JSON"); System.Console.WriteLine(traceContent); System.Console.WriteLine(); System.Console.WriteLine("Incidence JSON"); System.Console.WriteLine(incidenceContent); System.Console.WriteLine(); System.Console.WriteLine("Invoice JSON"); System.Console.WriteLine(invoiceContent); }
private void DrawTacticalMapScreen() { Logger.Debug(TraceMessage.Execute(this, $"Turn { _gameSession.Turn}.{turnStep}")); Image image = new Bitmap(Width, Height); var graphics = Graphics.FromImage(image); graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.Bicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; var currentTurnBoardInfo = new BoardInfo { GraphicSurface = graphics, ScreenInfo = _screenParameters, TurnInfo = granularTurnInformation, TurnStep = turnStep }; DrawMapTools.DrawGrid(currentTurnBoardInfo); DrawMapTools.DrawSelectedObject(graphics, _mode, _gameSession, MouseMoveCelestialObject, _connectorsSelect, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawConnectors(graphics, _gameSession, _connectorsShow, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawConnectors(graphics, _gameSession, _connectorsSelect, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawDestinationPoint(graphics, _gameSession, destinationPoint, _screenParameters); DrawMapTools.DrawChangeMovementDestination(graphics, _gameSession, pointInSpace, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawSpaceShipMovement(graphics, _gameSession, granularTurnInformation, turnStep, HistoryMovementLog, _screenParameters); DrawMapTools.DrawMissiles(graphics, _gameSession, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawExplosions(graphics, _gameSession, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawSpaceShipTrajectories(graphics, _gameSession, granularTurnInformation, _screenParameters); DrawMapTools.DrawScreen(graphics, _gameSession, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawActiveModule(graphics, _activeModule, mouseCoordinates, _gameSession, granularTurnInformation, turnStep, _screenParameters); DrawMapTools.DrawMouseMoveObject(graphics, _gameSession, MouseMoveCelestialObject, granularTurnInformation, turnStep, _screenParameters); BackgroundImage = image; }
public void ServiceResultExceptionCreateWithMessageTestMethod() { TraceMessage traceMessage = TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdInvalidSyntax, "BuildError_BadNodeIdInvalid"); ServiceResultException _ex = new ServiceResultException(traceMessage, "test message"); Assert.IsNotNull(_ex); Assert.IsNotNull(_ex.TraceMessage); Assert.IsNull(_ex.InnerException); Assert.AreEqual <string>("test message", _ex.Message); Assert.IsNotNull(_ex.TraceMessage); Assert.AreEqual <Focus>(BuildError.NodeIdInvalidSyntax.Focus, _ex.TraceMessage.BuildError.Focus); Assert.AreEqual <TraceEventType>(TraceEventType.Information, _ex.TraceMessage.TraceLevel); }
public static void WriteLogEntry(TraceMessage m) { //Get the operating enterprise terminal try { _Client = new KronosServiceClient(); _Client.WriteLogEntry(m); _Client.Close(); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <ConfigurationFault> cfe) { _Client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { _Client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException(ce.Message); } }
internal static void AddLocalizedText(string keyField, string valueField, ref ModelDesign.LocalizedText description, Action <TraceMessage> traceEvent) { if (description != null) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NotSupportedFeature, "Parameter.Description does not supports array. The description is skipped.")); return; } description = new ModelDesign.LocalizedText() { Key = keyField, Value = valueField, }; }
void Report(TraceEventType eventType, string message) { var traceMessage = new TraceMessage() { Message = message, EventType = eventType, Source = "TraceHub", Origin = "TraceHub", TimeUtc = DateTime.UtcNow, }; Clients.All.WriteTrace(traceMessage); }
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { string clientId; string clientSecret; if (context.TryGetBasicCredentials(out clientId, out clientSecret) || context.TryGetFormCredentials(out clientId, out clientSecret)) { if (clientId == _clientID && clientSecret == _clientSecret) { context.Validated(); } var traceMessage = new TraceMessage { EventSource = ConfigurationManager.AppSettings["EventSource"].ToString(), TraceLevel = (int)TraceLevel.Info, MessageDateTime = DateTime.UtcNow, Topic = "ValidateClientAuthentication", Context = "ValidateClientAuthentication", MessageText = $"ClientID: {clientId}, ClientSecret: {clientSecret}", Title = "Context Validated." }; var dbContext = new ApplicationDbContext(); dbContext.TraceMessages.Add(traceMessage); dbContext.SaveChanges(); } else { var traceMessage = new TraceMessage { EventSource = ConfigurationManager.AppSettings["EventSource"].ToString(), TraceLevel = (int)TraceLevel.Error, MessageDateTime = DateTime.UtcNow, Topic = "ValidateClientAuthentication", Context = "ValidateClientAuthentication", MessageText = $"ClientID: {clientId}, ClientSecret: {clientSecret}", Title = "Context Rejected. Invalid client credentials." }; var dbContext = new ApplicationDbContext(); dbContext.TraceMessages.Add(traceMessage); dbContext.SaveChanges(); context.Rejected(); context.SetError("Access Denied", "Invalid Client Credentials"); } return(Task.FromResult(0)); }
protected abstract void OnTraceReceived(TraceMessage message);
public static void Show(IWin32Window pWindow, TraceMessage pTraceMessage) { TraceMessageDialog dialog = new TraceMessageDialog(pTraceMessage); dialog.ShowDialog(pWindow); }
protected TraceMessage CreateTraceMsg(string source, TraceEventType eventType, string message, string category, int id) { var msg = new TraceMessage() { Message = message, Level = MapEventTypeToString(eventType), Source = source, Category = category, ProcessId = _processId, ThreadId = Thread.CurrentThread.ManagedThreadId, Timestamp = DateTime.UtcNow, Machine = _machineName, EventId = id }; return msg; }
protected override void OnTraceReceived(TraceMessage message) { System.Diagnostics.Debug.WriteLine(message); }
public void Event(TraceEventType type, TraceMessage message) { }
public void Event(TraceEventType type, TraceMessage message) { Console.WriteLine("[{0} {1}]", type, message); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="message"></param> public Trace(TraceMessage message) { Contract.Requires<ArgumentNullException>(message != null); Message = message; }
public TraceMessageDialog(TraceMessage pTraceMessage) { InitializeComponent(); mTraceMessage = pTraceMessage; this.mIdTextBox.Text = pTraceMessage.Id.ToString(); this.mMessageTextBox.Text = pTraceMessage.Message; }
public void Event(TraceEventType type, TraceMessage message) { #if DEBUG Console.WriteLine("[{0} {1}]", type, message); #endif }