Пример #1
0
        private MenuEntity GetMenu(RightEntity rightEntity, PluginEntity pluginEntity)
        {
            string startWith = "/" + pluginEntity.Name + "/" ;
            string replace = "/" + pluginEntity.Name + "/" +pluginEntity.PVersion + "/";

            MenuEntity mm = new MenuEntity(rightEntity.Id, rightEntity.Name, "/plugins" + rightEntity.Url.Replace(startWith, replace), false, pluginEntity.Icon);
            foreach (var item in rightEntity.Children)
            {
                mm.Children.Add(GetMenu(item, pluginEntity));
            }
            return mm;
        }
Пример #2
0
        /// <summary>添加节点 
        /// </summary>
        /// <param name="rightEntity"></param>
        /// <returns>1:成功 -1:失败 -2:已存在相同url的节点</returns>
        public int AddRight(RightEntity rightEntity)
        {
            RightDal rightDal = new RightDal();
            if (rightDal.Exist(rightEntity.Url) > 0)
            {
                return -2;
            }
            else
            {
                return rightDal.AddRight(rightEntity);

            }
        }
Пример #3
0
 /// <summary>转换成实体类  
 /// </summary>
 /// <param name="dataRow"></param>
 /// <returns></returns>
 private RightEntity Conver2Entity(DataRow dataRow)
 {
     RightEntity rightEntity = new RightEntity();
     rightEntity.Id = Int32.Parse(dataRow["Id"].ToString());
     rightEntity.Name = (string)dataRow["Name"];
     rightEntity.Url = (string)dataRow["Url"];
     rightEntity.Level = Int32.Parse(dataRow["Level"].ToString());
     rightEntity.ParentId = Int32.Parse(dataRow["ParentId"].ToString());
     rightEntity.Describe = (string)dataRow["Describe"];
     rightEntity.IsMenu = Int32.Parse(dataRow["IsMenu"].ToString());
     rightEntity.Deleted = Int32.Parse(dataRow["Deleted"].ToString());
     rightEntity.Category = Int32.Parse(dataRow["Category"].ToString());
     return rightEntity;
 }
Пример #4
0
 /// <summary>获取权限列表
 /// </summary>
 /// <returns>json字符串</returns>
 public RightEntity GetAllRights()
 {
     RightDal rightDal = new RightDal();
     var rightEntities = rightDal.GetAllRights();
     var rootEntities = rightEntities.Where(m => m.ParentId == 0);
     AppendChild(rootEntities, rightEntities);
     RightEntity rightEntity = new RightEntity();
     rightEntity.Id = 0;
     rightEntity.IsMenu = 0;
     rightEntity.Level = 0;
     rightEntity.Name = "权限管理";
     rightEntity.ParentId = 0;
     rightEntity.Url = "..";
     rightEntity.Category = -1;
     rightEntity.Deleted = 0;
     rightEntity.Describe = "..";
     rightEntity.Children = rootEntities.ToList();
     return rightEntity;
 }
Пример #5
0
 /// <summary>修改权限 
 /// </summary>
 /// <param name="rightEntity"></param>
 /// <returns></returns>
 public int EditRight(RightEntity rightEntity)
 {
     rightEntity.Describe = HttpUtility.UrlDecode(rightEntity.Describe);
     rightEntity.Name = HttpUtility.UrlDecode(rightEntity.Name);
     return new RightBll().UpdateRight(rightEntity);
 }
Пример #6
0
 /// <summary>添加一个节点 
 /// </summary>
 /// <param name="rightEntity"></param>
 /// <returns></returns>
 public int AddRight(RightEntity rightEntity)
 {
     string sql = "insert into t_rights (Name,Url,Level,ParentId,Describe,IsMenu,Deleted,Category) values (@Name,@Url,@Level,@ParentId,@Describe,@IsMenu,@Deleted,@Category);select last_insert_rowid();";
     SQLiteParameter[] para = new SQLiteParameter[]{
             new SQLiteParameter("@Name",rightEntity.Name),
             new SQLiteParameter("@Url", rightEntity.Url),
             new SQLiteParameter("@Level", rightEntity.Level),
             new SQLiteParameter("@ParentId", rightEntity.ParentId),
             new SQLiteParameter("@Describe",rightEntity.Describe),
             new SQLiteParameter("@IsMenu",rightEntity.IsMenu),
             new SQLiteParameter("@Deleted",rightEntity.Deleted),
             new SQLiteParameter("@Category",rightEntity.Category)
         };
     DataTable dataTable = new SqlLiteHelper().GetDataTable(sql, para);
     if (dataTable != null && dataTable.Rows.Count == 1)
     {
         return Int32.Parse(dataTable.Rows[0][0].ToString());
     }
     return -1;
 }
Пример #7
0
 /// <summary>修改权限 
 /// </summary>
 /// <param name="rightEntity"></param>
 /// <returns></returns>
 public bool UpdateRight(RightEntity rightEntity)
 {
     const string sql = "update t_rights set Name=@Name,Url=@Url,Level=@Level,ParentId=@ParentId,Describe=@Describe,IsMenu=@IsMenu,Deleted=@Deleted where Id=@Id";
     SQLiteParameter[] para = new SQLiteParameter[]{
             new SQLiteParameter("@Name",rightEntity.Name),
             new SQLiteParameter("@Url", rightEntity.Url),
             new SQLiteParameter("@Level", rightEntity.Level),
             new SQLiteParameter("@ParentId", rightEntity.ParentId),
             new SQLiteParameter("@Describe",rightEntity.Describe),
             new SQLiteParameter("@IsMenu",rightEntity.IsMenu),
             new SQLiteParameter("@Deleted",rightEntity.Deleted),
             new SQLiteParameter("@Id",rightEntity.Id)
         };
     int result = new SqlLiteHelper().RunSQL(sql, para);
     return result > 0;
 }
Пример #8
0
 /// <summary>修改节点属性 
 /// </summary>
 /// <param name="rightEntity"></param>
 /// <returns>1:成功 -1:失败 -2:已存在相同的url</returns>
 public int UpdateRight(RightEntity rightEntity)
 {
     RightDal rightDal = new RightDal();
     int result = rightDal.Exist(rightEntity.Url);
     if (result > 0 && result != rightEntity.Id)
     {
         return -2;
     }
     return rightDal.UpdateRight(rightEntity) ? 1 : -1;
 }