Exemplo n.º 1
0
        public void ConnectToDb()
        {
            participantTable = new DataTable();
            eventTable       = new DataTable();

            if (MySQLConnection.OpenConnection() == false)
            {
                m_From.SendAsciiMessage("Cannot establish connection, try again later");
                return;
            }

            OdbcConnection dbConnection = MySQLConnection.GetmySQLConnection;

            //Initiate select strings
            string getParticipants = "SELECT * FROM participant";
            string getEvents       = "SELECT * FROM event";

            //Set participant adapter
            OdbcDataAdapter participants = new OdbcDataAdapter();
            OdbcCommand     selectP      = dbConnection.CreateCommand();

            selectP.CommandText        = getParticipants;
            participants.SelectCommand = selectP;

            //Set participant adapter
            OdbcDataAdapter events  = new OdbcDataAdapter();
            OdbcCommand     selectE = dbConnection.CreateCommand();

            selectE.CommandText  = getEvents;
            events.SelectCommand = selectE;

            //Set players joined
            participants.Fill(participantTable);
            SetPlayersJoined(participantTable, dbConnection, current_SWG);

            //Set winners
            participants.Fill(participantTable);
            SetWinners(participantTable, dbConnection, current_SWG);

            //Add event
            events.Fill(eventTable);
            AddEvent(eventTable, dbConnection);

            //Update ingame ladder and closes connections.
            UpdateIngameLadder();

            if (dbConnection != null && dbConnection.State == ConnectionState.Open)
            {
                dbConnection.Close();
            }
        }
Exemplo n.º 2
0
        public static void UpdateIngameLadder()
        {
            if (MySQLConnection.OpenConnection() == false)
            {
                return;
            }

            Fill1vs1Ladder();
            Fill2vs2Ladder();
            FillTotalLadder();

            MySQLConnection.GetmySQLConnection.Close();
            MySQLConnection.GetmySQLConnection = null;
        }