示例#1
0
 public RunWindow(ModelSystemEditingSession session, XTMFRun run, string runName)
 {
     InitializeComponent();
     Session = session;
     session.SessionClosed += Session_SessionClosed;
     StartRun(run, runName);
 }
示例#2
0
 public RunWindow(ModelSystemEditingSession session, XTMFRun run, string runName)
 {
     InitializeComponent();
     Session = session;
     session.SessionClosed += Session_SessionClosed;
     StartRun(run, runName);
 }
示例#3
0
        private static void RunModelSystem(Configuration config, BinaryReader reader, BlockingCollection <byte[]> messageQueue)
        {
            var runName           = reader.ReadString();
            var runDirectory      = reader.ReadString();
            var modelSystemString = reader.ReadString();

            Task.Factory.StartNew(() =>
            {
                var run              = XTMFRun.CreateRemoteClient(config, runName, runDirectory, modelSystemString);
                run.ValidationError += (message) =>
                {
                    WriteMessageToStream(messageQueue, (writer) =>
                    {
                        writer.Write((Int32)ToHost.ClientErrorValidatingModelSystem);
                        WriteErrors(writer, message);
                    });
                };
                run.RuntimeValidationError += (message) =>
                {
                    WriteMessageToStream(messageQueue, (writer) =>
                    {
                        writer.Write((Int32)ToHost.ClientErrorRuntimeValidation);
                        WriteErrors(writer, message);
                    });
                    messageQueue.CompleteAdding();
                };
                run.RuntimeError += (error) =>
                {
                    WriteMessageToStream(messageQueue, (writer) =>
                    {
                        writer.Write((Int32)ToHost.ClientErrorWhenRunningModelSystem);
                        WriteError(writer, error);
                    });
                    messageQueue.CompleteAdding();
                };
                run.ProjectSavedByRun += (_, _2) =>
                {
                    WriteMessageToStream(messageQueue, (writer) =>
                    {
                        writer.Write((Int32)ToHost.ProjectSaved);
                        writer.Flush();
                        run.ModelSystemStructureModelRoot.Save(writer.BaseStream);
                        writer.BaseStream.Flush();
                    });
                };
                run.RunCompleted += () =>
                {
                    WriteMessageToStream(messageQueue, (writer) =>
                    {
                        writer.Write((Int32)ToHost.ClientFinishedModelSystem);
                    });
                    messageQueue.CompleteAdding();
                };
                CurrentRun = run;
                run.Start();
                run.Wait();
            }, TaskCreationOptions.LongRunning);
        }
示例#4
0
 private void ShowError(Exception e, string header)
 {
     this.Dispatcher.Invoke(new Action(
                                delegate()
     {
         this.RunFinished = true;
         this.CurrentRun  = null;
         this.IsActive    = false;
         (new XTMF.Gui.UserControls.ErrorWindow()
         {
             Exception = e, Owner = this.XTMF
         }).ShowDialog();
     }));
     this.SetButtonsToFinished();
 }
示例#5
0
        public void SetActive(object data)
        {
            if (this.CurrentRun == null)
            {
                if (data is QuestionResult)
                {
                    this.WasCanceled              = false;
                    this.RunDirectory             = System.IO.Path.GetTempPath();
                    this.RunFinished              = false;
                    this.StartTime                = DateTime.Now;
                    this.ContinueButton.IsEnabled = false;
                    this.CancelButton.IsEnabled   = true;
                    this.StartTimeLabel.Content   = String.Format("Start Time: {0:g}", this.StartTime);
                    this.ProgressBar.Finished     = false;
                    this.ProgressReports.Clear();
                    this.SubProgressBars.Clear();
                    this.XTMF.XTMF.Configuration.ProgressReports.Clear();
                    this.ConsoleOutput.DataContext = new ConsoleOutputController(this);
                    this.ConsoleBorder.DataContext = this.ConsoleOutput.DataContext;

                    var    root             = (data as QuestionResult).Data as IModelSystemStructure;
                    string error            = null;
                    int    modelSystemIndex = this.XTMF.CurrentProject.ModelSystemStructure.IndexOf(root);
                    this.RunDirectory      = System.IO.Path.Combine(this.ProjectDirectory, this.XTMF.CurrentProject.Name, (this.RunName = (data as QuestionResult).Result));
                    this.RunNameLabel.Text = this.RunName;
                    this.CurrentRun        = this.XTMF.XTMF.RunController.CreateRun(this.RunName, this.XTMF.CurrentProject, modelSystemIndex, ref error);

                    HookupCurrentRun();
                    this.CurrentRun.Start();
                    if (CurrentRun == null)
                    {
                        MessageBox.Show(error, "Unable to Create Model System!", MessageBoxButton.OK, MessageBoxImage.Error);
                        this.ProgressBar.Value = 0;
                        this.RunFinished       = true;
                        SetButtonsToFinished();
                        return;
                    }
                    if (this.Windows7OrAbove)
                    {
                        this.TaskbarInformation.ProgressState = TaskbarItemProgressState.Normal;
                        this.TaskbarInformation.ProgressValue = 0;
                    }
                    this.CreateDirectoryStructure(RunDirectory);
                }
            }
        }
