public double FastTC(string UnitName, int year) { double temp = InvalidRate; DataTemperature TheData = FTemperatureDataList.Find(delegate(DataTemperature DT) { return((DT.TheYear == year) && (DT.UnitName == UnitName)); }); if (TheData.UnitName == UnitName) { temp = TheData.Tcontemporary; } return(temp); }
// 11.02.21 das public double FastRH(string UnitName, int year, int month) { double temp = InvalidRate; DataTemperature TheData = FTemperatureDataList.Find(delegate(DataTemperature DT) { return((DT.TheYear == year) && (DT.UnitName == UnitName) && (DT.TheMonth == month)); }); if (TheData.UnitName == UnitName) { temp = TheData.RelativeHumidity; } return(temp); }
/// <summary> /// /// </summary> /// <param name="DataDirectory"></param> /// <param name="Filename"></param> public DataClassTemperature(string DataDirectory, string Filename) { string errMessage = ""; bool isErr = false; FDataDirectory = DataDirectory; FFilename = Filename; UniDbConnection DbCon = new UniDbConnection(SQLServer.stText, "", FDataDirectory, "", "", ""); DbCon.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; FTavArray = new double[arraysize]; FContemporaryArray = new double[arraysize]; FRHArray = new double[arraysize]; FYearArray = new double[arraysize]; FMonthArray = new double[arraysize]; // FSunnyDaysArray = new double[arraysize]; //int CodeI = 0; foreach (DataRow DR in TheData.Rows) { // Get name and code // EDIT QUAY 2/19/18 // Setup to use region or state codes string namestr = DR[FNameFieldStr].ToString(); string codestr = DR[FCodeFieldStr].ToString(); // END EDIT // Decided not to use code in DataTable // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage); if (!isErr) { string maximumtempstr = DR[FMaximumTempFieldStr].ToString(); string contemporarytempstr = DR[FContemporaryTempFieldStr].ToString(); string relativeHumidity = DR[FRelativeHumidityFieldStr].ToString(); string ryearsstr = DR[FcurrentYearFieldStr].ToString(); string rmonthstr = DR[FcurrentMonthFieldStr].ToString(); //string rsunnystr = DR[FsunnyDaysFieldStr].ToString(); double TempTav = Tools.ConvertToDouble(maximumtempstr, ref isErr, ref errMessage); if (!isErr) { double TempTC = Tools.ConvertToDouble(contemporarytempstr, ref isErr, ref errMessage); if (!isErr) { double TempRH = Tools.ConvertToDouble(relativeHumidity, ref isErr, ref errMessage); if (!isErr) { int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage); if (!isErr) { int TempMonth = Tools.ConvertToInt32(rmonthstr, ref isErr, ref errMessage); if (!isErr) { // int TempSunny = Tools.ConvertToInt32(rsunnystr, ref isErr, ref errMessage); // if (!isErr) // { // OK DataTemperature DT = new DataTemperature(namestr, codestr, TempTav, TempTC, TempRH, TempYear, TempMonth); //DataTemperature DT = new DataTemperature(namestr, codestr, TempTav, TempTC, TempRH, TempSunny, TempYear, TempMonth ); FTemperatureDataList.Add(DT); //// add to dictionary //} } } } } } } } }