Ejemplo n.º 1
0
        // assumes this "xmlnode" n has <ml>...</ml> markup on it!
        public static String GetLocaleEntry(XmlNode n, String LocaleSetting, bool fallBack)
        {
            String tmpS = String.Empty;

            if (n != null)
            {
                if (n.InnerText.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(GetLocaleEntry(XmlDecode(n.InnerText), LocaleSetting, fallBack));
                }
                if (n.HasChildNodes && n.FirstChild.LocalName.Equals("ml", StringComparison.InvariantCultureIgnoreCase))
                {
                    String WebConfigLocale = Localization.GetDefaultLocale();
                    try
                    {
                        XmlNode node = n.SelectSingleNode("ml/locale[@name=\"" + LocaleSetting + "\"]");
                        if (fallBack && (node == null))
                        {
                            node = n.SelectSingleNode("ml/locale[@name=\"" + WebConfigLocale + "\"]");
                        }
                        if (node != null)
                        {
                            tmpS = node.InnerText.Trim();
                        }
                        if (tmpS.Length != 0)
                        {
                            tmpS = XmlCommon.XmlDecode(tmpS);
                        }
                    }
                    catch { }
                }
                else
                {
                    tmpS = n.InnerText.Trim(); // for backwards compatibility...they have no locale info, so just return the field.
                }
            }

            return(tmpS);
        }
Ejemplo n.º 2
0
        public HierarchicalTableMgr(String TableName, String NodeName, String IDColumnName, String GUIDColumnName, String NameColumnName, String XmlPackageName, int CacheMinutes, int SetInitialContextToNodeID, bool OnlyPublishedEntitiesAndObjects, int StoreID)
        {
            m_TableName      = TableName;
            m_NodeName       = NodeName;
            m_IDColumnName   = IDColumnName;
            m_GUIDColumnName = GUIDColumnName;
            m_NameColumnName = NameColumnName;
            m_CacheName      = String.Format("HTM_{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}", TableName, NodeName, IDColumnName, GUIDColumnName, NameColumnName, XmlPackageName, OnlyPublishedEntitiesAndObjects.ToString(), AppLogic.IsAdminSite.ToString(), StoreID.ToString());
            m_XmlPackageName = XmlPackageName;
            m_OnlyPublishedEntitiesAndObjects = OnlyPublishedEntitiesAndObjects;

            if (m_XmlDoc == null)
            {
                String RTParams = "EntityName=" + TableName + "&PublishedOnly=" + CommonLogic.IIF(m_OnlyPublishedEntitiesAndObjects, "1", "0");
                if (StoreID > 0)
                {
                    RTParams += "&FilterByStore=true&CurrentStoreID=" + StoreID.ToString();
                }
                using (XmlPackage2 p = new XmlPackage2(m_XmlPackageName, null, 1, String.Empty, RTParams, String.Empty, false))
                {
                    m_FinalXml   = p.TransformString();
                    m_DataSetXml = XmlCommon.XmlDecode(p.XmlSystemData);
                    m_XmlDoc     = new XmlDocument();
                    if (m_FinalXml.Length != 0)
                    {
                        using (StringReader sr = new StringReader(m_FinalXml))
                        {
                            using (XmlReader xr = XmlReader.Create(sr))
                            {
                                m_XmlDoc.Load(xr);
                            }
                        }
                    }
                }
            }
            m_NumRootLevelNodes = m_XmlDoc.SelectSingleNode("/root").ChildNodes.Count;
        }
Ejemplo n.º 3
0
        // ----------------------------------------------------------------
        //
        // SIMPLE Xml FIELD ROUTINES
        //
        // ----------------------------------------------------------------

        public static String GetLocaleEntry(String S, String LocaleSetting, bool fallBack)
        {
            String tmpS = String.Empty;

            if (S.Length == 0)
            {
                return(tmpS);
            }
            if (S.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
            {
                S = XmlDecode(S);
            }
            if (S.StartsWith("<ml>", StringComparison.InvariantCultureIgnoreCase))
            {
                String WebConfigLocale = Localization.GetDefaultLocale();
                if (AppLogic.AppConfigBool("UseXmlDOMForLocaleExtraction"))
                {
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(S);
                        XmlNode node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + LocaleSetting + "\"]");
                        if (fallBack && (node == null))
                        {
                            node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + WebConfigLocale + "\"]");
                        }
                        if (node != null)
                        {
                            tmpS = node.InnerText.Trim();
                        }
                        if (tmpS.Length != 0)
                        {
                            tmpS = XmlCommon.XmlDecode(tmpS);
                        }
                    }
                    catch { }
                }
                else
                {
                    // for speed, we are using lightweight simple string token extraction here, not full Xml DOM for speed
                    // return what is between <locale name=\"en-US\">...</locale>, Xml Decoded properly.
                    // we have a good locale field formatted field, so try to get desired locale:
                    if (S.IndexOf("<locale name=\"" + LocaleSetting + "\">") != -1)
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + LocaleSetting + "\">", "</locale>");
                    }
                    else if (fallBack && (S.IndexOf("<locale name=\"" + WebConfigLocale + "\">") != -1))
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + WebConfigLocale + "\">", "</locale>");
                    }
                    else
                    {
                        tmpS = String.Empty;
                    }
                    if (tmpS.Length != 0)
                    {
                        tmpS = XmlCommon.XmlDecode(tmpS);
                    }
                }
            }
            else
            {
                tmpS = S; // for backwards compatibility...they have no locale info, so just return the field.
            }
            return(tmpS);
        }