/// <summary> /// /// </summary> /// <param name="DataDirectory"></param> /// <param name="Filename"></param> public UnitDataCO(string DataDirectory, string Filename) { string errMessage = ""; bool isErr = false; FDataDirectory = DataDirectory; FFilename = Filename; UniDbConnection DbCon = new UniDbConnection(SQLServer.stText, "", FDataDirectory, "", "", "") { UseFieldHeaders = true }; DbCon.Open(); TheData = Tools.LoadTable(DbCon, FFilename, ref isErr, ref errMessage); if (isErr) { throw new Exception("Error loading Rate Data. " + errMessage); } // build data arrays int arraysize = TheData.Rows.Count; FCOriverFlows = new double[arraysize]; FCOriverInFlows = new double[arraysize]; //int CodeI = 0; foreach (DataRow DR in TheData.Rows) { // Get name and code // Setup to use region or state codes string namestr = DR[FNameFieldStr].ToString(); // Decided not to use code in DataTable // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage); if (!isErr) { string rCOriverFlows = DR[FColoradoRiverFlowData].ToString(); string rCOriverInFlows = DR[FColoradoRiverInFlowData].ToString(); string ryearsstr = DR[FcurrentYearFieldStr].ToString(); double TempCO = Tools.ConvertToDouble(rCOriverFlows, ref isErr, ref errMessage); if (!isErr) { double TempCOinFlow = Tools.ConvertToDouble(rCOriverInFlows, ref isErr, ref errMessage); if (!isErr) { int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage); if (!isErr) { // OK //string aUnitName, string aUnitCode, double anAcerageUrban, double anAcerageAg, double anAcerageInd, int aYear FlowData UD = new FlowData(namestr, TempCO, TempCOinFlow, TempYear); FDataList.Add(UD); //// add to dictionary } } } } } }
public double FastInFlow(int year) { double temp = InvalidRate; FlowData TheData = FDataList.Find(delegate(FlowData FD) { return((FD.TheYear == year)); }); temp = TheData.COriverInFlows; return(temp); }