public static DataTable GetTournamentLosersByRound(int toutnamentId, int round)
        {
            DataTable dt = BaseCollection.Execute("GetTournamentPlayersByRound", toutnamentId, round, false);

            dt.TableName = InfiChess.TournamentRound.ToString();
            return(dt);
        }
示例#2
0
        public static DataTable GetTournamentRoundByPlayers(int toutnamentId, int round, int whiteUserId, int blackUserId)
        {
            DataTable dt = BaseCollection.Execute("GetTournamentRoundByPlayers", toutnamentId, round, whiteUserId, blackUserId);

            dt.TableName = InfiChess.TournamentRound.ToString();
            return(dt);
        }
        public static void DeleteTournamentTeams(Cxt cxt, TournamentTeams TournamentTeams)
        {
            SqlTransaction trans = null;

            try
            {
                trans = SqlHelper.BeginTransaction(Config.ConnectionString);

                for (int i = 0; i < TournamentTeams.Count; i++)
                {
                    //TournamentTeams.Delete(InfiChess.TournamentTeam, Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TournamentTeamID"]));
                    BaseCollection.ExecuteSql2(trans, "update TournamentTeam statusid = @p1 where TournamentTeamID = @p2", (int)StatusE.Deleted, Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TournamentTeamID"]));
                }

                for (int i = 0; i < TournamentTeams.Count; i++)
                {
                    BaseCollection.Execute(trans, "UpdateTournamentUserStatusByTeamID",
                                           Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TeamID"]),
                                           TournamentTeams.TournamentID,
                                           cxt.CurrentUserID,
                                           DateTime.Now,
                                           (int)StatusE.Deleted);
                }



                SqlHelper.CommitTransaction(trans);
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);
                Log.Write(cxt, ex);
            }
        }
 public static void DeleteTournamentTeams(Cxt cxt, SqlTransaction trans, int tournamentID)
 {
     BaseCollection.Execute(trans, "UpdateTournamentTeamStatus",
                            tournamentID,
                            (int)StatusE.Deleted,
                            cxt.CurrentUserID, DateTime.Now);
 }
示例#5
0
        /// <summary>
        /// online client
        /// </summary>
        /// <param name="cxt"></param>
        /// <param name="items"></param>
        /// <param name="dtTournamentWantin"></param>
        private static void SaveWantinUsers(SqlTransaction trans,
                                            Cxt cxt,
                                            int statusID,
                                            int tournamentUserStatusID,
                                            int tournamentID,
                                            string userIDs,
                                            string tournamentWantinUserIDs,
                                            int teamID, int eloBefore)
        {
            string[] userIDArr = userIDs.Split(',');
            int      uId       = -1;

            foreach (string userID in userIDArr)
            {
                if (!Int32.TryParse(userID, out uId))
                {
                    continue;
                }

                BaseCollection.Execute(trans, "CreateTournamentRegisterUser",
                                       tournamentID, uId,
                                       statusID, teamID,
                                       eloBefore, cxt.CurrentUser.UserID,
                                       DateTime.Now);
            }

            string[] tournamentWantinUserIDArr = tournamentWantinUserIDs.Split(',');

            BaseCollection.Execute(trans, "UpdateWantinUserStatusByUserID",
                                   userIDs,
                                   tournamentID,
                                   tournamentUserStatusID,
                                   cxt.CurrentUserID, DateTime.Now);
        }
 public static void CreateServerStatistics(Cxt cxt)
 {
     try
     {
         BaseCollection.Execute("CreateServerStatistics");
     }
     catch (Exception ex)
     {
         Log.Write(cxt, ex);
     }
 }
示例#7
0
 public static DataTable GetTournamentUsers(int TournamentID, int TeamID, UserStatusE UserStatusID, TournamentEntityTypeE TournamentEntityTypeID)
 {
     if (TournamentEntityTypeID == TournamentEntityTypeE.RegisteredUser)
     {
         return(BaseCollection.Execute("GetTournamentRegisteredUsers", TournamentID, TeamID));
         //ExecuteSql("GetTournamentRegisteredUsers @p", );
     }
     else
     {
         return(BaseCollection.Execute("GetTournamentUsers", TournamentID, TeamID, UserStatusID.ToString("d")));
     }
 }
