Exemple #1
0
        void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list, PackDNA rated_packs)
        {
            string         misc_item = Options.Default["Rate Rank"]["Misc Item To Select Sale", "none"].Value;
            string         misc_dept = Options.Default["Rate Rank"]["Misc Dept To Select Sale", "none"].Value;
            MySQLDataTable table;

            if (misc_dept != "none")
            {
                MySQLDataTable specials = new MySQLDataTable(StaticDsnConnection.dsn
                                                             , "select transnum,sum(quantity) as count from misc_trans join misc_item using(item_id) join misc_dept using(dept_id)"
                                                             + " where misc_item.name='" + misc_item + "' and misc_dept.name='" + misc_dept + "'"
                                                             + " and misc_trans.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date)"
                                                             + " and misc_trans.session=" + session
                                                             + " and misc_trans.void=0"
                                                             + " group by transnum"
                                                             );
                table = new MySQLDataTable(StaticDsnConnection.dsn
                                           , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num from access_db_sale"
                                           + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                           + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session
                                           + " and matched=0"
                                           + " order by transnum,access_db_packs.id"
                                           );

                foreach (DataRow row in specials.Rows)
                {
                    int transnum = Convert.ToInt32(row["transnum"]);
                    PlayerTransaction transaction = null;
                    BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);
                    int count = Convert.ToInt32(row["count"]) + player.pack_sets.Count;
                    for (int n = player.pack_sets.Count; n < count; n++)
                    {
                        PackSet tmp;
                        player.pack_sets.Add(tmp = new PackSet());
                        tmp.set_id = n + 1;
                    }
                }
            }
            else
            {
                table = new MySQLDataTable(StaticDsnConnection.dsn
                                           , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num,pos_num from access_db_sale"
                                           + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                           + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session
                                           + " and matched=0"
                                           + " order by transnum,access_db_packs.id"
                                           );
            }

            foreach (DataRow row in table.Rows)
            {
                int transnum = Convert.ToInt32(row["transnum"]);

                PlayerTransaction transaction = null;
                BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);

                //Log.log( "Player : " + player.card );
                int packnum = Convert.ToInt32(row["pack_type"]);

                // ignore the macro pack labels.
                if (packnum < 100)
                {
                    PlayerPack pack = new PlayerPack();

                    transaction.Add(pack);
                    pack.start_card = Convert.ToInt32(row["start_card"]);
                    pack.pack_info  = pack_list.GetPack(row["pack_type_name"].ToString(), "Pos " + row["pos_num"].ToString());
                    if (pack.pack_info == null)
                    {
                        continue;                          // fail loading this.
                    }
                    //pack.game_list = _games;
                    pack.player      = player;
                    pack.unit_number = Convert.ToInt32(row["unit_num"]);

                    if (rated_packs != null)
                    {
                        bool   found    = false;
                        string packname = row["pack_type_name"].ToString();
                        //Log.log( "Looking for pack to stack: " + packname );
                        foreach (PackSet check_pack_set in player.pack_sets)
                        {
                            if (check_pack_set.Count == rated_packs.pack_sequence.Count)
                            {
                                bool empty_slot = false;
                                int  tmp_pos    = 0;
                                foreach (BingoPack seq_pack in rated_packs.pack_sequence)
                                {
                                    if (check_pack_set.Count > tmp_pos && check_pack_set[tmp_pos] == null)
                                    {
                                        empty_slot = true;
                                        break;
                                    }
                                    tmp_pos++;
                                }
                                if (!empty_slot)
                                {
                                    // this pack set is already full.
                                    //Log.log( "(all manager packs already loaded)stack is full... skipping..." );
                                    continue;
                                }
                            }
                            int pos = 0;
                            foreach (BingoPack seq_pack in rated_packs.pack_sequence)
                            {
                                if (check_pack_set.Count > pos && check_pack_set[pos] != null)
                                {
                                    //Log.log( "slot is full... skipping..." );
                                    pos++;
                                    continue;
                                }
                                //Log.log( "Comparing " + seq_pack.name +" vs " + packname );
                                if (((check_pack_set.Count <= pos) ||
                                     (check_pack_set.Count > pos && check_pack_set[pos] == null)) &&
                                    String.Compare(packname, seq_pack.name, true) == 0)
                                {
                                    //Log.log( "Steppig match_pos... setting id " + check_pack_set.set_id );
                                    check_pack_set.match_pos++;
                                    pack.pack_set = check_pack_set.set_id;
                                    check_pack_set.Set(pos, pack.pack_info);
                                    found = true;
                                    break;
                                }
                                pos++;
                            }
                            if (found)
                            {
                                //Log.log( "located..." );
                                break;
                            }
                        }
                        if (!found)
                        {
                            //if( player.card == "000000015200000761" )
                            //	Log.log( "something bad." );
                        }
                    }
                    Log.log("electronic pack starting card " + pack.start_card);

                    player.played_packs.Add(pack);
                }
            }
            //if( match_pos > 0 )
            foreach (BingoPlayer player in this)
            {
                foreach (PackSet check_pack_set in player.pack_sets)
                {
                    if (check_pack_set.Count == rated_packs.pack_sequence.Count)
                    {
                    }
                    else
                    {
                        Log.log("Incomplete pack sequence?");
                    }
                }
            }
        }
