Example #1
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var          sendCreateGroup = SendCreateGroup.ParseFrom(requestInfo.Body);
            GroupInfoDAL groupInfoDAL    = new GroupInfoDAL();

            DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(sendCreateGroup.UserID);
            byte[] returnDate             = null;
            if (userinfo != null)
            {
                int groupID = groupInfoDAL.CreateGroup(userinfo.nickname, userinfo.id, userinfo.unionid);
                //groupInfoDAL.AddUserToGroup(groupID, userinfo.id, 1);

                returnDate = ReturnMessgae.CreateBuilder().SetStatue(1).SetMessage(JsonConvert.SerializeObject(new { GroupID = groupID, Nickname = userinfo.nickname, UserID = userinfo.id })).Build().ToByteArray();//"{\"圈子ID\":{0},\"圈子名称\":{1},\"圈主ID\":{2}}").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnDate.Length, requestInfo.MessageNum, returnDate)));
            }
            else
            {
                returnDate = ReturnMessgae.CreateBuilder().SetMessage("不是游戏用户").SetStatue(0).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnDate.Length, requestInfo.MessageNum, returnDate)));
            }
        }
Example #2
0
        /// <summary>
        /// 注册代理后台是先判断是否是游戏用户
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var          agentSignIn  = SendAgentSignIn.ParseFrom(requestInfo.Body);
            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();

            DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(agentSignIn.UserID);
            byte[] returnDate             = null;
            if (userinfo != null)
            {
                //int groupID = groupInfoDAL.CreateGroup(userinfo.nickname, userinfo.id);
                //groupInfoDAL.AddUserToGroup(groupID, userinfo.id, 1);

                returnDate = ReturnMessgae.CreateBuilder().SetStatue(1).SetMessage("是游戏用户").Build().ToByteArray();//"{\"圈子ID\":{0},\"圈子名称\":{1},\"圈主ID\":{2}}").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnDate.Length, requestInfo.MessageNum, returnDate)));
            }
            else
            {
                returnDate = ReturnMessgae.CreateBuilder().SetMessage(string.Format("此游戏ID{0}不是游戏用户", agentSignIn.UserID)).SetStatue(0).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnDate.Length, requestInfo.MessageNum, returnDate)));
            }
        }
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();


            var groupUsersManager = SendAgentGroupUsersManager.ParseFrom(requestInfo.Body);
            // RedisUserInfoModel user = RedisUtility.Get<RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO,  groupUsersManager.Openid,  groupUsersManager.Unionid));

            var player           = Player.CreateBuilder();
            var returnPlayerList = ReturnPlayerList.CreateBuilder();
            var list             = groupInfoDAL.GetUsersIDListByGroupID(groupUsersManager.GroupID);
            var deluserInfo      = new mjuserinfoDAL().GetModel(groupUsersManager.DelByUserID);

            byte[] returnMessage = null;
            if (deluserInfo == null)
            {
                returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("没有该用户").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                // session.Close();
                return;
            }
            var groupInfo = groupInfoDAL.GetGroupInfoByGroupID(groupUsersManager.GroupID, deluserInfo.is_band.Value);

            if (groupInfo == null)
            {
                returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("没有该用户").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                // session.Close();
                return;
            }
            //删除用户
            if (groupUsersManager.HasDelByUserID && !groupUsersManager.HasAddUsers)
            {
                if (groupInfo.CreateUserID == groupUsersManager.DelByUserID)
                {
                    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("群主不能删除自己").Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    return;
                }

                // groupInfoDAL.DelUsersByUserIDTransaction( groupUsersManager.GroupID,  groupUsersManager.DelByUserID);
                groupInfoDAL.DelUsersByUserIDTransaction(groupUsersManager.GroupID, groupUsersManager.DelByUserID, 3, groupUsersManager.DelByUserID);
                returnMessage = ReturnMessgae.CreateBuilder().SetStatue(1).SetMessage("删除成功").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                return;
            }
            //添加用户
            else if (!groupUsersManager.HasDelByUserID && groupUsersManager.HasAddUsers)
            {
                //var groupInfo = groupInfoDAL.GetGroupInfoByGroupID(groupUsersManager.GroupID);
                //if (groupInfo.CreateUserID == groupUsersManager.AddUsers)
                //{
                //    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("添加失败").Build().ToByteArray();
                //    session.Send(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                //    return;
                //}
                if (new DAL.DAL.mjuserinfoDAL().GetModel(groupUsersManager.AddUsers) != null)
                {
                    //加入类型,1圈主添加,2申请加入,3推荐加入
                    var err = groupInfoDAL.AddUserToGroup(groupUsersManager.GroupID, groupUsersManager.AddUsers, 1);
                    if (err == 0)
                    {
                        returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("添加失败,已存在该用户").Build().ToByteArray();
                        session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    }
                    else
                    {
                        returnMessage = ReturnMessgae.CreateBuilder().SetStatue(1).SetMessage("添加成功").Build().ToByteArray();
                        groupInfoDAL.AddGroupTips(groupUsersManager.GroupID, groupUsersManager.AddUsers, 1);

                        //添加成狗后把用户丢到RedisUs  避免需重复登陆问题
                        RedisUserInfoModel user = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, groupUsersManager.AddUsers.ToString(), groupUsersManager.AddUsers.ToString()));
                        if (user != null)
                        {
                            user.GroupID.Add((int)groupUsersManager.GroupID);
                            RedisUtility.Set(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, user.Openid, user.Unionid), user);
                            var userInfo = Gongyong.userlist.Find(w => w.UserID == user.UserID);
                            if (userInfo != null)
                            {
                                userInfo.GroupID.Add((int)groupUsersManager.GroupID);
                            }
                        }

                        session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    }
                }
                else
                {
                    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("无此用户").Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    return;
                }
                return;
            }


            foreach (var userID in list)
            {
                DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(userID);
                if (userinfo == null)
                {
                    groupInfoDAL.DelUsersByUserID(groupUsersManager.GroupID, userID);
                }
                else
                {
                    player.SetGroupUserID(userID).SetNickName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userinfo.nickname))).SetPicture(userinfo.headimg);
                    returnPlayerList.AddPlayerList(player);
                }
            }

            //返回待审核人数
            int counts = groupInfoDAL.GroupApplyRecord(groupUsersManager.GroupID).Count();

            returnPlayerList.SetApplyUsers(counts);
            var returnPlayerListData = returnPlayerList.Build().ToByteArray();

            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1051, returnPlayerListData.Length, requestInfo.MessageNum, returnPlayerListData)));
        }
