Beispiel #1
0
        static public String GetName(int CurrencyID)
        {
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyID=" + CurrencyID.ToString() + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "Name");
            }
            return(tmpS);
        }
Beispiel #2
0
        static public String GetCurrencyCode(String Name)
        {
            if (Name.Length == 0)
            {
                throw new ArgumentException("Invalid Currency Name (empty string)");
            }
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@Name=" + Name + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "CurrencyCode");
            }
            return(tmpS);
        }
Beispiel #3
0
        static public String GetDisplaySpec(String CurrencyCode)
        {
            if (CurrencyCode.Length == 0)
            {
                throw new ArgumentException("Invalid CurrencyCode (empty string)");
            }
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyCode=" + CommonLogic.SQuote(CurrencyCode) + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "DisplaySpec");
            }
            return(tmpS);
        }
Beispiel #4
0
        static public ArrayList getCurrencyList()
        {
            ArrayList list = new ArrayList();

            foreach (XmlNode n in RatesDoc.SelectNodes("//Currency[@Published = 1]"))
            {
                int           cID  = XmlCommon.XmlAttributeNativeInt(n, "CurrencyID");
                string        cc   = XmlCommon.XmlAttribute(n, "CurrencyCode");
                string        cn   = XmlCommon.XmlAttribute(n, "Name");
                ListItemClass item = new ListItemClass();
                item.Item  = cc + " (" + cn + ")";
                item.Value = cID;
                list.Add(item);
            }

            return(list);
        }
Beispiel #5
0
        static public String GetSelectList(String SelectName, String OnChangeHandler, String CssClass, String SelectedCurrencyCode)
        {
            StringBuilder tmpS = new StringBuilder(4096);

            tmpS.Append("<select size=\"1\" id=\"" + SelectName + "\" name=\"" + SelectName + "\"");
            if (OnChangeHandler.Length != 0)
            {
                tmpS.Append(" onChange=\"" + OnChangeHandler + "\"");
            }
            if (CssClass.Length != 0)
            {
                tmpS.Append(" class=\"" + CssClass + "\"");
            }
            tmpS.Append(">");
            foreach (XmlNode n in RatesDoc.SelectNodes("//Currency[@Published = 1]"))
            {
                string cc = XmlCommon.XmlAttribute(n, "CurrencyCode");
                tmpS.Append("<option value=\"" + cc + "\" " + CommonLogic.IIF(SelectedCurrencyCode == cc, " selected ", "") + ">" + cc + " (" + XmlCommon.XmlAttribute(n, "Name") + ")</option>");
            }
            tmpS.Append("</select>");
            return(tmpS.ToString());
        }
Beispiel #6
0
 static public IEnumerable <CurrencyInfo> GetCurrencies()
 {
     return(RatesDoc
            .SelectNodes("//Currency[@Published = 1]")
            .OfType <XmlNode>()
            .Select(node => new CurrencyInfo(
                        currencyId: XmlCommon.XmlAttributeNativeInt(node, "CurrencyID"),
                        currencyGuid: Guid.Parse(XmlCommon.XmlAttribute(node, "CurrencyGUID")),
                        name: XmlCommon.XmlAttribute(node, "Name"),
                        currencyCode: XmlCommon.XmlAttribute(node, "CurrencyCode"),
                        exchangeRate: XmlCommon.XmlAttributeNativeDecimal(node, "ExchangeRate"),
                        wasLiveRate: XmlCommon.XmlAttributeBool(node, "WasLiveRate"),
                        displayLocaleFormat: XmlCommon.XmlAttribute(node, "DisplayLocaleFormat"),
                        symbol: XmlCommon.XmlAttribute(node, "Symbol"),
                        extensionData: XmlCommon.XmlAttribute(node, "ExtensionData"),
                        published: XmlCommon.XmlAttributeBool(node, "Published"),
                        displayOrder: XmlCommon.XmlAttributeNativeInt(node, "DisplayOrder"),
                        displaySpec: XmlCommon.XmlAttribute(node, "DisplaySpec"),
                        lastUpdated: XmlCommon.XmlAttributeNativeDateTime(node, "LastUpdated"),
                        createdOn: XmlCommon.XmlAttributeNativeDateTime(node, "CreatedOn"),
                        updatedOn: XmlCommon.XmlAttributeNativeDateTime(node, "UpdatedOn"))));
 }
Beispiel #7
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 { }
                }
            }
        }