Пример #1
0
        static void Main(string[] args)
        {
            var fn = @"C:\temp\pn.pdb";
            //var svr_vm = MySqlServer.GetMySqlServer("vm", "timeseries");
            var svr_vm = new SQLiteServer(fn);

            if (svr_vm.TableExists("seriescatalog"))
            {
                svr_vm.RunSqlCommand("truncate seriescatalog");
            }
            if (svr_vm.TableExists("sitescatalog"))
            {
                svr_vm.RunSqlCommand("truncate sitecatalog");
            }

            var db_vm    = new TimeSeriesDatabase(svr_vm, Reclamation.TimeSeries.Parser.LookupOption.TableName);
            var sites_vm = db_vm.GetSiteCatalog();

            var svr   = PostgreSQL.GetPostgresServer("timeseries", "lrgs1");
            var db    = new TimeSeriesDatabase(svr, Reclamation.TimeSeries.Parser.LookupOption.TableName);
            var sites = db.GetSiteCatalog();

            string program = "agrimet";
            var    sc      = db.GetSeriesCatalog("timeinterval='Daily'", "program:" + program);
            var    sc_vm   = db_vm.GetSeriesCatalog();

            LoadDailyUsbrCatalog(sc, sc_vm, program);
            //db_vm.Server.SaveTable(sc_vm);

            LoadUpperSnakeHydromet(sc_vm);

            db_vm.Server.SaveTable(sc_vm);
            // install all sites that are referenced in series catalog

            var tmp = db_vm.Server.Table("tmp", "select distinct siteid from seriescatalog");

            for (int i = 0; i < tmp.Rows.Count; i++)
            {
                string siteid = tmp.Rows[i]["siteid"].ToString();
                var    rows   = sites.Select("siteid='" + siteid + "'");
                if (rows.Length > 0)
                {
                    var newRow = sites_vm.NewsitecatalogRow();
                    newRow.ItemArray = rows[0].ItemArray;
                    sites_vm.Rows.Add(newRow);
                }
            }

            db_vm.Server.SaveTable(sites_vm);
        }
Пример #2
0
        public void TestSQLite()
        {
            var fn = FileUtility.GetTempFileName(".pdb");

            SQLiteServer svr = new SQLiteServer(fn);
            var          db  = new TimeSeriesDatabase(svr);

            var sql = "insert into quality_limit values ('*_OB',120,-50,null); ";

            svr.RunSqlCommand(sql);

            var s = new Series();

            s.Table.TableName = "karl_ob";
            s.Add("1-1-2013", 100);
            s.Add("1-2-2013", -51);
            s.Add("1-3-2013", 100);
            s.Add("1-4-2013", 150);

            //db.TimeSeriesImporter.Process(s);
            TimeSeriesImporter ti = new TimeSeriesImporter(db);

            ti.Import(s);

            //db.ImportSeriesUsingTableName(s, true, setQualityFlags: true);
            s = db.GetSeriesFromTableName("karl_ob");
            s.Read();
            Console.WriteLine("has flags = " + s.HasFlags);
            s.WriteToConsole(true);

            Assert.AreEqual("", s["1-1-2013"].Flag);
            Assert.AreEqual("-", s["1-2-2013"].Flag);
            Assert.AreEqual("", s["1-3-2013"].Flag);
            Assert.AreEqual("+", s["1-4-2013"].Flag);
        }