Exemplo n.º 1
0
        /// <summary>
        /// 创建好友请求信息
        /// </summary>
        /// <param name="friendshipRequestInfo">好友请求信息</param>
        /// <param name="userGroupInfo">当前用户用户组信息</param>
        /// <returns></returns>
        public static CreateNewFriendshipRequestEnum CreateNewFriendshipRequest(FriendshipRequestInfo friendshipRequestInfo, UserGroupInfo userGroupInfo)
        {
            if (friendshipRequestInfo.FromUid <= 0 || friendshipRequestInfo.ToUid <= 0 || friendshipRequestInfo.FromUid == friendshipRequestInfo.ToUid)
                return CreateNewFriendshipRequestEnum.MessageError;
            //如果用户之间已经是好友或者用户之间已经有一方请求的
            IsFriendshipExistEnum existResult = IsFriendshipExist(friendshipRequestInfo.FromUid, friendshipRequestInfo.ToUid);

            if (existResult == IsFriendshipExistEnum.Exist)
                return CreateNewFriendshipRequestEnum.FriendshipAlreadyExists;

            if (existResult == IsFriendshipExistEnum.RequestExist)
                return CreateNewFriendshipRequestEnum.RequestAlreadyExists;

            if (GetUserFriendsCount(friendshipRequestInfo.FromUid) >= userGroupInfo.MaxFriendsCount)
                return CreateNewFriendshipRequestEnum.UserFriendshipOverflow;

            if (Data.Friendship.CreateNewFriendshipRequest(friendshipRequestInfo) == (int)CreateNewFriendshipRequestEnum.Success)
            {
                int olId = OnlineUsers.GetOlidByUid(friendshipRequestInfo.ToUid);

                if (olId > 0)//如果被请求用户在线,则更新其在线状态
                    OnlineUsers.UpdateNewFriendsRequest(olId, 1);

                return CreateNewFriendshipRequestEnum.Success;
            }

            return CreateNewFriendshipRequestEnum.MessageError;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 通过好友的请求信息
 /// </summary>
 /// <param name="friendshipInfo"></param>
 /// <returns></returns>
 public int PassFriendship(FriendshipRequestInfo friendshipInfo, int groupId)
 {
     DbParameter[] parms = {
                                 DbHelper.MakeInParam("@fromuid", (DbType)SqlDbType.Int, 4, friendshipInfo.FromUid),
                                 DbHelper.MakeInParam("@touid", (DbType)SqlDbType.Int, 4, friendshipInfo.ToUid),
                                 DbHelper.MakeInParam("@togroupid", (DbType)SqlDbType.Int, 4, groupId)
                             };
     return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, string.Format("{0}passfriendship", BaseConfigs.GetTablePrefix), parms));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 创建好友请求信息
 /// </summary>
 /// <param name="friendshipInfo"></param>
 /// <returns></returns>
 public int CreateNewFriendshipRequest(FriendshipRequestInfo friendshipInfo)
 {
     DbParameter[] parms = {
                                 DbHelper.MakeInParam("@fromuid", (DbType)SqlDbType.Int, 4, friendshipInfo.FromUid),
                                 DbHelper.MakeInParam("@touid", (DbType)SqlDbType.Int, 4, friendshipInfo.ToUid),
                                 DbHelper.MakeInParam("@fromusername", (DbType)SqlDbType.Char, 20, friendshipInfo.FromUserName),
                                 DbHelper.MakeInParam("@gid", (DbType)SqlDbType.Int, 4, friendshipInfo.GroupId),
                                 DbHelper.MakeInParam("@note", (DbType)SqlDbType.NVarChar, 100, friendshipInfo.Note)
                             };
     return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, string.Format("{0}createnewfriendshiprequest", BaseConfigs.GetTablePrefix), parms));
 }