/// <summary> /// Called when a message is received. /// </summary> /// <param name="channel">The channel.</param> /// <param name="message">The message.</param> private void OnMessage(RedisChannel channel, RedisValue message) { byte[] messageBytes = ChannelHelper.Decompress(message); var response = ChannelHelper.Deserialize <ChannelMessage <DiagnosticResponse> >(messageBytes); var flushCachesResponse = response.Message as FlushCachesResponse; if (flushCachesResponse != null) { ///// // Message response received. ///// } }
/// <summary> /// Called when a message is received. /// </summary> /// <param name="channel">The channel.</param> /// <param name="message">The message.</param> private void OnMessage(RedisChannel channel, RedisValue message) { byte[] messageBytes = ChannelHelper.Decompress(message); var response = ChannelHelper.Deserialize <ChannelMessage <DiagnosticResponse> >(messageBytes); var execResponse = response.Message as RemoteExecResponse; if (execResponse != null) { _dispatcher.Invoke(() => { foreach (var data in execResponse.Data) { var execData = new RemoteExecData(data.Item1, data.Item2); var msg = new RemoteExecMessage(channel, response.MachineName, response.ProcessName, response.ProcessId, response.AppDomainName, response.AppDomainId, response.Date, messageBytes.Length, response.HostTenantId, execData); _messages.Add(msg); } }); } }
/// <summary> /// Called when a message is received. /// </summary> /// <param name="channel">The channel.</param> /// <param name="message">The message.</param> private void OnMessage(RedisChannel channel, RedisValue message) { byte[] messageBytes = ChannelHelper.Decompress(message); var response = ChannelHelper.Deserialize <ChannelMessage <DiagnosticResponse> >(messageBytes); var threadResponse = response.Message as ThreadResponse; if (threadResponse != null) { Dictionary <ThreadKey, ThreadMessage> existingMessages = _messages.ToDictionary(m => new ThreadKey(m.Message.SourceProcessId, m.Message.SourceAppDomainId, m.Message.Id)); bool showUnmanagedThreads = Settings.Default.ShowUnmanagedThreads; _dispatcher.Invoke(() => { foreach (ThreadInfo thread in threadResponse.Threads) { if (!showUnmanagedThreads && thread.OsThreadId <= 0) { continue; } ThreadMessage existingMessage; if (existingMessages.TryGetValue(new ThreadKey(response.ProcessId, response.AppDomainId, thread.Id), out existingMessage)) { existingMessage.Message.BackGround = MessageDefault; existingMessage.Message.CallStack = thread.CallStack; existingMessage.Message.CpuUsage = thread.CpuUsage; existingMessage.Message.OsThreadId = thread.OsThreadId; } else { var threadData = ThreadData.FromThreadInfo(thread); threadData.SourceProcessId = response.ProcessId; threadData.SourceAppDomainId = response.AppDomainId; if (string.IsNullOrEmpty(threadData.AppDomain)) { threadData.AppDomain = response.AppDomainName; } var threadMessage = new ThreadMessage(channel, response.MachineName, response.ProcessName, response.ProcessId, response.AppDomainName, response.AppDomainId, response.Date, messageBytes.Length, response.HostTenantId, threadData); if (existingMessages.Any(m => m.Key.ProcessId == response.ProcessId && m.Key.AppDomainId == response.AppDomainId)) { threadMessage.Message.BackGround = MessageAdded; } _messages.Add(threadMessage); } } Dictionary <ThreadKey, ThreadInfo> newMessages = threadResponse.Threads.ToDictionary(ti => new ThreadKey(response.ProcessId, response.AppDomainId, ti.Id)); foreach (var existingMessage in existingMessages) { if (existingMessage.Key.ProcessId == response.ProcessId && existingMessage.Key.AppDomainId == response.AppDomainId && !newMessages.ContainsKey(existingMessage.Key)) { if (existingMessage.Value.Message.BackGround == MessageDefault) { existingMessage.Value.Message.BackGround = MessageRemoved; } else { _messages.Remove(existingMessage.Value); } } } }); } }
/// <summary> /// Called when [message]. /// </summary> /// <param name="channel">The channel.</param> /// <param name="message">The message.</param> private void OnMessage(RedisChannel channel, RedisValue message) { byte[] messageBytes = ChannelHelper.Decompress(message); var response = ChannelHelper.Deserialize <ChannelMessage <DiagnosticResponse> >(messageBytes); var workflowResponse = response.Message as WorkflowResponse; if (workflowResponse != null) { Workflow wf; workflowResponse.Status = workflowResponse.Status.Replace("WorkflowRun", ""); if (!string.IsNullOrEmpty(workflowResponse.TaskId) && _taskMap.TryGetValue(workflowResponse.TaskId, out wf)) { if (wf.Id != workflowResponse.Id) { _idMap.Remove(wf.Id); } wf.Id = workflowResponse.Id; wf.InstanceName = workflowResponse.WorkflowRunName; wf.WorkflowName = workflowResponse.WorkflowName; wf.Date = workflowResponse.Date; wf.TriggeredBy = workflowResponse.TriggeredBy; wf.Status = workflowResponse.Status; wf.TaskId = workflowResponse.TaskId; wf.Server = workflowResponse.Server; wf.Process = workflowResponse.Process; if (workflowResponse.Status == "Completed") { _taskMap.Remove(workflowResponse.TaskId); wf.CompletedAt = DateTime.UtcNow; if (!Settings.Default.WorkflowShowCompletedRuns) { _dispatcher.Invoke(() => _messages.Remove(wf)); } } } else { if (_idMap.TryGetValue(workflowResponse.Id, out wf)) { wf.Id = workflowResponse.Id; wf.InstanceName = workflowResponse.WorkflowRunName; wf.WorkflowName = workflowResponse.WorkflowName; wf.Date = workflowResponse.Date; wf.TriggeredBy = workflowResponse.TriggeredBy; wf.Status = workflowResponse.Status; wf.TaskId = workflowResponse.TaskId; wf.Server = workflowResponse.Server; wf.Process = workflowResponse.Process; } else { wf = new Workflow { Id = workflowResponse.Id, InstanceName = workflowResponse.WorkflowRunName, WorkflowName = workflowResponse.WorkflowName, Date = workflowResponse.Date, TriggeredBy = workflowResponse.TriggeredBy, Status = workflowResponse.Status, TaskId = workflowResponse.TaskId, Server = workflowResponse.Server, Process = workflowResponse.Process }; if (!Settings.Default.WorkflowShowCompletedRuns && wf.Status == "Completed") { _dispatcher.Invoke(() => _messages.Remove(wf)); } else { _dispatcher.Invoke(() => _messages.Insert(0, wf)); if (!string.IsNullOrEmpty(wf.TaskId)) { _taskMap[wf.TaskId] = wf; } _idMap[wf.Id] = wf; } } } } }