예제 #1
0
        internal static void Refresh()
        {
            DbDataReader r;

            r = StaticDsnConnection.KindExecuteReader("select bingoday,session from called_game_player_rank order by called_game_player_rank_id desc limit 1");
            if (r != null && r.HasRows)
            {
                int col;
                r.Read();
                last_date    = r.GetDateTime(0);
                last_session = r.GetInt32(1);
            }

            r = StaticDsnConnection.KindExecuteReader("select count(*),count(distinct card) from called_game_player_rank where bingoday=" + MySQLDataTable.MakeDateOnly(last_date) + " and session=" + last_session + " and pack_set_id>0");
            if (r != null && r.HasRows)
            {
                r.Read();
                pack_count   = r.GetInt32(0);
                player_count = r.GetInt32(1);
            }

            r = StaticDsnConnection.KindExecuteReader("select min(total_points),max(total_points) from called_game_player_rank where bingoday=" + MySQLDataTable.MakeDateOnly(last_date) + " and session=" + last_session
                                                      );
            if (r != null && r.HasRows)
            {
                r.Read();
                try
                {
                    if (r.IsDBNull(0))
                    {
                        low_score = 0;
                    }
                    else
                    {
                        low_score = r.GetInt32(0);
                    }
                }
                catch
                {
                    low_score = 0;
                }
                try
                {
                    if (r.IsDBNull(1))
                    {
                        high_score = 0;
                    }
                    else
                    {
                        high_score = r.GetInt32(1);
                    }
                }
                catch
                {
                    high_score = 0;
                }
            }
        }
예제 #2
0
        static void LoadUsers()
        {
            DbDataReader db = StaticDsnConnection.KindExecuteReader("select * from permission_user_info");

            if (db != null)
            {
                while (db.Read())
                {
                    User user = new User((String)db["name"]);
                    users.Add(user);
                }
            }
        }
