コード例 #1
0
        // GET: TempGroup
        public ActionResult Index(string groupid)
        {
            if (string.IsNullOrEmpty(groupid))
            {
                return(Redirect("~/Page/Index?msg=群组标识不能为空"));
            }

            ViewBag.GroupId = groupid;
            var entity = _groupInfoService.Find(groupid.ToGuid());

            ViewBag.GroupName = (entity == null ? "" : entity.GroupName);

            return(View());
        }
コード例 #2
0
        /// <summary>
        /// 检查组信息
        /// </summary>
        /// <param name="imuserid">用户标识</param>
        /// <param name="groupid">组标识</param>
        /// <returns></returns>
        private bool CheckGroupInfo(string imuserid, string groupid)
        {
            if (groupid.IsNullOrEmpty())
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "参数无效", buginfo = "参数无效" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }

            //检查组
            var usergougroup = _userGroupService.FindUserGroup(imuserid.ToGuid(), groupid.ToGuid());

            if (usergougroup == null)
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "非法用户", buginfo = "非法用户" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }
            if (usergougroup.IsValid == 0)
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "您已被移除", buginfo = "您已被移除" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }

            //组信息
            var groupinfo = _groupInfoService.Find(usergougroup.GroupId);

            if (groupinfo == null)
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "非法组", buginfo = "非法组" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }
            if (groupinfo.IsValid == 0)
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "组已被移除", buginfo = "组已被移除" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }

            //检查用户
            var userinfo = _imUserInfoService.Find(imuserid.ToGuid());

            if (!groupinfo.GroupUserTypes.Contains(userinfo.UserType.ToString()))
            {
                System.Web.HttpContext.Current.AcceptWebSocketRequest((e) =>
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    var data = new { status = 0, msg = "用户没有权限", buginfo = "用户没有权限" }.ToJson();
                    return(e.WebSocket.SendMessage(cancellationToken, data));
                });
                System.Web.HttpContext.Current.Response.End();
                return(false);
            }

            _channelid = groupinfo.ChannelId.ToString();
            return(true);
        }