//, AggregationSummary summary) //public ActionResult Index() //{ // string projectName = "Test Project"; // Calculator.AggregationSummary summary = new Calculator.ProjectCalculator(projectName).GenerateSummary(); // return View(summary); //} // // GET: /Summary/Details/5 public ActionResult Details(string id, int iterationCount) { Console.WriteLine(id); string projectName = id; AggregationSummary summary = new ProjectCalculator(projectName, iterationCount).GenerateSummary(); summary.CalculationTime = TimeSinceFirstRequest(projectName); AndyTimer.Reset(); return View(summary); }
public override void Run() { while (!IsStopped) { CalculationParameters calculationParameters = null; if (UseMessageBus) { try { // Receive the message BrokeredMessage receivedMessage = null; receivedMessage = QueueClient.Receive(); if (receivedMessage != null) { // Process the message Trace.WriteLine("Processing", receivedMessage.SequenceNumber.ToString()); calculationParameters = receivedMessage.GetBody<CalculationParameters>(); receivedMessage.Complete(); } } catch (MessagingException e) { if (!e.IsTransient) { Trace.WriteLine(e.Message); throw; } Thread.Sleep(10000); } catch (OperationCanceledException e) { if (!IsStopped) { Trace.WriteLine(e.Message); throw; } } } else { //--------------------------------- // Pick up messages from the "Main" message queue sent from the website // which provides info about the project (name, number of tasks, etc) // Then use the ProjectCalculator object to InitiateCalculation // This creates a Task Aggregator and call the InitiateSimulations method // which fires off one message for each simulation run // to a "simulation" message queue. // This will get picked up by a different worker process. //using (CalculatorDataSource dataSource = new CalculatorDataSource("main")) //{ calculationParameters = dataSource.GetObjectFromQueueMessage<CalculationParameters>(); //} //--------------------------------- } if (calculationParameters != null) { string projectName = calculationParameters.ProjectName; int iterationCount = calculationParameters.IterationCount; if (!string.IsNullOrEmpty(projectName)) { // Now we have the project name, create a new Calculator and initiate the calculation ProjectCalculator calculator = new ProjectCalculator(projectName, iterationCount); calculator.InitiateCalculation(); // Now we have initiated a project, we can pause for a while Thread.Sleep(10000); } } } }