示例#1
0
    void showMembers(List <ClubMember> members)
    {
        for (int i = 0; i < members.Count; i++)
        {
            Transform  item = getItem(i);
            ClubMember mb   = members[i];

            setText(item, "name", mb.name);
            setText(item, "id", "" + mb.id);
            setText(item, "score", "" + mb.score);
            setText(item, "limit", "" + mb.limit);
            setIcon(item, "icon", mb.logo);

            setBtnEvent(item, "btn_edit", () => {
                mEditMember = mb;
                onBtnEdit();
            });

            setBtnEvent(item, "btn_history", () => {
                ClubHistory ch = GameObject.Find("PClubHistory").GetComponent <ClubHistory>();
                ch.enter(mClubID, mb.id);
            });
        }

        updateItems(members.Count);
    }
示例#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);
            }
        }
示例#3
0
        private static int      GetRealPosition(bool isSingleSeasonView, ClubHistory clubInfo, Season season, int index)
        {
            if (isSingleSeasonView)
            {
                return(season.Games[index].PositionAfter + season.GetLeaguePositionOffset());
            }

            season = clubInfo.Seasons.FirstOrDefault(a => a.FinishYear == Config.FirstYear + index);
            return(season == null ? -1 : season.RealPosition);
        }
示例#4
0
        public static void              WriteClubHistory(string countryName, ClubHistory clubHistory)
        {
            var fileName = Config.ClubsDataDirectory + @"\" + countryName + @"\" + clubHistory.ClubName + ".data";
            var file     = new FileStream(fileName, FileMode.Create, FileAccess.Write);
            var writer   = new BinaryWriter(file);

            WriteClubHistoryInternal(writer, clubHistory);

            writer.Close();
        }
示例#5
0
        public async Task <IActionResult> AddClubHistory(AddClubHistoryModel model)
        {
            var history = new ClubHistory
            {
                TeamId     = model.TeamId,
                Season     = model.Season,
                LeagueName = model.LeagueName,
                Position   = model.Position,
                Points     = model.Points
            };
            await _historyService.Create(history);

            return(RedirectToAction("Index", "Home"));
        }
示例#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);
            }
        }
示例#7
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);
            }
        }
示例#8
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);
        }
示例#9
0
        internal static void SaveClubHistory(ClubHistory ch)
        {
            var sql =
                "INSERT INTO dbo.AcnClub_LogClub VALUES (@clubID, @actionType, GETDATE(), @actionUserName, @OperatorUserName, @ActionDescription)";

            var para = new SqlParameter[5];

            para[0] = new SqlParameter("@clubID", ch.ClubID);
            para[1] = new SqlParameter("@actionType", ch.ActionType);
            para[2] = new SqlParameter("@actionUserName", ch.ActionUserName);
            para[3] = new SqlParameter("@operatorUserName", ch.OperatorUserName);
            para[4] = new SqlParameter("@actionDescription", ch.ActionDescription);

            SqlHelper.ExecuteNonQuery(SQLConn.GetConnection(), CommandType.Text, sql, para);
        }
示例#10
0
        private static ClubHistory              ReadClubHistory(BinaryReader reader)
        {
            reader.ReadByte();
            var clubHistory = new ClubHistory {
                ClubName = new string (reader.ReadChars(reader.ReadByte()))
            };
            var seasonCount = reader.ReadByte();

            for (var i = 0; i < seasonCount; i++)
            {
                var season = ReadClubSeason(reader);
                clubHistory.Seasons.Add(season);
            }

            return(clubHistory);
        }
示例#11
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");
            }
        }
示例#12
0
        public static ClubHistory               GetAllSeasonsForTeam(string country, string clubName, string url)
        {
            var result = new ClubHistory {
                ClubName = clubName
            };
            var htmlDoc = WebPagesAccess.GetHtmlBody(Config.MainSite + url + "/history");

            result.Seasons = htmlDoc.DocumentNode
                             .SelectSingleNode("//table[@class='table history lightbox']")
                             .SelectNodes("//tr[@data-row]")
                             .Select(a => new Season
            {
                Country     = country,
                FinishYear  = int.Parse(a.ChildNodes[0].InnerText.Substring(5)),
                LeagueOrder = getCellValue(a, 1),
                Position    = getCellValue(a, 2),
                GamesPlayed = getCellValue(a, 3),
                Wins        = getCellValue(a, 4),
                Draws       = getCellValue(a, 5),
                Losses      = getCellValue(a, 6),
                Points      = getCellValue(a, 23),
            }).ToList();
            return(result);
        }
示例#13
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");
            }
        }
示例#14
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;
        }
示例#15
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.");
        }
示例#16
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.");
            }
        }
示例#17
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);
            }
        }
示例#18
0
        private static void             WriteClubHistoryInternal(BinaryWriter writer, ClubHistory club)
        {
            writer.Write(club.ClubName);
            writer.Write((byte)club.Seasons.Count);

            foreach (var season in club.Seasons)
            {
                WriteClubSeason(writer, season);
            }
        }
示例#19
0
 public async Task Create(ClubHistory clubHistory)
 {
     _db.Add(clubHistory);
     await _db.SaveChangesAsync();
 }
示例#20
0
        internal static void SaveClubHistory(ClubHistory ch)
        {
            var sql =
                "INSERT INTO dbo.AcnClub_LogClub VALUES (@clubID, @actionType, GETDATE(), @actionUserName, @OperatorUserName, @ActionDescription)";

            var para = new SqlParameter[5];

            para[0] = new SqlParameter("@clubID", ch.ClubID);
            para[1] = new SqlParameter("@actionType", ch.ActionType);
            para[2] = new SqlParameter("@actionUserName", ch.ActionUserName);
            para[3] = new SqlParameter("@operatorUserName", ch.OperatorUserName);
            para[4] = new SqlParameter("@actionDescription", ch.ActionDescription);

            SqlHelper.ExecuteNonQuery(SQLConn.GetConnection(), CommandType.Text, sql, para);
        }