Пример #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (String.IsNullOrEmpty(listFormat))
            {
                return;
            }

            if (this.Page.Request["type"] != null)
            {
                dicType = Dictionary.ConvertTypeFromString(this.Page.Request["type"].Trim().ToUpper());
            }

            foreach (DictionaryItem dicItem in Dictionary.List(dicType))
            {
                writer.WriteLine(String.Format(listFormat, dicItem.Type.ToString(), dicItem.Key, dicItem.Value));
            }
        }
Пример #2
0
 public static IQueryable<DepotDictionary> DepotDictionaryLoad(this DepotEntities db, Guid depotId, DictionaryType type)
 {
     return db.DepotDictionary.Where(o => o.DepotId == depotId && o.Type == type).OrderBy(o => o.Name);
 }
Пример #3
0
 public static void DepotDictionaryAdd(this DepotEntities db, Guid depotId, DictionaryType type, string name)
 {
     if (name.None())
         return;
     var count = db.DepotDictionaryLoad(depotId, type).Count(o => o.Name == name);
     if (count == 0)
     {
         var dictionary = new DepotDictionary
         {
             DepotId = depotId,
             Type = type,
             Name = name,
             PinYin = db.ToPinYin(name).Single()
         };
         db.DepotDictionary.Add(dictionary);
         db.SaveChanges();
     }
 }
Пример #4
0
        private string GetDictionaryList(DictionaryType t, string items)
        {
            string ret = "";
            switch (t)
            {
                case DictionaryType.A:
                case DictionaryType.I:
                    ret = Dictionary.GetDictionaryNames(t, items.Split(','), ",");
                    break;
                case DictionaryType.N:
                    ret = Dictionary.GetDictionaryName(t, items);
                    break;
            }

            return Util.CutString(ret, 0, 60)+"...";
        }
Пример #5
0
 /// <summary>
 /// ���ۺ���
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 /// <param name="key">�ֵ����</param>
 /// <param name="value">�ֵ�ֵ</param>
 /// <param name="dep">���</param>
 public DictionaryItem(DictionaryType dicType, string itemKey, string itemValue,int dep)
 {
     type = dicType;
     key = itemKey;
     value = itemValue;
     depth = dep;
     children = new ArrayList();
 }
Пример #6
0
 /// <summary>
 /// ���캯��
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 public DictionaryItem(DictionaryType dicType)
 {
     type = dicType;
     key = "";
     value = "";
     children = new ArrayList();
 }
