/// <summary> /// Method to generate a list of qualifiers in a ValuesDataSet /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <returns></returns> public static List <qualifier> datasetQualifiers(ValuesDataSet ds) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ List <qualifier> qualifiers = new List <qualifier>(); try { DataView qview = new DataView(ds.DataValues); qview.RowFilter = "QualifierID is not Null"; DataTable qids = qview.ToTable("qualifiers", true, new string[] { "QualifierID" }); foreach (DataRow q in qids.Rows) { try { Object qid = q["QualifierID"]; ValuesDataSet.QualifiersRow qual = ds.Qualifiers.FindByQualifierID((int)qid); if (qual != null) { qualifier qt = new qualifier(); qt.qualifierID = qual.QualifierID.ToString(); if (!qual.IsQualifierCodeNull()) { qt.qualifierCode = qual.QualifierCode; } if (!String.IsNullOrEmpty(qual.QualifierDescription)) { qt.Value = qual.QualifierDescription; } qualifiers.Add(qt); } } catch (Exception e) { log.Error("Error generating a qualifier " + q.ToString() + e.Message); } } return(qualifiers); } catch (Exception e) { log.Error("Error generating a qualifiers " + e.Message); // non fatal exceptions return(null); } }
public static TsValuesSingleVariableType CreateTimeSeriesValuesElement( //TimeSeriesResponseType result, VariableParam vp, string aURL, Boolean provisional) { // add the URL to be requested to the result //result.queryInfo.queryURL = aURL; // download the iformation String resultFile = GetHTTPFile(aURL, 10); //result.timeSeries.values = new TsValuesSingleVariableType(); //result.TimeSeries.Values.valueUnits = units; // this needs to be done earlier TsValuesSingleVariableType values = new TsValuesSingleVariableType(); DataTable aTable = NWISDelimitedTextParser.ParseFileIntoDT(resultFile); // dwv add code to get the code, and use that to find the correct columns int time = 2; // present location of time column // String code = result.timeSeries.variable.variableCode[0].Value; String code = vp.Code; String stat = null; try { stat = option2UsgsStatCode(vp); } catch (Exception ex) { log.Debug("option2UsgsStatCode() failed :" + ex.ToString()); stat = null; } int aValue; int qualifier; //if (result.timeSeries.variable.options != null) //{ // stat = result.timeSeries.variable.options[0].Value; //} try { aValue = getVarColumn(aTable, code, stat); qualifier = getVarQualifiersColumn(aTable, code, stat); } catch (WaterOneFlowException we) { /* even I'm confused here... * parsing column names gives an error * * This is post data rereiveal, so * if we do not find the correct column, then throw an error * */ string mess = "BAD COLUMN HEADER FROM USGS URL: " + aURL; // need to insert the URL in the exception if (string.IsNullOrEmpty(stat)) { log.Error("Bad Column varCode:" + code + " stat_cd:NULL " + mess, we); throw new WaterOneFlowSourceException("Improper COLUMN HEADER FROM USGS URL: " + aURL, we); //+"' variable '"+code+"' not found at site."); } else { log.Error("Bad Column varCode:" + code + " Stat_cd: " + stat + " " + mess, we); throw new WaterOneFlowSourceException("Improper COLUMN HEADER FROM USGS URL: " + aURL, we); //+ "' variable '"+code+"' statistic '"+stat +"' not found at site. Try not using the statistic", we); } } List <ValueSingleVariable> tsTypeList = new List <ValueSingleVariable>(); TimeSeriesFromRDB(aTable, time, aValue, qualifier, tsTypeList, provisional); values.count = tsTypeList.Count.ToString(); values.value = tsTypeList.ToArray(); if (provisional) { List <qualifier> quals = new List <qualifier>(); if (values.qualifier != null) { quals = new List <qualifier>(values.qualifier); } // this code is take from the daily values remark code // unit values just says provisional data in the header qualifier qual = new qualifier(); qual.qualifierCode = "P"; qual.network = "USGS"; qual.vocabulary = "dv_rmk_cd"; qual.Value = "Provisional data subject to revision."; quals.Add(qual); values.qualifier = quals.ToArray(); } return(values); }
return((false, item).Match(qualifier, action));