Esempio n. 1
0
        public ICommand LoadOntogenyForMolecule(IndividualMolecule molecule, TSimulationSubject simulationSubject)
        {
            var dataImporterSettings = new DataImporterSettings
            {
                Caption = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportOntogeny}",
                Icon    = ApplicationIcons.Excel
            };

            var data = _dataImporter.ImportDataSet(new List <MetaDataCategory>(), getColumnInfos(), dataImporterSettings);

            if (data == null)
            {
                return(null);
            }

            var ontogeny = new UserDefinedOntogeny {
                Table = formulaFrom(data), Name = data.Name
            };

            //only first formulation will be imported
            if (_ontogenyRepository.AllNames().Contains(ontogeny.Name))
            {
                var name = _entityTask.NewNameFor(ontogeny, _ontogenyRepository.AllNames());
                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }

                ontogeny.Name = name;
            }

            return(SetOntogenyForMolecule(molecule, ontogeny, simulationSubject));
        }
        public ICommand LoadOntogenyForMolecule(IndividualMolecule molecule, ISimulationSubject simulationSubject)
        {
            var dataImporterSettings = new DataImporterSettings
            {
                Caption  = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportOntogeny}",
                IconName = ApplicationIcons.Excel.IconName
            };

            dataImporterSettings.AddNamingPatternMetaData(Constants.FILE);

            var data = _dataImporter.ImportDataSets(
                new List <MetaDataCategory>(),
                getColumnInfos(),
                dataImporterSettings,
                _dialogCreator.AskForFileToOpen(Captions.Importer.OpenFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA)
                ).DataRepositories.FirstOrDefault();

            if (data == null)
            {
                return(null);
            }

            var ontogeny = new UserDefinedOntogeny {
                Table = formulaFrom(data), Name = data.Name
            };

            //only first ontogeny will be imported
            if (_ontogenyRepository.AllNames().Contains(ontogeny.Name))
            {
                var name = _entityTask.NewNameFor(ontogeny, _ontogenyRepository.AllNames());
                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }

                ontogeny.Name = name;
            }

            return(SetOntogenyForMolecule(molecule, ontogeny, simulationSubject));
        }