Ejemplo n.º 1
0
 /// <summary>
 /// Event handler for a job runner's <see cref="IJobRunner.AllJobsCompleted"/> event.
 /// Asserts that the job ran successfully.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="args">Event arguments.</param>
 public static void EnsureJobRanGreen(object sender, JobCompleteArguments args)
 {
     if (args.ExceptionThrowByJob != null)
     {
         throw new Exception(string.Format("Exception was thrown when running via {0}, when we expected no error to be thrown.", sender.GetType().Name), args.ExceptionThrowByJob);
     }
 }
Ejemplo n.º 2
0
 /// <summary>Called once when all jobs have completed running. Should throw on error.</summary>
 protected override void PostRun(JobCompleteArguments args)
 {
     lock (this)
     {
         if (!(args.Job is EmptyJob))
         {
             NumberOfSimulationsCompleted++;
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Write part of a complete message to a string builder.
 /// </summary>
 /// <param name="e">The event arguments of the completed job.</param>
 /// <param name="message">The string builder to write to.</param>
 private static void WriteDetailsToMessage(JobCompleteArguments e, StringBuilder message)
 {
     if (e.Job is SimulationDescription)
     {
         message.Append((e.Job as SimulationDescription).Name);
         if (string.IsNullOrEmpty(fileName))
         {
             message.Append(" (");
             message.Append(fileName);
             message.Append(')');
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Write a complete message to the console.
        /// </summary>
        /// <param name="e">The event arguments of the completed job.</param>
        private static void WriteCompleteMessage(JobCompleteArguments e)
        {
            var message = new StringBuilder();

            WriteDetailsToMessage(e, message);
            if (e.Job != null)
            {
                message.Append(" has finished. Elapsed time was ");
                message.Append(e.ElapsedTime.TotalSeconds.ToString("F1"));
                message.Append(" seconds.");
            }
            Console.WriteLine(message);
        }
Ejemplo n.º 5
0
 /// <summary>Job has completed</summary>
 private static void OnJobCompleted(object sender, JobCompleteArguments e)
 {
     if (e.ExceptionThrowByJob != null)
     {
         lock (lockObject)
         {
             exceptionsWrittenToConsole.Add(e.ExceptionThrowByJob);
             Console.WriteLine("----------------------------------------------");
             Console.WriteLine(e.ExceptionThrowByJob.ToString());
             exitCode = 1;
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Write a complete message to the console.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">The event arguments of the completed job.</param>
        private static void WriteCompleteMessage(object sender, JobCompleteArguments e)
        {
            if (e.Job == null)
            {
                return;
            }

            var message = new StringBuilder(e.Job.Name);

            if (e.Job is SimulationDescription sim && !string.IsNullOrEmpty(sim.SimulationToRun?.FileName))
            {
                message.Append($" ({sim.SimulationToRun.FileName})");
            }
            string duration = e.ElapsedTime.TotalSeconds.ToString("F1");

            message.Append($" has finished. Elapsed time was {duration} seconds.");
            Console.WriteLine(message);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Invoked when a job is completed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The event arguments.</param>
 private void OnJobCompleted(object sender, JobCompleteArguments e)
 {
     AddException(e.ExceptionThrowByJob);
     SimulationCompleted?.Invoke(this, e);
 }
Ejemplo n.º 8
0
 void IJobManager.JobHasCompleted(JobCompleteArguments args)
 {
 }
Ejemplo n.º 9
0
 /// <summary>Called once when all jobs have completed running. Should throw on error.</summary>
 protected override void PostRun(JobCompleteArguments args)
 {
     lock (this)
         NumberOfSimulationsCompleted++;
 }
Ejemplo n.º 10
0
 private void EnsureJobRanRed(object sender, JobCompleteArguments args)
 {
     Assert.NotNull(args.ExceptionThrowByJob, "Simulation with a faulty manager script has run green.");
 }