Ejemplo n.º 1
0
        private void LoadFromFile(DataGroupItem dataGroup, DataSourceItem sourceItem)
        {
            FileCentralDataSource ds = sourceItem.SourceInformation as FileCentralDataSource;

            TimeSeries[] allTS = (TimeSeries[])NonInteractiveIO.Load(ds.Filename);
            if (allTS == null)
            {
                return;
            }
            for (var i = 0; i < allTS.Length; i++)
            {
                var             ts       = allTS[i];
                DataDetailsItem dataItem = new DataDetailsItem
                {
                    Data = new TimeSeriesPersistent {
                        TimeSeries = ts
                    },
                    DataInformation = new FileDataDetails {
                        Name = ts.name, ReloadOnRun = ReloadOnRun, Column = i
#if V3 || V4_0 || V4_1 || V4_2
#else
                        , StartDate = ts.Start
#endif
                    }
                };
                sourceItem.Data.Add(dataItem);

                var gdd = new GenericDataDetails {
                    Name = ts.name
                };
                gdd.AssociatedData.Add(dataItem);
                dataGroup.DataDetails.Add(gdd);
            }
        }
Ejemplo n.º 2
0
        public DataGroupItem AddToScenario(RiverSystemScenario scenario)
        {
            var dm            = scenario.Network.DataManager;
            var asFile        = Items.All(i => i.DetailsAsCSV == null);
            var dataGroupType = asFile
                ? typeof(FileCentralDataSource)
                : typeof(GeneratedCentralDataSource);

            var dataGroup = DataGroupItem.CreateGroup(dataGroupType, scenario.Network.InputSets);

            dataGroup.Name = Name;
            if (asFile)
            {
                dataGroup.InputSetItems.ForEachItem(i =>
                {
                    FileCentralDataSource ds = i.DataSource.SourceInformation as FileCentralDataSource;
                    ds.Filename = Name;
                });
            }

            dm.DataGroups.Add(dataGroup);

            if (Items == null)
            {
                return(dataGroup);
            }

            for (int i = 0; i < Items.Length; i++)
            {
                var item = Items[i];
                item.AddToGroup(scenario, dataGroup, i);
            }
            return(dataGroup);
        }