예제 #3
0
        public SQLSecurity()
        {
            tracker = new SecurityTracker(null);
            //trackers = new List<SecurityTracker>();
            tokens = new List <string>();
            DbDataReader reader = StaticDsnConnection.KindExecuteReader("select * from permission_tokens");

            if (reader != null && reader.HasRows)
            {
                while (reader.Read())
                {
                    tokens.Add((string)reader["name"]);
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: d3x0r/xperdex
        bool BuildRunInfo(bool one_session)
        {
            if (ori == null)
            {
                ori = new OddsRunInfo( );
            }

#if this_loaded_player_tracking_for_phsycial_players
            BingoPlayers players = new BingoPlayers();
            DbDataReader reader  = StaticDsnConnection.KindExecuteReader("select card,sum(value) from player_track where bingoday="
                                                                         + MySQLDataTable.MakeDateOnly(result.bingoday.AddYears(2006).AddDays(7).AddMonths(5))
                                                                         + " and session=" + (_sessions + 1)
                                                                         + " and card<>'000000000000000000'"
                                                                         + " group by card");
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    BingoPlayer player;
                    players.Add(player = new BingoPlayer(reader.GetString(0)));
                    int spend = reader.GetInt32(1);
                    for (int p = 0; p < (spend / 2000); p++)
                    {
                        BingoPack  pack = GameList.pack_list.GetPack(true, Cards, "Fictional Pack");
                        PlayerPack played;
                        pack.pack_set = p;
                        player.played_packs.Add(played = new PlayerPack());
                        played.pack_info = pack;
                        played.player    = player;
                        played.game_list = GameList;
                    }
                }
            }
#endif
            if (ori.trigger_stats.enabled = checkBoxTriggerBalls.Checked)
            {
                ori.trigger_stats.max_triggered = Convert.ToInt32(textBoxMaxTriggered.Text);
                ori.trigger_stats.triggered     = new int[ori.trigger_stats.max_triggered + 1];
                ori.trigger_stats.trigger_wins  = new int[ori.trigger_stats.max_triggered + 1];
            }
            if (one_session)
            {
                ori.Years    = 1;
                ori.Days     = 1;
                ori.Sessions = 1;
                ori.Halls    = 1;
                ori.Players  = Convert.ToInt32(textBoxPlayers.Text);
                ori.Cards    = Convert.ToInt32(textBoxCards.Text);
                // this will be overridden later, if external game grid is used.
                ori.Games = Convert.ToInt32(textBoxGames.Text);
            }
            else
            {
                ori.Years = Convert.ToInt32(textBoxYears.Text);
                ori.Days  = Convert.ToInt32(textBoxDays.Text);

                //move all days into the day counter
                // the DateTime thing will take just adding days.
                ori.Days  = ori.Years * ori.Days;
                ori.Years = 1;

                ori.Sessions = Convert.ToInt32(textBoxSessions.Text);
                ori.Halls    = Convert.ToInt32(textBoxHalls.Text);
                ori.Players  = Convert.ToInt32(textBoxPlayers.Text);
                ori.Cards    = Convert.ToInt32(textBoxCards.Text);
                // this will be overridden later, if external game grid is used.
                ori.Games = Convert.ToInt32(textBoxGames.Text);
            }

            ori.colored_balls = textBoxColorBallCount.Text.Length > 0 ? Convert.ToInt32(textBoxColorBallCount.Text) : 0;

            ori.flags.use_blower   = radioBallBlower.Checked;
            ori.flags.database_run = checkBoxDatabase.Checked;

            ori.flags.save_winning_cards = checkBoxSaveWinningCards.Checked;
            ori.flags.Count_BINGO_Calls  = checkBoxCountBINGOCalls.Checked;
            ori.flags.countColorBINGO    = checkBoxCountColorBINGO.Checked;
            ori.flags.quickshot          = checkBoxQuickshot.Checked;

            ori.flags.starburst     = checkBoxStarburst.Checked;
            ori.flags.simulate      = checkBoxSimulate.Checked;
            ori.flags.only_simulate = true;

            // this will be overridden later, if external game grid is used.
            ori.flags.hotball = checkBoxHotball.Checked;

            // this will be overridden later, if external game grid is used.
            ori.flags._5cashball = checkBox5Hotball.Checked;

            ori.PackSize = Convert.ToInt32(textBoxPackSize.Text);
            if ((ori.Cards / ori.PackSize) * ori.PackSize != ori.Cards)
            {
                ori = null;
                MessageBox.Show("Cards does not divide by Pack Size evenly...");
                return(false);
            }

            if (comboBox1.SelectedItem != null)
            {
                String name = (comboBox1.SelectedItem as DataRowView).Row["name"].ToString();
                if (name != null && name.Length > 0)
                {
                    try
                    {
                        DataRow row      = (comboBox1.SelectedItem as DataRowView).Row;
                        DataRow original = row["original_row"] as DataRow;
                        if (original != null)
                        {
                            ori.dealer = BingoDealers.GetDealer(original);
                        }
                        //ori.cardreader = new CardReader( row["original_row"] as DataRow );
                        //if( ori.cardreader.Length != 0 )
                        //	ori.flags.cardfile = true;
                    }
                    catch { }
                }
                else
                {
                    ori.dealer = BingoDealers.nodealer;
                }
            }
            else
            {
                ori.dealer = BingoDealers.nodealer;
            }

            if (!LoadGameInfoFromGrid())
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
파일: Overview.cs 프로젝트: d3x0r/xperdex
        private void button5_Click(object sender, EventArgs e)
        {
            bool         first      = true;
            DbDataReader check_past = StaticDsnConnection.KindExecuteReader("select ID from session_day_sessions where bingoday > cast(now() as date)");

            if ((check_past != null) && check_past.HasRows)
            {
                Console.WriteLine("Sessions scheduled after today, not deleting todays sessions - the computer clock may have been set backwards.\n");
            }
            else
            {
                StaticDsnConnection.KindExecuteNonQuery("delete from session_day_sessions where bingoday=cast(now() as date)");
            }

            StaticDsnConnection.KindExecuteNonQuery("update session_day_sessions set open_for_sales_flag=0");

            DbDataReader reader = StaticDsnConnection.KindExecuteReader(
                "select session_name,elec_sch_session_macro_session.session_number,bingoday from elec_sch_session_macro_info"
                + " join elec_sch_session_macro_session on elec_sch_session_macro_session.session_macro_info_id=elec_sch_session_macro_info.session_macro_info_id"
                + " join elec_sch_session_info on elec_sch_session_info.session_info_id=elec_sch_session_macro_session.session_info_id"
                + " join session_sales_pages on session_sales_pages.session_number=elec_sch_session_macro_session.session_number"
                + " join session_sales_session_sales_pages using(session_sales_pages_id)"
                + " join session_sales_schedule using(session_sales_info_id)"
                + " where month(month)=month(now()) and bingoday=cast(now() as date)"
                + " order by elec_sch_session_macro_session.session_number"
                );

            if (reader != null)
            {
                while (reader.Read())
                {
                    string   session_name;
                    int      session_number;
                    DateTime session_date;
                    session_name   = reader.GetString(0);
                    session_number = reader.GetInt32(1);
                    session_date   = reader.GetDateTime(2);
                    long         mysql_session_date = (session_date.Year * 10000 + session_date.Month * 100 + session_date.Day);
                    DbDataReader check_exist        = StaticDsnConnection.KindExecuteReader("select ID from session_day_sessions where bingoday='" + mysql_session_date + "' and `session number`=" + session_number);
                    long         ID = 0;
                    if (check_exist != null && check_exist.HasRows)
                    {
                        check_exist.Read();
                        ID = check_exist.GetInt32(0);
                        Console.WriteLine("Updating session " + ID + " to " + session_name + "[" + session_number + "] on " + mysql_session_date + "\n");
                        if (!StaticDsnConnection.KindExecuteNonQuery("replace into session_day_sessions (ID,session_id,`session number`,bingoday,`session name`,open_for_sales_flag,acurals_flag) values ("
                                                                     + ID + "," + session_number + "," + session_number + ",'" + mysql_session_date + "','" + session_name + "',1,1)"
                                                                     ))
                        {
                            Console.WriteLine("Failed to UPDATE session in session_day_sessions\nfor " + mysql_session_date + "(" + session_name + ") number " + session_number + "\n");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Creating session " + session_name + "[" + session_number + "] on " + mysql_session_date + "\n");
                        ID = StaticDsnConnection.KindExecuteInsert("insert into session_day_sessions (session_id,`session number`,bingoday,`session name`,open_for_sales_flag,acurals_flag) values ("
                                                                   + session_number + "," + session_number + ",'" + mysql_session_date + "','" + session_name + "',1,1)");
                        if (ID == -1)
                        {
                            Console.WriteLine("Failed to INSERT session in session_day_sessions\nfor " + mysql_session_date + "(" + session_name + ") number " + session_number + "\n");
                        }
                    }
                    if (first)
                    {
                        StaticDsnConnection.KindExecuteNonQuery("update operational_configuration set current_session_id='" + session_number + ",current_bingoday="
                                                                + mysql_session_date + "',current_session_day_sessions_id=" + ID + " where ID=0");
                        //StaticDsnConnection.KindExecuteNonQuery( "update
                        first = false;
                    }
                }
            }
        }
예제 #6
0
        BingoPlayer GetPlayer(DateTime bingoday, int transnum, ref PlayerTransaction transaction)
        {
            BingoPlayer player = this.Find(delegate(BingoPlayer p) { foreach (PlayerTransaction t in p.transactions)
                                                                     {
                                                                         if (t.transnum == transnum)
                                                                         {
                                                                             return(true);
                                                                         }
                                                                     }
                                                                     return(false); });

            if (!players_loaded && player == null)
            {
                DbDataReader r = StaticDsnConnection.KindExecuteReader("select card,id from player_track where transnum=" + transnum.ToString() + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, bingoday));
                if (r != null && r.HasRows)
                {
                    r.Read();
                    String player_card = r.GetString(0);
                    int    ID          = r.GetInt32(1);
                    if (max_player_id < ID)
                    {
                        max_player_id = ID;
                    }
                    StaticDsnConnection.EndReader(r);
                    player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); });
                    if (player != null)
                    {
                        player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                    }
                    if (player == null)
                    {
                        player = new BingoPlayer();
                        player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        player.card = player_card;
                        player.ID   = Guid.NewGuid();                      // this.Count;
                        Add(player);
                    }
                }
                else
                {
                    if (allow_any_player)
                    {
                        String player_card = transnum.ToString();
                        player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); });
                        if (player != null)
                        {
                            player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        }
                        if (player == null)
                        {
                            player = new BingoPlayer();
                            player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                            player.card = player_card;
                            player.ID   = Guid.NewGuid();                          //this.Count;
                            Add(player);
                        }
                    }
                }
            }
            else
            {
                foreach (PlayerTransaction t in player.transactions)
                {
                    if (t.transnum == transnum)
                    {
                        transaction = t;
                    }
                }
            }
            return(player);
        }
