public void GetSites_SaveXmlFilesFlag_ReturnsSameData(string url) { try { var target = new WaterOneFlowClient(url, 5) { SaveXmlFiles = false }; var sites1 = target.GetSites(); target.SaveXmlFiles = true; var sites2 = target.GetSites(); Assert.AreEqual(sites1.Count, sites2.Count); for (var i = 0; i < sites1.Count; i++) { var site1 = sites1[i]; var site2 = sites2[i]; Assert.AreEqual(site1.Code, site2.Code); Assert.AreEqual(site1.Name, site2.Name); } } catch (WebException ex) { if (ex.Status.HasFlag(WebExceptionStatus.ProtocolError) || ex.Status.HasFlag(WebExceptionStatus.Timeout)) { Assert.Inconclusive("Unable to test GetSites() from: " + url); } throw; } }
public void CanSaveMultipleSeries() { Random random = new Random(); //string url1 = @"http://his02.usu.edu/littlebearriver/cuahsi_1_0.asmx"; //string url2 = @"http://icewater.boisestate.edu/dcew2dataservices/cuahsi_1_0.asmx"; string url3 = @"http://his.crwr.utexas.edu/TXEvap/cuahsi_1_0.asmx"; MetadataCacheManagerSQL manager = TestConfig.MetadataCacheManager; WaterOneFlowClient client = new WaterOneFlowClient(url3); IList <Site> siteList = client.GetSites(); IList <SeriesMetadata> seriesList = new List <SeriesMetadata>(); DataServiceInfo service = GeDatatService(random.Next()); manager.SaveDataService(service); foreach (Site site in siteList) { IList <SeriesMetadata> seriesList1 = client.GetSiteInfo(site.Code); foreach (SeriesMetadata series in seriesList1) { seriesList.Add(series); } } foreach (SeriesMetadata series in seriesList) { manager.SaveSeries(series, service); } }
public void TestCRWR_10() { string url = @"http://his.crwr.utexas.edu/tcoonts/tcoon.asmx"; WaterOneFlowClient client = new WaterOneFlowClient(url); IList <Site> sites = client.GetSites(); Assert.Greater(sites.Count, 0); }
private void button1_Click(object sender, EventArgs e) { variablesListBox.Items.Clear(); waterOneFlowClient = new WaterOneFlowClient(urlTextbox.Text); // Update service info in the metadata database var waterOneFlowServiceInfo = waterOneFlowClient.ServiceInfo; var service = waterOneFlowServiceInfo; // Get all sites for this service IList <Site> siteList; siteList = waterOneFlowClient.GetSites(); var variableList = new List <string>(); foreach (var site in siteList) { // Get series for this site IList <SeriesMetadata> currentSeriesList; try { currentSeriesList = waterOneFlowClient.GetSiteInfo(site.Code); } catch (WebException ex) { if (ex.Response != null) { var rdr = new StreamReader(ex.Response.GetResponseStream()); rdr.ReadToEnd(); } continue; } // Save series info to metadata cache database foreach (var series in currentSeriesList) { if (!variableList.Contains(series.Variable.Name)) { var variable = series.Variable.Name; variableList.Add(variable); } } } foreach (var variable in variableList) { this.variablesListBox.Items.Add(variable, false); } if (variablesListBox.Items.Count != 0) { button1.Enabled = false; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; } }
public void TestLittleBearRiver_10() { string url = @"http://icewater.usu.edu/LittleBearRiver/cuahsi_1_0.asmx"; WaterOneFlowClient client = new WaterOneFlowClient(url); IList <Site> sites = client.GetSites(); IList <SeriesMetadata> seriesList = client.GetSiteInfo(sites[0].Code); IList <Series> downloadedData = client.GetValues(seriesList[0].Site.Code, seriesList[0].Variable.Code, DateTime.MinValue, DateTime.Now); Assert.IsNotNull(seriesList); Assert.Greater(seriesList.Count, 0); Assert.AreNotEqual(seriesList[0].Source.ToString(), "unknown"); Assert.AreNotEqual(seriesList[0].Method.ToString(), "unknown"); }
public void TestTCOON_11() { string url = @"http://his.crwr.utexas.edu/tcoonts/tcoon.asmx"; WaterOneFlowClient client = new WaterOneFlowClient(url); IList <Site> sites = client.GetSites(); IList <SeriesMetadata> seriesList = client.GetSiteInfo(sites[0].Code); //IList<Series> downloadedData = client.GetValues(seriesList[0].Site.Code, seriesList[0].Variable.Code, DateTime.MinValue, DateTime.Now); //Assert.IsNotNull(downloadedData); //Assert.Greater(downloadedData.Count, 0); //Assert.AreNotEqual(downloadedData[0].Source.ToString(), "unknown"); //Assert.AreNotEqual(downloadedData[0].Method.ToString(), "unknown"); }
public void CanSaveOneSeries() { Random random = new Random(); string url = @"http://his.crwr.utexas.edu/TXEvap/cuahsi_1_0.asmx"; MetadataCacheManagerSQL manager = TestConfig.MetadataCacheManager; WaterOneFlowClient client = new WaterOneFlowClient(url); IList <Site> sites = client.GetSites(); IList <SeriesMetadata> seriesList = client.GetSiteInfo(sites[0].Code); SeriesMetadata firstSeries = seriesList[0]; DataServiceInfo service = GeDatatService(random.Next()); manager.SaveDataService(service); firstSeries.DataService = service; manager.SaveSeries(firstSeries, service); }
static void HandleSites_1_0(string url) { string network, siteCode, varCode; int seriesCatalogID, newSCID; string queryParam = string.Empty; string errMsg = string.Empty; WaterML10.WaterOneFlowClient WofClient = new WaterOneFlowClient("WaterOneFlow", url); string[] blank = new string[0]; WaterML10.SiteInfoResponseType sitesAll = null; try { // WaterML1.0 sitesAll = WofClient.GetSites(blank, ""); // WaterML1.1 //sitesAll = WofClient.GetSitesObject(blank, ""); } catch (Exception e) { errMsg = "Exception@HandleSites: " + e.Message; Console.WriteLine(errMsg); } if (sitesAll == null) { if (errMsg.Length == 0) { errMsg = "Info: no site was returned from the URL."; } Console.WriteLine(errMsg); HQT.HandleQueryTimeseries("", "", -1, -1, -1, null, url, errMsg); return; } WaterML10.SiteInfoResponseTypeSite[] sitesRt = sitesAll.site; int nsites = sitesRt.Count(); Console.WriteLine("........................................."); Console.WriteLine("Reading {0} sites from {1}", nsites, url); WaterML10.seriesCatalogType[] sctAll; #region Loop for each site for (int i = 0; i < nsites; i++) { if (CPEnabled) { if (CP.siteIndex > i) { continue; } } if (i % 100 == 0) { // Do this check and refresh for after every 100 sites CheckAndRefreshResources(); } network = sitesRt[i].siteInfo.siteCode[0].network; siteCode = network + ":" + sitesRt[i].siteInfo.siteCode[0].Value; if (CPEnabled) { CP.siteIndex = i; CP.siteCode = siteCode; SaveCheckPoint(); } //queryParam = string.Format("QueryID = (SELECT TOP 1 QueryID FROM dbo.QueryTimeseries where SiteCode = '{0}'" + // " ORDER BY QueryID DESC) and DATEDIFF(HOUR, QueryDateTime, GETDATE()) <= {1}", // siteCode, NoCheckHours); //if (OD_Utils.Exists("dbo.QueryTimeseries", queryParam, HQT.Adapter.Connection)) //{ // Console.WriteLine("..Skip Site {0} which was already checked in last {1} hours.", // siteCode, NoCheckHours); // continue; //} if (sitesRt[i].seriesCatalog != null) { sctAll = sitesRt[i].seriesCatalog; } else { sctAll = LoadOnesiteInfo(WofClient, url, siteCode, ref errMsg); } if (sctAll == null) { if (errMsg.Length == 0) { errMsg = "Error: LoadOneSiteInfo() returned NULL."; } Console.WriteLine(errMsg); HQT.HandleQueryTimeseries(siteCode, "", -1, -1, -1, null, url, errMsg); continue; } if ((i + 1) % 100 == 0) { Console.WriteLine("..Site[{0}] {1} with {2} catalogs from {3} Time {4:HH:mm:ss}.", i, siteCode, sctAll.Count(), url, DateTime.Now); } else { Console.WriteLine("..Site[{0}] {1} with {2} catalogs Time {3:HH:mm:ss}.", i, siteCode, sctAll.Count(), DateTime.Now); } // network = SRBHOS, sites[i].seriesCatalog=null // My assumption is that // Under that situation, need to get SiteInfoResponseType one site by one site // Here is the one example siteCode for testing //WaterML11.SiteInfoResponseType rt = new WaterML11.SiteInfoResponseType(); //rt = WofClient.GetSiteInfoObject("SRBHOS:RTHNet", ""); #region Loop for each seriesCatalogType for (int j = 0; j < sctAll.Count(); j++) { int valueCount; WaterML10.seriesCatalogType sct = sctAll[j]; if (sct.series == null) { errMsg = string.Format("Error: WaterML10.seriesCatalogType[{0}].series is NULL.", j); HQT.HandleQueryTimeseries(siteCode, "", -1, -1, -1, null, url, errMsg); continue; } #region Loop for each seriesCatalogTypeSeries for (int k = 0; k < sct.series.Count(); k++) { WaterML10.seriesCatalogTypeSeries scts = sct.series[k]; WaterML10.TimeIntervalType ti = (WaterML10.TimeIntervalType)scts.variableTimeInterval; DateTime beginDateTime = ti.beginDateTime; DateTime endDateTime = ti.endDateTime; string code = scts.variable.variableCode[0].Value; varCode = network + ":" + code; valueCount = scts.valueCount.Value; if (valueCount <= MinValueCount) { Console.WriteLine( "....Series[{0}] varCode: {1} valCount: {2}, too small, record in Query table, no further action.", k, code, valueCount); queryParam = String.Format(" <{0}--{1}> ", beginDateTime, endDateTime); errMsg = "Info: value count is too small, no further action."; HQT.HandleQueryTimeseries(siteCode, varCode, -1, -1, valueCount, null, queryParam, errMsg); continue; } // Check hiscentral/SeriesCatalog table to get seriesCatalogID. // Note: beginDateTime and endDateTime are obtained from web service. seriesCatalogID = newSCID = 0; hiscentralDataSet.SeriesCatalogRow hscRow = HisSC.GetRow(siteCode, varCode, scts); if (hscRow != null) { seriesCatalogID = hscRow.SeriesID; if (hscRow.SeriesCode != null) { // Don't want to repeatedly print siteCode and network int idx = hscRow.SeriesCode.IndexOf(code); code = hscRow.SeriesCode.Substring(idx); } Console.WriteLine("....Series[{0}] var: {1}, ID: {2}, valCount: {3}", k, code, seriesCatalogID, valueCount); } else { newSCID = HSC.GetOrCreateSeriesID(siteCode, varCode, scts); Console.WriteLine("....Series[{0}] var: {1}||{2}||{3}||{4}, newID: {5}, valCount: {6}", k, code, // Where WaterML1.1 and WaterML1.0 differ scts.Method.methodID, scts.Source.sourceID, scts.QualityControlLevel.QualityControlLevelID, newSCID, valueCount); } // Update HealthQuery/DataValue table if datavalue changed int[] hasChanged = null; try { if (valueCount > 5000) { WaterML10.TimeSeriesResponseType[] tsRtAll = null; tsRtAll = LoadDataValueInfoSplit(siteCode, varCode, WofClient, valueCount, beginDateTime, endDateTime, ref queryParam, ref errMsg); if (tsRtAll != null) { hasChanged = HDV.HandleDataValueInfoSplit(seriesCatalogID, newSCID, tsRtAll); } } else { WaterML10.TimeSeriesResponseType tsRt = null; tsRt = LoadDataValueInfo(siteCode, varCode, WofClient, beginDateTime, endDateTime, ref queryParam, ref errMsg); if (tsRt != null) { hasChanged = HDV.HandleDataValueInfo(seriesCatalogID, newSCID, tsRt); } } } catch (Exception ex) { errMsg = "Exception@HandleSites1: " + ex.Message; Console.WriteLine(errMsg); } // Add to HealthQuery/QueryTimeseries table. HQT.HandleQueryTimeseries(siteCode, varCode, seriesCatalogID, newSCID, valueCount, hasChanged, queryParam, errMsg); } #endregion Loop for each seriesCatalogTypeSeries // We delay inserting records to Query table to improve performance, check and do it now if (HQT.Table.Count > Program.DbUpdateBatchSize / 2) { HQT.Adapter.Update(HQT.Table); HQT.Table.Clear(); } } #endregion Loop for each seriesCatalogType } #endregion Loop for each site if (HQT.Table.Count > 0) { HQT.Adapter.Update(HQT.Table); HQT.Table.Clear(); } } // end of HandleSites_1_0()
private void button2_Click(object sender, EventArgs e) { variablesListBox.Enabled = false; urlTextbox.Enabled = false; titleTextbox.Enabled = false; button1.Enabled = false; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; waterOneFlowClient = new WaterOneFlowClient(urlTextbox.Text); var waterOneFlowServiceInfo = waterOneFlowClient.ServiceInfo; // Trim the query off of the URL if it still exists int index = waterOneFlowServiceInfo.EndpointURL.IndexOf("?"); if (index > -1) { waterOneFlowServiceInfo.EndpointURL = waterOneFlowServiceInfo.EndpointURL.Substring(0, index); } var serviceInfo = new DataServiceInfo(); serviceInfo.IsHarvested = false; serviceInfo.ServiceName = waterOneFlowServiceInfo.ServiceName; serviceInfo.Version = waterOneFlowServiceInfo.Version; serviceInfo.ServiceType = waterOneFlowServiceInfo.ServiceType; serviceInfo.Protocol = waterOneFlowServiceInfo.Protocol; serviceInfo.VariableCount = waterOneFlowServiceInfo.VariableCount; IList <Site> siteList; siteList = waterOneFlowClient.GetSites(); // Default extent for the service. These values are designed to be overwritten as we query sites in the service double east = -180; double west = 360; double north = -90; double south = 90; int valueCount = 0; var totalDataCartSeriesList = new List <SeriesDataCart>(); foreach (var site in siteList) { // Get series for this site IList <SeriesMetadata> currentSeriesList; var dataCartSeriesList = new List <SeriesDataCart>(); try { currentSeriesList = waterOneFlowClient.GetSiteInfo(site.Code); } catch (WebException ex) { continue; } catch (Exception ex) { continue; } // Update service extent if (site.Latitude > north) { north = site.Latitude; } if (site.Latitude < south) { south = site.Latitude; } if (site.Longitude > east) { east = site.Longitude; } if (site.Longitude < west) { west = site.Longitude; } // Save series info to metadata cache database foreach (var series in currentSeriesList) { valueCount += series.ValueCount; try { if (checkedVariables.Count != 0) { if (checkedVariables.Contains(series.Variable.Name)) { var seriesDataCart = getDataCartFromMetadata(series, waterOneFlowServiceInfo); dataCartSeriesList.Add(seriesDataCart); } } else { var seriesDataCart = getDataCartFromMetadata(series, waterOneFlowServiceInfo); dataCartSeriesList.Add(seriesDataCart); } } catch (Exception ex) { continue; } } totalDataCartSeriesList.AddRange(dataCartSeriesList); variablesListBox.Enabled = true; urlTextbox.Enabled = true; titleTextbox.Enabled = true; button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; } // Update service info serviceInfo.IsHarvested = true; serviceInfo.HarveDateTime = DateTime.Now; serviceInfo.EastLongitude = east; serviceInfo.WestLongitude = west; serviceInfo.NorthLatitude = north; serviceInfo.SouthLatitude = south; serviceInfo.SiteCount = siteList.Count; serviceInfo.ValueCount = valueCount; serviceInfo.VariableCount = waterOneFlowServiceInfo.VariableCount; SearchResult resultFeatureSet = null; if (totalDataCartSeriesList.Count > 0) { resultFeatureSet = SearchHelper.ToFeatureSetsByDataSource(totalDataCartSeriesList); } if (resultFeatureSet != null) { //We need to reproject the Search results from WGS84 to the projection of the map. var wgs84 = KnownCoordinateSystems.Geographic.World.WGS1984; foreach (var item in resultFeatureSet.ResultItems) { item.FeatureSet.Projection = wgs84; } var layers = ShowSearchResults(resultFeatureSet); Debug.WriteLine("ShowSearchResults done."); // Unselect all layers in legend (http://hydrodesktop.codeplex.com/workitem/8559) App.Map.MapFrame.GetAllLayers().ForEach(r => r.IsSelected = false); // Select first search result layer var first = layers.FirstOrDefault().GetParentItem(); if (first != null) { first.IsSelected = true; } // Unselect "Map Layers" legend item (http://hydrodesktop.codeplex.com/workitem/8458) App.Legend.RootNodes .ForEach(delegate(ILegendItem item) { if (item.LegendText == "Map Layers") { item.IsSelected = false; } }); Debug.WriteLine("Finished."); } }
public void TestValidURL() { string goodURL = @"http://his.crwr.utexas.edu/TXEvap/cuahsi_1_0.asmx"; WaterOneFlowClient client = new WaterOneFlowClient(goodURL); IList <Site> sites = client.GetSites(); }
private string FetchMetadata(List <string> serviceUrls, DoWorkEventArgs e) { var totalServices = serviceUrls.Count; var currentService = 0; var seriesCount = 0; // Keeps track of how many series were successfully processed var cacheManager = DatabaseOperations.GetCacheManager(); var errors = new StringBuilder(); // Keep track of errors and report them at the end foreach (var serviceUrl in serviceUrls) { // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress currentService++; bgwMain.ReportProgress(100 * (currentService - 1) / totalServices, "Reading database info for service " + currentService + " of " + totalServices + "..."); // Get the service info for this item var serviceInfo = DatabaseOperations.GetDataServiceFromCache(serviceUrl); // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100 * (currentService - 1) / totalServices, "Deleting old records for service " + currentService + " of " + totalServices + "..."); // Delete existing records for this service cacheManager.DeleteRecordsForService(serviceInfo, false); // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100 * (currentService - 1) / totalServices, "Connecting to service " + currentService + " of " + totalServices + "..."); // Create a WaterOneFlow Service for this URL WaterOneFlowClient waterOneFlowClient; try { waterOneFlowClient = new WaterOneFlowClient(serviceUrl); } catch (Exception ex) { // Flag the error and continue to the next service errors.AppendLine("Could not connect to service with URL: " + serviceUrl + ".\n" + ex.Message + "\n\n"); continue; } // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100 * (currentService - 1) / totalServices, "Updating database description for service " + currentService + " of " + totalServices + "..."); // Update service info in the metadata database var waterOneFlowServiceInfo = waterOneFlowClient.ServiceInfo; serviceInfo.IsHarvested = false; serviceInfo.ServiceName = waterOneFlowServiceInfo.ServiceName; serviceInfo.Version = waterOneFlowServiceInfo.Version; serviceInfo.ServiceType = waterOneFlowServiceInfo.ServiceType; serviceInfo.Protocol = waterOneFlowServiceInfo.Protocol; serviceInfo.VariableCount = (cacheManager.GetVariablesByService((int)serviceInfo.Id)).Count; cacheManager.UpdateDataRow(serviceInfo); // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100 * (currentService - 1) / totalServices, "Downloading site list for service " + currentService + " of " + totalServices + "..."); // Get all sites for this service IList <Site> siteList; try { siteList = waterOneFlowClient.GetSites(); } catch (WebException ex) { var sr = new StreamReader(ex.Response.GetResponseStream()); sr.ReadToEnd(); // Flag the error and continue to the next service errors.AppendLine("Could not get site list from service with URL: " + serviceUrl + ".\n" + ex.Message + "\n\n"); continue; } // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } var totalSteps = siteList.Count; var currentStep = 0; // Error tracking var siteErrorCount = 0; // Keeps track of how many errors we had while downloading site info for the current service var saveErrorCount = 0; // Keeps track of how many errors we had while saving site info for the current service var firstSiteError = ""; // Records the message from the first error we had while getting site info for the current service var firstSaveError = ""; // Records the message from the first error we had while saving site info for the current service // Default extent for the service. These values are designed to be overwritten as we query sites in the service double east = -180; double west = 360; double north = -90; double south = 90; int valueCount = 0; IList <Site> siteList1, siteList2; if (siteList.Count % 2 == 0) { siteList1 = (siteList as List <Site>).GetRange(0, siteList.Count / 2); siteList2 = (siteList as List <Site>).GetRange(siteList.Count / 2, siteList.Count / 2); } else { siteList1 = (siteList as List <Site>).GetRange(0, (siteList.Count / 2) + 1); siteList2 = (siteList as List <Site>).GetRange((siteList.Count / 2) + 1, siteList.Count / 2); } var thread1 = new Thread(() => ProcessSites(siteList1)); thread1.Start(); var thread2 = new Thread(() => ProcessSites(siteList2)); thread2.Start(); foreach (var site in siteList) { // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress currentStep++; bgwMain.ReportProgress(100 * currentStep / totalSteps, "Processing site " + currentStep + " of " + totalSteps + " from service " + currentService + " of " + totalServices + "..."); // Get series for this site IList <SeriesMetadata> currentSeriesList; try { currentSeriesList = waterOneFlowClient.GetSiteInfo(site.Code); } catch (WebException ex) { // Flag the error and continue to the next site siteErrorCount++; if (siteErrorCount == 1) { firstSiteError = ex.Message; } if (ex.Response != null) { var rdr = new StreamReader(ex.Response.GetResponseStream()); rdr.ReadToEnd(); } continue; } catch (Exception ex) { // Flag the error and continue to the next site siteErrorCount++; if (siteErrorCount == 1) { firstSiteError = ex.Message; } continue; } // Update service extent if (site.Latitude > north) { north = site.Latitude; } if (site.Latitude < south) { south = site.Latitude; } if (site.Longitude > east) { east = site.Longitude; } if (site.Longitude < west) { west = site.Longitude; } // Save series info to metadata cache database foreach (var series in currentSeriesList) { valueCount += series.ValueCount; // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } try { cacheManager.SaveSeries(series, serviceInfo); } catch (Exception ex) { // Flag the error and continue to the next series saveErrorCount++; if (saveErrorCount == 1) { firstSaveError = ex.Message; } continue; } // Keep track of how many series were successfully processed seriesCount++; } } // Log errors if (siteErrorCount == 1) { errors.AppendLine("Could not get site info for 1 site in service with URL: " + serviceUrl + "\n" + firstSiteError + "\n\n"); } else if (siteErrorCount > 1) { errors.AppendLine("Could not get site info for " + siteErrorCount + " sites in service with URL: " + serviceUrl + "\n" + firstSiteError + "\n\n"); } if (saveErrorCount == 1) { errors.AppendLine("Could not save site info for 1 site in service with URL: " + serviceUrl + "\n" + firstSaveError + "\n\n"); } else if (saveErrorCount > 1) { errors.AppendLine("Could not save site info for " + siteErrorCount + " sites in service with URL: " + serviceUrl + "\n" + firstSaveError + "\n\n"); } // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100 * currentService / totalServices, "Updating harvested statistics for service " + currentService + " of " + totalServices + "..."); // Update service info serviceInfo.IsHarvested = true; serviceInfo.HarveDateTime = DateTime.Now; serviceInfo.EastLongitude = east; serviceInfo.WestLongitude = west; serviceInfo.NorthLatitude = north; serviceInfo.SouthLatitude = south; serviceInfo.SiteCount = siteList.Count; serviceInfo.ValueCount = valueCount; serviceInfo.VariableCount = (cacheManager.GetVariablesByService((int)serviceInfo.Id)).Count; cacheManager.UpdateDataRow(serviceInfo); // Updates properties like harvest datetime and service extent } // Check for cancel if (bgwMain.CancellationPending) { e.Cancel = true; return("Operation cancelled"); } // Update progress bgwMain.ReportProgress(100, "Operation complete"); // Report result var message = "Download complete. " + seriesCount + " series saved to metadata cache database."; if (errors.Length > 0) { message += "\n\nSome errors occurred during the operation:\n\n" + errors; } return(message); }