Web Sitemiz için Döviz Kuru

16 Mart Pazartesi, 2009 | Asp.net Xml /*Yorumlar (0)*/

Daha önceki "Web Sitemiz .." başlıklı bir kaç yazımda Web Part' lar hazırlamıştım.
Yeni bir kontrol daha; Tcmb günlük döviz bilgileri.

Uygulamayı indirmek için tıklayın.

Kullanım kolaylığı için 2 adet özellik eklendi. design

Bu tip uygulamaları yaparken kaynağın kopyası üzerinde çalışmayı tercih ederim. Hız açısından.

public static string[] dovizBilgisi(DovizTipleri tip)
{
    if (HttpContext.Current.Cache[tip.ToString()] == null)
    {
        XmlDocument xDoc = new XmlDocument();
        // local -> test
        xDoc.Load(HttpContext.Current.Server.MapPath("App_Data/doviz.xml"));
        // online -> application
        // xDoc.Load("http://www.tcmb.gov.tr/kurlar/today.xml");
        string[] doviz = {
            xDoc.SelectSingleNode(string.Format(
                                    "Tarih_Date/Currency[@Kod='{0}']/ForexBuying",
                                    tip.ToString())).InnerText.Replace('.', ','),
            xDoc.SelectSingleNode(string.Format(
                                    "Tarih_Date/Currency[@Kod='{0}']/ForexSelling",
                                    tip.ToString())).InnerText.Replace('.', ',')
                            };
        HttpContext.Current.Cache.Insert(
            tip.ToString(),
            doviz,
            null,
            DateTime.Now.AddHours(2),
            TimeSpan.Zero);
    }
    return (string[])HttpContext.Current.Cache[tip.ToString()];
}

Döviz Kontrol

Yorum Yaz

Ad

Email (sahte adresli yorumlar silinir.)

Yorum