Exemplo n.º 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);
        }