/// <summary> /// Method called from the view. This clear every list and field. Should be called when /// we load a new experiment if one is already loaded or when we hit the delete button /// from the view. /// </summary> public void ClearReportViewer() { ExperimentalUnits.Clear(); LoggedExperiments.Clear(); Reports.Clear(); NotifyOfPropertyChange(() => VariablesLoaded); NotifyOfPropertyChange(() => ForksLoaded); Query.Reset(); CanSaveReports = false; LogsLoaded = false; ForksLoaded = false; }
/// <summary> /// Method called from the view. This clear every list and field. Should be called when /// we load a new experiment if one is already loaded or when we hit the delete button /// from the view. /// </summary> public void ClearReportViewer() { ExperimentalUnits.Clear(); LoggedExperiments.Clear(); LogQueryResults.Clear(); NotifyOfPropertyChange(() => VariablesLoaded); NotifyOfPropertyChange(() => ForksLoaded); Query = new LogQueryViewModel(); //Add the listening function to the LogQuery object with all the parameters Query.PropertyChanged += OnChildPropertyChanged; LogsLoaded = false; ForksLoaded = false; }
private int LoadLoggedExperiment(XmlNode node, string baseDirectory , SimionFileData.LoadUpdateFunction loadUpdateFunction) { LoggedExperimentViewModel newExperiment = new LoggedExperimentViewModel(node, baseDirectory, true, false, loadUpdateFunction); LoggedExperiments.Add(newExperiment); ExperimentalUnits.AddRange(newExperiment.ExperimentalUnits); Query.AddLogVariables(newExperiment.VariablesInLog); ForksLoaded |= newExperiment.Forks.Count > 0; newExperiment.TraverseAction(true, (n) => { if (n is LoggedForkViewModel fork) { fork.PropertyChanged += OnChildPropertyChanged; } }); return(ExperimentalUnits.Count); }
/// <summary> /// Load an experiment from a batch file. If <paramref name="batchFileName"/> is either /// null or empty, a dialog window will be opened to let the user select a batch file. /// </summary> /// <param name="batchFileName">The name of the file to load</param> public void LoadExperimentBatch(string batchFileName) { //Ask the user for the name of the batch if (string.IsNullOrEmpty(batchFileName)) { bool bSuccess = Files.OpenFileDialog(ref batchFileName , Files.ExperimentBatchDescription, Files.ExperimentBatchFilter); if (!bSuccess) { return; } } //reset the view if a batch was succesfully selected ClearReportViewer(); //Inefficient but not so much as to care //First we load the batch file to cout how many experimental units we have StartLongOperation(); LoadedBatch = "Reading batch file"; //first count the total number of experimental units m_numExperimentalUnits = ExperimentBatch.CountExperimentalUnits(batchFileName, LoadOptions.ExpUnitSelection.All); Task.Run(() => { //load finished experimental units from the batch LoadOptions loadOptions = new LoadOptions() { Selection = LoadOptions.ExpUnitSelection.OnlyFinished, LoadVariablesInLog = true, OnExpUnitLoaded = OnExperimentalUnitProcessed }; LoadedBatch = "Reading experiment files"; ExperimentBatch batch = new ExperimentBatch(); batch.Load(batchFileName, loadOptions); //Create ViewModels from LoggedExperimentBatch foreach (Experiment experiment in batch.Experiments) { LoggedExperimentViewModel newExperiment = new LoggedExperimentViewModel(experiment); LoggedExperiments.Add(newExperiment); ExperimentalUnits.AddRange(newExperiment.ExperimentalUnits); Query.AddLogVariables(newExperiment.VariablesInLog); ForksLoaded |= newExperiment.Forks.Count > 0; newExperiment.TraverseAction(true, (n) => { if (n is LoggedForkViewModel fork) { fork.PropertyChanged += OnChildPropertyChanged; } }); } //Update flags use to enable/disable parts of the report generation menu NotifyOfPropertyChange(() => ForksLoaded); NotifyOfPropertyChange(() => VariablesLoaded); LoadedBatch = batchFileName; LogsLoaded = true; EndLongOperation(); }); }