Esempio n. 1
0
        public bool UpdateRole(AddRoleServiceForm form)
        {
            if (string.IsNullOrEmpty(form.ID))
            {
                throw new Exception("更新角色时没有ID");
            }
            ISqlMapper            mapper = Common.GetMapperFromSession();
            RoleDao               dao    = new RoleDao(mapper);
            Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper);

            rmadao.Delete(new Role_Module_ActionQueryForm {
                RoleID = form.ID
            });
            AddRoleAuth(mapper, form, form.ID);

            return(dao.Update(new RoleUpdateForm
            {
                Entity = new Role
                {
                    LastUpdator = form.LastUpdator,
                    Name = form.Name,
                    ParentID = form.ParentID,
                    Remark = form.Remark,
                    DataAccessType = form.DataAccessType,
                },
                RoleQueryForm = new RoleQueryForm {
                    ID = form.ID
                },
            }));
        }
Esempio n. 2
0
        public string AddRole(AddRoleServiceForm form)
        {
            string weixinid = Common.WeiXinDepartmentID;

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["WeiXinDepartmentID"]))
            {
                weixinid = ConfigurationManager.AppSettings["WeiXinDepartmentID"];
            }
            Role role = new Role
            {
                DataAccessType = form.DataAccessType,
                Creator        = form.Creator,
                IsDeleted      = 0,
                Name           = form.Name,
                ParentID       = form.ParentID,
                Remark         = form.Remark,
                WeiXinID       = weixinid,
            };
            //新增角色
            ISqlMapper mapper = Common.GetMapperFromSession();
            RoleDao    dao    = new RoleDao(mapper);

            #region risk role
            string id = dao.Add(role);
            AddRoleAuth(mapper, form, id);
            #endregion
            return(id);
        }
Esempio n. 3
0
        public bool UpdateRole(AddRoleServiceForm form)
        {
            UserBLL userbll = new UserBLL();
            var     user    = userbll.GetCurrentUser();

            form.LastUpdator = user.User.ID;
            return(bll.UpdateRole(form));
        }
Esempio n. 4
0
        public string AddRole(AddRoleServiceForm form)
        {
            UserBLL userbll = new UserBLL();
            var     user    = userbll.GetCurrentUser();

            form.Creator = user.User.ID;
            string weixinid = "20";

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["WeiXinDepartmentID"]))
            {
                weixinid = ConfigurationManager.AppSettings["WeiXinDepartmentID"];
            }
            form.WeiXinID = weixinid;
            return(bll.AddRole(form));
        }
Esempio n. 5
0
 private void AddRoleAuth(ISqlMapper mapper, AddRoleServiceForm form, string roleid)
 {
     #region 权限新增
     //权限操作
     Role_Module_ActionDao rmadao  = new Role_Module_ActionDao(mapper);
     List <Module>         modules = TableCacheHelper.GetDataFromCache <Module>(typeof(ModuleDao));
     List <Model.Action>   actions = TableCacheHelper.GetDataFromCache <Model.Action>(typeof(ActionDao));
     AuthorityMapping      mapping = XMLHelper.DeserializeFromFile <AuthorityMapping>(Common.AuthorityMappingFile);
     foreach (var auth in form.Authority)
     {
         if (!auth.Checked)
         {
             continue;
         }
         var authonode = mapping.AuthNode.Find(t => t.ID.Equals(auth.ID));
         if (authonode == null)
         {
             continue;
         }
         AddAuth(authonode.Item, roleid, rmadao);
     }
     #endregion
 }