Exemple #1
0
        static public void GetLiveRates()
        {
            String PN = AppLogic.AppConfig("Localization.CurrencyFeedXmlPackage");

            if (PN.Length != 0)
            {
                try
                {
                    using (XmlPackage2 p = new XmlPackage2(PN))
                    {
                        m_LastRatesResponseXml    = p.XmlDataDocument.InnerXml;
                        m_LastRatesTransformedXml = p.TransformString();
                        if (m_LastRatesTransformedXml.Length != 0)
                        {
                            // update master db table:
                            XmlDocument d = new XmlDocument();
                            d.LoadXml(m_LastRatesTransformedXml);
                            foreach (XmlNode n in d.SelectNodes("//currency"))
                            {
                                String CurrencyCode = XmlCommon.XmlAttribute(n, "code");
                                String rate         = XmlCommon.XmlAttribute(n, "rate");
                                DB.ExecuteSQL("update Currency set ExchangeRate=" + rate + ", WasLiveRate=1, LastUpdated=getdate() where CurrencyCode=" + DB.SQuote(CurrencyCode));
                            }
                        }
                    }
                    FlushCache(); // flush anyway for safety
                }
                catch (Exception ex)
                {
                    try
                    {
                        AppLogic.SendMail(AppLogic.AppConfig("StoreName") + " Currency.GetLiveRates Failure", "Occurred at: " + Localization.ToNativeDateTimeString(System.DateTime.Now) + CommonLogic.GetExceptionDetail(ex, ""), false, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), AppLogic.AppConfig("MailMe_ToAddress"), AppLogic.AppConfig("MailMe_ToName"), String.Empty, AppLogic.MailServer());
                    }
                    catch { }
                }
            }
        }