예제 #1
0
파일: 3.cs 프로젝트: artyomkonyaev/8-term
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter the currency code (for example, usd, eur): ");
                String currencyCode = Console.ReadLine();

                var info = new RBKServise.DailyInfo();

                String currencySystemCode = GetValuteSystemCode(GetValutesTable(info), currencyCode);

                if (String.IsNullOrEmpty(currencySystemCode))
                {
                    throw new ArgumentException();
                }


                var latestDateTime = info.GetLatestDateTime();

                var valutesList = GetValutesList(info, currencySystemCode, latestDateTime, latestDateTime.AddDays(1));

                Console.WriteLine("The {0} exchange valutes against the ruble from {1:dd.mm.yyyy} to {2:dd.mm.yyyy}:", currencyCode, latestDateTime, latestDateTime.AddDays(1));

                foreach (var valute in valutesList)
                {
                    Console.WriteLine(valute);
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Can't find this valute!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter the currency code (for example, usd, eur): ");
                String currencyCode = Console.ReadLine();

                var info = new RBKServise.DailyInfo();

                String currencySystemCode = "";
                String currencyName       = "";

                foreach (DataRow i in GetValutesTable(info))
                {
                    if (i.ItemArray[6].ToString().ToUpper() == currencyCode.ToString().ToUpper())
                    {
                        currencySystemCode = i.ItemArray[0].ToString().Trim();
                        currencyName       = i.ItemArray[1].ToString().Trim();

                        break;
                    }
                }


                if (String.IsNullOrEmpty(currencySystemCode))
                {
                    throw new ArgumentException();
                }


                var latestDateTime = info.GetLatestDateTime();

                var row = info.GetCursDynamic(latestDateTime, latestDateTime.AddDays(1), currencySystemCode).Tables[0].Rows[0];

                Console.WriteLine("{0} {1} равно {2} российских рублей", row[2], currencyName, row[3]);

                var row2 = row[3].ToString().Split(new char[] { ',', '.' });

                var morpher = new Morpher.WebService();
                morpher.CredentialsValue = new Morpher.Credentials()
                {
                    Username = Const.userName, Password = Const.password
                };

                Console.WriteLine("Status: {0}", morpher.GetAccountStatus());
                Console.WriteLine();

                var currency = morpher.Propis(UInt32.Parse(row[2].ToString()), currencyName.ToLower());
                var ruble    = morpher.Propis(UInt32.Parse(row2[0]), "рубль");
                var kopeck   = morpher.Propis(UInt32.Parse(row2[1]), "копейка");

                Console.WriteLine("{0} {1} {2} {3} равны {4} {5}", ruble.n.И, ruble.unit.И, kopeck.n.И, kopeck.unit.И, currency.n.Д, currency.unit.Д);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Can't find this valute!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e);
            }
        }