Esempio n. 1
0
        //



        /// <summary>
        ///
        /// </summary>
        /// <param name="UnitCode"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public double FastRainFall(int UnitCode, int year)
        {
            double temp = InvalidRate;
            DataStructRainWater TheData = FRainFallDataList.Find(delegate(DataStructRainWater RW)
            {
                return((RW.Year == year) && (RW.RegionCode == UnitCode));
            });

            if (TheData.RegionCode == UnitCode)
            {
                temp = TheData.Rainfall;
            }
            return(temp);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public DataClassRainFall(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;

            FRainFallArray = new double[arraysize];
            FYearArray     = new double[arraysize];
            //

            int i = 0;

            //
            //int CodeI = 0;
            foreach (DataRow DR in TheData.Rows)
            {
                i += 1;

                // Get name and code
                // EDIT QUAY 2/19/18
                // Setup to use region or state codes
                string namestr  = DR[FNameFieldStr].ToString();
                string codestr  = DR[FScodeFieldStr].ToString();
                string Rcodestr = DR[FRcodeFieldStr].ToString();
                // END EDIT

                // Decided not to use code in DataTable
                // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage);

                if (!isErr)
                {
                    string rrainfallstr = DR[FRainFallFieldStr].ToString();
                    string ryearsstr    = DR[FcurrentYearFieldStr].ToString();

                    int StateC = Tools.ConvertToInt32(codestr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        int RegionC = Tools.ConvertToInt32(Rcodestr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                if (i == 1)
                                {
                                    FirstYear = TempYear;
                                }
                                Tyear = TempYear;
                                double TempRain = Tools.ConvertToInt32(rrainfallstr, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    // OK
                                    DataStructRainWater RW = new DataStructRainWater(StateC, RegionC, namestr, TempYear, TempRain);
                                    FRainFallDataList.Add(RW);
                                }
                            }
                        }
                    }
                }

                DataTableRows = i;
            }
            LastYear = Tyear;
        }