Beispiel #1
0
        private static void NotifyClubUser(Game game)
        {
            var clubUses = ClubHelper.GetClubUserIdList(game.ClubId);

            if (clubUses.IsNotNullOrEmpty())
            {
                var    club = ClubHelper.GetClub(game.ClubId);
                string msg  = string.Format("{0}创建了比赛[{1}],比赛时间[{2}],请积极报名参加。", club.Name, game.Name, game.PlayBeginTime.ToString(Constant.DateTimeFormatCN));
                JPushHelper.SendNotify(MasterType.GAME.Id, game.Id, msg, clubUses);
            }
        }
Beispiel #2
0
        private static void SendNotifyToClubUser(Activity activity)
        {
            var clubUses = ClubHelper.GetClubUserIdList(activity.ClubId);

            if (clubUses.IsNotNullOrEmpty())
            {
                var    club = ClubHelper.GetClub(activity.ClubId);
                string msg  = string.Format("{0}创建了活动{1},开始时间{2}。请积极报名参加。", club.Name, activity.Name, activity.BeginTime.ToString(Constant.DateTimeFormatCN));
                JPushHelper.SendNotify(MasterType.ACTIVITY.Id, activity.Id, msg, clubUses);
            }
        }
Beispiel #3
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);
        }
        /// <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_AuditClubRequest");

            cmd.Params.Add("@requestId", obj.Id);
            cmd.Params.Add("@level", obj.Level, DataType.Int32);
            cmd.Params.Add("@state", obj.State.GetId());
            cmd.Params.Add("@auditorId", obj.AuditorId.GetId());
            cmd.CreateParamMsg();

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

            //审核结果通知本人
            if (result.IsSuccess)
            {
                try
                {
                    var club   = ClubHelper.GetClub(obj.ClubId);
                    var admins = new List <string> {
                        obj.CreatorId.GetId()
                    };
                    var msg = string.Format("您的入群请求[{0}]{1}。", club.Name, obj.State.GetId() == ClubRequestState.PASS.Id ? "已通过" : "被拒绝");
                    JPushHelper.SendNotify(MasterType.CLUB.Id, obj.ClubId, msg, admins);
                }
                catch (Exception)
                {
                }

                //同步加入IM群
                ClubHelper.Instance.ImportToIMGroup(obj.ClubId, UserHelper.GetUserById(obj.CreatorId.GetId()).Code);
            }

            return(result);
        }