public string SetRoleMenu(string loginIdentifer, string roleId, string menuIds)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;

            try
            {
                string str = "修改失败";

                try
                {
                    Role role = RoleModule.GetRole(long.Parse(roleId));

                    if (MenuModule.DeleteRoleMenuByRoleId(role.Id))
                    {
                        List <long> list = new List <long>();
                        string[]    strs = menuIds.Trim().Trim(',').Split(',');
                        foreach (string s in strs)
                        {
                            long id = long.Parse(s);
                            Menu m  = MenuModule.GetMenu(id);
                            if (m != null)
                            {
                                list.Add(id);

                                if (!list.Contains(m.ParentId))
                                {
                                    list.Add(m.ParentId);
                                }
                            }
                        }
                        if (strs.Length > 0)
                        {
                            if (MenuModule.AddRoleMenu(role.Id, list.ToArray()))
                            {
                                str            = "修改成功";
                                obj2["Result"] = true;
                            }
                        }
                    }
                    obj2["Message"] = str;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }

                try
                {
                    SysLog log = new SysLog();
                    log.LogUserId   = loginUser.UserId;
                    log.LogUserName = loginUser.LoginName;
                    log.LogAddress  = ToolsWeb.GetIP(context.Request);
                    log.LogTime     = DateTime.Now;
                    log.LogType     = "修改角色权限";
                    log.LogContent  = obj2["Message"].ToString() + "|" + roleId + "|" + menuIds;
                    SysLogModule.Add(log);
                }
                catch { }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string ModifyRole(string loginIdentifer, string roleJSONString)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;

            try
            {
                JavaScriptObject obj3 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(roleJSONString);
                if (obj3 == null)
                {
                    obj2["Message"] = "参数格式错误";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }

                try
                {
                    Role role = RoleModule.GetRole(long.Parse(obj3["ID"].ToString()));
                    role.RoleName = obj3["角色名"].ToString();
                    role.IsAllow  = 1;
                    role.Weight   = 1;

                    long existsId = RoleModule.GetRoleId(role.RoleName);
                    if (existsId > 0 && existsId != role.Id)
                    {
                        obj2["Message"] = "此角色已经存在!";
                        return(JavaScriptConvert.SerializeObject(obj2));
                    }

                    string str = "修改失败";
                    if (RoleModule.ModifyRole(role))
                    {
                        str            = "修改成功";
                        obj2["Result"] = true;
                    }
                    obj2["Message"] = str;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = loginUser.UserId;
                log.LogUserName = loginUser.LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request);
                log.LogTime     = DateTime.Now;
                log.LogType     = "修改角色";
                log.LogContent  = obj2["Message"].ToString() + "|" + roleJSONString;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }