private static void LoadDailyUsbrCatalog(TimeSeriesDatabaseDataSet.SeriesCatalogDataTable sc, TimeSeriesDatabaseDataSet.SeriesCatalogDataTable sc_vm, string program) { for (int i = 0; i < sc.Rows.Count; i++) { if (i == 55) { return; } var row = sc[i]; string[] path = { "water.usbr.gov", "pn", program, row.siteid, "daily" }; var folderID = sc_vm.GetOrCreateFolder(path); TimeSeriesName tn = new TimeSeriesName(row.TableName); var newRow = sc_vm.NewSeriesCatalogRow(); newRow.ItemArray = row.ItemArray; newRow.id = sc_vm.NextID(); newRow.iconname = ""; newRow.Provider = "HydrometDailySeries"; newRow.ConnectionString = "server=PN;cbtt=" + tn.siteid + ";pcode=" + tn.pcode + ";"; newRow.TableName = "pnhydromet_" + row.TableName; newRow.Units = HydrometInfoUtility.LookupDailyUnits(tn.pcode); newRow.Parameter = HydrometInfoUtility.LookupDailyParameterName(tn.pcode); newRow.ParentID = folderID; sc_vm.Rows.Add(newRow); } }
private static void FixFolderStructure(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogDataTable sc) { var siteCatalog = db.GetSiteCatalog(); for (int i = 0; i < sc.Count; i++) { var row = sc[i]; if (row.IsFolder || row.TimeInterval != TimeInterval.Irregular.ToString() || row.Provider != "Series") { continue; } TimeSeriesName tn = new TimeSeriesName(row.TableName); var s = db.GetSeries(row.id); var program = EstimateProgramName(siteCatalog, s); if (program == "" || (program != "hydromet" && program != "agrimet")) { Console.WriteLine("Error: will skip, no program defined in series or type in sitecatalog"); continue; } if (!IsQualityParameter(tn.pcode)) { continue; } var myPath = sc.GetPath(row.id); var myPathJoin = String.Join("/", myPath); string[] path = { "timeseries", program, tn.siteid, "instant" }; if (IsQualityParameter(tn.pcode)) { path = new string[] { "timeseries", program, tn.siteid, "quality" } } ; var expectedPath = String.Join("/", path); if (myPathJoin != expectedPath) { Console.WriteLine(tn.pcode + ": " + myPathJoin + " --> " + expectedPath); var id = sc.GetOrCreateFolder(path); row.ParentID = id; } } db.Server.SaveTable(sc); }
private static void LoadUpperSnakeHydromet(TimeSeriesDatabaseDataSet.SeriesCatalogDataTable sc_vm) { // load hydromet/upper snake var lines = upperSnakeDaily.Split('\n'); foreach (var item in lines) { var tokens = item.Trim().Split(' ', '\t'); var cbtt = tokens[0].Trim().ToLower(); var pcode = tokens[1].Trim().ToLower(); string[] path = { "water.usbr.gov", "pn", "hydromet", cbtt, "daily" }; var folderID = sc_vm.GetOrCreateFolder(path); HydrometDailySeries s = new HydrometDailySeries(cbtt, pcode); s.SiteID = cbtt; s.Parameter = HydrometInfoUtility.LookupDailyParameterName(pcode); sc_vm.AddSeriesCatalogRow(s, sc_vm.NextID(), folderID, "pnhydromet_" + s.Table.TableName); } }