Example #4
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();


            var sendApplyRecord = SendApplyRecord.ParseFrom(requestInfo.Body);

            //       var player = Player.CreateBuilder();
            var groupApplyInfo       = GroupApplyInfo.CreateBuilder();
            var returnGroupApplyInfo = ReturnGroupApplyInfo.CreateBuilder();

            Byte[] returnData = null;


            List <DAL.Model.ApplyRecord> list = null;

            if (sendApplyRecord.HasGroupID)
            {
                list = groupInfoDAL.GroupApplyRecord(sendApplyRecord.GroupID);
                if (list.Count == 0)
                {
                    returnData = returnGroupApplyInfo.Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1061, returnData.Length, requestInfo.MessageNum, returnData)));
                }
                else
                {
                    foreach (var item in list)
                    {
                        DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(item.ApplyJoinUserID);
                        var player = Player.CreateBuilder().SetGroupUserID(userinfo.id).SetNickName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userinfo.nickname))).SetPicture(userinfo.headimg);
                        groupApplyInfo.SetGroupID(item.GroupID).SetApplyStatus(item.ApplyStatus).AddPlayerInfo(player).SetApplyDateTime(TimeToLong.ConvertDateTimeInt(item.ApplyDateTime)).SetGroupName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(item.GroupName)));
                        //       returnGroupApplyInfo.AddGroupApplyInfoList(groupApplyInfo);
                        returnGroupApplyInfo.AddGroupApplyInfoList(groupApplyInfo);
                    }
                    //      groupApplyInfo.SetGroupID(item.GroupID).SetApplyStatus(item.ApplyStatus).AddPlayerInfo(player).SetApplyDateTime(TimeToLong.ConvertDateTimeInt(item.ApplyDateTime)).SetGroupName(item.GroupName);

                    returnData = returnGroupApplyInfo.Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1061, returnData.Length, requestInfo.MessageNum, returnData)));
                    //session.Close();
                }
            }
            else
            {
                list = groupInfoDAL.PlayerApplyRecord(sendApplyRecord.UserID);

                if (list.Count == 0)
                {
                    returnData = returnGroupApplyInfo.Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1061, returnData.Length, requestInfo.MessageNum, returnData)));
                }
                else
                {
                    foreach (var item in list)
                    {
                        DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(item.ApplyJoinUserID);
                        var player = Player.CreateBuilder().SetGroupUserID(userinfo.id).SetNickName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userinfo.nickname))).SetPicture(userinfo.headimg);
                        groupApplyInfo.SetGroupID(item.GroupID).SetApplyStatus(item.ApplyStatus).AddPlayerInfo(player).SetApplyDateTime(TimeToLong.ConvertDateTimeInt(item.ApplyDateTime)).SetGroupName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(item.GroupName)));
                        //   returnGroupApplyInfo.AddGroupApplyInfoList(groupApplyInfo);
                        returnGroupApplyInfo.AddGroupApplyInfoList(groupApplyInfo);
                    }

                    returnData = returnGroupApplyInfo.Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1061, returnData.Length, requestInfo.MessageNum, returnData)));
                }
            }
        }