Пример #7
0
        /// <summary>
        /// �ݹ�XML�ڵ㵽ָ������
        /// </summary>
        /// <param name="list">ָ������</param>
        /// <param name="pNode">���ڵ�</param>
        /// <param name="depth">�ڵ����</param>
        private static void LoopNodes(ArrayList list,DictionaryType type, XmlNode pNode, int depth)
        {
            DictionaryItem item;

            foreach (XmlNode node in pNode.SelectNodes("Item"))
            {
                item = new DictionaryItem(type,node.Attributes["key"].Value, node.Attributes["value"].Value, depth);
                list.Add(item);

                if (node.HasChildNodes)
                {
                    depth++;
                    LoopNodes(item.Children,type,node, depth);
                    depth--;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// �����ݿ��ȡ�ֵ��б�
        /// </summary>
        /// <param name="type">�ֵ�����</param>
        /// <returns>ArrayList</returns>
        public static ArrayList List(DictionaryType type)
        {
            /*
             DictList
             @type char(1)
             */

            ArrayList list = new ArrayList();
            SqlDataReader reader = null;

            try
            {
                DictionaryItem dicItem;
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictList",
                                                new SqlParameter[] { Database.MakeInParam("@type", SqlDbType.Char, 1, type.ToString()) });
                while (reader.Read())
                {
                    /*Type, [Key], [Value]*/
                    dicItem = new DictionaryItem(type);
                    dicItem.Key = reader.GetString(1);
                    dicItem.Value = reader.GetString(2);
                    list.Add(dicItem);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
Пример #9
0
 /// <summary>
 /// �����ݿ�ɾ��һ���ֵ���
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 /// <param name="key">����</param>
 /// <returns></returns>
 public static bool RemoveItem(DictionaryType type, string key)
 {
     /*
      DictDelete
     @type char(1),
     @key varchar(50)
      */
     try
     {
         Database.ExecuteNonQuery(CommandType.StoredProcedure, "DictDelete",
                 new SqlParameter[]{
                      Database.MakeInParam("@type",SqlDbType.Char,1,type.ToString()),
                      Database.MakeInParam("@key",SqlDbType.VarChar,50,key)
                 }
         );
     }
     catch
     {
         return false;
     }
     return true;
 }
Пример #10
0
 public static string GetDictionaryNames(DictionaryType type, string[] codes,string separator)
 {
     string[] names = new string[codes.Length];
     for (int i=0;i<codes.Length;i++)
     {
         names[i] = GetDictionaryName(type, codes[i]);
     }
     return String.Join(separator, names);
 }
Пример #11
0
        /// <summary>
        /// �����ݿ��ȡһ���ֵ���
        /// </summary>
        /// <param name="type">�ֵ�����</param>
        /// <param name="key">����</param>
        /// <returns></returns>
        public static DictionaryItem GetItem(DictionaryType type, string key)
        {
            /*
             DictGet
            @type char(1),
            @key varchar(50)
             */

            DictionaryItem dic = null;

            SqlDataReader reader = null;

            try
            {
                /*Type, [Key], [Value]*/
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictGet",
                                                new SqlParameter[] {
                                                    Database.MakeInParam("@type",SqlDbType.Char,1,type.ToString()),
                                                    Database.MakeInParam("@key",SqlDbType.VarChar,50,key)
                                                });
                if (reader.Read())
                {
                    dic = new DictionaryItem(type);
                    dic.Key = reader.GetString(1);
                    dic.Value = reader.GetString(2);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return dic;
        }
Пример #12
0
 public static string GetDictionaryNames(DictionaryType type, string codes, char spliter, string separator)
 {
     return GetDictionaryNames(type, codes.Split(spliter), separator);
 }
Пример #13
0
        public static string GetDictionaryName(DictionaryType type,string code)
        {
            if (String.IsNullOrEmpty(code))
            {
                return "";
            }

            if (type == DictionaryType.A && code == "000000")
            {
                return "ȫ��";
            }

            if (type == DictionaryType.I && code == "000000")
            {
                return "������ҵ";
            }

            string name = "";
            XmlNode node = null;
            switch (type)
            {
                case DictionaryType.A:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='A']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.C:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='C']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.I:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='I']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.L:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='L']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.N:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='N']//Item[@key='" + code + "']");
                    break;
            }

            if (node != null)
            {
                name = node.Attributes["value"].Value;
            }

            return name;
        }
Пример #14
0
 public static DictionaryItem AddItem(DictionaryType type, string key, string value)
 {
     DictionaryItem item = new DictionaryItem(type, key, value);
     if (item.Save())
     {
         return item;
     }
     return null;
 }
Пример #15
0
 public static void DepotDictionaryRemove(this DepotEntities db, Guid depotId, DictionaryType type, string name)
 {
     var dictionary = db.DepotDictionaryLoad(depotId, type).SingleOrDefault(o => o.Name == name);
     if (dictionary != null)
     {
         db.DepotDictionary.Remove(dictionary);
         db.SaveChanges();
     }
 }
Пример #16
0
 /// <summary>
 /// ���´ʵ��ļ�
 /// </summary>
 /// <param name="type"></param>
 /// <param name="parentKey"></param>
 /// <param name="item"></param>
 public static void UpdateDictionaryFile(DictionaryType type,string parentKey,DictionaryItem item)
 {
 }
Пример #17
0
            private bool FindDictcnResult( QueryResult queryResult, DictionaryType targetType, out DictResult dictResult )
            {
                bool hasFound = false;
                dictResult = null;
                if ( queryResult != null )
                {
                    if ( queryResult.DictResultItems != null )
                    {

                        foreach ( DictResult resultItem in queryResult.DictResultItems )
                        {
                            if ( resultItem != null && resultItem.DictionaryType == targetType )
                            {
                                dictResult = resultItem;
                                hasFound = true;
                                break;
                            }
                        }
                    }
                }
                return hasFound;
            }
Пример #18
0
 public DictionaryList()
     : base()
 {
     dicType = DictionaryType.A;
     listFormat = "";
 }