コード例 #1
0
ファイル: Login.cs プロジェクト: zhaoy615/Guizhoule
        /// <summary>
        /// 判断登陆用户信息(如无则添加)
        /// </summary>
        /// <param name="md"></param>
        /// <returns></returns>
        public mjuserinfo AddUser(mjuserinfo md, GameSession session)
        {
            mjuserinfoDAL dal    = new mjuserinfoDAL();
            mjuserinfo    model  = dal.GetModel(md.openid);
            LogDAL        Ldal   = new LogDAL();
            login_log     Lmodel = new login_log();

            if (model == null)
            {
                try
                {
                    md.addtime = DateTime.Now;
                    // string fileName =Guid.NewGuid() + ".jpg"; ;
                    //  string imgurl = PictureUtility.SavePicture(md.headimg, out fileName);//将图片保存至本地返回详细路径和文件名
                    //    if (!string.IsNullOrEmpty(imgurl))//验证是否保存成功
                    //     md.headimg = PutObjectSample.PutObjectFromFile(md.headimg, fileName, -1);//服务器没有图片,因此不能存储至图片服务器

                    dal.Add(md);
                    Lmodel.ID          = Guid.NewGuid().ToString();
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Lmodel.City        = md.city;
                    Ldal.Add(Lmodel);
                }
                catch (Exception ex)
                {
                    session.Logger.Error(ex);
                }
                return(dal.GetModel(md.openid));;
            }
            else
            {
                try
                {
                    md.id = model.id;
                    //if (!md.Oldheadimg.Equals(model.Oldheadimg))
                    //{
                    //    string fileName = Guid.NewGuid() + ".jpg"; ;
                    //    //服务器没有图片,因此不能存储至图片服务器  md.headimg = PutObjectSample.PutObjectFromFile(md.headimg, fileName, -1);
                    //}
                    dal.Update(md);
                    Lmodel.ID          = Guid.NewGuid().ToString();
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Lmodel.City        = md.city;
                    Ldal.Add(Lmodel);
                }
                catch (Exception ex)
                {
                    session.Logger.Error(ex);
                }

                return(md);
            }
        }
コード例 #2
0
ファイル: WXLogin.cs プロジェクト: zhaoy615/Guizhoule
        /// <summary>
        /// 判断登陆用户信息(如无则添加)
        /// </summary>
        /// <param name="md"></param>
        /// <returns></returns>
        public mjuserinfo AddUser(mjuserinfo md, GameSession session)
        {
            int           returnid = 0;
            mjuserinfoDAL dal      = new mjuserinfoDAL();
            mjuserinfo    model    = dal.GetModel(md.openid);
            login_logDAL  Ldal     = new login_logDAL();
            login_log     Lmodel   = new login_log();



            if (model == null)
            {
                try
                {
                    returnid   = dal.GetMaxID() + 1;
                    md.id      = returnid;
                    md.addtime = DateTime.Now;
                    string fileName = string.Empty;
                    string imgurl   = PictureUtility.SavePicture(md.headimg, out fileName); //将图片保存至本地返回详细路径和文件名
                    if (!string.IsNullOrEmpty(imgurl))                                      //验证是否保存成功
                    {
                        md.headimg = PutObjectSample.PutObjectFromFile(imgurl, fileName);
                    }
                    dal.Add(md);
                    Lmodel.id          = Ldal.GetMaxID() + 1;
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Ldal.Add(Lmodel);
                }
                catch (Exception ex)
                {
                    session.Logger.Error(ex);
                }



                return(md);
            }
            else
            {
                try
                {
                    Lmodel.id          = Ldal.GetMaxID() + 1;
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Ldal.Add(Lmodel);
                }
                catch (Exception)
                {
                    throw;
                }

                return(model);
            }
        }
コード例 #3
0
ファイル: SearchPlayer.cs プロジェクト: zhaoy615/Guizhoule
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL groupInfoDAL     = new GroupInfoDAL();
            var          sendSearchPlayer = SendSearchPlayer.ParseFrom(requestInfo.Body);

            mjuserinfoDAL mjuserinfoDAL = new mjuserinfoDAL();
            var           userinfo      = mjuserinfoDAL.GetModel(sendSearchPlayer.UserID);

            if (userinfo != null)
            {
                var returnDate = Player.CreateBuilder().SetGroupUserID(userinfo.id).SetNickName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userinfo.nickname))).SetPicture(userinfo.headimg).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER, returnDate.Length, requestInfo.MessageNum, returnDate)));
            }
            else
            {
                var returnMessage = ReturnMessgae.CreateBuilder().SetStatue(0).SetMessage("该用户不存在").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1104, returnMessage.Length, requestInfo.MessageNum, returnMessage)));
            }
        }
