public static VariableInfoType CreateVariableDescriptionType() { VariableInfoType vdt = new VariableInfoType(); VariableInfoTypeVariableCode[] var = new VariableInfoTypeVariableCode[1]; var[0] = new VariableInfoTypeVariableCode(); vdt.variableCode = var; vdt.unit = new UnitsType(); return(vdt); }
/// <summary> /// Builds a VariableInfoType which is part of the VariablesResponse; /// Columns: /// VariableID /// VariableCode (R) /// VariableVocabulary /// VariableName (r) - will display 'not specified' /// </summary> /// <param name="aRow"></param> /// <returns></returns> public static VariableInfoType CreateVariableRecord(DataRow aRow) { CoreTables.VariablesDataTable vDs = new CoreTables.VariablesDataTable(); vDs.ImportRow(aRow); vDs.AcceptChanges(); VariableInfoType vit = new VariableInfoType(); if (vDs.Rows.Count > 0) { CoreTables.VariablesRow row = (CoreTables.VariablesRow)vDs.Rows[0]; { // set attributes if (!row.IsVariableIDNull()) { vit.oid = row.VariableID.ToString(); } // add a vCode vit.variableCode = new VariableInfoTypeVariableCode[1]; VariableInfoTypeVariableCode vCode = new VariableInfoTypeVariableCode(); if (!row.IsVariableVocabularyNull()) { vCode.vocabulary = row.VariableVocabulary; vCode.@default = true; vCode.defaultSpecified = true; } vCode.Value = row.VariableCode; vit.variableCode[0] = vCode; // add name if (!row.IsVariableNameNull()) { vit.variableName = row.VariableName; } else { vit.variableName = "Not Specified."; } // value type if (!row.IsValueTypeNull()) { // SetEnumFromText(vit, row, "valueType", typeof(valueTypeEnum)); vit.valueType = row.ValueType; } //add DataType if (!row.IsDataTypeNull()) { //SetEnumFromText(vit, row, "dataType", typeof(dataTypeEnum)); vit.dataType = row.DataType; } //add General Categoy // if (!row.IsGeneralCategoryNull()) { // SetEnumFromText(vit, row, "generalCategory", typeof(generalCategoryEnum)); vit.generalCategory = row.GeneralCategory; } // Units // if just the ID exists... then it's not useful if (!row.IsVariableUnitsNameNull() || !row.IsVariableUnitsAbbreviationNull()) { UnitsType unit = new UnitsType(); if (!row.IsVariableUnitsNameNull()) { unit.unitName = row.VariableUnitsName; } if (!row.IsVariableUnitsAbbreviationNull()) { unit.unitAbbreviation = row.VariableUnitsAbbreviation; } if (!row.IsVariableUnitsIDNull()) { unit.unitCode = row.VariableUnitsID.ToString(); } vit.unit = unit; } } // add time support if (!row.IsIsRegularNull() && row.IsRegular) { vit.timeScale = new VariableInfoTypeTimeScale(); vit.timeScale.isRegular = row.IsRegular; //vit.timeScale.isRegularSpecified = true; // add time support // check to be sure we've got some vaild stuff if (!row.IsTimeSupportNull()) { vit.timeScale.timeSupport = row.TimeSupport; } if (!row.IsTimeUnitsNameNull() || !row.IsTimeUnitsAbbreviationNull() ) { vit.timeScale.unit = new UnitsType(); if (!row.IsTimeUnitsNameNull()) { vit.timeScale.unit.unitName = row.TimeUnitsName; } if (!row.IsTimeUnitsAbbreviationNull()) { vit.timeScale.unit.unitAbbreviation = row.TimeUnitsAbbreviation; } // vit.timeSupport.unit.UnitType = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum("Time", typeof(UnitsTypeEnum)); vit.timeScale.unit.unitType = "Time"; } else { // try to get info from time unitsID ///@TODO fix this //if (!row.IsTimeUnitsIDNull()) //{ // vit.timeSupport.unit = new UnitsType(); // vit.timeSupport.unit.UnitID = 104; // vit.timeSupport.unit.UnitIDSpecified = true; // vit.timeSupport.unit.UnitDescription = "day"; // vit.timeSupport.unit.UnitAbbreviation = "d"; // vit.timeSupport.unit.UnitType = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum("Time", typeof(UnitsTypeEnum)); ; //} } } } return(vit); }
public static VariableInfoType CreateVariableDescriptionType() { VariableInfoType vdt = new VariableInfoType(); VariableInfoTypeVariableCode[] var = new VariableInfoTypeVariableCode[1]; var[0] = new VariableInfoTypeVariableCode(); vdt.variableCode = var; vdt.unit = new UnitsType(); return vdt; }