Ejemplo n.º 1
0
        public static void SetBonusGot(int playerID, int bonusToClub, int clubID, int luckyPlayerID)
        {
            var sql = "UPDATE dbo.Arsenalcn_Config SET ConfigValue = 'true' WHERE ConfigKey = 'LuckyPlayerBonusGot'; ";

            sql = sql +
                  "UPDATE dbo.AcnClub_LogLuckyPlayer SET BonusGot = 1 WHERE [ID] = (SELECT TOP 1 [ID] FROM AcnClub_LogLuckyPlayer ORDER BY [Date] DESC); ";

            using (var con = SQLConn.GetConnection())
            {
                var com = new SqlCommand(sql, con);

                con.Open();

                com.ExecuteNonQuery();

                //con.Close();
            }

            var player  = PlayerStrip.GetPlayerInfoByPlayerID(playerID);
            var lPlayer = PlayerStrip.GetPlayerInfoByPlayerID(luckyPlayerID);

            if (player != null && clubID > 0)
            {
                var ch = new ClubHistory();
                ch.ClubID            = clubID;
                ch.ActionUserName    = lPlayer.UserName;
                ch.OperatorUserName  = player.UserName;
                ch.ActionType        = ClubHistoryActionType.LuckyPlayer.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.LuckyPlayer,
                                                                            bonusToClub.ToString(), lPlayer.UserName);

                ClubLogic.SaveClubHistory(ch);
            }
        }
Ejemplo n.º 2
0
        public static void ApproveJoinClub(int applyHistoryId, bool approved, string operatorUserName)
        {
            var ah = ClubLogic.GetApplyHistory(applyHistoryId);

            ah.IsAccepted = approved;

            ClubLogic.SaveApplyHistory(ah);

            var ch = new ClubHistory();

            ch.ClubID           = ah.ClubUid;
            ch.ActionUserName   = ah.UserName;
            ch.OperatorUserName = operatorUserName;
            ch.ActionDate       = DateTime.Now;

            if (approved)
            {
                //insert user club
                var uc = new UserClub();

                uc.ClubUid        = ah.ClubUid;
                uc.JoinClubDate   = DateTime.Now;
                uc.FromDate       = DateTime.Now;
                uc.IsActive       = true;
                uc.Responsibility = (int)Responsibility.Member;
                uc.Userid         = ah.Userid;
                uc.UserName       = ah.UserName;

                ClubLogic.SaveUserClub(uc);

                ch.ActionType        = ClubHistoryActionType.JoinClub.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.JoinClub, null);
            }
            else
            {
                ch.ActionType        = ClubHistoryActionType.RejectJoinClub.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.RejectJoinClub, null);
            }

            ClubLogic.SaveClubHistory(ch);

            if (approved)
            {
                ClubSysPrivateMessage.SendMessage(ah.ClubUid, ah.UserName, ClubSysMessageType.ApproveJoinClub);
            }
            else
            {
                ClubSysPrivateMessage.SendMessage(ah.ClubUid, ah.UserName, ClubSysMessageType.RejectJoinClub);
            }
        }
