//Gets the rates table based on Base currency
 //param string currencyList - list of comma separated Currencies to be included in the table. All currencies by default
 //returns IEnumerable<Rates> containing desired currencies and rates
 //Throws ApplicationException if currency is not in currency list
 public IEnumerable<Rates> GetRatesTable(string currencyList = null)
 {
     List<Rates> result = new List<Rates>();
     Rates tempRate = new Rates();
     if (currencyList == null)
     {
         foreach (string currency in this.exchangeRates.Keys)
         {
             tempRate.Currency = currency;
             tempRate.Rate = String.Format("{0:0.0000}", this.exchangeRates[currency]);
             result.Add(tempRate);
         }
     }
     else
     {
         currencyList = currencyList.ToUpper();
         char[] delimiter = {',', ' ', ';'}; //just in case some one don't know what comma separated is
         string[] list = currencyList.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
         foreach (string currency in list)
         {
             currency.Trim();
             CheckCurrency(currency);
             tempRate.Currency = currency;
             tempRate.Rate = String.Format("{0:0.0000}", this.exchangeRates[currency]);
             result.Add(tempRate);
         }
     }
     return result;
 }
예제 #2
0
 public TrendPridictor(Rates rates, string baseCurrency, string targetCurrency)
 {
     this.rates     = rates;
     BaseCurrency   = baseCurrency;
     TargetCurrency = targetCurrency;
 }
예제 #3
0
        public void ReadFile(DateTime date)
        {
            string[] lines = System.IO.File.ReadAllLines(@"D:\Учебная\13НС-1СПр\02-UserDirs\VladychenkoA\ADO.NET KURS\InsertRates\данные\30072010.txt", Encoding.GetEncoding(1251));
            int      r     = 0;
            int      count = 1;

            foreach (string line in lines)
            {
                Rates  rates = new Rates();
                string temp  = null;
                rates._date     = date.Date;
                rates._currency = count;
                count          += 1;
                for (int i = 0; i < line.Length; i++)
                {
                    //if(i > 18 && line[i].ToString().ToLower() != " ")
                    //{

                    //}
                    temp += line[i];
                    if (i > 1 && line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
                    {
                        r = i;
                        break;
                    }
                    rates._name = temp;
                }
                temp = null;
                for (int i = r + 1; i < line.Length; i++)
                {
                    temp += line[i];
                    if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
                    {
                        r = i;
                        break;
                    }
                    rates._price = temp;
                }
                temp = null;
                for (int i = r + 1; i < line.Length; i++)
                {
                    temp += line[i];
                    if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
                    {
                        r = i;
                        break;
                    }
                    rates._absoluteChange = temp;
                }
                temp = null;
                for (int i = r + 1; i < line.Length; i++)
                {
                    temp += line[i];
                    if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
                    {
                        r = i;
                        break;
                    }
                    rates._relativeChange = temp;
                }
                ArrayListRates.Add(rates);
            }
        }
예제 #4
0
 public void ReadFile(DateTime date)
 {
     string[] lines = System.IO.File.ReadAllLines(@"D:\Учебная\13НС-1СПр\02-UserDirs\VladychenkoA\ADO.NET KURS\InsertRates\данные\30072010.txt", Encoding.GetEncoding(1251));
     int r = 0;
     int count = 1;
     foreach (string line in lines)
     {
         Rates rates = new Rates();
         string temp = null;
         rates._date = date.Date;
         rates._currency = count;
         count += 1;
         for (int i =  0 ; i < line.Length; i++)
         {
             //if(i > 18 && line[i].ToString().ToLower() != " ")
             //{
                 
             //}
             temp += line[i];
             if(i > 1 && line[i-1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
             {
                 r = i;
                 break;
             }
             rates._name = temp;
         }
         temp = null;
         for (int i = r + 1; i < line.Length; i++)
         {
             temp += line[i];
             if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
             {
                 r = i;
                 break;
             }
             rates._price = temp;
         }
         temp = null;
         for (int i = r + 1; i < line.Length; i++)
         {
             temp += line[i];
             if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
             {
                 r = i;
                 break;
             }
             rates._absoluteChange = temp;
         }
         temp = null;
         for (int i = r + 1; i < line.Length; i++)
         {
             temp += line[i];
             if (line[i - 1].ToString().ToLower() == " " && line[i].ToString().ToLower() == " ")
             {
                 r = i;
                 break;
             }
             rates._relativeChange = temp;
         }
         ArrayListRates.Add(rates);
     }
 }