Example #5
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();


            var requestUsersManager = SendGroupUsersManager.ParseFrom(requestInfo.Body);
            // RedisUserInfoModel user = RedisUtility.Get<RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, requestUsersManager.Openid, requestUsersManager.Unionid));
            var nowUser = Gongyong.userlist.First(w => w != null && w.unionid.Equals(requestUsersManager.Unionid));

            if (nowUser == null)
            {
                session.Logger.Debug("管理朋友圈用户 未登录!");
                return;
            }
            var player           = Player.CreateBuilder();
            var returnPlayerList = ReturnPlayerList.CreateBuilder();
            var list             = groupInfoDAL.GetUsersIDListByGroupID(requestUsersManager.GroupID);

            byte[] returnMessage = null;

            var groupInfo = groupInfoDAL.GetGroupInfoByGroupID(requestUsersManager.GroupID, nowUser.Type);

            if (nowUser.Type == 0)
            {
                if (groupInfo.CreateUserID != nowUser.UserID)
                {
                    session.Logger.Debug("管理朋友圈用户不是圈主!");
                    return;
                }
            }
            else if (nowUser.Type == 1)//龙宝用户
            {
                if (!groupInfo.CreateUserUnionID.Equals(nowUser.unionid))
                {
                    session.Logger.Debug("管理朋友圈用户不是圈主!");
                    return;
                }
            }
            //删除用户
            if (requestUsersManager.HasDelByUserID && !requestUsersManager.HasAddUsers)
            {
                if (groupInfo.CreateUserID == requestUsersManager.DelByUserID)
                {
                    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("群主不能删除自己").Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    return;
                }
                else
                {
                    // groupInfoDAL.DelUsersByUserID(requestUsersManager.GroupID, requestUsersManager.DelByUserID);
                    groupInfoDAL.DelUsersByUserIDTransaction(requestUsersManager.GroupID, requestUsersManager.DelByUserID, 3, requestUsersManager.DelByUserID);


                    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage(string.Format("删除用户{0}成功", requestUsersManager.DelByUserID)).Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    return;
                }
            }
            //添加用户
            else if (!requestUsersManager.HasDelByUserID && requestUsersManager.HasAddUsers)
            {
                //加入类型,1圈主添加,2申请加入,3推荐加入
                // byte[] returnMessage = null;
                //var groupInfo = groupInfoDAL.GetGroupInfoByGroupID(requestUsersManager.GroupID);
                //if (groupInfo.CreateUserID == requestUsersManager.AddUsers)
                //{
                //    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("添加失败").Build().ToByteArray();
                //    session.Send(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                //    return;
                //}
                if (new DAL.DAL.mjuserinfoDAL().GetModel(requestUsersManager.AddUsers) != null)
                {
                    var err = groupInfoDAL.AddUserToGroup(requestUsersManager.GroupID, requestUsersManager.AddUsers, 1);

                    if (err == 0)
                    {
                        returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("添加失败,已存在该用户").Build().ToByteArray();
                        session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    }
                    else
                    {
                        returnMessage = ReturnMessgae.CreateBuilder().SetStatue(1).SetMessage("添加成功").Build().ToByteArray();


                        //添加成狗后把用户丢到RedisUs  避免需重复登陆问题
                        RedisUserInfoModel user = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, requestUsersManager.AddUsers.ToString(), requestUsersManager.AddUsers.ToString()));
                        if (user != null)
                        {
                            user.GroupID.Add((int)requestUsersManager.GroupID);
                            RedisUtility.Set(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, user.Openid, user.Unionid), user);
                            var userInfo = Gongyong.userlist.Find(w => w.UserID == user.UserID);
                            if (userInfo != null)
                            {
                                userInfo.GroupID.Add((int)requestUsersManager.GroupID);
                            }
                        }

                        session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    }
                }
                else
                {
                    returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("无此用户").Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
                    return;
                }
                return;
            }
            else if (requestUsersManager.HasCheckRecordByUserID)
            {
                var createRommRecord = CreateRommRecord.CreateBuilder();
                var returnRecordList = ReturnRecordList.CreateBuilder();
                var listRecord       = groupInfoDAL.GetCreateRoomRecord(requestUsersManager.CheckRecordByUserID, requestUsersManager.GroupID);
                foreach (var item in listRecord)
                {
                    createRommRecord.SetGroupID(item.GroupID).SetRoomID(item.RoomID).SetCreateUserID(item.CreateUserID).SetCreateDate(TimeToLong.ConvertDateTimeInt(item.CreateDate)).SetUseRoomCard(item.UseRoomCard);
                    returnRecordList.AddCreateRommRecordList(createRommRecord);
                }

                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1052, returnRecordList.Build().ToByteArray().Length, requestInfo.MessageNum, returnRecordList.Build().ToByteArray())));
                // session.Close();
                return;
            }

            foreach (var userID in list)
            {
                DAL.Model.mjuserinfo userinfo = new DAL.DAL.mjuserinfoDAL().GetModel(userID);
                if (userinfo == null)
                {
                    groupInfoDAL.DelUsersByUserID(requestUsersManager.GroupID, userID);
                }
                else
                {
                    player.SetGroupUserID(userID).SetNickName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userinfo.nickname))).SetPicture(userinfo.headimg);
                    returnPlayerList.AddPlayerList(player);
                }
            }

            //返回待审核人数
            int counts = groupInfoDAL.GroupApplyRecord(requestUsersManager.GroupID).Count();

            returnPlayerList.SetApplyUsers(counts);
            var returnPlayerListData = returnPlayerList.Build().ToByteArray();

            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1051, returnPlayerListData.Length, requestInfo.MessageNum, returnPlayerListData)));
        }