示例#6
0
 private void StartRun(XTMFRun run, string runName)
 {
     Run = run;
     Dispatcher.BeginInvoke(new Action(() =>
     {
         MainWindow.Us.SetWindowName(this, "Run - " + runName);
         RunNameLabel.Text = runName;
     }));
     ProgressReports               = Run.Configuration.ProgressReports;
     ProgressReports.ListChanged  += new ListChangedEventHandler(ProgressReports_ListChanged);
     ProgressReports.BeforeRemove += new EventHandler <ListChangedEventArgs>(ProgressReports_BeforeRemove);
     SubProgressBars.ListChanged  += new ListChangedEventHandler(SubProgressBars_ListChanged);
     SubProgressBars.BeforeRemove += new EventHandler <ListChangedEventArgs>(SubProgressBars_BeforeRemove);
     Run.RunComplete              += Run_RunComplete;
     Run.RunStarted             += Run_RunStarted;
     Run.RuntimeError           += Run_RuntimeError;
     Run.RuntimeValidationError += Run_RuntimeValidationError;
     Run.ValidationStarting     += Run_ValidationStarting;
     Run.ValidationError        += Run_ValidationError;
     RunDirectory   = Run.RunDirectory;
     Timer          = new DispatcherTimer();
     Timer.Interval = TimeSpan.FromMilliseconds(1000 / 30);
     Timer.Tick    += new EventHandler(Timer_Tick);
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         var major = Environment.OSVersion.Version.Major;
         if (major > 6 || (major >= 6 && Environment.OSVersion.Version.Minor >= 1))
         {
             Windows7OrAbove = true;
             MainWindow.Us.TaskbarItemInfo    = TaskbarInformation = new TaskbarItemInfo();
             TaskbarInformation.ProgressState = TaskbarItemProgressState.Normal;
             TaskbarInformation.ProgressValue = 0;
         }
     }
     this.ConsoleOutput.DataContext = new ConsoleOutputController(this);
     this.ConsoleBorder.DataContext = this.ConsoleOutput.DataContext;
     StartRunAsync();
     Timer.Start();
 }