Exemple #2
0
        void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list)
        {
            MySQLDataTable table = new MySQLDataTable(StaticDsnConnection.dsn
                                                      , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num,access_db_sale.bingoday from access_db_sale"
                                                      + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                                      + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session.session_number
                                                      + " order by mod(start_card,50),start_card/50"
                                                      );

            foreach (DataRow row in table.Rows)
            {
                int start_card = Convert.ToInt32(row["start_card"]);
                if (start_card == 0)
                {
                    // these are special case macro label place holders... no real cards.
                    continue;
                }
                int transnum = Convert.ToInt32(row["transnum"]);

                PlayerTransaction transaction = null;
                BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);
                if (player != null)
                {
                    int packnum = Convert.ToInt32(row["pack_type"]);

                    if (packnum < 100)
                    {
                        PlayerPack pack = new PlayerPack();
                        pack.electronic  = true;
                        pack.start_card  = start_card;
                        pack.transaction = transaction;
                        try
                        {
                            pack.pack_info = pack_list.GetPack(row["pack_type_name"].ToString());
                            pack.dealer    = pack.pack_info.GetRangeDealer(start_card);
                        }
                        catch (Exception e) {
                            //System.Windows.Forms.MessageBox.Show( e.Message );
                            throw new Exception("Fail loading packs.");
                            continue;
                        }
                        if (pack.pack_info == null)
                        {
                            continue;                              // fail loading this.
                        }
                        pack.paper = false;
                        //pack.game_list = _games;

                        pack.player      = player;
                        pack.unit_number = Convert.ToInt32(row["unit_num"]);
#if each_pack_has_counts
                        foreach (BingoGame game in _games)
                        {
                            int x;
                            // pack doesn't play in this game.
                            if (pack.pack_info.ID >= game.pack_card_counts.Count)
                            {
                                pack.game_card_count[game.game_ID] = 0;
                                continue;
                            }
                            x = pack.game_card_count[game.game_ID] = game.pack_card_counts[pack.pack_info.ID - 1];
                            if (x > pack.most_game_card_count)
                            {
                                if (pack.least_game_card_count == 0)
                                {
                                    pack.least_game_card_count = x;
                                }
                                pack.most_game_card_count = x;
                            }
                            if (x > 0 && x < pack.least_game_card_count)
                            {
                                pack.least_game_card_count = x;
                            }
                        }
#endif
                        if (bDoLogCards)
                        {
                            Log.log("electronic pack starting card " + pack.start_card);
                        }
                        //pack.pack_info.ID = player.played_packs.Count;
                        transaction.Add(pack);
                        player.played_packs.Add(pack);
                    }
                    else
                    {
                        // ignore macros
                    }
                }
            }
            table.Dispose();
        }
