Пример #1
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (ScenarioName == scenario.Name)
            {
                return(this);
            }

            var sr = m_db.GetNewSeriesRow(false);

            sr.ItemArray = SeriesCatalogRow.ItemArray;


            string cs = sr.ConnectionString;
            string scenario_model_run_id   = ConnectionStringUtility.GetToken(scenario.Path, "model_run_id", "-1");
            string scenario_model_run_name = ConnectionStringUtility.GetToken(scenario.Path, "model_run_name", "");
            string scenario_run_date       = ConnectionStringUtility.GetToken(scenario.Path, "run_date", "");

            cs = ConnectionStringUtility.Modify(cs, "model_run_id", scenario_model_run_id);
            cs = ConnectionStringUtility.Modify(cs, "model_run_name", scenario_model_run_name);
            cs = ConnectionStringUtility.Modify(cs, "run_date", scenario_run_date);

            sr.ConnectionString = cs;
            var s = new HdbModelSeries(m_db, sr);

            s.Appearance.LegendText = BuildScenairoName(scenario_model_run_name, scenario_model_run_id, scenario_run_date)
                                      + " " + Name;
            return(s);
        }
Пример #2
0
        /// <summary>
        /// Creates table that can be
        /// appended to the SeriesCatalog in Pisces
        /// </summary>
        /// <returns></returns>
        public static TimeSeriesDatabaseDataSet.SeriesCatalogDataTable PiscesSeriesCatalog(int model_id,
                                                                                           string m_table,   // model table i.e. m_month, m_day,...
                                                                                           DateTime t,       // consider model runs after this date
                                                                                           int nextPiscesID, // next avaliable id in Pisces
                                                                                           int parentID)     // container for this model
        {                                                                                                    // get unique list of site_datatype_id -- based on these parameters
            var       rval = new TimeSeriesDatabaseDataSet.SeriesCatalogDataTable();
            DataTable sitesAndParameters = Hdb.Instance.ModelParameterList(t, model_id, m_table);
            DataTable siteList           = DataTableUtility.SelectDistinct(sitesAndParameters, "Site_ID");
            int       model_run_id       = -1;
            string    model_run_name     = "";
            string    run_date           = "";

            Hdb.Instance.FirstModelRunInfo(t, model_id, out model_run_id, out model_run_name, out run_date);
            //string scenarioName =  "";// "(" + model_run_id + ")";

            for (int i = 0; i < siteList.Rows.Count; i++)
            {
                int       site_id   = Convert.ToInt32(siteList.Rows[i]["site_id"]);
                DataRow[] rows      = sitesAndParameters.Select("Site_ID=" + site_id);
                int       siteRowID = nextPiscesID++;
                rval.AddSeriesCatalogRow(siteRowID, parentID, true, 1, "HdbModel",
                                         rows[0]["site_name"].ToString(), "", "", "", "", "", "", "", "", "", true);

                for (int j = 0; j < rows.Length; j++)
                {
                    string cs = HdbModelSeries.BuildConnectionString(m_table, model_run_id.ToString(), model_run_name, run_date, rows[j]["site_datatype_id"].ToString());
                    rval.AddSeriesCatalogRow(nextPiscesID++, siteRowID, false, j,
                                             "HdbModel", rows[j]["datatype_common_name"].ToString(),
                                             rows[j]["site_name"].ToString(),
                                             rows[j]["unit_common_name"].ToString(),
                                             IntervalString(m_table),
                                             rows[j]["datatype_common_name"].ToString(),
                                             "", "HdbModelSeries", cs, "", "", true);
                }
            }
            return(rval);
        }