示例#7
0
 private void StartRun(XTMFRun run, string runName)
 {
     Run = run;
     Dispatcher.BeginInvoke(new Action(() =>
         {
             MainWindow.Us.SetWindowName(this, "Run - " + runName);
             RunNameLabel.Text = runName;
         }));
     ProgressReports = Run.Configuration.ProgressReports;
     ProgressReports.ListChanged += new ListChangedEventHandler(ProgressReports_ListChanged);
     ProgressReports.BeforeRemove += new EventHandler<ListChangedEventArgs>(ProgressReports_BeforeRemove);
     SubProgressBars.ListChanged += new ListChangedEventHandler(SubProgressBars_ListChanged);
     SubProgressBars.BeforeRemove += new EventHandler<ListChangedEventArgs>(SubProgressBars_BeforeRemove);
     Run.RunComplete += Run_RunComplete;
     Run.RunStarted += Run_RunStarted;
     Run.RuntimeError += Run_RuntimeError;
     Run.RuntimeValidationError += Run_RuntimeValidationError;
     Run.ValidationStarting += Run_ValidationStarting;
     Run.ValidationError += Run_ValidationError;
     RunDirectory = Run.RunDirectory;
     Timer = new DispatcherTimer();
     Timer.Interval = TimeSpan.FromMilliseconds(1000 / 30);
     Timer.Tick += new EventHandler(Timer_Tick);
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         var major = Environment.OSVersion.Version.Major;
         if (major > 6 || (major >= 6 && Environment.OSVersion.Version.Minor >= 1))
         {
             Windows7OrAbove = true;
             MainWindow.Us.TaskbarItemInfo = TaskbarInformation = new TaskbarItemInfo();
             TaskbarInformation.ProgressState = TaskbarItemProgressState.Normal;
             TaskbarInformation.ProgressValue = 0;
         }
     }
     this.ConsoleOutput.DataContext = new ConsoleOutputController(this);
     this.ConsoleBorder.DataContext = this.ConsoleOutput.DataContext;
     StartRunAsync();
     Timer.Start();
 }
示例#8
0
 private void StartRun(ModelSystemEditingSession session, string runName)
 {
     string error = null;
     Dispatcher.BeginInvoke(new Action(() =>
         {
             MainWindow.Us.SetWindowName(this, "Run - " + runName);
             RunNameLabel.Text = runName;
         }));
     Run = session.Run(runName, ref error);
     ProgressReports = Run.Configuration.ProgressReports;
     Run.RunComplete += Run_RunComplete;
     Run.RunStarted += Run_RunStarted;
     Run.RuntimeError += Run_RuntimeError;
     Run.RuntimeValidationError += Run_RuntimeValidationError;
     Run.ValidationStarting += Run_ValidationStarting;
     Run.ValidationError += Run_ValidationError;
     RunDirectory = Run.RunDirectory;
     Timer = new DispatcherTimer();
     Timer.Interval = TimeSpan.FromMilliseconds(1000 / 30);
     Timer.Tick += new EventHandler(Timer_Tick);
     if(Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         var major = Environment.OSVersion.Version.Major;
         if(major > 6 || (major >= 6 && Environment.OSVersion.Version.Minor >= 1))
         {
             Windows7OrAbove = true;
             TaskbarInformation = new TaskbarItemInfo();
         }
     }
     StartRunAsync();
     Timer.Start();
 }
示例#9
0
 private void CurrentRun_RunComplete()
 {
     this.SetButtonsToFinished();
     this.RunFinished = true;
     this.CurrentRun  = null;
 }
示例#10
0
 private void ShowError(Exception e, string header)
 {
     this.Dispatcher.Invoke( new Action(
         delegate()
         {
             this.RunFinished = true;
             this.CurrentRun = null;
             this.IsActive = false;
             ( new XTMF.Gui.UserControls.ErrorWindow() { Exception = e, Owner = this.XTMF } ).ShowDialog();
         } ) );
     this.SetButtonsToFinished();
 }
示例#11
0
 private void CurrentRun_RunComplete()
 {
     this.SetButtonsToFinished();
     this.RunFinished = true;
     this.CurrentRun = null;
 }
