예제 #1
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);
        }
예제 #2
0
        public ArrayList GetEntityArrayList(int ForParentEntityID, String Prefix, int FilterEntityID, String LocaleSetting, bool AllowCaching)
        {
            ArrayList al;
            String    CacheName = String.Format("GetEntityArrayList_{0}_{1}_{2}_{3}_{4}_{5}", m_EntitySpecs.m_EntityName, ForParentEntityID.ToString(), Prefix, FilterEntityID.ToString(), LocaleSetting, AppLogic.IsAdminSite.ToString());

            if (AppLogic.CachingOn && AllowCaching)
            {
                al = (ArrayList)HttpContext.Current.Cache.Get(CacheName);
                if (al != null)
                {
                    if (CommonLogic.ApplicationBool("DumpSQL"))
                    {
                        HttpContext.Current.Response.Write("Cache Hit Found!\n");
                    }
                    return(al);
                }
            }

            al = new ArrayList();

            StringWriter         tmpS    = new StringWriter();
            String               XslFile = "EntityArrayListXML";
            XslCompiledTransform xForm;
            string               XslFilePath = CommonLogic.SafeMapPath(string.Format("{0}/EntityHelper/{1}.xslt", AppLogic.AdminDir(), XslFile));

            xForm = (XslCompiledTransform)HttpContext.Current.Cache.Get(XslFilePath);
            if (xForm == null)
            {
                xForm = new XslCompiledTransform(false);
                xForm.Load(XslFilePath);
                HttpContext.Current.Cache.Insert(XslFilePath, xForm, new CacheDependency(XslFilePath));
            }
            XsltArgumentList xslArgs = new XsltArgumentList();

            xslArgs.AddParam("ForParentEntityID", "", ForParentEntityID);
            xslArgs.AddParam("filterID", "", FilterEntityID);
            xslArgs.AddParam("custlocale", "", LocaleSetting);
            xslArgs.AddParam("deflocale", "", Localization.GetDefaultLocale());
            xslArgs.AddParam("adminsite", "", AppLogic.IsAdminSite);
            xForm.Transform(m_TblMgr.XmlDoc, xslArgs, tmpS);

            XmlDocument returnedXML = new XmlDocument();

            returnedXML.LoadXml(tmpS.ToString());

            XmlNodeList entityNodes = returnedXML.SelectNodes("/Entities/Entity");

            foreach (XmlNode n in entityNodes)
            {
                try
                {
                    XmlNode idNode   = n.SelectNodes("EntityId")[0];
                    XmlNode nameNode = n.SelectNodes("EntityName")[0];
                    int     entityId;
                    if (int.TryParse(idNode.InnerText, out entityId) && !string.IsNullOrEmpty(nameNode.InnerText))
                    {
                        ListItemClass li = new ListItemClass();
                        li.Value = entityId;
                        li.Item  = Security.HtmlEncode(nameNode.InnerText);
                        al.Add(li);
                    }
                }
                catch (Exception)
                {
                }
            }

            if (AppLogic.AppConfigBool("XmlPackage.DumpTransform"))
            {
                try                 // don't let logging crash the site
                {
                    StreamWriter sw = File.CreateText(CommonLogic.SafeMapPath(String.Format("{0}images/{1}_{2}_{3}.xfrm.xml", CommonLogic.IIF(AppLogic.IsAdminSite, "~/", ""), XslFile, m_EntitySpecs.m_EntityName, CommonLogic.IIF(AppLogic.IsAdminSite, "admin", "store"))));
                    sw.WriteLine(XmlCommon.PrettyPrintXml(tmpS.ToString()));
                    sw.Close();
                }
                catch { }
            }

            if (AppLogic.CachingOn && AllowCaching)
            {
                HttpContext.Current.Cache.Insert(CacheName, al, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
            }
            return(al);
        }