Exemple #3
0
        void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list, List <String> rated_packs)
        {
            MySQLDataTable table = new MySQLDataTable(StaticDsnConnection.dsn
                                                      , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num,pos_num from access_db_sale"
                                                      + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                                      + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session
                                                      + " and matched=0"
                                                      + " order transnum" /*by mod(start_card,50),start_card/50"*/
                                                      );

            foreach (DataRow row in table.Rows)
            {
                if (rated_packs != null)
                {
                    bool   found    = false;
                    string packname = row["pack_type_name"].ToString();
                    foreach (String rated_packname in rated_packs)
                    {
                        if (String.Compare(packname, rated_packname, true) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                    // ignore loading this pack.  it's not allowed.
                    if (!found)
                    {
                        continue;
                    }
                }
                int transnum = Convert.ToInt32(row["transnum"]);
                PlayerTransaction transaction = null;
                BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);
                int packnum = Convert.ToInt32(row["pack_type"]);

                if (packnum < 100)
                {
                    PlayerPack pack = new PlayerPack();
                    pack.electronic = true;
                    pack.start_card = Convert.ToInt32(row["start_card"]);
                    pack.pack_info  = pack_list.GetPack(row["pack_type_name"].ToString(), "Pos " + row["pos_num"].ToString());
                    if (pack.pack_info == null)
                    {
                        continue;                          // fail loading this.
                    }
                    pack.paper = false;
                    //pack.game_list = _games;

                    pack.player      = player;
                    pack.unit_number = Convert.ToInt32(row["unit_num"]);
#if each_pack_has_counts
                    foreach (BingoGame game in _games)
                    {
                        int x;
                        // pack doesn't play in this game.
                        if (pack.pack_info.ID >= game.pack_card_counts.Count)
                        {
                            pack.game_card_count[game.game_ID] = 0;
                            continue;
                        }
                        x = pack.game_card_count[game.game_ID] = game.pack_card_counts[pack.pack_info.ID - 1];
                        if (x > pack.most_game_card_count)
                        {
                            if (pack.least_game_card_count == 0)
                            {
                                pack.least_game_card_count = x;
                            }
                            pack.most_game_card_count = x;
                        }
                        if (x > 0 && x < pack.least_game_card_count)
                        {
                            pack.least_game_card_count = x;
                        }
                    }
#endif
                    //pack.pack_info.ID = player.played_packs.Count;
                    player.played_packs.Add(pack);
                }
            }
        }
Exemple #4
0
        void LoadPaper(BingoSessionEvent session, BingoPacks pack_list, List <String> rated_packs)
        {
            MySQLDataTable paper_table = new MySQLDataTable(StaticDsnConnection.dsn
                                                            , "select * from pos_paper_barcode_master"
                                                            + " join pos_paper_barcode_item on pos_paper_barcode_master.pos_paper_barcode_master_id=pos_paper_barcode_item.pos_paper_barcode_master_id"
                                                            + " join item_descriptions on item_descriptions.item_description_id=pos_paper_barcode_item.item_description_id"
                                                            + " join floor_paper_names on floor_paper_names.floor_paper_name_id=pos_paper_barcode_item.floor_paper_name_id"
                                                            + " where pos_paper_barcode_master.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and pos_paper_barcode_master.session=" + session.session.session
                                                            + " order by transnum" //start_card"
                                                            );

            foreach (DataRow row in paper_table.Rows)
            {
                string packname = row["name"].ToString();
                if (rated_packs != null)
                {
                    bool found = false;
                    foreach (String rated_packname in rated_packs)
                    {
                        if (String.Compare(packname, rated_packname, true) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                    // ignore loading this pack.  it's not allowed.
                    if (!found)
                    {
                        continue;
                    }
                }
                int transnum = Convert.ToInt32(row["transnum"]);
                if (transnum == 0)
                {
                    // these are special case packs (paper usage tracking only)
                    continue;
                }
                PlayerTransaction transaction = null;
                BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);
                if (player != null)
                {
                    PlayerPack pack = new PlayerPack();
                    pack.electronic  = false;
                    pack.transaction = transaction;
                    pack.start_card  = Convert.ToInt32(row["start_card"]);
                    pack.pack_info   = pack_list.GetPack(packname);
                    if (pack.pack_info != null)
                    {
                        //pack.pack_info.game_list = _games;
                        pack.player       = player;
                        pack.unit_number  = Convert.ToInt32(row["packnum"]);
                        pack.dealer       = pack_list.GetDealer(pack.pack_info, pack.start_card);
                        pack.paper        = true;
                        pack.pack_info.ID = player.played_packs.Count;
                        {
                            // fix the starting card....
                            // need to figure this out ( sam's town )
                            if (bDoLogCards)
                            {
                                Log.log("paper pack starting card " + pack.start_card);
                            }

                            pack.unit_number = Convert.ToInt32(row["packnum"]);
                            player.played_packs.Add(pack);
                        }
                        transaction.Add(pack);
                    }
                }
            }
            paper_table.Dispose();
        }