Beispiel #1
0
        //FDataList = new List<ICSDataStruct>();
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public UnitData_ICS(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;

            //
            FRC_ICS = new double[arraysize];

            foreach (DataRow DR in TheData.Rows)
            {
                // Get name and code
                // Setup to use region or state codes
                string statestr = DR[FSCFieldStr].ToString();
                string namestr  = DR[FNameFieldStr].ToString();
                string codestr  = DR[FCodeFieldStr].ToString();
                // Decided not to use code in DataTable
                // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage);

                if (!isErr)
                {
                    string rICS      = DR[FICSFieldStr].ToString();
                    string ryearsstr = DR[FcurrentYearFieldStr].ToString();
                    string rstatestr = DR[FScodeFieldStr].ToString();
                    //
                    int TempSC = Tools.ConvertToInt32(rstatestr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempICS = Tools.ConvertToDouble(rICS, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                // OK
                                ICSDataStruct ICS = new ICSDataStruct(TempSC, namestr, codestr, TempYear, TempICS);
                                FDataList.Add(ICS);
                                //// add to dictionary
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        //
        public double Fast_ICS(int Code, int year)
        {
            double        temp    = InvalidData;
            ICSDataStruct TheData = FDataList.Find(delegate(ICSDataStruct RC)
            {
                return(RC.TheYear == year);
            });
            ICSDataStruct TheCode = FDataList.Find(delegate(ICSDataStruct TC) {
                return(TC.Code == Code);
            });

            temp = TheData.ICS;
            return(temp);
        }