Beispiel #1
0
 public static List <MenuTreeDto> Tree(string role)
 {
     lock (obj)
     {
         if (DataItemUtil.GetValues("Roles").Contains(role))
         {
             var tree = new List <MenuTreeDto>();
             if (_trees.TryGetValue(role, out tree))
             {
                 return(tree);
             }
             else
             {
                 return(SetTree(role));
             }
         }
         else
         {
             return(new List <MenuTreeDto>());
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 设置数据字典,如果键已存在则更新该记录,键不存在则新建记录
        /// </summary>
        /// <param name="k">键</param>
        /// <param name="v">值</param>
        /// <param name="user">操作人</param>
        /// <returns></returns>
        public Result Set(string k, string v, IAppUser user)
        {
            var entity = db.Load <DataItemEntity>(MySearchUtil.New()
                                                  .AndEqual("IsDel", false)
                                                  .AndEqual("K", k.Trim()));

            if (entity == null)
            {
                entity = new DataItemEntity
                {
                    K = k.Trim(),
                    V = v.Trim()
                };
                return(Create(entity, user, () =>
                {
                    DataItemUtil.Clear();
                }));
            }
            else
            {
                entity.V = v;
                return(Update(entity, user));
            }
        }