Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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];
            FYearArray         = 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 ryearsstr           = DR[FcurrentYearFieldStr].ToString();

                    double TempTav = Tools.ConvertToDouble(maximumtempstr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempTC = Tools.ConvertToDouble(contemporarytempstr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                // OK
                                DataTemperature DT = new DataTemperature(namestr, codestr, TempTav, TempTC, TempYear);
                                FTemperatureDataList.Add(DT);
                                //// add to dictionary
                            }
                        }
                    }
                }
            }
        }