private void HandleProcessAgentResults(ProcessAgentResults m) { var x = new AgentFinished(testId, agentId, FinishedRequests.ToList()); Console.WriteLine($"Result is {JsonConvert.SerializeObject(x)}"); publishMediator.Tell(new Publish(Constants.Topics.AGENT_TOPIC, new AgentFinished(testId, agentId, FinishedRequests.ToList()))); }
private void HandleAgentFinished(AgentFinished x) { if (!AgentStatistics.ContainsKey(x.TestId)) { AgentStatistics.Add(x.TestId, new List <AgentResultDto>()); } double rate = 0.0; if (!RequestDetails.ContainsKey(string.Concat(x.TestId, x.AgentId))) { RequestDetails.Add(string.Concat(x.TestId, x.AgentId), new List <RequestResultDto>()); } if (x.Requests.Any()) { rate = (double)x.Requests.Count(m => m.ResultCode == System.Net.HttpStatusCode.OK) / (double)x.Requests.Count(); foreach (var item in x.Requests) { // in real life: write to DB RequestDetails[string.Concat(x.TestId, x.AgentId)].Add(new RequestResultDto(item.ResultCode, item.RequestDuration, item.Requestid)); } } // in real life: write to DB AgentStatistics[x.TestId].Add(new AgentResultDto(rate, x.AgentId)); }