Exemplo n.º 1
0
        public static int GetClubMemberEquipmentCount(int clubID)
        {
            var totalCount = 0;

            var ucs = ClubLogic.GetClubMembers(clubID);

            foreach (var uc in ucs)
            {
                var player  = GetPlayerInfo(uc.Userid.Value);
                var numbers = GetMyNumbers(uc.Userid.Value);

                if (player != null)
                {
                    totalCount += (player.Shirt + player.Shorts + player.Sock);
                }

                totalCount += numbers.Count;

                foreach (var number in numbers)
                {
                    if (number.IsActive)
                    {
                        totalCount += 15;
                    }
                }
                totalCount += (Entity.UserVideo.GetUserVideosByUserID(uc.Userid.Value).Count *16);
            }

            return(totalCount);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public static void UpdateBingoResultLog(int userID, BingoResult result)
        {
            var sql =
                "UPDATE AcnClub_LogBingo SET Result = @result, ResultDetail = @resultDetail WHERE [ID] = (SELECT TOP 1 [ID] FROM AcnClub_LogBingo WHERE UserID = @userID AND Result is NULL ORDER BY ActionDate DESC)";

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

                object tempValue = null;

                com.Parameters.Add(new SqlParameter("@userID", userID));

                if (result.Result == BingoResultType.Null)
                {
                    tempValue = DBNull.Value;
                }
                else
                {
                    tempValue = (int)result.Result;
                }

                com.Parameters.Add(new SqlParameter("@result", tempValue));

                com.Parameters.Add(new SqlParameter("@resultDetail", ClubLogic.ParseNullableParam(result.ResultDetail)));

                con.Open();

                com.ExecuteNonQuery();

                //con.Close();
            }
        }