Ejemplo n.º 3
0
        public static bool LeaveClub(int userID, int clubID, bool isKicked, string kickUserName)
        {
            var uc = ClubLogic.GetActiveUserClub(userID, clubID);

            if (uc != null)
            {
                uc.ToDate   = DateTime.Now;
                uc.IsActive = false;

                if (uc.Responsibility == (int)Responsibility.Manager)
                {
                    return(false);
                }

                ClubLogic.SaveUserClub(uc);

                var ch = new ClubHistory();
                ch.ClubID         = clubID;
                ch.ActionUserName = uc.UserName;

                if (isKicked)
                {
                    ch.ActionType        = ClubHistoryActionType.MandatoryLeaveClub.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(
                        ClubHistoryActionType.MandatoryLeaveClub, null);
                    ch.OperatorUserName = kickUserName;
                }
                else
                {
                    ch.ActionType        = ClubHistoryActionType.LeaveClub.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.LeaveClub, null);
                    ch.OperatorUserName  = uc.UserName;
                }

                ClubLogic.SaveClubHistory(ch);

                if (isKicked)
                {
                    ClubSysPrivateMessage.SendMessage(clubID, uc.UserName, ClubSysMessageType.MandatoryLeaveClub);
                }
                else
                {
                    ClubSysPrivateMessage.SendMessage(clubID, uc.UserName, ClubSysMessageType.LeaveClub);
                }

                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static void TransferMemberExtcredit(int clubID, int fromUserID, int toUserID, float extCredit,
                                                   int extCreditType)
        {
            //UserClub ucFrom = ClubLogic.GetActiveUserClub(fromUserID, clubID);
            //UserClub ucTo = ClubLogic.GetActiveUserClub(toUserID, clubID);

            var userFrom = Users.GetUserInfo(fromUserID);
            var userTo   = Users.GetUserInfo(toUserID);

            if (fromUserID != toUserID)
            {
                if (extCredit > Users.GetUserExtCredits(fromUserID, extCreditType))
                {
                    throw new Exception("Insufficient Founds");
                }

                var list = ClubLogic.GetUserManagedClubs(fromUserID);
                if (list == null || list.Count <= 0)
                {
                    throw new Exception("No privilege of tranfer");
                }

                // Transfer Logic

                Users.UpdateUserExtCredits(fromUserID, extCreditType, -extCredit);
                Users.UpdateUserExtCredits(toUserID, extCreditType, extCredit);

                // Club History Log & SMS

                var ch = new ClubHistory();
                ch.ClubID            = clubID;
                ch.ActionUserName    = userTo.Username.Trim();
                ch.ActionType        = ClubHistoryActionType.TransferExtcredit.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.TransferExtcredit,
                                                                            userTo.Username.Trim(), extCredit.ToString(), "枪手币");
                ch.OperatorUserName = userFrom.Username.Trim();

                ClubLogic.SaveClubHistory(ch);

                ClubSysPrivateMessage.SendMessage(clubID, userTo.Username.Trim(), ClubSysMessageType.TransferExtcredit,
                                                  userFrom.Username.Trim(), extCredit.ToString("N0"), "枪手币");
            }
            else
            {
                throw new Exception("Can't transfer to yourself");
            }
        }
Ejemplo n.º 5
0
        public static void ChangeResponsibility(int userID, string userName, int clubID, Responsibility res,
                                                string operatorUserName)
        {
            var userClub = ClubLogic.GetActiveUserClub(userID, clubID);

            if (userClub != null && userClub.Responsibility == (int)res)
            {
                return;
            }

            var club = ClubLogic.GetClubInfo(clubID);

            if (club != null)
            {
                if (res == Responsibility.Manager)
                {
                    #region Proceed previous manager user club info

                    var preManagerUid  = club.ManagerUid.Value;
                    var preManagerName = club.ManagerUserName;
                    LeaveClub(preManagerUid, clubID);

                    var preManagerUc = ClubLogic.GetActiveUserClub(preManagerUid, clubID);

                    var preUC = new UserClub();
                    preUC.ClubUid        = clubID;
                    preUC.JoinClubDate   = preManagerUc.JoinClubDate;
                    preUC.FromDate       = DateTime.Now;
                    preUC.IsActive       = true;
                    preUC.Responsibility = (int)Responsibility.Member;
                    preUC.Userid         = preManagerUid;
                    preUC.UserName       = preManagerName;

                    ClubLogic.SaveUserClub(preUC);

                    #endregion

                    club.ManagerUid      = userID;
                    club.ManagerUserName = userName;
                    club.UpdateDate      = DateTime.Now;
                    ClubLogic.SaveClub(club);
                }

                LeaveClub(userID, clubID);

                var uc = new UserClub();
                uc.ClubUid      = clubID;
                uc.JoinClubDate = userClub.JoinClubDate;
                uc.FromDate     = DateTime.Now;
                uc.IsActive     = true;
                uc.Userid       = userID;
                uc.UserName     = userName;


                var ch = new ClubHistory();
                ch.ClubID           = clubID;
                ch.ActionUserName   = userName;
                ch.OperatorUserName = operatorUserName;

                if (userClub.Responsibility.Value > (int)res)
                {
                    //nominate
                    ch.ActionType        = ClubHistoryActionType.Nominated.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.Nominated,
                                                                                ClubLogic.TranslateResponsibility(res));
                }
                else
                {
                    //dismiss
                    ch.ActionType        = ClubHistoryActionType.Dismiss.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.Dismiss,
                                                                                ClubLogic.TranslateResponsibility(res));
                }

                uc.Responsibility = (int)res;

                ClubLogic.SaveUserClub(uc);
                ClubLogic.SaveClubHistory(ch);
            }
            else
            {
                throw new Exception("Club not exist.");
            }
        }