예제 #7
0
        public List <PlayerTransaction> LoadPlayers()
        {
            List <PlayerTransaction> new_players = null;

            if (this.Count == 0)
            {
                PlayerTransaction transaction;
                DbDataReader      r = StaticDsnConnection.KindExecuteReader("select card,transnum,ID from player_track where session=" + session_event.session_number + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, session_event.bingoday));
                max_player_id = 0;
                if (r != null && r.HasRows)
                {
                    String player_card = r.GetString(0);
                    int    transnum    = r.GetInt32(1);
                    int    player_id   = r.GetInt32(2);
                    if (player_id > max_player_id)
                    {
                        max_player_id = player_id;
                    }
                    BingoPlayer player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); });
                    if (player != null)
                    {
                        transaction = player.transactions.Find(delegate(PlayerTransaction p) { return(p.transnum == transnum); });
                        if (transaction == null)
                        {
                            player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        }
                        // new transaction on player....
                        if (new_players == null)
                        {
                            new_players = new List <PlayerTransaction>();
                        }
                        new_players.Add(transaction);
                    }
                    else
                    {
                        player = new BingoPlayer();
                        player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        player.card = player_card;
                        player.ID   = Guid.NewGuid();
                        Add(player);

                        if (new_players == null)
                        {
                            new_players = new List <PlayerTransaction>();
                        }
                        new_players.Add(transaction);
                    }
                }
            }
            else
            {
                PlayerTransaction transaction;
                DbDataReader      r = StaticDsnConnection.KindExecuteReader("select card,transnum,ID from player_track where session="
                                                                            + session_event.session_number
                                                                            + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, session_event.bingoday)
                                                                            + " and ID>" + max_player_id);
                if (r != null && r.HasRows)
                {
                    String player_card = r.GetString(0);
                    int    transnum    = r.GetInt32(1);
                    int    player_id   = r.GetInt32(2);

                    if (player_id > max_player_id)
                    {
                        max_player_id = player_id;
                    }

                    BingoPlayer player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); });
                    if (player != null)
                    {
                        transaction = player.transactions.Find(delegate(PlayerTransaction p) { return(p.transnum == transnum); });
                        if (transaction == null)
                        {
                            player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        }
                        // new transaction on player....
                        if (new_players == null)
                        {
                            new_players = new List <PlayerTransaction>();
                        }
                        new_players.Add(transaction);
                    }
                    else
                    {
                        player = new BingoPlayer();
                        player.transactions.Add(transaction = new PlayerTransaction(player, transnum));
                        player.card = player_card;
                        player.ID   = Guid.NewGuid();
                        Add(player);
                        if (new_players == null)
                        {
                            new_players = new List <PlayerTransaction>();
                        }
                        new_players.Add(transaction);
                    }
                }
            }
            return(new_players);
        }
