예제 #1
0
        static void Main(string[] args)
        {
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 3600000; // 1 hour
            aTimer.Interval = 30000;   // 1 hour
            aTimer.Enabled  = true;
            Console.WriteLine("=======================================");
            Console.WriteLine("|");
            Console.WriteLine("| Start :" + DateTime.Now);
            Console.WriteLine("| My currency system updating is running...");
            Console.WriteLine("|");
            Console.WriteLine("|");
            Console.WriteLine("| Press \'q\' to quit.");
            Console.WriteLine("|");
            Console.WriteLine("=======================================");
            FixerIO.GenerateRate();
            while (Console.Read() != 'q')
            {
                ;
            }


            //Console.WriteLine(r);
            //Rate rate = JsonConvert.DeserializeObject<Rate>(r);


            Console.ReadKey();
        }
예제 #2
0
        public void CurrenciyleriCekVeAyristir()
        {
            try
            {
                string jsontext = new WebClient().DownloadString(url);

                fixSample = JsonConvert.DeserializeObject <FixerIO>(jsontext);
            }
            catch
            {
                Console.WriteLine(" döviz verisi bulunmadi.");
            }
        }
예제 #3
0
        // GET: api/api?from=USD&to=EUR&amount=111
        public string Get(string from, string to, int amount)
        {
            Doviz   d   = new Doviz();
            FixerIO fix = new FixerIO
            {
                url = "http://api.fixer.io/latest?base=" + from
            };

            fix.CurrenciyleriCekVeAyristir();
            d.currency = to;
            double miktar = fix.rates[to];

            d.amount = miktar;
            string json = JsonConvert.SerializeObject(d);

            return(json);
        }
예제 #4
0
 public static void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     FixerIO.GenerateRate();
     //Console.WriteLine(DateTime.Now.ToLocalTime());
 }