string getConfigVal(DataConfigSettingCollection col, string strName) { DataConfigSetting s = col.Find(strName); if (s == null) { throw new Exception("Could not find the setting '" + strName + "'!"); } return(s.Value.ToString()); }
int getConfigValAsInt(DataConfigSettingCollection col, string strName) { DataConfigSetting s = col.Find(strName); if (s == null) { throw new Exception("Could not find the setting '" + strName + "'!"); } return((int)s.Value - 1); }
Schema loadSchema(DataConfigSettingCollection col) { string strTagCol = getConfigVal(col, "Tag Col"); string strDateCol = getConfigVal(col, "Date Col"); string strDataStartCol = getConfigVal(col, "Data Start Col"); string strDataEndCol = getConfigVal(col, "Data End Col"); string strLabelStartCol = getConfigVal(col, "Label Start Col"); string strLabelEndCol = getConfigVal(col, "Label End Col"); string strExtraStartCol = getConfigVal(col, "Extra Start Col"); string strExtraEndCol = getConfigVal(col, "Extra End Col"); int nTagCol = SchemaColumn.ConvertCol(strTagCol); int nDateCol = SchemaColumn.ConvertCol(strDateCol); int nDataStartCol = SchemaColumn.ConvertCol(strDataStartCol); int nDataEndCol = SchemaColumn.ConvertCol(strDataEndCol); int nLabelStartCol = SchemaColumn.ConvertCol(strLabelStartCol); int nLabelEndCol = SchemaColumn.ConvertCol(strLabelEndCol); int nExtraStartCol = SchemaColumn.ConvertCol(strExtraStartCol); int nExtraEndCol = SchemaColumn.ConvertCol(strExtraEndCol); SchemaColumn colS = new SchemaColumn(nTagCol, nDateCol, nDataStartCol, nDataEndCol, nLabelStartCol, nLabelEndCol, nExtraStartCol, nExtraEndCol); int nDataDescRow = getConfigValAsInt(col, "Data Desc Row"); int nLabelStartRow = getConfigValAsInt(col, "Label Start Row"); int nLabelEndRow = getConfigValAsInt(col, "Label End Row"); int nDataStartRow = getConfigValAsInt(col, "Data Start Row"); SchemaRow rowS = new SchemaRow(nDataDescRow, nLabelStartRow, nLabelEndRow, nDataStartRow); DataConfigSetting s = col.Find("Use Binary Values"); bool bBinaryValues = ((int)s.Value == 0) ? false : true; s = col.Find("Cell Size"); int nCellSize = (int)s.Value; Properties.Settings.Default.TagCol = strTagCol; Properties.Settings.Default.DateCol = strDateCol; Properties.Settings.Default.DataStartCol = strDataStartCol; Properties.Settings.Default.DataEndCol = strDataEndCol; Properties.Settings.Default.LabelStartCol = strLabelStartCol; Properties.Settings.Default.LabelEndCol = strLabelEndCol; Properties.Settings.Default.ExtraStartCol = strExtraStartCol; Properties.Settings.Default.ExtraEndCol = strExtraEndCol; Properties.Settings.Default.DataDescRow = nDataDescRow + 1; Properties.Settings.Default.LabelStartRow = nLabelStartRow + 1; Properties.Settings.Default.LabelEndRow = nLabelEndRow + 1; Properties.Settings.Default.DataStartRow = nDataStartRow + 1; Properties.Settings.Default.UseBinary = bBinaryValues; Properties.Settings.Default.CellSize = nCellSize; Properties.Settings.Default.Save(); return(new Schema(colS, rowS, bBinaryValues, nCellSize)); }