public AddOrUpdateLoadTestsValidationResult AddOrUpdateLoadTests(IList <LoadTest> loadTestsAddedOrUpdated) { List <LoadTest> toBeInserted = new List <LoadTest>(); List <LoadTest> toBeUpdated = new List <LoadTest>(); List <LoadTest> failed = new List <LoadTest>(); StringBuilder resultSummaryBuilder = new StringBuilder(); string NL = Environment.NewLine; foreach (LoadTest loadtest in loadTestsAddedOrUpdated) { LoadTest existing = LoadTests.FirstOrDefault(l => l.Id == loadtest.Id); if (existing != null) { LoadTestValidationSummary validationSummary = OkToAddOrModify(loadtest); if (validationSummary.OkToAddOrModify) { existing.Update (loadtest.Parameters, loadtest.AgentId, loadtest.CustomerId, loadtest.EngineerId, loadtest.LoadTestTypeId, loadtest.ProjectId, loadtest.ScenarioId); toBeUpdated.Add(existing); resultSummaryBuilder.Append(string.Format("Load test ID {0} (update) successfully validated.{1}", existing.Id, NL)); } else { failed.Add(loadtest); resultSummaryBuilder.Append(string.Format("Loaf test ID {0} (update) validation failed: {1}{2}.", existing.Id, validationSummary.ReasonForValidationFailure, NL)); } } else { LoadTestValidationSummary validationSummary = OkToAddOrModify(loadtest); if (validationSummary.OkToAddOrModify) { LoadTests.Add(loadtest); toBeInserted.Add(loadtest); resultSummaryBuilder.Append(string.Format("Load test ID {0} (insertion) successfully validated.{1}", loadtest.Id, NL)); } else { failed.Add(loadtest); resultSummaryBuilder.Append(string.Format("Load test ID {0} (insertion) validation failed: {1}{2}.", loadtest.Id, validationSummary.ReasonForValidationFailure, NL)); } } } AddOrUpdateLoadTestsValidationResult validationResult = new AddOrUpdateLoadTestsValidationResult(toBeInserted, toBeUpdated, failed, resultSummaryBuilder.ToString()); TimetableChangedEventArgs args = new TimetableChangedEventArgs(validationResult); DomainEventMediator.RaiseEvent(args); return(new AddOrUpdateLoadTestsValidationResult(toBeInserted, toBeUpdated, failed, resultSummaryBuilder.ToString())); }
public AddOrUpdateLoadtestsValidationResult AddOrUpdateLoadtests(IList<Loadtest> loadtestsAddedOrUpdated) { List<Loadtest> toBeInserted = new List<Loadtest>(); List<Loadtest> toBeUpdated = new List<Loadtest>(); List<Loadtest> failed = new List<Loadtest>(); StringBuilder resultSummaryBuilder = new StringBuilder(); string NL = Environment.NewLine; foreach (Loadtest loadtest in loadtestsAddedOrUpdated) { Loadtest existing = (from l in Loadtests where l.Id == loadtest.Id select l).FirstOrDefault(); if (existing != null) //update { LoadtestValidationSummary validationSummary = OkToAddOrModify(loadtest); if (validationSummary.OkToAddOrModify) { existing.Update (loadtest.Parameters, loadtest.AgentId, loadtest.CustomerId, loadtest.EngineerId, loadtest.LoadtestTypeId, loadtest.ProjectId, loadtest.ScenarioId); toBeUpdated.Add(existing); resultSummaryBuilder.Append(string.Format("Load test ID {0} (update) successfully validated.{1}", existing.Id, NL)); } else { failed.Add(loadtest); resultSummaryBuilder.Append(string.Format("Load test ID {0} (update) validation failed: {1}{2}.", existing.Id, validationSummary.ReasonForValidationFailure, NL)); } } else //insertion { LoadtestValidationSummary validationSummary = OkToAddOrModify(loadtest); if (validationSummary.OkToAddOrModify) { Loadtests.Add(loadtest); toBeInserted.Add(loadtest); resultSummaryBuilder.Append(string.Format("Load test ID {0} (insertion) successfully validated.{1}", loadtest.Id, NL)); } else { failed.Add(loadtest); resultSummaryBuilder.Append(string.Format("Load test ID {0} (insertion) validation failed: {1}{2}.", loadtest.Id, validationSummary.ReasonForValidationFailure, NL)); } } } AddOrUpdateLoadtestsValidationResult validationResult = new AddOrUpdateLoadtestsValidationResult(toBeInserted, toBeUpdated, failed, resultSummaryBuilder.ToString()); TimetableChangedEventArgs args = new TimetableChangedEventArgs(validationResult); DomainEventMediator.RaiseEvent(args); return validationResult; }
public void Handle(EventArgs eventArgs) { TimetableChangedEventArgs e = eventArgs as TimetableChangedEventArgs; if (e != null) { AddOrUpdateLoadtestsValidationResult addOrUpdateValidationResult = e.AddOrUpdateLoadtestsValidationResult; if ((addOrUpdateValidationResult.ToBeInserted.Any() || addOrUpdateValidationResult.ToBeUpdated.Any()) && !addOrUpdateValidationResult.Failed.Any()) { EmailArguments args = new EmailArguments("Load tests added or updated", "Load tests added or updated", "The Boss", "The developer", "123.456.678"); _emailService.SendEmail(args); } } }
public void Handle(EventArgs eventArgs) { TimetableChangedEventArgs e = eventArgs as TimetableChangedEventArgs; if (e != null) { AddOrUpdateLoadTestsValidationResult validationResult = e.AddOrUpdateLoadtestsValidationResult; if ((validationResult.ToBeInserted.Any() || validationResult.ToBeUpdated.Any()) && !validationResult.Failed.Any()) { EmailArguments args = new EmailArguments("Load tests added or updated", "Load tests added or updated", "My boss", "Developer1", "127.0.0.1"); _emailService.SendMail(args); } } }
public void Handle(EventArgs eventArgs) { TimetableChangedEventArgs e = eventArgs as TimetableChangedEventArgs; if (e != null) { AddOrUpdateLoadtestsValidationResult addOrUpdateValidationResult = e.AddOrUpdateLoadtestsValidationResult; if ((addOrUpdateValidationResult.ToBeInserted.Any() || addOrUpdateValidationResult.ToBeUpdated.Any()) && !addOrUpdateValidationResult.Failed.Any()) { IConnection connection = GetRabbitMqConnection(); IModel model = connection.CreateModel(); string message = addOrUpdateValidationResult.OperationResultSummary; IBasicProperties basicProperties = model.CreateBasicProperties(); byte[] messageBytes = Encoding.UTF8.GetBytes(message); string queue = _configurationRepository.GetConfigurationValue <string>("LoadtestEventMessageQueueName", "LoadtestEventMessageQueue"); model.BasicPublish("", queue, basicProperties, messageBytes); } } }