Пример #1
0
        public Response Execute(string request)
        {
            var req = JsonConvert.DeserializeObject <Request <ClubUser> >(request);

            if (req.Entities.Count == 0)
            {
                return(ResultHelper.Fail("要移除的成员为空, 请传要移除的成员"));
            }

            Response result = new Response();

            foreach (var obj in req.Entities)
            {
                var cmd = CommandHelper.CreateText(FetchType.Execute, "DELETE FROM ClubUser WHERE ClubId=@clubId AND UserId=@userId");
                cmd.CreateParamUser(obj.UserId.GetId());
                cmd.Params.Add("@clubId", obj.ClubId.GetId());

                result = DbContext.GetInstance().Execute(cmd);

                //退群通知管理员及本人
                try
                {
                    var club   = ClubHelper.GetClub(obj.ClubId);
                    var admins = ClubHelper.GetClubAdminIdList(obj.ClubId);
                    admins.Add(obj.UserId.GetId());
                    JPushHelper.SendNotify(MasterType.CLUB.Id, obj.ClubId, string.Format("您已退出群[{0}]。", club.Name), admins);
                }
                catch (Exception)
                {
                }
            }

            //删除IM群成员
            if (result.IsSuccess)
            {
                result = RemoveGroupMember(req);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 保存俱乐部加入申请
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public Response Execute(User currentUser, string request)
        {
            var req = JsonConvert.DeserializeObject <Request <ClubRequest> >(request);
            var obj = req.Entities.FirstOrDefault();

            var cmd = CommandHelper.CreateProcedure(FetchType.Execute, "sp_SaveClubRequest");

            cmd.Params.Add("@clubId", obj.ClubId.GetId());
            cmd.Params.Add("@userId", obj.CreatorId.GetId());
            cmd.Params.Add("@remark", obj.Remark);
            cmd.CreateParamMsg();

            var result = DbContext.GetInstance().Execute(cmd);

            //加群请求通知管理员
            if (result.IsSuccess)
            {
                try
                {
                    JPushHelper.SendNotify(MasterType.CLUB.Id, obj.ClubId, string.Format("有新入群请求,来自[{0}]。", currentUser.PetName), ClubHelper.GetClubAdminIdList(obj.ClubId));
                }
                catch (Exception)
                {
                }
            }
            return(result);
        }