예제 #8
0
        public void BeginRun()
        {
            _years      = -1;
            _days       = Days;
            _sessions   = Sessions;
            _halls      = Halls;
            _games      = Games;
            _players    = Players;
            _cards      = Cards * Players;
            hotwins     = 0;
            besthotwins = 0;
            TotalWins   = 0;
            TotalCount  = 0;
            played      = 0;
            wins        = new int[ball_count + 1];
            bestwins    = new int[wins.Length];
            //hotball_wins = new int[max_balls];
            //
            //card_factory = new CardFactory(ball_count);
            end = false;

            if (flags.database_run)
            {
                try
                {
                    DbDataReader reader = StaticDsnConnection.KindExecuteReader("select max(bingoday) from bingo_events_session_tracking");
                    if (reader != null && reader.HasRows)
                    {
                        reader.Read();
                        if (!reader.IsDBNull(0))
                        {
                            DateTime val_time = DateTime.Now;
                            try
                            {
                                base_date = reader.GetDateTime(0);
                            }
                            catch
                            {
                                String val = reader.GetString(0);
                                base_date = Convert.ToDateTime(val).AddDays(1);
                            }
                        }
                        else
                        {
                            base_date = new DateTime(1972, 1, 1);
                        }
                    }
                    else
                    {
                        base_date = new DateTime(1972, 1, 1);
                    }
                }
                catch
                {
                    base_date = DateTime.Now;
                }
            }
            else
            {
                base_date = new DateTime(1972, 1, 1);
            }
        }
예제 #9
0
파일: Form1.cs 프로젝트: d3x0r/xperdex
 void SetupNewSession(DateTime the_day, DataRow session)
 {
     StaticDsnConnection.KindExecuteNonQuery("update bingo_game_processed set processed=0 join bingo_game using(bingo_game_id) where bingoday=" + MySQLDataTable.MakeDateOnly(the_day) + " and session=" + session["session"].ToString());
 }