Esempio n. 1
0
        // 2012/10/25
        public List <DbFromInfo> GetFromInfos(string strLang)
        {
            List <DbFromInfo> results = new List <DbFromInfo>();
            XmlNodeList       nodes   = this.nodeDatabase.SelectNodes("from");

            foreach (XmlNode node in nodes)
            {
                string strCaption = DomUtil.GetCaption(strLang, node);
                if (strCaption == null)
                {   // 如果下面根本没有定义<caption>元素,则采用<from>元素的name属性值
                    strCaption = DomUtil.GetAttr(node, "name");
                    if (String.IsNullOrEmpty(strCaption) == true)
                    {
                        continue;   // 实在没有,只好舍弃
                    }
                }

                DbFromInfo info = new DbFromInfo();
                info.Caption = strCaption;
                info.Style   = DomUtil.GetAttr(node, "style");
                results.Add(info);
            }

            return(results);
        }
Esempio n. 2
0
        // 2020/6/17
        // 根据 Style 去重
        public static void RemoveDupByStyle(ref List <DbFromInfo> target)
        {
            for (int i = 0; i < target.Count; i++)
            {
                DbFromInfo from1 = target[i];

                string strStyle1 = from1.Style;
                // 把caption(特定语种)为空的事项丢弃
                if (string.IsNullOrEmpty(strStyle1) == true)
                {
                    target.RemoveAt(i);
                    i--;
                    continue;
                }

                for (int j = i + 1; j < target.Count; j++)
                {
                    DbFromInfo from2     = target[j];
                    string     strStyle2 = from2.Style;

                    if (strStyle1 == strStyle2)
                    {
                        target.RemoveAt(j);
                        j--;
                    }
                }
            }
        }
Esempio n. 3
0
        // 获得全部可用的From列表
        public int GetFroms(
            string strLang,
            out DbFromInfo[] infos,
            out string strError)
        {
            strError = "";
            infos    = null;

            // 把所有库的from累加起来
            List <DbFromInfo> all = new List <DbFromInfo>();

            foreach (VirtualDatabase v in this)
            {
                List <DbFromInfo> current = v.GetFromInfos(strLang);
                all.AddRange(current);
            }

            // 根据 Caption 值去重。以前做法
            // RemoveDupByCaption(ref all);

            // 根据 Style 值去重。2020/6/17 做法
            RemoveDupByStyle(ref all);

            int nIndexOfID = -1;    // __id途径所在的下标

            for (int i = 0; i < all.Count; i++)
            {
                DbFromInfo from = all[i];

                if (from.Caption == "__id" || from.Style == "recid")
                {
                    nIndexOfID = i;
                }
            }

            // 如果曾经出现过 __id caption
            if (nIndexOfID != -1)
            {
                DbFromInfo temp = all[nIndexOfID];
                all.RemoveAt(nIndexOfID);
                all.Add(temp);
            }

            infos = new DbFromInfo[all.Count];
            all.CopyTo(infos);
            return(0);
        }