示例#12
0
        public void SetActive(object data)
        {
            if ( this.CurrentRun == null )
            {
                if ( data is QuestionResult )
                {
                    this.WasCanceled = false;
                    this.RunDirectory = System.IO.Path.GetTempPath();
                    this.RunFinished = false;
                    this.StartTime = DateTime.Now;
                    this.ContinueButton.IsEnabled = false;
                    this.CancelButton.IsEnabled = true;
                    this.StartTimeLabel.Content = String.Format( "Start Time: {0:g}", this.StartTime );
                    this.ProgressBar.Finished = false;
                    this.ProgressReports.Clear();
                    this.SubProgressBars.Clear();
                    this.XTMF.XTMF.Configuration.ProgressReports.Clear();
                    this.ConsoleOutput.DataContext = new ConsoleOutputController( this );
                    this.ConsoleBorder.DataContext = this.ConsoleOutput.DataContext;

                    var root = ( data as QuestionResult ).Data as IModelSystemStructure;
                    string error = null;
                    int modelSystemIndex = this.XTMF.CurrentProject.ModelSystemStructure.IndexOf( root );
                    this.RunDirectory = System.IO.Path.Combine( this.ProjectDirectory, this.XTMF.CurrentProject.Name, ( this.RunName = ( data as QuestionResult ).Result ) );
                    this.RunNameLabel.Text = this.RunName;
                    this.CurrentRun = this.XTMF.XTMF.RunController.CreateRun( this.RunName, this.XTMF.CurrentProject, modelSystemIndex, ref error );

                    HookupCurrentRun();
                    this.CurrentRun.Start();
                    if ( CurrentRun == null )
                    {
                        MessageBox.Show( error, "Unable to Create Model System!", MessageBoxButton.OK, MessageBoxImage.Error );
                        this.ProgressBar.Value = 0;
                        this.RunFinished = true;
                        SetButtonsToFinished();
                        return;
                    }
                    if ( this.Windows7OrAbove )
                    {
                        this.TaskbarInformation.ProgressState = TaskbarItemProgressState.Normal;
                        this.TaskbarInformation.ProgressValue = 0;
                    }
                    this.CreateDirectoryStructure( RunDirectory );
                }
            }
        }
示例#13
0
        /// <summary>
        /// </summary>
        /// <param name="session"></param>
        /// <param name="run"></param>
        /// <param name="runName"></param>
        /// <param name="immediateRun"></param>
        /// <param name="launchedFrom"></param>
        public RunWindow(ModelSystemEditingSession session, XTMFRun run, string runName, DateTime delayedStartTime,
                         ModelSystemDisplay launchedFrom = null, SchedulerWindow schedulerWindow = null)
        {
            InitializeComponent();
            ErrorVisibility = Visibility.Collapsed;
            Session         = session;
            Run             = run;
            SchedulerWindow = schedulerWindow;
            OpenDirectoryButton.IsEnabled = true;
            Dispatcher.BeginInvoke(new Action(() =>
            {
                RunNameLabel.Text = runName;
                RunNameText.Text  = runName;
                IsRunClearable    = false;
            }));
            if (launchedFrom != null)
            {
                _launchedFromModelSystemDisplay = launchedFrom;
            }
            _progressReports               = Run.Configuration.ProgressReports;
            _progressReports.ListChanged  += ProgressReports_ListChanged;
            _progressReports.BeforeRemove += ProgressReports_BeforeRemove;
            _subProgressBars.ListChanged  += SubProgressBars_ListChanged;
            _subProgressBars.BeforeRemove += SubProgressBars_BeforeRemove;
            Run.RunCompleted              += Run_RunComplete;
            Run.RunStarted             += Run_RunStarted;
            Run.RuntimeError           += Run_RuntimeError;
            Run.RuntimeValidationError += Run_RuntimeValidationError;
            Run.ValidationStarting     += RunOnValidationStarting;
            Run.ValidationError        += RunOnValidationError;

            ErrorGroupBox.Visibility          = Visibility.Collapsed;
            BaseGrid.RowDefinitions[1].Height = new GridLength(0);
            _runDirectory = Run.RunDirectory;
            _timer        = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(100)
            };
            _isFinished  = false;
            _wasCanceled = false;
            _timer.Tick += Timer_Tick;
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                var major = Environment.OSVersion.Version.Major;
                if (major > 6 || major >= 6 && Environment.OSVersion.Version.Minor >= 1)
                {
                    _windows7OrAbove = true;
                    MainWindow.Us.TaskbarItemInfo     = _taskbarInformation = new TaskbarItemInfo();
                    _taskbarInformation.ProgressState = TaskbarItemProgressState.Normal;
                    _taskbarInformation.ProgressValue = 0;
                }
            }
            ConfigureLogger();
            var conc = new ConsoleOutputController(this, Run, iLog);

            ConsoleOutput.DataContext = conc;
            _consoleAppener.ConsoleOutputController = conc;
            ConsoleBorder.DataContext = ConsoleOutput.DataContext;
            session.ExecuteDelayedRun(run, delayedStartTime);
            DetailsGroupBox.DataContext = this;
            StartRunAsync();
            _timer.Start();
        }