示例#8
0
        public static void CreateRegisterUsers(Cxt cxt, SqlTransaction sqlTrans, DataTable dt)
        {
            foreach (DataRow dr in dt.Rows)
            {
                TournamentUser tournamentUser = new TournamentUser(cxt, dr);

                BaseCollection.Execute(sqlTrans, "CreateTournamentRegisterUser",
                                       tournamentUser.TournamentID, tournamentUser.UserID,
                                       tournamentUser.StatusID, tournamentUser.TeamID,
                                       tournamentUser.EloBefore, cxt.CurrentUser.UserID,
                                       DateTime.Now);
            }
        }
示例#9
0
        public static bool GetTournamentMatchByTournamentUserID(Cxt cxt, int tournamentID, int userID)
        {
            bool result = false;

            DataTable dt = BaseCollection.Execute("GetTournamentMatchByTournamentUserID", tournamentID, userID);

            if (dt.Rows.Count > 0)
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#10
0
        //public static void UpdateWantinUsers(Cxt cxt, UpdateTournamentUsersS UpdateTournamentUsersS)
        //{
        //    SqlTransaction sqltrans = null;

        //    try
        //    {
        //        sqltrans = SqlHelper.BeginTransaction(Config.ConnectionString);

        //        BaseCollection.Execute(sqltrans, "UpdateTournamentUserStatus",
        //                                UpdateTournamentUsersS.TournamentUserIDs,
        //                                UpdateTournamentUsersS.TournamentID,
        //                                UpdateTournamentUsersS.UserId,
        //                                DateTime.Now,
        //                                UpdateTournamentUsersS.statusID.ToString("d"));

        //        BaseCollection.Execute(sqltrans, "UpdateTournamentWantinUserStatus",
        //                                "",
        //                                UpdateTournamentUsersS.TournamentWantinUserIDs,
        //                                UpdateTournamentUsersS.tournamentUserStatusID.ToString("d"),
        //                                (int)StatusE.Active,
        //                                UpdateTournamentUsersS.UserId, DateTime.Now);

        //        //BaseCollection.Execute(sqltrans, "DeleteTournamentMatchByUserID",
        //        //                        UpdateTournamentUsersS.TournamentUserIDs,
        //        //                        UpdateTournamentUsersS.TournamentID ,
        //        //                        1);

        //        SqlHelper.CommitTransaction(sqltrans);
        //    }
        //    catch (Exception ex)
        //    {
        //        SqlHelper.RollbackTransaction(sqltrans);
        //        Log.Write(cxt, ex);
        //    }
        //}

        /// <summary>
        /// Online client wantin user update
        /// </summary>
        /// <param name="cxt"></param>
        /// <param name="statusID"></param>
        /// <param name="tournamentUserStatusID"></param>
        /// <param name="tournamentID"></param>
        /// <param name="userIDs"></param>
        /// <param name="tournamentWantinUserIDs"></param>
        public static void SaveWantinUsers(Cxt cxt,
                                           int statusID,
                                           int tournamentUserStatusID,
                                           int tournamentID,
                                           string userIDs,
                                           string tournamentWantinUserIDs,
                                           int teamID, int eloBefore)
        {
            SqlTransaction sqltrans = null;

            try
            {
                sqltrans = SqlHelper.BeginTransaction(Config.ConnectionString);

                StatusE StatusIDE = (StatusE)Enum.ToObject(typeof(StatusE), statusID);

                if (StatusIDE == StatusE.Active)
                {
                    SaveWantinUsers(sqltrans, cxt, statusID, tournamentUserStatusID, tournamentID, userIDs, tournamentWantinUserIDs, teamID, eloBefore);
                }
                else
                {
                    BaseCollection.Execute(sqltrans, "UpdateTournamentUserStatus",
                                           userIDs,
                                           tournamentID,
                                           cxt.CurrentUserID,
                                           DateTime.Now,
                                           statusID);

                    BaseCollection.Execute(sqltrans, "UpdateWantinUserStatusByUserID",
                                           userIDs,
                                           tournamentID,
                                           tournamentUserStatusID,
                                           cxt.CurrentUserID, DateTime.Now);
                }


                SqlHelper.CommitTransaction(sqltrans);
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(sqltrans);
                Log.Write(cxt, ex);
            }
        }
示例#11
0
        public static void UpdateStatus(SqlTransaction trans, Cxt cxt, TournamentMatchStatusE tournamentMatchStatusID, string tournamentMatchIDs, GameResultE gameResultID)
        {
            StringBuilder sb = new StringBuilder();

            BaseCollection.Execute(trans, "UpdateTournamentMatchStatus",
                                   tournamentMatchIDs,
                                   tournamentMatchStatusID.ToString("d"),
                                   gameResultID.ToString("d"),
                                   cxt.CurrentUserID
                                   );

            if (tournamentMatchStatusID != TournamentMatchStatusE.Scheduled &&
                tournamentMatchStatusID != TournamentMatchStatusE.Absent)
            {
                BaseCollection.Execute(trans, "UpdateTournamentChallengeStatus",
                                       tournamentMatchIDs,
                                       StatusE.Deleted.ToString("d"),
                                       cxt.CurrentUserID);
            }
        }
示例#12
0
        public static Kv UpdateReplacePlayer(Cxt cxt, int tournamentID, int userID, int userID2)
        {
            Kv             kv    = new Kv();
            SqlTransaction trans = null;

            try
            {
                trans = SqlHelper.BeginTransaction(Config.ConnectionString);

                bool result = TournamentMatch.GetTournamentMatchByTournamentUserID(cxt, tournamentID, userID);

                if (result)
                {
                    kv.Set("Result", (int)MsgE.ErrorTournamentPlayerReplaceUser);
                    return(kv);
                }

                TournamentUser tu = GetTournamentUserById(cxt, tournamentID, userID);

                BaseCollection.Execute(trans, "UpdateTournamentMatchWithUser", tournamentID, userID, userID2, cxt.CurrentUserID, 3);

                if (tu.UserID2 > 0)
                {
                    userID = tu.UserID2;
                }


                BaseCollection.Execute(trans, "UpdateTournamentMatchWithUser", tournamentID, userID, userID2, cxt.CurrentUserID, 0);

                BaseCollection.Execute(trans, "UpdateTournamentMatchWithUser", tournamentID, userID, userID2, cxt.CurrentUserID, 1);

                SqlHelper.CommitTransaction(trans);
                kv.Set("Result", 0);
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);
                Log.Write(cxt, ex);
            }
            return(kv);
        }
        public static void DeleteTournamentTeams(Cxt cxt, string tournamentTeamIDs, int tournamentID)
        {
            string[] tournamentTeamIDsArr = tournamentTeamIDs.Split(',');

            SqlTransaction trans = null;

            try
            {
                trans = SqlHelper.BeginTransaction(Config.ConnectionString);

                foreach (string itemID in tournamentTeamIDsArr)
                {
                    if (string.IsNullOrEmpty(itemID))
                    {
                        continue;
                    }
                    BaseCollection.ExecuteSql2(trans, "update TournamentTeam set StatusID = @p1 where TeamID = @p2 and TournamentID = @p3", (int)StatusE.Deleted, Convert.ToInt32(itemID), tournamentID);
                    //TournamentTeams.DeleteInfiChess.TournamentTeam, Convert.ToInt32(itemID));
                }

                BaseCollection.Execute(trans, "UpdateTournamentUserStatusByTeamID",
                                       tournamentTeamIDs,
                                       tournamentID,
                                       cxt.CurrentUserID,
                                       DateTime.Now,
                                       (int)StatusE.Deleted);

                BaseCollection.Execute(trans, "UpdateTournamentWantinUserStatus",
                                       tournamentTeamIDs, tournamentID,
                                       (int)TournamentUserStatusE.Declined,
                                       (int)StatusE.Deleted,
                                       cxt.CurrentUserID, DateTime.Now);

                SqlHelper.CommitTransaction(trans);
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);
                Log.Write(cxt, ex);
            }
        }