コード例 #4
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var sendChangeApplyStatus = SendChangeApplyStatus.ParseFrom(requestInfo.Body);

            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();

            byte[] resultData = null;
            DAL.DAL.mjuserinfoDAL mjuserinfo = new mjuserinfoDAL();
            if (sendChangeApplyStatus.ApplyStatus == 1 || sendChangeApplyStatus.ApplyStatus == 2)
            {
                var userinfo = mjuserinfo.GetModel(sendChangeApplyStatus.UserID);
                if (userinfo != null)
                {//=========================================================
                    if (groupInfoDAL.GetIsExistenceApplyStatus(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, 0) == 1)
                    {
                        if (groupInfoDAL.AgreeApplyStatus(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, sendChangeApplyStatus.ApplyStatus, 0) != 0)
                        {
                            if (sendChangeApplyStatus.ApplyStatus == 1)
                            {
                                groupInfoDAL.AddUserToGroup(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, 2);
                                RedisUserInfoModel user = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, userinfo.openid, userinfo.unionid));
                                if (user != null)
                                {
                                    user.GroupID.Add((int)sendChangeApplyStatus.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)sendChangeApplyStatus.GroupID);
                                    }
                                }
                                resultData = ReturnChangeApplyStatus.CreateBuilder().SetStatus(1).SetMessage("修改成功").Build().ToByteArray();
                                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1071, resultData.Length, requestInfo.MessageNum, resultData)));
                            }
                        }
                    }
                    resultData = ReturnChangeApplyStatus.CreateBuilder().SetStatus(1).SetMessage("修改失败").Build().ToByteArray();
                    session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1071, resultData.Length, requestInfo.MessageNum, resultData)));
                }
            }
            else if (sendChangeApplyStatus.ApplyStatus == 5 || sendChangeApplyStatus.ApplyStatus == 6)
            {
                var userinfo = mjuserinfo.GetModel(sendChangeApplyStatus.UserID);
                if (userinfo != null)
                {
                    if (groupInfoDAL.GetIsExistenceApplyStatus(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, 4) == 1)
                    {
                        if (groupInfoDAL.AgreeApplyStatus(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, sendChangeApplyStatus.ApplyStatus) != 0)
                        {
                            if (sendChangeApplyStatus.ApplyStatus == 5)
                            {
                                groupInfoDAL.DelUsersByUserIDTransaction(sendChangeApplyStatus.GroupID, sendChangeApplyStatus.UserID, 5);
                                RedisUserInfoModel user = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, userinfo.openid, userinfo.unionid));
                                if (user != null)
                                {
                                    user.GroupID.Remove((int)sendChangeApplyStatus.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.Remove((int)sendChangeApplyStatus.GroupID);
                                    }
                                }
                                resultData = ReturnChangeApplyStatus.CreateBuilder().SetStatus(1).SetMessage("修改成功").Build().ToByteArray();
                                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1071, resultData.Length, requestInfo.MessageNum, resultData)));
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var             userInfo = SendGetUserRecord.ParseFrom(requestInfo.Body);
            RedisLoginModel olduser  = RedisUtility.Get <RedisLoginModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERLIST, userInfo.Openid, userInfo.Unionid));

            if (olduser == null)
            {
                return;
            }
            var list        = new userRecordLOGDAL().Get48hourInfoByUserID(userInfo.UserID, userInfo.HasGroupID? userInfo.GroupID:0);
            var userinfoDAL = new mjuserinfoDAL();

            var  returnUserRecord = ReturnUserRecord.CreateBuilder();
            long userid;

            foreach (var item in list)
            {
                var userRecord = UserRecord.CreateBuilder();
                userRecord.SetRoomInfoID(item.RoomInfoID);
                userRecord.SetCreateDate(TimeToLong.ConvertDateTimeInt(item.CreateDate));
                userRecord.SetEndTime(TimeToLong.ConvertDateTimeInt(item.EndTime));
                userRecord.SetUserID(item.CreateUserID);//需要显示房主标签
                userRecord.SetRoomMsg(
                    ReturnRoomMsg.CreateBuilder()
                    .SetCount(item.RoomNumber)
                    .SetIsBenji(item.IsBenJi)
                    .SetIsLianzhuang(item.CountPointsType == 3 ? 1 : 0)
                    .SetIsShangxiaji(item.IsSangXiaJi)
                    .SetIsWgj(item.IsWGJ)
                    .SetIsXinqiji(item.IsXinQiJi)
                    .SetIsYikousan(item.CountPointsType == 1 ? 1 : 0)
                    .SetIsYuanque(item.IsYuanQue)
                    .SetQuickCard(item.QuickCard)
                    .SetRoomPeo(item.RoomPeo)
                    );
                foreach (var userWinLose in item.UserWinLose.Split('|'))
                {
                    long     userID = 0;
                    string[] info   = userWinLose.Split(',');
                    if (long.TryParse(info[0], out userID))
                    {
                        if (userRecord.RecordUserInfoList.Any(w => w.UserID == userID))
                        {
                            var userInfoData = userRecord.RecordUserInfoList.First(w => w.UserID == userID);
                            userRecord.AddRecordUserInfo(RecordUserInfo.CreateBuilder()
                                                         .SetHeadimg(userInfoData.Headimg)
                                                         .SetNickname(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userInfoData.Nickname)))
                                                         .SetOpenid(userInfoData.Openid)
                                                         .SetScore(info[1])
                                                         .SetSex(userInfoData.Sex)
                                                         .SetUserID(userInfoData.UserID));
                        }
                        else
                        {
                            var userInfoData = userinfoDAL.GetModel(userID);
                            userRecord.AddRecordUserInfo(RecordUserInfo.CreateBuilder()
                                                         .SetHeadimg(userInfoData.headimg)
                                                         .SetNickname(HttpUtility.UrlDecode(HttpUtility.UrlDecode(userInfoData.nickname)))
                                                         .SetOpenid(userInfoData.openid)
                                                         .SetScore(info[1])
                                                         .SetSex(userInfoData.sex.Value)
                                                         .SetUserID(userInfoData.id));
                        }
                    }
                }
                returnUserRecord.AddUserRecord(userRecord);
            }
            var data = returnUserRecord.Build().ToByteArray();

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