Exemplo n.º 4
0
        internal static bool JoinClub(int userID, string userName, int clubID)
        {
            var ah = ClubLogic.GetActiveApplyHistoryByUserClub(userID, clubID);

            if (ah == null)
            {
                //proceed it
                ApplyJoinClub(userID, userName, clubID);
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        public static void ApplyJoinClub(int userID, string userName, int clubID)
        {
            var ah = new ApplyHistory();

            ah.Userid    = userID;
            ah.UserName  = userName;
            ah.ClubUid   = clubID;
            ah.ApplyDate = DateTime.Now;

            ClubLogic.SaveApplyHistory(ah);

            ClubSysPrivateMessage.SendMessage(clubID, userName, ClubSysMessageType.ApplyJoinClub);
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        internal static bool CancelApplication(int userID, string userName, int clubID)
        {
            var ah = ClubLogic.GetActiveApplyHistoryByUserClub(userID, clubID);

            if (ah != null)
            {
                //proceed to cancel it
                ah.IsAccepted = false;

                ClubLogic.SaveApplyHistory(ah);

                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
        public static void UserClubStatistics()
        {
            foreach (var club in ClubLogic.GetActiveClubs())
            {
                try
                {
                    var clubMemberFortune = 0;
                    var clubMemberCredit  = 0;
                    var clubMemberLoyalty = 0;
                    var clubMemberRP      = 0;

                    var members = ClubLogic.GetClubMembers(club.ID.Value);

                    foreach (var member in members)
                    {
                        try
                        {
                            var userInfo = Users.GetShortUserInfo(member.Userid.Value);

                            if (userInfo != null)
                            {
                                clubMemberFortune += (int)userInfo.Extcredits2;
                                clubMemberCredit  += userInfo.Credits;
                                clubMemberLoyalty += (int)(DateTime.Now - member.JoinClubDate.Value).TotalDays;
                                clubMemberRP      += (int)userInfo.Extcredits4;
                            }
                        }
                        catch
                        {
                        }
                    }

                    club.MemberFortune = clubMemberFortune;
                    club.MemberCredit  = clubMemberCredit;
                    club.MemberLoyalty = clubMemberLoyalty;
                    club.MemberRP      = clubMemberRP;

                    var ra = new RankAlgorithm(club);
                    club.RankScore = ra.SummaryRankPoint;

                    ClubLogic.SaveClub(club);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 10
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");
            }
        }
Exemplo n.º 11
0
        public static void CalcClubFortuneIncrement()
        {
            foreach (var club in ClubLogic.GetActiveClubs())
            {
                try
                {
                    var clubFortuneIncrement = 0;

                    var members = ClubLogic.GetClubMembers(club.ID.Value);

                    foreach (var member in members)
                    {
                        try
                        {
                            var userInfo = Users.GetShortUserInfo(member.Userid.Value);

                            if (userInfo != null)
                            {
                                clubFortuneIncrement += FortuneContributeAlgorithm.CalcContributeFortune(userInfo, true);

                                //int memberFortune = (int)userInfo.Extcredits2;
                                //int memberCredit = userInfo.Credits;
                                //float memberMana = userInfo.Extcredits1;//威望

                                //clubFortuneIncrement += (int)(Config.ClubFortuneIncrementVariable * Math.Pow(Math.Log10(memberCredit), 4)) + (int)((memberMana + 1) * Math.Log10(memberFortune));
                            }
                        }
                        catch
                        {
                        }
                    }

                    club.Fortune = club.Fortune.Value + clubFortuneIncrement;

                    var ra = new RankAlgorithm(club);
                    club.RankLevel = RankLevel.GetInstance().GetRank(club.Fortune.Value).ID;

                    ClubLogic.SaveClub(club);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 12
0
        public static int GetClubMemberVideoCount(int clubID)
        {
            var totalCount = 0;

            var ucs = ClubLogic.GetClubMembers(clubID);

            foreach (var uc in ucs)
            {
                var player = GetPlayerInfo(uc.Userid.Value);
                //DataTable dt = UserVideo.GetUserVideo(uc.Userid.Value);

                if (player != null)
                {
                    totalCount += Entity.UserVideo.GetUserVideosByUserID(uc.Userid.Value).Count;
                }
            }

            return(totalCount);
        }
Exemplo n.º 13
0
        public static int GetClubMemberCardCount(int clubID)
        {
            var totalCount = 0;

            var ucs = ClubLogic.GetClubMembers(clubID);

            foreach (var uc in ucs)
            {
                var player  = GetPlayerInfo(uc.Userid.Value);
                var numbers = GetMyNumbers(uc.Userid.Value);

                if (player != null)
                {
                    totalCount += numbers.Count;
                }
            }

            return(totalCount);
        }
Exemplo n.º 14
0
        //for internal temp leave usage
        internal static bool LeaveClub(int userID, int clubID)
        {
            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);

                return(true);
            }
            return(false);
        }
Exemplo n.º 15
0
        public static void SendMessage(int clubID, string userName, ClubSysMessageType messageType, params string[] para)
        {
            var userID = Users.GetUserId(userName);
            var club   = ClubLogic.GetClubInfo(clubID);

            PrivateMessageInfo pm;

            switch (messageType)
            {
            case ClubSysMessageType.ApplyClub:
                foreach (var aID in ConfigGlobal.PluginAdmin)
                {
                    pm = new PrivateMessageInfo();

                    pm.Msgfrom   = ClubSysAdminName;
                    pm.Msgfromid = 0;

                    pm.Folder  = 0;
                    pm.Message = string.Format(ApplyClub_Message, userName, club.FullName);

                    pm.Msgtoid      = Convert.ToInt32(aID);
                    pm.Msgto        = Users.GetUserInfo(aID).Username.Trim();
                    pm.New          = 1;
                    pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    pm.Subject      = string.Format(ApplyClub_Subject, userName);

                    PrivateMessages.CreatePrivateMessage(pm, 0);
                }
                break;

            case ClubSysMessageType.ApplyJoinClub:
                var users = ClubLogic.GetClubLeads(clubID);
                foreach (var userClub in users)
                {
                    pm = new PrivateMessageInfo();

                    pm.Msgfrom   = ClubSysAdminName;
                    pm.Msgfromid = 0;

                    pm.Folder       = 0;
                    pm.Message      = string.Format(ApplyJoinClub_Message, userName, club.FullName);
                    pm.Msgto        = userClub.UserName;
                    pm.Msgtoid      = userClub.Userid.Value;
                    pm.New          = 1;
                    pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    pm.Subject      = string.Format(ApplyJoinClub_Subject, userName);

                    PrivateMessages.CreatePrivateMessage(pm, 0);
                }
                break;

            case ClubSysMessageType.ApproveClub:
                if (club != null)
                {
                    var result = "通过";
                    if (!club.IsActive.Value)
                    {
                        result = "驳回";
                    }

                    pm = new PrivateMessageInfo();

                    pm.Msgfrom   = ClubSysAdminName;
                    pm.Msgfromid = 0;

                    pm.Folder       = 0;
                    pm.Message      = string.Format(ApproveClub_Message, club.FullName, result);
                    pm.Msgto        = club.CreatorUserName;
                    pm.Msgtoid      = club.CreatorUid.Value;
                    pm.New          = 1;
                    pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    pm.Subject      = ApproveClub_Subject;

                    PrivateMessages.CreatePrivateMessage(pm, 0);
                }
                break;

            case ClubSysMessageType.ApproveJoinClub:
                pm = new PrivateMessageInfo();

                pm.Msgfrom   = ClubSysAdminName;
                pm.Msgfromid = 0;

                pm.Folder       = 0;
                pm.Message      = string.Format(ApproveJoinClub_Message, club.FullName);
                pm.Msgto        = userName;
                pm.Msgtoid      = userID;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = ApproveJoinClub_Subject;

                PrivateMessages.CreatePrivateMessage(pm, 0);
                break;

            case ClubSysMessageType.LeaveClub:
                pm = new PrivateMessageInfo();

                pm.Msgfrom   = ClubSysAdminName;
                pm.Msgfromid = 0;

                pm.Folder       = 0;
                pm.Message      = string.Format(LeaveClub_Message, club.FullName);
                pm.Msgto        = userName;
                pm.Msgtoid      = userID;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = LeaveClub_Subject;

                PrivateMessages.CreatePrivateMessage(pm, 0);

                break;

            case ClubSysMessageType.MandatoryLeaveClub:
                pm = new PrivateMessageInfo();

                pm.Msgfrom   = ClubSysAdminName;
                pm.Msgfromid = 0;

                pm.Folder       = 0;
                pm.Message      = string.Format(MandatoryLeaveClub_Message, club.FullName);
                pm.Msgto        = userName;
                pm.Msgtoid      = userID;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = MandatoryLeaveClub_Subject;

                PrivateMessages.CreatePrivateMessage(pm, 0);

                break;

            case ClubSysMessageType.RejectJoinClub:
                pm = new PrivateMessageInfo();

                pm.Msgfrom   = ClubSysAdminName;
                pm.Msgfromid = 0;

                pm.Folder       = 0;
                pm.Message      = string.Format(RejectJoinClub_Message, club.FullName);
                pm.Msgto        = userName;
                pm.Msgtoid      = userID;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = RejectJoinClub_Subject;

                PrivateMessages.CreatePrivateMessage(pm, 0);

                break;

            case ClubSysMessageType.TransferExtcredit:
                pm = new PrivateMessageInfo();

                pm.Msgfrom   = para[0];
                pm.Msgfromid = Users.GetUserId(para[0]);

                pm.Folder       = 0;
                pm.Message      = string.Format(TransferExtcredit_Message, para[0], para[1], para[2]);
                pm.Msgto        = userName;
                pm.Msgtoid      = userID;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = string.Format(TransferExtcredit_Subject, club.FullName);

                PrivateMessages.CreatePrivateMessage(pm, 0);

                break;

            default:
                break;
            }
        }
Exemplo n.º 16
0
 public RankAlgorithm(Club club)
 {
     currentClub = club;
     memberCount = ClubLogic.GetClubMemberCount(currentClub.ID.Value);
 }
Exemplo n.º 17
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.");
            }
        }