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(); }
public void CurrenciyleriCekVeAyristir() { try { string jsontext = new WebClient().DownloadString(url); fixSample = JsonConvert.DeserializeObject <FixerIO>(jsontext); } catch { Console.WriteLine(" döviz verisi bulunmadi."); } }
// 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); }
public static void OnTimedEvent(object source, ElapsedEventArgs e) { FixerIO.GenerateRate(); //Console.WriteLine(DateTime.Now.ToLocalTime()); }