Пример #1
0
        /// <summary>All jobs have completed</summary>
        private void OnAllJobsCompleted(object sender, Runner.AllJobsCompletedArgs e)
        {
            if (e.AllExceptionsThrown != null)
            {
                errors.AddRange(e.AllExceptionsThrown);
            }
            try
            {
                Stop();
            }
            catch
            {
                // We could display the error message, but we're about to display output to the user anyway.
            }
            if (errors.Count == 0)
            {
                explorerPresenter.MainPresenter.ShowMessage(string.Format("{0} complete [{1} sec]", jobName, e.ElapsedTime.TotalSeconds.ToString("#.00")), Simulation.MessageType.Information);
            }
            else
            {
                explorerPresenter.MainPresenter.ShowError(errors);
            }

            SoundPlayer player = new SoundPlayer();

            if (DateTime.Now.Month == 12)
            {
                player.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.notes.wav");
            }
            else
            {
                player.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.success.wav");
            }
            player.Play();
        }
Пример #2
0
        /// <summary>All jobs have completed</summary>
        private void OnAllJobsCompleted(object sender, Runner.AllJobsCompletedArgs e)
        {
            IsRunning = false;
            if (timer != null)
            {
                timer.Elapsed -= OnTimerTick;
            }

            if (e.AllExceptionsThrown != null)
            {
                errors.AddRange(e.AllExceptionsThrown);
            }
            try
            {
                Stop();
            }
            catch
            {
                // We could display the error message, but we're about to display output to the user anyway.
            }
            if (errors.Count == 0)
            {
                explorerPresenter.MainPresenter.ShowMessage(string.Format("{0} complete [{1} sec]", jobName, e.ElapsedTime.TotalSeconds.ToString("#.00")), Simulation.MessageType.Information);
            }
            else
            {
                explorerPresenter.MainPresenter.ShowError(errors);
            }

            if (!Configuration.Settings.Muted)
            {
                // Play a completion sound.
                SoundPlayer player = new SoundPlayer();
                if (errors.Count > 0)
                {
                    if (File.Exists(Configuration.Settings.SimulationCompleteWithErrorWavFileName))
                    {
                        player.SoundLocation = Configuration.Settings.SimulationCompleteWithErrorWavFileName;
                    }
                    else
                    {
                        player.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.Sounds.Fail.wav");
                    }
                }
                else
                {
                    if (File.Exists(Configuration.Settings.SimulationCompleteWavFileName))
                    {
                        player.SoundLocation = Configuration.Settings.SimulationCompleteWithErrorWavFileName;
                    }
                    else
                    {
                        player.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.Sounds.Success.wav");
                    }
                }

                player.Play();
            }
        }
Пример #3
0
 /// <summary>All jobs have completed</summary>
 private static void OnAllJobsCompleted(object sender, Runner.AllJobsCompletedArgs e)
 {
     if (e.AllExceptionsThrown != null)
     {
         foreach (var exception in e.AllExceptionsThrown)
         {
             if (!exceptionsWrittenToConsole.Contains(exception))
             {
                 Console.WriteLine("----------------------------------------------");
                 Console.WriteLine(exception.ToString());
                 exitCode = 1;
             }
         }
     }
 }
Пример #4
0
        /// <summary>All jobs have completed</summary>
        private static void OnAllJobsCompleted(object sender, Runner.AllJobsCompletedArgs e)
        {
            if (sender is Runner runner)
            {
                (sender as Runner).DisposeStorage();
            }

            if (e.AllExceptionsThrown == null)
            {
                return;
            }

            foreach (Exception error in e.AllExceptionsThrown)
            {
                if (!exceptionsWrittenToConsole.Contains(error))
                {
                    Console.WriteLine("----------------------------------------------");
                    Console.WriteLine(error.ToString());
                    exitCode = 1;
                }
            }
        }