示例#14
0
 public static DataTable GetChallengesByRoomID(Cxt cxt, int roomID, int userID)
 {
     return(BaseCollection.Execute("GetChallengesByRoomID", roomID, userID));
 }
示例#15
0
 public static DataTable GetAllUser(int roomId)
 {
     return(BaseCollection.Execute("GetUsersByRoomID", roomId));
 }
示例#16
0
 public static DataTable GetUsersByGameType(Cxt cxt, ChessTypeE ChessTypeE, GameType GameTypeE)
 {
     return(BaseCollection.Execute("GetTopRatingByGameType", ChessTypeE.ToString("d"), GameTypeE.ToString("d")));
 }
示例#17
0
 public static void UpdateGameStatusWithTournamentMatchID(Cxt cxt, SqlTransaction trans, string gameIDs, GameResultE gameResultID)
 {
     BaseCollection.Execute(trans, "UpdateGameStatusWithTournamentMatchID",
                            gameIDs, gameResultID.ToString("d"),
                            cxt.CurrentUserID, DateTime.Now);
 }
示例#18
0
 public static DataTable GetAllGamesByTournamentID(Cxt cxt, int tournamentID)
 {
     return(BaseCollection.Execute("GetAllGamesByTournamentID", tournamentID));
 }
示例#19
0
        public static DataTable GetGamesByUserName(Cxt cxt, string userName)
        {
            User user = User.GetUser(cxt, userName);

            return(BaseCollection.Execute("GetGamesByUserID", user.UserID));
        }
