示例#1
0
        /// <summary>
        /// 获取默认的附加项(“请选择”和“所有”)的配置数据,对应web.config中codeNamePair节点下的appendItems的对应语言的配置(根据当前线程获取LanguageCode)
        /// </summary>
        /// <param name="appendSelectItem">“请选择”附加项的配置数据</param>
        /// <param name="appendAllItem">“所有”附加项的配置数据</param>
        public static void GetDefaultAppendItem(out CodeNamePair appendSelectItem, out CodeNamePair appendAllItem)
        {
            Tuple <string, string> defaultAppendItem;

            CodeNamePairSection.GetSetting().AppendItems.TryGetValue(Thread.CurrentThread.CurrentCulture.Name.ToUpper(), out defaultAppendItem);

            if (defaultAppendItem != null && defaultAppendItem.Item1 != null && defaultAppendItem.Item1.Trim().Length > 0)
            {
                appendSelectItem = new CodeNamePair {
                    Code = null, Name = defaultAppendItem.Item1.Trim()
                };
            }
            else
            {
                appendSelectItem = null;
            }

            if (defaultAppendItem != null && defaultAppendItem.Item2 != null && defaultAppendItem.Item2.Trim().Length > 0)
            {
                appendAllItem = new CodeNamePair {
                    Code = null, Name = defaultAppendItem.Item2.Trim()
                };
            }
            else
            {
                appendAllItem = null;
            }
        }
示例#2
0
        public static string GetCode(string domainName, string key, string name)
        {
            List <CodeNamePair> list = GetList(domainName, key, Thread.CurrentThread.CurrentCulture.Name);
            CodeNamePair        cnp  = list.Find(f => f.Name.Trim().ToLower() == name.Trim().ToLower());

            if (cnp != null)
            {
                return(cnp.Code);
            }
            return(null);
        }
示例#3
0
        /// <summary>
        ///  获取配置的对应语言编码的CodeNamePair列表
        /// </summary>
        /// <param name="domainName">Domain名称: [Customer,IM,Inventory,Invoice,MKT,PO,RMA,SO,Common]</param>
        /// <param name="key">对应到配置文件中xml节点codeNamePair的属性key的值</param>
        /// <param name="languageCode">语言编码</param>
        /// <param name="appendSelectItem">返回配置文件中对应key的xml节点codeNamePair的属性customSelectAppendItem的值,作为“选择”的附加项(如果不存在此配置,则读取系统默认附加项)</param>
        /// <param name="appendAllItem">返回配置文件中对应key的xml节点codeNamePair的属性customAllAppendItem的值,作为“所有”的附加项(如果不存在此配置,则读取系统默认附加项)</param>
        /// <returns>返回对应key的codeNamePair节点下的所有item的列表,每个item节点对应一个KeyValuePair对象,item节点的code属性的值赋值到KeyValuePair对象的属性Key上,item节点的name属性的值赋值到KeyValuePair对象的属性Value上</returns>
        private static List <CodeNamePair> GetList(string domainName, string key, string languageCode,
                                                   out CodeNamePair appendSelectItem, out CodeNamePair appendAllItem)
        {
            string cacheKey = domainName.ToUpper().Trim() + "." + languageCode.ToUpper().Trim();
            Dictionary <string, CodeNamePairList> data;

            if (!s_Cache.TryGetValue(cacheKey, out data))
            {
                lock (s_SyncObj)
                {
                    if (!s_Cache.TryGetValue(cacheKey, out data))
                    {
                        data = LoadConfigFile(domainName, languageCode);
                        s_Cache.Add(cacheKey, data);
                    }
                }
            }
            CodeNamePairList list;

            if (!data.TryGetValue(key.ToUpper(), out list) || list == null)
            {
                appendSelectItem = null;
                appendAllItem    = null;
                return(new List <CodeNamePair>(0));
            }
            appendSelectItem = new CodeNamePair {
                Code = null, Name = list.SelectAppendItem
            };
            appendAllItem = new CodeNamePair {
                Code = null, Name = list.AllAppendItem
            };
            if (list == null || list.Count <= 0)
            {
                return(new List <CodeNamePair>(0));
            }
            List <CodeNamePair> rstList = new List <CodeNamePair>(list.Count);

            foreach (var entry in list)
            {
                rstList.Add(new CodeNamePair {
                    Code = entry.Key, Name = entry.Value
                });
            }
            return(rstList);
        }
示例#4
0
 /// <summary>
 ///  获取配置的CodeNamePair列表(根据当前线程获取LanguageCode)
 /// </summary>
 /// <param name="domainName">Domain名称: [Customer,IM,Inventory,Invoice,MKT,PO,RMA,SO,Common]</param>
 /// <param name="key">对应到配置文件中xml节点codeNamePair的属性key的值</param>
 /// <param name="appendSelectItem">返回配置文件中对应key的xml节点codeNamePair的属性customSelectAppendItem的值,作为“选择”的附加项(如果不存在此配置,则读取系统默认附加项)</param>
 /// <param name="appendAllItem">返回配置文件中对应key的xml节点codeNamePair的属性customAllAppendItem的值,作为“所有”的附加项(如果不存在此配置,则读取系统默认附加项)</param>
 /// <returns>返回对应key的codeNamePair节点下的所有item的列表,每个item节点对应一个KeyValuePair对象,item节点的code属性的值赋值到KeyValuePair对象的属性Key上,item节点的name属性的值赋值到KeyValuePair对象的属性Value上</returns>
 public static List <CodeNamePair> GetList(string domainName, string key,
                                           out CodeNamePair appendSelectItem, out CodeNamePair appendAllItem)
 {
     return(GetList(domainName, key, Thread.CurrentThread.CurrentCulture.Name, out appendSelectItem, out appendAllItem));
 }