Ejemplo n.º 1
0
        public Response Execute(User currentUser, string request)
        {
            var req    = JsonConvert.DeserializeObject <Request <GetClubUserListFilter> >(request);
            var result = ClubHelper.GetClubUserList(req.Filter);

            return(result);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        private static void SetClubUserList(Club club)
        {
            GetClubUserListFilter filter = new GetClubUserListFilter {
                ClubId = club.Id, PageIndex = 1, PageSize = 10
            };
            var teamListResult = ClubHelper.GetClubUserList(filter);

            if (teamListResult.Entities.IsNotNullOrEmpty())
            {
                club.ClubUserList = teamListResult.Entities.ToList <EntityBase, ClubUser>();
            }
        }
Ejemplo n.º 5
0
        public Response Execute(User currentUser, string request)
        {
            var req = JsonConvert.DeserializeObject <Request <Club> >(request);
            var cmd = CommandHelper.CreateProcedure <Club>(text: "sp_GetClub");

            cmd.Params.Add(CommandHelper.CreateParam("@clubId", req.Filter.Id));
            cmd.Params.Add(CommandHelper.CreateParam("@userId", currentUser.Id));
            var result = DbContext.GetInstance().Execute(cmd);

            var club = result.FirstEntity <Club>();

            if (club != null)
            {
                club.TryGetFiles();
                club.ClubAddressList = ClubHelper.GetClubAddressList(club.Id);
                SetClubUserList(club);
            }
            return(result);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public Response Execute(User currentUser, string request)
        {
            var req = JsonConvert.DeserializeObject <Request <ClubUser> >(request);
            var obj = req.Entities.FirstOrDefault();

            obj.ClubId = obj.ClubId.GetId();
            obj.UserId = obj.UserId.GetId();
            obj.SetNewEntity();
            //验证是否是俱乐部成员,存在则直接返回
            if (ClubHelper.HasClubMember(obj.ClubId, obj.UserId))
            {
                return(ResultHelper.Fail("已经是俱乐部成员。"));
            }
            var cmd    = CommandHelper.CreateSave(req.Entities);
            var result = DbContext.GetInstance().Execute(cmd);

            if (result.IsSuccess)
            {
                ClubHelper.Instance.ImportToIMGroup(obj.ClubId, UserHelper.GetUserById(obj.UserId).Code);
            }
            return(result);
        }
Ejemplo n.º 8
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_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);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 创建比赛
        /// </summary>
        /// <param name="currentUser">忽略</param>
        /// <param name="request">Request.Game</param>
        /// <returns>Response.EmptyEntity</returns>
        public Response Execute(User currentUser, string request)
        {
            var req  = JsonConvert.DeserializeObject <Request <Game> >(request);
            var game = req.FirstEntity();

            SetLinkIdField(game);

            //俱乐部赛事,验证管理员权限
            if (game.ClubId.IsNotNullOrEmpty() && !ClubHelper.IsUserClubAdmin(game.ClubId, currentUser.Id))
            {
                return(ResultHelper.Fail("俱乐部管理员才能创建俱乐部比赛。"));
            }

            //非小组循环后模式,则设置IsKnockOutAB为false,否则保持用户输入。
            if (game.KnockoutOption != KnockoutOption.ROUND_KNOCKOUT.Id)
            {
                game.IsKnockOutAB = false;
            }

            if (game.RowState == RowState.Added)
            {
                game.SetNewId();
                game.SetCreateDate();
                game.CreatorId = currentUser.Id;
            }
            game.ModifyHeadIcon();

            List <EntityBase> entities = new List <EntityBase> {
                game
            };

            //获取将要保存的图片列表
            game.GetWillSaveFileList(entities);

            ////更改相应对阵模板的使用次数,更新多数代码迁移至比赛结束代码接口处,这样统计更准确
            //string oldTempletId = string.Empty;
            //if (game.RowState == RowState.Modified)
            //{
            //    var cmd2 = CommandHelper.CreateText<Game>(FetchType.Fetch, "SELECT TeamMode FROM Game WHERE Id=@gameId");
            //    cmd2.Params.Add("@gameId", game.Id);
            //    var res2 = DbContext.GetInstance().Execute(cmd2);
            //    oldTempletId = (res2.Entities[0] as Game).TeamMode;//旧模板ID
            //}
            //GameLoopTempletHelper.UpdateTempletUseCount(game.TeamMode, oldTempletId);
            /////////////////////////

            var result = DbContext.GetInstance().Execute(CommandHelper.CreateSave(entities));


            if (game.ClubId.IsNotNullOrEmpty() && game.RowState == RowState.Added)
            {
                try
                {
                    NotifyClubUser(game);
                }
                catch (Exception)
                {
                }
            }
            return(result);
        }
Ejemplo n.º 10
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);
        }