Esempio n. 1
0
        public AmtListViewModel()
        {
            MtdbList     = new ObservableCollection <AmtInfo>();
            QualityStats = new ObservableCollection <AmtPeptideOptions>();
            IsSaving     = false;

            Lookup = new DmsLookupUtility();

            Action refreshMtdbsAction = RefreshMtdbs;
            Action getStatsAction     = GetStats;
            Action exportAction       = Export;

            RefreshMtdbsCommand        = new DelegateCommand(refreshMtdbsAction);
            GetStatsCommand            = new DelegateCommand(getStatsAction);
            GetStatsCommand.Executable = false;
            ExportCommand            = new DelegateCommand(exportAction);
            ExportCommand.Executable = false;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DmsLookupViewModel"/> class.
        /// </summary>
        /// <param name="dialogService">Dialog service for opening dialogs from view model.</param>
        public DmsLookupViewModel(IDialogService dialogService)
        {
            IsFirstSearch       = true;
            Status              = false;
            this.dialogService  = dialogService;
            previousResultsList = new List <Tuple <string, int> >();
            NumberOfWeeks       = 10;
            PreviousDatasets    = new Dictionary <string, int>();
            Datasets            = new ReactiveList <DmsDatasetViewModel>();
            Jobs             = new ReactiveList <DmsJobViewModel>();
            dmsLookupUtility = new DmsLookupUtility();

            LookupCommand = ReactiveCommand.Create(Lookup);

            // If there is no data set selected or there is no job selected, disable open button
            OpenCommand = ReactiveCommand.Create(OpenImplementation, this.WhenAnyValue(x => x.SelectedDataset, x => x.SelectedJob)
                                                 .Select(x => !string.IsNullOrEmpty(x.Item1?.DatasetFolderPath) && !string.IsNullOrEmpty(x.Item2?.JobFolderPath)));

            CloseCommand = ReactiveCommand.Create(CloseImplementation);

            SelectedDataset = new DmsDatasetViewModel();
            SelectedJob     = new DmsJobViewModel();

            // When a data set is selected, find jobs for the data set
            this.WhenAnyValue(x => x.SelectedDataset)
            .Subscribe(x =>
            {
                Jobs.Clear();
                if (selectedDataset == null)
                {
                    return;
                }

                var jobMap =
                    dmsLookupUtility.GetJobsByDataset(
                        new List <DmsLookupUtility.UdtDatasetInfo> {
                    selectedDataset.UdtDatasetInfo
                });
                if (jobMap.TryGetValue(selectedDataset.DatasetId, out var jobs))
                {
                    foreach (var job in jobs)
                    {
                        Jobs.Add(new DmsJobViewModel(job));
                    }
                }

                if (Jobs.Count > 0)
                {
                    SelectedJob = Jobs[0];
                }
            });

            // When a null data set is selected and a search has occurred, show no results screen
            this.WhenAnyValue(x => x.Datasets.Count, x => x.IsFirstSearch)
            .Select(x => x.Item1 == 0 && !x.Item2)
            .Subscribe(noResults => IsNoResultsShown = noResults);

            // When the dataset filter changes, find the number of weeks previously selected for the filter
            this.WhenAnyValue(x => x.DatasetFilter)
            .Where(filter => !string.IsNullOrEmpty(filter))
            .Where(filter => PreviousDatasets.ContainsKey(filter))
            .Select(filter => PreviousDatasets[filter])
            .Subscribe(numWeeks => NumberOfWeeks = numWeeks);

            OpenPreviousResultFile();
        }
Esempio n. 3
0
 public DmsExporterViewModel()
 {
     m_lookup         = new DmsLookupUtility();
     AmtListViewModel = new AmtListViewModel();
 }