public static VariableInfoType[] getVariables(VariableParam[] vParams, VariablesDataset ds) { List <VariableInfoType> vit = new List <VariableInfoType>(); // if there are no variableParameters, return all varaibles if (vParams == null || vParams.Length == 0) { foreach (VariablesDataset.VariablesRow row in ds.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vit.Add(result); } return(vit.ToArray()); } else { foreach (VariableParam vParam in vParams) { VariableInfoType[] vars = getVariable(vParam, ds); if (vars != null) { vit.AddRange(vars); } } return(vit.ToArray()); } }
public GetVariablesOD() { // // TODO: Add constructor logic here // Variables = ODvariables.GetVariableDataSet(); }
/// <summary> /// Returns the variable associated with a variableID /// /// Note: this will only return one value... and only one value. /// </summary> /// <param name="variableID"></param> /// <param name="ds"></param> /// <returns></returns> public static VariableInfoType GetVariableByID(Nullable <int> variableID, VariablesDataset ds) { VariableInfoType[] vit; if (variableID.HasValue) { vit = GetVariablesByID(new int[] { variableID.Value }, ds); } else { vit = GetVariablesByID(new int[] {}, ds); } if (vit == null) { return(null); } else { // there should only be one, and only one value with a variable ID. if (vit.Length == 1) { return(vit[0]); } else { return(vit[0]); // TODO throw error } } }
/// <summary> /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd /// /// In SDSC code, this variable is loaded once, and is stored in an /// Application, or AppServer variable, and queries are run against the stored dataset. /// Other methods in this class are used to query the dataset. /// </summary> /// <param name="networkID"></param> /// <returns></returns> public static VariablesDataset GetVariableDataSet(int networkID) { VariablesDataset ds = new VariablesDataset(); UnitsTableAdapter unitTableAdapter = new UnitsTableAdapter(); VariablesTableAdapter varsTableAdapter = new VariablesTableAdapter(); CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); unitTableAdapter.Connection.ConnectionString = Config.ODDB(); varsTableAdapter.Connection.ConnectionString = Config.ODDB(); categoriesTableAdapter.Connection.ConnectionString = Config.ODDB(); try { unitTableAdapter.Fill(ds.Units); varsTableAdapter.Fill(ds.Variables); categoriesTableAdapter.Fill(ds.Categories); } catch (Exception e) { log.Fatal("Cannot retrieve units or variables from database" + e.Message); //+ unitTableAdapter.Connection.DataSource throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e); } return(ds); }
private static seriesCatalogType createSeriesCatalog( seriesCatalogDataSet ds, VariablesDataset vds) { if (ds.SeriesCatalog.Count > 0) { Boolean useOD; String siteServiceURL; String siteServiceName; try { useOD = Boolean.Parse(ConfigurationManager.AppSettings["UseODForValues"]); if (!useOD) { siteServiceURL = ConfigurationManager.AppSettings["externalGetValuesService"]; siteServiceName = ConfigurationManager.AppSettings["externalGetValuesName"]; } else { siteServiceURL = "http://localhost/"; siteServiceName = "OD Web Services"; } } catch { useOD = true; // should be caught earlier siteServiceURL = "http://locahost/"; siteServiceName = "Fix UseODForValues, externalGetValuesService, externalGetValuesName"; } seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog( ds.SeriesCatalog.Count, siteServiceName, // menu name (aka OD name siteServiceURL // web service location ); List <seriesCatalogTypeSeries> seriesRecords = new List <seriesCatalogTypeSeries>(); foreach (seriesCatalogDataSet.SeriesCatalogRow row in ds.SeriesCatalog.Rows) { seriesCatalogTypeSeries aRecord = row2SeriesCatalogElement( row, ds, vds); seriesRecords.Add(aRecord); } catalog.series = seriesRecords.ToArray(); return(catalog); } else { seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(0, null, // menu name (aka OD name String.Empty // web service location ); return(catalog); } }
public GetValuesOD() { // // TODO: Add constructor logic here // variableDs = ODvariables.GetVariableDataSet(); unitsDs = ODUnits.getUnitsDataset(); oDconnectionString = ConfigurationManager.ConnectionStrings["ODDB"]; }
public GetValuesOD() { // // TODO: Add constructor logic here // variableDs = ODvariables.GetVariableDataSet(); unitsDs = ODUnits.getUnitsDataset(); oDconnectionString = ConfigurationManager.ConnectionStrings["ODDB"]; }
private static seriesCatalogType createSeriesCatalog(seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { if (ds.SeriesCatalog.Count > 0) { Boolean useOD; String siteServiceURL; String siteServiceName; try { useOD = Boolean.Parse(ConfigurationManager.AppSettings["UseODForValues"]); if (!useOD) { siteServiceURL = ConfigurationManager.AppSettings["externalGetValuesService"]; siteServiceName = ConfigurationManager.AppSettings["externalGetValuesName"]; } else { siteServiceURL = "http://localhost/"; siteServiceName = "OD Web Services"; } } catch { useOD = true; // should be caught earlier siteServiceURL = "http://locahost/"; siteServiceName = "Fix UseODForValues, externalGetValuesService, externalGetValuesName"; } seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(ds.SeriesCatalog.Count, siteServiceName, // menu name (aka OD name siteServiceURL // web service location ); List<seriesCatalogTypeSeries> seriesRecords = new List<seriesCatalogTypeSeries>(); foreach (seriesCatalogDataSet.SeriesCatalogRow row in ds.SeriesCatalog.Rows) { seriesCatalogTypeSeries aRecord = row2SeriesCatalogElement( row, ds, vds, vocabularyDataset); seriesRecords.Add(aRecord); } catalog.series = seriesRecords.ToArray(); return catalog; } else { seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(0, null, // menu name (aka OD name "http://locahost/" // web service location ); return catalog; } }
public static VariableInfoType[] GetVariablesByID(int[] variableIDs, VariablesDataset ds) { List <VariableInfoType> vars = new List <VariableInfoType>(); if (variableIDs.Length == 0) { foreach (VariablesDataset.VariablesRow row in ds.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vars.Add(result); } return(vars.ToArray()); } else { StringBuilder sBuilder = new StringBuilder("("); int i = 0; foreach (int s in variableIDs) { if (i > 0) { sBuilder.Append(","); } sBuilder.Append("'"); sBuilder.Append(s.ToString()); sBuilder.Append("'"); i++; } sBuilder.Append(")"); //DataRow dr = ds.Tables["variables"].Select("variableCode = " + vCode); DataRow[] dr = ds.Tables["variables"].Select("variableID IN " + sBuilder.ToString()); if (dr.Length > 0) { foreach (DataRow row in dr) { VariableInfoType result = rowToVariableInfoType(( VariablesDataset.VariablesRow)row, ds ); vars.Add(result); } return(vars.ToArray()); } else { return(null); } } }
/// <summary> /// Gets the variables. /// used to test the variable datatable. /// </summary> /// <returns></returns> public static VariableInfoType[] GetVariables() { List <VariableInfoType> vars = new List <VariableInfoType>(); VariablesDataset ds = GetVariableDataSet(); foreach (VariablesDataset.VariablesRow row in ds.Variables) { VariableInfoType vit = rowToVariableInfoType(row, ds); vars.Add(vit); } return(vars.ToArray()); }
/// <summary> /// Add catagories for each one of the variableID's /// </summary> /// <param name="ds"></param> /// <returns></returns> public static void GetCategories(VariablesDataset ds) { if (ds != null) { CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); ds.Categories.Clear(); //foreach (VariablesRow vRow in ds.Variables.Rows) //{ // categoriesTableAdapter.FillByVariableID(ds.Categories, vRow.VariableID); //} } }
public static string GetCategoryTerm(int variableID, decimal dataValue, VariablesDataset vds) { DataRow[] dr = vds.Tables["categories"].Select("( variableID = " + variableID + ") AND (dataValue = " + dataValue + ")"); if (dr.Length == 1) { DataRow row = dr[0]; return((string)row["categoryDescription"]); } else { return(null); } }
public static seriesCatalogType[] dataSet2SeriesCatalog(seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { /* logic * for each sourceID that is associated with the site * * */ List<seriesCatalogType> catalogs = new List<seriesCatalogType>(); seriesCatalogType catalog = createSeriesCatalog(ds, vds, vocabularyDataset); if (catalog != null) catalogs.Add(catalog); return catalogs.ToArray(); }
public static seriesCatalogType[] dataSet2SeriesCatalog( seriesCatalogDataSet ds, VariablesDataset vds) { /* logic * for each sourceID that is associated with the site * * */ List <seriesCatalogType> catalogs = new List <seriesCatalogType>(); seriesCatalogType catalog = createSeriesCatalog(ds, vds); if (catalog != null) { catalogs.Add(catalog); } return(catalogs.ToArray()); }
public static units getUnitsElement(int unitsID, VariablesDataset ds) { DataRow[] dr = ds.Tables["units"].Select("unitsID = " + unitsID); if (dr.Length > 0) { VariablesDataset.UnitsRow row = (VariablesDataset.UnitsRow)dr[0]; string uID = row.UnitsID.ToString(); string unitType = String.IsNullOrEmpty(row.UnitsType) ? null : row.UnitsType; string unitAbbrev = String.IsNullOrEmpty(row.UnitsAbbreviation) ? null : row.UnitsAbbreviation; string unitName = String.IsNullOrEmpty(row.UnitsName) ? null : row.UnitsName; units u = CuahsiBuilder.CreateUnitsElement(null, uID, unitAbbrev, unitName); CuahsiBuilder.SetEnumFromText(u, row, "unitsType", typeof(UnitsTypeEnum)); return(u); } else { return(null); } }
public static UnitsType getUnitsElement(int unitsID, VariablesDataset ds) { DataRow[] dr = ds.Tables["units"].Select("unitsID = " + unitsID); if (dr.Length > 0) { VariablesDataset.UnitsRow row = (VariablesDataset.UnitsRow)dr[0]; string uID = row.UnitsID.ToString(); string unitType = row.UnitsType; string unitAbbrev = row.UnitsAbbreviation; string unitName = row.UnitsName; UnitsType u = CuahsiBuilder.CreateUnitsElement(unitType, uID, unitAbbrev, unitName); return(u); } else { return(null); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { VariablesDataset ds = new VariablesDataset(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public GetSiteInfoOD() { variablesDs = ODvariables.GetVariableDataSet(); vocabulariesDs = ODvocabularies.GetVocabularyDataset(); }
/// <summary> /// Builds a VariableInfoType from a dataset row /// the dataSet is stored in the NWISService variableDataSet. /// Find the rwo you want with the command: /// /// and convert. /// </summary> /// <param name="row"></param> /// <returns></returns> public static VariableInfoType rowToVariableInfoType(VariablesDataset.VariablesRow row, VariablesDataset ds) { units aUnit = null; aUnit = getUnitsElement(row.VariableUnitsID, ds); String vCode = !String.IsNullOrEmpty(row.VariableCode) ? row.VariableCode : null; int vid = row.VariableID; // appSetting['vocabulary'] String vocab = System.Configuration.ConfigurationManager.AppSettings["vocabulary"]; String varName = !String.IsNullOrEmpty(row.VariableName) ? row.VariableName : null; VariableInfoType vt = CuahsiBuilder.CreateVariableInfoType( vid.ToString(), vocab, vCode, varName, null, //variable description aUnit ); // add time support vt.timeSupport = new VariableInfoTypeTimeSupport(); if (row.IsRegular) { vt.timeSupport.isRegular = true; vt.timeSupport.isRegularSpecified = true; vt.timeSupport.timeInterval = Convert.ToInt32(row.TimeSupport); vt.timeSupport.timeIntervalSpecified = true; // this is different that the other "units", so populate by code units tUnit = getUnitsElement(row.TimeUnitsID, ds); if (tUnit != null) { vt.timeSupport.unit = new UnitsType(); vt.timeSupport.unit.UnitID = int.Parse(tUnit.unitsCode); vt.timeSupport.unit.UnitIDSpecified = true; vt.timeSupport.unit.UnitDescription = tUnit.Value; vt.timeSupport.unit.UnitAbbreviation = tUnit.unitsAbbreviation; if (tUnit.unitsTypeSpecified) { // if it's specified in the units, then it's a valid enum vt.timeSupport.unit.UnitType = tUnit.unitsType; vt.timeSupport.unit.UnitTypeSpecified = true; } } } else { vt.timeSupport.isRegular = false; vt.timeSupport.isRegularSpecified = true; } CuahsiBuilder.SetEnumFromText(vt, row, "valueType", typeof(valueTypeEnum)); CuahsiBuilder.SetEnumFromText(vt, row, "sampleMedium", typeof(SampleMediumEnum)); CuahsiBuilder.SetEnumFromText(vt, row, "dataType", typeof(dataTypeEnum)); CuahsiBuilder.SetEnumFromText(vt, row, "generalCategory", typeof(generalCategoryEnum)); // if (!String.IsNullOrEmpty(row.NoDataValue)) { vt.NoDataValue = row.NoDataValue.ToString(); // } return(vt); }
public static VariableInfoType[] getVariable(VariableParam vParam, VariablesDataset ds) { List <VariableInfoType> vars = new List <VariableInfoType>(); if (vParam != null) { /* need to use a data view, so the we can set a filter that does not effect the whole dataset * DataView has a ToTable method that is uses to create a new DS, and fill * a new VariablesDataset. Typed Datasets are useful ;) */ DataView view = new DataView(); view.Table = ds.Tables["Variables"]; if (vParam.IsId) { view.RowFilter = "VariableID = " + vParam.Code + " "; } else { view.RowFilter = "VariableCode = '" + vParam.Code + "' "; // list of possible options. Allowing any will break the query (aka QualityControlLevelID, etc) String[] options = { "samplemedium", "datatype", "valuetype" }; foreach (string opt in options) { if (vParam.options.ContainsKey(opt)) { if (!String.IsNullOrEmpty(vParam.options[opt])) { String rowFilter = view.RowFilter + " AND " + opt + "='" + vParam.options[opt] + "'"; view.RowFilter = rowFilter; } } } } DataTable v = view.ToTable(); if (v.Rows.Count > 0) { VariablesDataset vtemp = new VariablesDataset(); vtemp.Variables.Merge(v); foreach (VariablesDataset.VariablesRow row in vtemp.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vars.Add(result); } return(vars.ToArray()); } else { return(null); } } else { return(null); } }
public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable <W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC); beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan); } Nullable <W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC); endDateTime = new W3CDateTime(row.EndDateTime, timeSpan); } Nullable <int> valueCount = null; if (!row.IsValueCountNull()) { valueCount = row.ValueCount; } string qualityControlLevelTerm = null; int? QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; ControlledVocabularyDataset.QualityControlLevelsRow qcRow = vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value); if (qcRow != null) { qualityControlLevelTerm = qcRow.Definition; } } int?MethodID = null; if (!row.IsMethodIDNull()) { MethodID = row.MethodID; } int?SourceID = null; if (!row.IsSourceIDNull()) { SourceID = row.SourceID; } Nullable <Boolean> valueCountIsEstimated = false; /* public static seriesCatalogTypeSeries createSeriesCatalogRecord( * VariableInfoType variable, * string sampleMedium, * Nullable<W3CDateTime> beginDateTime, * Nullable<W3CDateTime> endDateTime, * Nullable<int> valueCount, * Nullable<Boolean> valueCountIsEstimated, * string dataType, * string valueType, * string generalCategory * ) */ seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time row.QualityControlLevelCode, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation, true, // include UTC Time qualityControlLevelTerm ); return(record); }
public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable<W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC); beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan); } Nullable<W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC); endDateTime = new W3CDateTime(row.EndDateTime, timeSpan); } Nullable<int> valueCount = null; if (!row.IsValueCountNull()) valueCount = row.ValueCount; string qualityControlLevelTerm = null; int? QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; ControlledVocabularyDataset.QualityControlLevelsRow qcRow = vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value); if (qcRow != null ) { qualityControlLevelTerm = qcRow.Definition; } } int? MethodID = null; if (!row.IsMethodIDNull()) MethodID = row.MethodID; int? SourceID = null; if (!row.IsSourceIDNull()) SourceID = row.SourceID; Nullable<Boolean> valueCountIsEstimated = false; /* public static seriesCatalogTypeSeries createSeriesCatalogRecord( VariableInfoType variable, string sampleMedium, Nullable<W3CDateTime> beginDateTime, Nullable<W3CDateTime> endDateTime, Nullable<int> valueCount, Nullable<Boolean> valueCountIsEstimated, string dataType, string valueType, string generalCategory ) */ seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time row.QualityControlLevelCode, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation, true, // include UTC Time qualityControlLevelTerm ); return record; }
public virtual int Update(VariablesDataset.CategoriesDataTable dataTable) { return this.Adapter.Update(dataTable); }
/// <summary> /// Returns the variable associated with a variableID /// /// Note: this will only return one value... and only one value. /// </summary> /// <param name="variableID"></param> /// <param name="ds"></param> /// <returns></returns> public static VariableInfoType GetVariableByID(Nullable<int> variableID, VariablesDataset ds) { VariableInfoType[] vit; if (variableID.HasValue) { vit = GetVariablesByID(new int[] {variableID.Value}, ds); } else { vit = GetVariablesByID(new int[] {}, ds); } if (vit == null) { return null; } else { // there should only be one, and only one value with a variable ID. if (vit.Length == 1) { return vit[0]; } else { return vit[0]; // TODO throw error } } }
public static VariableInfoType[] getVariables(VariableParam[] vParams, VariablesDataset ds) { List<VariableInfoType> vit = new List<VariableInfoType>(); // if there are no variableParameters, return all varaibles if (vParams == null || vParams.Length == 0) { foreach (VariablesDataset.VariablesRow row in ds.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vit.Add(result); } return vit.ToArray(); } else { foreach (VariableParam vParam in vParams) { VariableInfoType[] vars = getVariable(vParam, ds); if (vars != null) vit.AddRange(vars); } return vit.ToArray(); } }
public static VariableInfoType[] getVariable(VariableParam vParam, VariablesDataset ds) { List<VariableInfoType> vars = new List<VariableInfoType>(); if (vParam != null) { /* need to use a data view, so the we can set a filter that does not effect the whole dataset DataView has a ToTable method that is uses to create a new DS, and fill * a new VariablesDataset. Typed Datasets are useful ;) */ DataView view = new DataView(); view.Table = ds.Tables["Variables"]; if (vParam.IsId) { view.RowFilter = "VariableID = " + vParam.Code + " "; } else { view.RowFilter = "VariableCode = '" + vParam.Code + "' "; // list of possible options. Allowing any will break the query (aka QualityControlLevelID, etc) String[] options = {"samplemedium", "datatype", "valuetype"}; foreach (string opt in options) { if (vParam.options.ContainsKey(opt)) { if (!String.IsNullOrEmpty(vParam.options[opt])) { String rowFilter = view.RowFilter + " AND " + opt + "='" + vParam.options[opt] + "'"; view.RowFilter = rowFilter; } } } } DataTable v = view.ToTable(); if (v.Rows.Count > 0) { VariablesDataset vtemp = new VariablesDataset(); vtemp.Variables.Merge(v); foreach (VariablesDataset.VariablesRow row in vtemp.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vars.Add(result); } return vars.ToArray(); } else { return null; } } else { return null; } }
public GetVariablesOD() { Variables = ODvariables.GetVariableDataSet(); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); VariablesDataset ds = new VariablesDataset(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "VariablesDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public virtual int FillByVariableCode(VariablesDataset.VariablesDataTable dataTable, string variableCode) { this.Adapter.SelectCommand = this.CommandCollection[1]; if ((variableCode == null)) { throw new global::System.ArgumentNullException("variableCode"); } else { this.Adapter.SelectCommand.Parameters[0].Value = ((string)(variableCode)); } if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public GetVariablesOD() { Variables = ODvariables.GetVariableDataSet(); }
public virtual int FillByVariableID(VariablesDataset.CategoriesDataTable dataTable, int variableID) { this.Adapter.SelectCommand = this.CommandCollection[1]; this.Adapter.SelectCommand.Parameters[0].Value = ((int)(variableID)); if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public GetSiteInfoOD() { variablesDs = ODvariables.GetVariableDataSet(); vocabulariesDs = ODvocabularies.GetVocabularyDataset(); }
public virtual int Fill(VariablesDataset.CategoriesDataTable dataTable) { this.Adapter.SelectCommand = this.CommandCollection[0]; if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public static string GetCategoryTerm(int variableID, decimal dataValue, VariablesDataset vds) { DataRow[] dr = vds.Tables["categories"].Select("( variableID = " + variableID + ") AND (dataValue = " + dataValue +")"); if (dr.Length == 1) { DataRow row = dr[0]; return (string) row["categoryDescription"]; } else { return null; } }
/// <summary> /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd /// /// In SDSC code, this variable is loaded once, and is stored in an /// Application, or AppServer variable, and queries are run against the stored dataset. /// Other methods in this class are used to query the dataset. /// </summary> /// <param name="networkID"></param> /// <returns></returns> public static VariablesDataset GetVariableDataSet(int networkID) { VariablesDataset ds = new VariablesDataset(); UnitsTableAdapter unitTableAdapter = new UnitsTableAdapter(); VariablesTableAdapter varsTableAdapter = new VariablesTableAdapter(); CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); unitTableAdapter.Connection.ConnectionString = Config.ODDB(); varsTableAdapter.Connection.ConnectionString = Config.ODDB(); categoriesTableAdapter.Connection.ConnectionString = Config.ODDB(); try { unitTableAdapter.Fill(ds.Units); varsTableAdapter.Fill(ds.Variables); categoriesTableAdapter.Fill(ds.Categories); } catch (Exception e) { log.Fatal("Cannot retrieve units or variables from database" + e.Message); //+ unitTableAdapter.Connection.DataSource throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e); } return ds; }
/// <summary> /// Builds a VariableInfoType from a dataset row /// the dataSet is stored in the NWISService variableDataSet. /// Find the rwo you want with the command: /// /// and convert. /// </summary> /// <param name="row"></param> /// <returns></returns> public static VariableInfoType rowToVariableInfoType(VariablesDataset.VariablesRow row, VariablesDataset ds) { UnitsType aUnit = null; aUnit = getUnitsElement(row.VariableUnitsID, ds); String vCode = row.VariableCode; int vid = row.VariableID; String vocab = System.Configuration.ConfigurationManager.AppSettings["vocabulary"]; String varName = row.VariableName; VariableInfoType vt = CuahsiBuilder.CreateVariableInfoType( vid, vocab, vCode, varName, null, //variable description aUnit ); // add time support vt.timeScale = new VariableInfoTypeTimeScale(); vt.timeScale.isRegular = row.IsRegular; vt.timeScale.timeSupport = Convert.ToInt32(row.TimeSupport); vt.timeScale.timeSupportSpecified = true; // future, when ODM reports spacing //if (row.["timeSpacing"] != null) //{ // vt.timeScale.timeSpacing = Convert.ToInt32(row["timeSpacing"]); // vt.timeScale.timeSpacingSpecified = true; //} UnitsType tUnit = getUnitsElement(row.TimeUnitsID, ds); if (tUnit != null) { vt.timeScale.unit = tUnit; } vt.valueType = String.IsNullOrEmpty(row.ValueType) ? null : row.ValueType; vt.sampleMedium = String.IsNullOrEmpty(row.SampleMedium) ? null : row.SampleMedium; vt.dataType = String.IsNullOrEmpty(row.DataType) ? null : row.DataType; if (vt.dataType.Equals("Categorical", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <VariableInfoTypeCategory> categories = getCategoryElement(vid, ds); vt.categories = new List <VariableInfoTypeCategory>(categories).ToArray(); } vt.generalCategory = String.IsNullOrEmpty(row.GeneralCategory) ? null : row.GeneralCategory; // zero is default value for datatype... so don't add it if it is the default value if (!row.NoDataValue.Equals(0)) { vt.noDataValue = row.NoDataValue; vt.noDataValueSpecified = true; } vt.speciation = String.IsNullOrEmpty(row.Speciation) ? null : row.Speciation; return(vt); }
public static IEnumerable <ValueSingleVariable> dataset2ValuesList(ValuesDataSet ds, VariableParam variable, int?VariableId, VariablesDataset variablesDs) { Boolean variableIsCategorical = false; VariableInfoType variableInfoType = ODvariables.GetVariableByID(VariableId, variablesDs); if (variableInfoType != null && variableInfoType.dataType.Equals("Categorical")) { variableIsCategorical = true; } /* logic * if there is a variable that has options, then get a set of datarows * using a select clause * use an enumerator, since it is generic * */ IEnumerator dataValuesEnumerator; // = ds.DataValues.GetEnumerator(); ValuesDataSet.DataValuesRow[] dvRows; // if we find options, we need to use this. String select = OdValuesCommon.CreateValuesWhereClause(variable, VariableId); if (select.Length > 0) { dvRows = (ValuesDataSet.DataValuesRow[])ds.DataValues.Select(select.ToString()); dataValuesEnumerator = dvRows.GetEnumerator(); } else { dataValuesEnumerator = ds.DataValues.GetEnumerator(); } while (dataValuesEnumerator.MoveNext()) { ValuesDataSet.DataValuesRow aRow = (ValuesDataSet.DataValuesRow)dataValuesEnumerator.Current; ValueSingleVariable tsTypeValue = new ValueSingleVariable(); Boolean goodValue = false; try { tsTypeValue.dateTime = Convert.ToDateTime(aRow.DateTime); DateTime temprealdate; TimeSpan zone = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); Double offset = Convert.ToDouble(aRow.UTCOffset); if (zone.TotalHours.Equals(offset)) { temprealdate = DateTime.SpecifyKind(Convert.ToDateTime(aRow.DateTime), DateTimeKind.Local); } else { temprealdate = DateTime.SpecifyKind(Convert.ToDateTime(aRow.DateTime), DateTimeKind.Utc); temprealdate = temprealdate.AddHours(offset); } temprealdate = Convert.ToDateTime(aRow.DateTime); tsTypeValue.dateTime = temprealdate; tsTypeValue.dateTimeUTC = aRow.DateTimeUTC; tsTypeValue.dateTimeUTCSpecified = true; tsTypeValue.timeOffset = OffsetDoubleToHoursMinutesString(aRow.UTCOffset); //tsTypeValue.dateTime = new DateTimeOffset(temprealdate); //tsTypeValue.dateTimeSpecified = true; if (string.IsNullOrEmpty(aRow.Value.ToString())) { continue; } else { tsTypeValue.Value = Convert.ToDecimal(aRow.Value); } try { tsTypeValue.censorCode = aRow.CensorCode; if (!aRow.IsOffsetTypeIDNull()) { //tsTypeValue.offsetTypeID = aRow.OffsetTypeID.ToString(); tsTypeValue.offsetTypeCode = aRow.OffsetTypeID.ToString(); // HIS-97 moved to OffsetUnitsType // ValuesDataSet.OffsetTypesRow off = // ds.OffsetTypes.FindByOffsetTypeID(aRow.OffsetTypeID); // ValuesDataSet.UnitsRow offUnit = ds.Units.FindByUnitsID(off.OffsetUnitsID); // tsTypeValue.offsetUnitsCode = offUnit.UnitsID.ToString(); // tsTypeValue.offsetUnitsAbbreviation = offUnit.UnitsAbbreviation; } // offset value may be separate from the units... anticpating changes for USGS if (!aRow.IsOffsetValueNull()) { tsTypeValue.offsetValue = aRow.OffsetValue; tsTypeValue.offsetValueSpecified = true; } ValuesDataSet.MethodsRow meth = ds.Methods.FindByMethodID(aRow.MethodID); // tsTypeValue.methodID = aRow.MethodID.ToString(); tsTypeValue.methodCode = aRow.MethodID.ToString(); // qualifiers if (!aRow.IsQualifierIDNull()) { ValuesDataSet.QualifiersRow qual = ds.Qualifiers.FindByQualifierID(aRow.QualifierID); if (qual != null) { tsTypeValue.qualifiers = qual.QualifierCode; } } // quality control level ValuesDataSet.QualityControlLevelsRow qcl = ds.QualityControlLevels.FindByQualityControlLevelID(aRow.QualityControlLevelID); string qlName = qcl.Definition.Replace(" ", ""); tsTypeValue.qualityControlLevelCode = qcl.QualityControlLevelCode; //if (!String.IsNullOrEmpty(qlName)) //{ // tsTypeValue.qualityControlLevel = qlName; //} // tsTypeValue.sourceID = aRow.SourceID.ToString(); tsTypeValue.sourceCode = aRow.SourceID.ToString(); if (!aRow.IsSampleIDNull()) { //tsTypeValue.sampleID = aRow.SampleID.ToString(); ValuesDataSet.SamplesRow lsc = ds.Samples.FindBySampleID(aRow.SampleID); tsTypeValue.labSampleCode = lsc.LabSampleCode; } // categorical if (variableIsCategorical && VariableId.HasValue) { tsTypeValue.codedVocabularyTerm = ODvariables.GetCategoryTerm(VariableId.Value, tsTypeValue.Value, variablesDs); if (!String.IsNullOrEmpty(tsTypeValue.codedVocabularyTerm)) { tsTypeValue.codedVocabulary = true; } tsTypeValue.codedVocabularySpecified = true; } } catch (Exception e) { log.Debug("Error generating a value " + e.Message); // non fatal exceptions } goodValue = true; } catch (Exception e) { goodValue = false; // If there is an error, we do not add it. } if (goodValue) { yield return(tsTypeValue); } } }
public static IEnumerable <VariableInfoTypeCategory> getCategoryElement(int variableID, VariablesDataset ds) { DataRow[] dr = ds.Tables["categories"].Select("variableID = " + variableID); foreach (VariablesDataset.CategoriesRow row in dr) { VariableInfoTypeCategory category = new VariableInfoTypeCategory(); category.dataValue = Convert.ToDecimal(row.DataValue); category.description = row.CategoryDescription; yield return(category); } }
public static seriesCatalogTypeSeries row2SeriesCatalogElement( seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable <W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { beginDateTime = new W3CDateTime(row.BeginDateTime); } Nullable <W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { endDateTime = new W3CDateTime(row.EndDateTime); } Nullable <int> valueCount = null; if (!row.IsValueCountNull()) { valueCount = row.ValueCount; } int?QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; } int?MethodID = null; if (!row.IsMethodIDNull()) { MethodID = row.MethodID; } int?SourceID = null; if (!row.IsSourceIDNull()) { SourceID = row.SourceID; } Nullable <Boolean> valueCountIsEstimated = false; seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time null, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation); return(record); }
public static VariableInfoType[] GetVariablesByID(int[] variableIDs, VariablesDataset ds) { List<VariableInfoType> vars = new List<VariableInfoType>(); if (variableIDs.Length == 0) { foreach (VariablesDataset.VariablesRow row in ds.Variables.Rows) { VariableInfoType result = rowToVariableInfoType(row, ds ); vars.Add(result); } return vars.ToArray(); } else { StringBuilder sBuilder = new StringBuilder("("); int i = 0; foreach (int s in variableIDs) { if (i > 0) sBuilder.Append(","); sBuilder.Append("'"); sBuilder.Append(s.ToString()); sBuilder.Append("'"); i++; } sBuilder.Append(")"); DataRow[] dr = ds.Tables["variables"].Select("variableID IN " + sBuilder.ToString()); if (dr.Length > 0) { foreach (DataRow row in dr) { VariableInfoType result = rowToVariableInfoType(( VariablesDataset.VariablesRow) row, ds ); vars.Add(result); } return vars.ToArray(); } else { return null; } } }
public virtual int Update(VariablesDataset dataSet) { return this.Adapter.Update(dataSet, "Categories"); }
public static IEnumerable<ValueSingleVariable> dataset2ValuesList(ValuesDataSet ds, VariableParam variable, int? VariableId, VariablesDataset variablesDs) { Boolean variableIsCategorical = false; VariableInfoType variableInfoType = ODvariables.GetVariableByID(VariableId, variablesDs); if (variableInfoType != null && variableInfoType.dataType.Equals("Categorical")) { variableIsCategorical = true; } /* logic * if there is a variable that has options, then get a set of datarows * using a select clause * use an enumerator, since it is generic * */ IEnumerator dataValuesEnumerator; // = ds.DataValues.GetEnumerator(); ValuesDataSet.DataValuesRow[] dvRows; // if we find options, we need to use this. String select = OdValuesCommon.CreateValuesWhereClause(variable, VariableId); if (select.Length > 0) { dvRows = (ValuesDataSet.DataValuesRow[]) ds.DataValues.Select(select.ToString()); dataValuesEnumerator = dvRows.GetEnumerator(); } else { dataValuesEnumerator = ds.DataValues.GetEnumerator(); } while (dataValuesEnumerator.MoveNext()) { ValuesDataSet.DataValuesRow aRow = (ValuesDataSet.DataValuesRow) dataValuesEnumerator.Current; ValueSingleVariable tsTypeValue = new ValueSingleVariable(); Boolean goodValue = false; try { tsTypeValue.dateTime = Convert.ToDateTime(aRow.DateTime); DateTime temprealdate; TimeSpan zone = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); Double offset = Convert.ToDouble(aRow.UTCOffset); if (zone.TotalHours.Equals(offset)) { temprealdate = DateTime.SpecifyKind(Convert.ToDateTime(aRow.DateTime), DateTimeKind.Local); } else { temprealdate = DateTime.SpecifyKind(Convert.ToDateTime(aRow.DateTime), DateTimeKind.Utc); temprealdate = temprealdate.AddHours(offset); } temprealdate = Convert.ToDateTime(aRow.DateTime); tsTypeValue.dateTime = temprealdate; tsTypeValue.dateTimeUTC = aRow.DateTimeUTC; tsTypeValue.dateTimeUTCSpecified = true; tsTypeValue.timeOffset = OffsetDoubleToHoursMinutesString(aRow.UTCOffset); //tsTypeValue.dateTime = new DateTimeOffset(temprealdate); //tsTypeValue.dateTimeSpecified = true; if (string.IsNullOrEmpty(aRow.Value.ToString())) continue; else tsTypeValue.Value = Convert.ToDecimal(aRow.Value); try { tsTypeValue.censorCode = aRow.CensorCode; if (!aRow.IsOffsetTypeIDNull()) { //tsTypeValue.offsetTypeID = aRow.OffsetTypeID.ToString(); tsTypeValue.offsetTypeCode = aRow.OffsetTypeID.ToString(); // HIS-97 moved to OffsetUnitsType // ValuesDataSet.OffsetTypesRow off = // ds.OffsetTypes.FindByOffsetTypeID(aRow.OffsetTypeID); // ValuesDataSet.UnitsRow offUnit = ds.Units.FindByUnitsID(off.OffsetUnitsID); // tsTypeValue.offsetUnitsCode = offUnit.UnitsID.ToString(); // tsTypeValue.offsetUnitsAbbreviation = offUnit.UnitsAbbreviation; } // offset value may be separate from the units... anticpating changes for USGS if (!aRow.IsOffsetValueNull()) { tsTypeValue.offsetValue = aRow.OffsetValue; tsTypeValue.offsetValueSpecified = true; } ValuesDataSet.MethodsRow meth = ds.Methods.FindByMethodID(aRow.MethodID); // tsTypeValue.methodID = aRow.MethodID.ToString(); tsTypeValue.methodCode = aRow.MethodID.ToString(); // qualifiers if (!aRow.IsQualifierIDNull()) { ValuesDataSet.QualifiersRow qual = ds.Qualifiers.FindByQualifierID(aRow.QualifierID); if (qual != null) { tsTypeValue.qualifiers = qual.QualifierCode; } } // quality control level ValuesDataSet.QualityControlLevelsRow qcl = ds.QualityControlLevels.FindByQualityControlLevelID(aRow.QualityControlLevelID); string qlName = qcl.Definition.Replace(" ", ""); tsTypeValue.qualityControlLevelCode = qcl.QualityControlLevelCode; //if (!String.IsNullOrEmpty(qlName)) //{ // tsTypeValue.qualityControlLevel = qlName; //} // tsTypeValue.sourceID = aRow.SourceID.ToString(); tsTypeValue.sourceCode = aRow.SourceID.ToString(); if (!aRow.IsSampleIDNull()) { //tsTypeValue.sampleID = aRow.SampleID.ToString(); ValuesDataSet.SamplesRow lsc = ds.Samples.FindBySampleID(aRow.SampleID); tsTypeValue.labSampleCode = lsc.LabSampleCode; } // categorical if (variableIsCategorical && VariableId.HasValue) { tsTypeValue.codedVocabularyTerm = ODvariables.GetCategoryTerm(VariableId.Value, tsTypeValue.Value, variablesDs); if (!String.IsNullOrEmpty(tsTypeValue.codedVocabularyTerm) ) { tsTypeValue.codedVocabulary = true; } tsTypeValue.codedVocabularySpecified = true; } } catch (Exception e) { log.Debug("Error generating a value " + e.Message); // non fatal exceptions } goodValue = true; } catch (Exception e) { goodValue = false; // If there is an error, we do not add it. } if (goodValue) { yield return tsTypeValue; } } }
/// <summary> /// Builds a VariableInfoType from a dataset row /// the dataSet is stored in the NWISService variableDataSet. /// Find the rwo you want with the command: /// /// and convert. /// </summary> /// <param name="row"></param> /// <returns></returns> public static VariableInfoType rowToVariableInfoType(VariablesDataset.VariablesRow row, VariablesDataset ds) { UnitsType aUnit = null; aUnit = getUnitsElement(row.VariableUnitsID, ds); String vCode = row.VariableCode; int vid = row.VariableID; String vocab = System.Configuration.ConfigurationManager.AppSettings["vocabulary"]; String varName = row.VariableName; VariableInfoType vt = CuahsiBuilder.CreateVariableInfoType( vid, vocab, vCode, varName, null, //variable description aUnit ); // add time support vt.timeScale = new VariableInfoTypeTimeScale(); vt.timeScale.isRegular = row.IsRegular; vt.timeScale.timeSupport = Convert.ToInt32(row.TimeSupport); vt.timeScale.timeSupportSpecified = true; // future, when ODM reports spacing //if (row.["timeSpacing"] != null) //{ // vt.timeScale.timeSpacing = Convert.ToInt32(row["timeSpacing"]); // vt.timeScale.timeSpacingSpecified = true; //} UnitsType tUnit = getUnitsElement(row.TimeUnitsID, ds); if (tUnit != null) { vt.timeScale.unit = tUnit; } vt.valueType = String.IsNullOrEmpty(row.ValueType) ? null : row.ValueType; vt.sampleMedium = String.IsNullOrEmpty(row.SampleMedium) ? null : row.SampleMedium; vt.dataType = String.IsNullOrEmpty(row.DataType) ? null : row.DataType; if (vt.dataType.Equals("Categorical",StringComparison.InvariantCultureIgnoreCase)) { IEnumerable<VariableInfoTypeCategory> categories = getCategoryElement(vid, ds); vt.categories = new List<VariableInfoTypeCategory>(categories).ToArray(); } vt.generalCategory = String.IsNullOrEmpty(row.GeneralCategory) ? null : row.GeneralCategory; // zero is default value for datatype... so don't add it if it is the default value if (!row.NoDataValue.Equals(0)) { vt.noDataValue = row.NoDataValue; vt.noDataValueSpecified = true; } vt.speciation = String.IsNullOrEmpty(row.Speciation) ? null : row.Speciation; return vt; }
public static UnitsType getUnitsElement(int unitsID, VariablesDataset ds) { DataRow[] dr = ds.Tables["units"].Select("unitsID = " + unitsID); if (dr.Length > 0) { VariablesDataset.UnitsRow row = (VariablesDataset.UnitsRow) dr[0]; string uID = row.UnitsID.ToString(); string unitType = row.UnitsType; string unitAbbrev = row.UnitsAbbreviation; string unitName = row.UnitsName; UnitsType u = CuahsiBuilder.CreateUnitsElement(unitType, uID, unitAbbrev, unitName); return u; } else { return null; } }
public static IEnumerable<VariableInfoTypeCategory> getCategoryElement(int variableID, VariablesDataset ds) { DataRow[] dr = ds.Tables["categories"].Select("variableID = " + variableID); foreach (VariablesDataset.CategoriesRow row in dr) { VariableInfoTypeCategory category = new VariableInfoTypeCategory(); category.dataValue = Convert.ToDecimal(row.DataValue); category.description = row.CategoryDescription; yield return category; } }
public static void addCategoricalInformation(List <ValueSingleVariable> variables, int variableID, VariablesDataset vds) { foreach (ValueSingleVariable variable in variables) { string selectquery = String.Format("VariableID = {0} AND DataValue = {1}", variableID.ToString(), variable.Value); DataRow[] rows = vds.Categories.Select(selectquery); if (rows.Length > 0) { variable.codedVocabulary = true; variable.codedVocabularySpecified = true; variable.codedVocabularyTerm = (string)rows[0]["CategoryDescription"]; } } }
public GetSiteInfoOD() { variablesDs = ODvariables.GetVariableDataSet(); }