示例#20
0
 public static void DeleteTournamentUser(Cxt cxt, SqlTransaction trans, int tournamentID)
 {
     BaseCollection.Execute(trans, "UpdateTournamentUserStatusByTeamID",
                            "0", tournamentID,
                            cxt.CurrentUserID, DateTime.Now, (int)StatusE.Deleted);
 }
示例#21
0
 public static DataTable GetGamesByRoomID(Cxt cxt, int roomID)
 {
     return(BaseCollection.Execute("GetGamesByRoomID", roomID));
 }
示例#22
0
 public static void UpdateAllChallenges(SqlTransaction t, int challengeID, int currentUserID, int ChallengerUserID)
 {
     BaseCollection.Execute(t, "UpdateAllChallengesByID", challengeID, currentUserID, ChallengerUserID);
 }
示例#23
0
 public static DataTable GetTournamentsMatchByTournamentID(int tournamentID)
 {
     return(BaseCollection.Execute("GetTournamentMatchByTournamentID", tournamentID));
 }
示例#24
0
 public static DataTable GetuserMessages(Cxt cxt, int userID)
 {
     return(BaseCollection.Execute("GetuserMessages", userID));
 }
示例#25
0
 public static DataTable GetAllTournaments(TournamentStatusE TournamentStatusID)
 {
     return(BaseCollection.Execute("GetAllTournament", TournamentStatusID.ToString("d")));
 }
示例#26
0
 public static DataTable GetHighestRankingPlayerGame(Cxt cxt)
 {
     return(BaseCollection.Execute("GetHighestRankingPlayerGame", cxt.CurrentUserID));
 }
示例#27
0
 public static DataTable GetUserByName(Cxt cxt, string userName)
 {
     return(BaseCollection.Execute("GetUserInfoByUserID", 0, userName));
 }
示例#28
0
 public static DataTable GetGamesByUserID(Cxt cxt, int userID)
 {
     return(BaseCollection.Execute("GetGamesByUserID", userID));
 }
示例#29
0
 public static DataTable GetSchTournamentWantinUsers(int TournamentID)
 {
     return(BaseCollection.Execute("GetSchTournamentWantinUsers", TournamentID));
 }
示例#30
0
 public static DataTable GetTournamentUsersByRound(int tournamentID, int round)
 {
     return(BaseCollection.Execute("GetTournamentUsersByRound", tournamentID, round));
 }