コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string           key   = context.Request["key"];
            CommRelationType nType = new CommRelationType();

            if (!Enum.TryParse(key, out nType))
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "该关系不能识别";
                bllCommRelation.ContextResponse(context, apiResp);
                return;
            }

            if (bllCommRelation.ExistRelation(nType, bllCommRelation.WebsiteOwner, ""))
            {
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = "该关系存在";
                apiResp.status = true;
            }
            else
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "该关系不存在";
            }
            bllCommRelation.ContextResponse(context, apiResp);
        }
コード例 #2
0
ファイル: IsFollow.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string toUserId = context.Request["autoid"];

            if (string.IsNullOrEmpty(toUserId))
            {
                apiResp.msg  = "autoid 为必填项,请检查";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            UserInfo toUserModel = bllUser.GetUserInfoByAutoID(int.Parse(toUserId));

            if (toUserModel == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                apiResp.msg  = "不存在关注的用户";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (bLLCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.FollowUser, toUserModel.UserID, CurrentUserInfo.UserID))
            {
                apiResp.msg  = "已经关注";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsRepeat;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            apiResp.msg    = "没有关注过此用户";
            apiResp.status = true;
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #3
0
ファイル: DelCommUserRelation.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string rtype    = context.Request["rtype"],
                   mainId   = context.Request["mainId"],
                   exchange = context.Request["exchange"]; //1时mainId,relationId互换

            BLLJIMP.Enums.CommRelationType nType = new BLLJIMP.Enums.CommRelationType();
            if (!Enum.TryParse(rtype, out nType))
            {
                apiResp.code = 1;
                apiResp.msg  = "类型格式不能识别";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            if (mainId == "0" || string.IsNullOrWhiteSpace(mainId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.ContentNotFound;
                apiResp.msg  = "关联主Id错误";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            currentUserInfo = bLLCommRelation.GetCurrentUserInfo();
            if (this.currentUserInfo == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin;
                apiResp.msg  = "请先登录";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            string relationId = this.currentUserInfo.AutoID.ToString();

            if (mainId == relationId)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg  = "不能跟自己建立关系";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            if (exchange == "1")
            {
                relationId = mainId;
                mainId     = this.currentUserInfo.AutoID.ToString();
            }

            if (!this.bLLCommRelation.ExistRelation(nType, mainId, relationId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsRepeat;
                apiResp.msg  = "关系不存在";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }

            if (this.bLLCommRelation.DelCommRelation(nType, mainId, relationId))
            {
                if (nType == CommRelationType.FriendApply)
                {
                    UserInfo toUser = bllUser.GetUserInfoByAutoID(int.Parse(mainId));
                    //拒绝好友申请删除申请关系
                    bLLCommRelation.DelCommRelation(CommRelationType.FriendApply, relationId, mainId);
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.RejectFriendApply, this.currentUserInfo, null, new List <UserInfo>()
                    {
                        toUser
                    }, null);
                }
                else if (nType == CommRelationType.Friend)
                {
                    UserInfo toUser = bllUser.GetUserInfoByAutoID(int.Parse(mainId));
                    //删除好友关系
                    bLLCommRelation.DelCommRelation(CommRelationType.Friend, mainId, relationId);
                    bLLCommRelation.DelCommRelation(CommRelationType.Friend, relationId, mainId);

                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.DeleteFriend, this.currentUserInfo, null, new List <UserInfo>()
                    {
                        toUser
                    }, null);
                }
                else if (nType == CommRelationType.JuActivityPraise)
                {
                    JuActivityInfo article = bll.GetJuActivity(int.Parse(mainId), false);

                    //点赞数直接修改到主表
                    int praiseCount = bLLCommRelation.GetRelationCount(nType, mainId, null);
                    bll.Update(article, string.Format("PraiseCount={0}", praiseCount), string.Format("JuActivityID={0}", article.JuActivityID));
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.DisJuActivityPraise, this.currentUserInfo, article, article.UserID, null);
                }

                apiResp.status = true;
                apiResp.msg    = "删除完成";
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg  = "删除失败";
            }
            bLLCommRelation.ContextResponse(context, apiResp);
        }
コード例 #4
0
ファイル: List.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string relationId = context.Request["rel_id"];
            int    page       = 1;
            int    rows       = int.MaxValue;

            if (!string.IsNullOrWhiteSpace(context.Request["page"]))
            {
                page = Convert.ToInt32(context.Request["page"]);
            }
            if (!string.IsNullOrWhiteSpace(context.Request["rows"]))
            {
                rows = Convert.ToInt32(context.Request["rows"]);
            }

            UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo();

            if (string.IsNullOrWhiteSpace(relationId) && CurrentUserInfo != null)
            {
                relationId = CurrentUserInfo.AutoID.ToString();
            }
            if (string.IsNullOrWhiteSpace(relationId))
            {
                relationId = "-999";
            }
            List <CommRelationInfo> rellist = bLLCommRelation.GetRelationList(CommRelationType.Friend, null, relationId, 1, int.MaxValue, colName: "AutoId,MainId");

            if (rellist.Count == 0)
            {
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                apiResp.msg    = "查询完成";
                apiResp.status = true;
                apiResp.result = new
                {
                    totalcount = 0,
                    list       = rellist
                };
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }

            string          autoIds = ZentCloud.Common.MyStringHelper.ListToStr(rellist.Select(p => p.MainId).ToList(), "", ",");
            int             total   = 0;
            List <UserInfo> uList   = bllUser.GetUserList(page, rows, null, null, null, null, null, out total, autoIds,
                                                          "AutoID,UserID,WXNickname,TrueName,WebsiteOwner,WXHeadimgurl,Avatar,Phone,ViewType,TotalScore,OnlineTimes,Description");

            var list = from p in uList
                       join r in rellist
                       on p.AutoID.ToString() equals r.MainId
                       orderby r.AutoId descending
                       select new
            {
                id              = p.AutoID,
                avatar          = bllUser.GetUserDispalyAvatar(p),
                userName        = bllUser.GetUserDispalyName(p),
                describe        = p.Description,
                phone           = p.ViewType == 1 ? "" : p.Phone,
                score           = p.TotalScore,
                times           = p.OnlineTimes,
                userHasRelation = CurrentUserInfo == null ? false : bLLCommRelation.ExistRelation(CommRelationType.Friend, p.AutoID.ToString(), CurrentUserInfo.AutoID.ToString())
            };



            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            apiResp.msg    = "查询完成";
            apiResp.status = true;
            apiResp.result = new
            {
                totalcount = total,
                list       = list
            };
            bLLCommRelation.ContextResponse(context, apiResp);
        }
コード例 #5
0
        public void ProcessRequest(HttpContext context)
        {
            int    pageIndex  = int.Parse(context.Request["pageIndex"]);
            int    pageSize   = int.Parse(context.Request["pageSize"]);
            string userAutoId = context.Request["userAutoId"];
            string keyword    = context.Request["keyword"];  //昵称搜索
            string type       = context.Request["type"];     //昵称搜索
            string exchange   = context.Request["exchange"]; //1时mainId,relationId互换
            string isid       = context.Request["isid"];     //AutoID建立的关系

            BLLJIMP.Enums.CommRelationType nType = BLLJIMP.Enums.CommRelationType.FollowUser;
            if (!string.IsNullOrWhiteSpace(type))
            {
                if (!Enum.TryParse(type, out nType))
                {
                    apiResp.code = 1;
                    apiResp.msg  = "类型格式不能识别";
                    bLLCommRelation.ContextResponse(context, apiResp);
                    return;
                }
            }
            currentUserInfo = bLLCommRelation.GetCurrentUserInfo();

            string mainId     = "";
            string relationId = "";

            if (isid == "1")
            {
                relationId = userAutoId;
            }
            else
            {
                UserInfo user = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId));
                relationId = user.UserID;
            }
            if (exchange == "1")
            {
                mainId     = relationId;
                relationId = "";
            }

            int             TCount = 0;
            List <UserInfo> users  = bllUser.GetRelationUserList(pageSize, pageIndex, nType, mainId, relationId, keyword, out TCount, isid == "1");

            var list = from p in users
                       select new
            {
                id              = p.AutoID,
                avatar          = bllUser.GetUserDispalyAvatar(p),
                userName        = bllUser.GetUserDispalyName(p),
                describe        = p.Description,
                phone           = p.ViewType == 1?"": p.Phone,
                score           = p.TotalScore,
                times           = p.OnlineTimes,
                userHasRelation = this.currentUserInfo == null ? false : (isid == "1" ? bLLCommRelation.ExistRelation(nType, p.AutoID.ToString(), this.currentUserInfo.AutoID.ToString()) : bLLCommRelation.ExistRelation(nType, p.UserID, this.currentUserInfo.UserID)),
                relationTime    = p.LastLoginDate.ToString("yyyy/MM/dd hh:mm:ss")
            };

            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            apiResp.msg    = "查询完成";
            apiResp.status = true;
            apiResp.result = new
            {
                totalcount = TCount,
                list       = list
            };
            bLLCommRelation.ContextResponse(context, apiResp);
        }