コード例 #1
0
 /// <summary>
 /// Creates the database.
 /// </summary>
 public void CreateDatabase()
 {
     NotBusy = false;
     Connecting(this, EventArgs.Empty);
     DbCreator.Create(AsBuilder.ConnectionString, ConfigurationService.CurrentSchemaVersion);
     NotBusy = true;
 }
コード例 #2
0
        static void Main(string[] args)
        {
            log.Info("Connection string           : " + connectionString);
            Console.WriteLine("Database Type               : " + dbtype);
            Console.WriteLine("Sleep Time                  : " + sleepTime);
            Console.WriteLine("Service Host                : " + predictionServiceHost + ":" + predictionServicePort);
            Console.WriteLine(" ");

            int sleep = 2000;

            int.TryParse(sleepTime, out sleep);

            Database dbStuff = new Database(DbCreator.Create(dbtype));

            int cnt     = 0;
            int maxWait = 10;

            while (true)
            {
                try
                {
                    dbStuff.Connect(connectionString);
                    break;
                }
                catch (Exception e)
                {
                    log.Error(e);
                    log.Warn("Cannot connect to DB... retrying in 10 seconds");
                    if (cnt++ < maxWait)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    else
                    {
                        break;
                    }
                }
            }


            var gen = new PredictionsGenerator(dbStuff, mode, predictionServiceHost + ":" + predictionServicePort);

            gen.Go();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            int r = 0;

            bool phantomMode = false;

            foreach (string arg in args)
            {
                log.Info("args[" + r + "] " + arg);

                if (arg.ToLower().Contains("-m:willhill"))
                {
                    gOpMode = OperationMode.WilliamHillScan;
                }

                if (arg.ToLower().Contains("-m:bet365"))
                {
                    gOpMode = OperationMode.Bet365Scan;
                }

                if (arg.ToLower().Contains("-n:"))
                {
                    try
                    {
                        numBots = int.Parse(arg.Substring("-n:".Length));
                    }
                    catch
                    {
                        log.Warn("Couldn't parse number of bots: " + arg);
                    }
                }

                if (arg.ToLower().Contains("-m:uploadwh"))
                {
                    gOpMode = OperationMode.UploadWilliamHill;
                }

                if (arg.ToLower().Contains("-m:upload365"))
                {
                    gOpMode = OperationMode.UploadBet365;
                }

                if (arg.ToLower().Contains("-p:"))
                {
                    xmlPath = arg.Substring("-p:".Length);
                }

                if (arg.ToLower().Contains("-m:skip"))
                {
                    gSkipAddGames = true;
                }

                if (arg.ToLower().Contains("-m:justtodds"))
                {
                    gJustOdds = true;
                }

                if (arg.ToLower().Contains("-m:scratch"))
                {
                    ScratchPad();
                    return;
                }

                if (arg.ToLower().Contains("-m:phantom"))
                {
                    phantomMode = true;
                }

                ++r;
            }

            log.Info("Bot starting, scanning site : " + gOpMode);
            log.Info("Connection string           : " + connectionString);
            log.Info("Database Type               : " + dbtype);
            log.Info("XML Path                    : " + xmlPath);
            log.Info("Sleep Time                  : " + sleepTime);
            log.Info(" ");

            int sleep = 2000;

            int.TryParse(sleepTime, out sleep);

            if (Directory.Exists(xmlPath) == false)
            {
                log.Error("Directory " + xmlPath + " does not exist :(");
                return;
            }

            DriverCreator driverCreator = null;

            if (phantomMode)
            {
                driverCreator = new PhantomDriverCreator();
            }
            else
            {
                driverCreator = new ChromeDriverCreator();
            }

            Database dbStuff = new Database(DbCreator.Create(dbtype));

            int cnt     = 0;
            int maxWait = 10;

            while (true)
            {
                try
                {
                    dbStuff.Connect(connectionString);
                    break;
                }
                catch (Exception e)
                {
                    log.Error(e);
                    log.Warn("Cannot connect to DB... retrying in 10 seconds");
                    if (cnt++ < maxWait)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Scanner scanner = null;

            switch (gOpMode)
            {
            case OperationMode.Bet365Scan:
                scanner = new ScanBet365(driverCreator, dbStuff, xmlPath, gSkipAddGames);
                break;

            case OperationMode.WilliamHillScan:
                scanner = new ScanWilliamHill(driverCreator, dbStuff, xmlPath, gSkipAddGames);
                break;

            case OperationMode.UploadBet365:
                scanner = new UploadBet365(driverCreator, dbStuff, xmlPath, gSkipAddGames);
                break;

            default:
                scanner = new UpdateFromXmlToWeb(driverCreator, dbStuff, xmlPath, gSkipAddGames);
                break;
            }

            scanner.scan(20);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            log.Info("Connection string           : " + connectionString);
            log.Info("Database Type               : " + dbtype);
            log.Info("Sleep Time                  : " + sleepTime);
            log.Info(" ");
            log.Info("Ids:");
            int sleep = 2000;

            int.TryParse(sleepTime, out sleep);

            Database dbStuff = new Database(DbCreator.Create(dbtype));

            int cnt     = 0;
            int maxWait = 10;

            while (true)
            {
                try
                {
                    dbStuff.Connect(connectionString);
                    break;
                }
                catch (Exception e)
                {
                    log.Error(e);
                    log.Warn("Cannot connect to DB... retrying in 10 seconds");
                    if (cnt++ < maxWait)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            List <aMatch> matches = new List <aMatch>();

            dbStuff.RunSQL("SELECT id FROM games"
                           + " WHERE date_part('DAY', kodate) = date_part('DAY', now())"
                           + " AND date_part('month', kodate) = date_part('month', now())"
                           + " AND date_part('year', kodate) = date_part('year', now())"
                           // + "kodate > now()"
                           ,
                           (dr) =>
            {
                var match = new aMatch();
                match.id  = dr[0].ToString();
                matches.Add(match);
            }
                           );

            //134510, 134511



            log.Info("Getting odds: ");
            foreach (aMatch match in matches)
            {
                log.Info("match: " + match.id);
                dbStuff.RunSQL("SELECT homeprice, drawprice, awayprice"
                               + " FROM fulltimeprice"
                               + " WHERE game_id = '" + match.id + "';"
                               ,
                               (dr) =>
                {
                    match.homeWinPrice = dr[0].ToString();
                    match.drawPrice    = dr[1].ToString();
                    match.awayWinPrice = dr[2].ToString();
                }
                               );
                log.Info("ods for match: homeWin: " + match.homeWinPrice);
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            int r = 0;

            bool phantomMode = false;

            gOpMode = OperationMode.Bet365Scan;

            foreach (string arg in args)
            {
                Console.WriteLine("args[" + r + "] " + arg);

                if (arg.ToLower().Contains("-p:"))
                {
                    xmlPath = arg.Substring("-p:".Length);
                }

                ++r;
            }

            Console.WriteLine("Bot starting, scanning site : " + gOpMode);
            Console.WriteLine("Connection string           : " + connectionString);
            Console.WriteLine("Database Type               : " + dbtype);
            Console.WriteLine("XML Path                    : " + xmlPath);
            Console.WriteLine("Sleep Time                  : " + sleepTime);
            Console.WriteLine(" ");

            int sleep = 2000;

            int.TryParse(sleepTime, out sleep);

            if (Directory.Exists(xmlPath) == false)
            {
                log.Error("Directory " + xmlPath + " does not exist :(");
                return;
            }

            DriverCreator driverCreator = null;

            if (phantomMode)
            {
                driverCreator = new PhantomDriverCreator();
            }
            else
            {
                driverCreator = new ChromeDriverCreator();
            }

            Database dbStuff = new Database(DbCreator.Create(dbtype));

            int cnt     = 0;
            int maxWait = 10;

            while (true)
            {
                try
                {
                    dbStuff.Connect(connectionString);
                    break;
                }
                catch (Exception e)
                {
                    log.Error(e);
                    log.Warn("Cannot connect to DB... retrying in 10 seconds");
                    if (cnt++ < maxWait)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                    else
                    {
                        break;
                    }
                }
            }


            string agentString = "--user-agent=\"Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533/1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1\"";

            using (var driverWrapper = driverCreator.CreateDriver(agentString))
            {
                if (driverWrapper == null)
                {
                    log.Error("Failed to make a Selenium Driver");
                }

                var scanner = new OddScanner(dbStuff);
                scanner.AddTodaysMatches(2000, driverWrapper);
            }
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbCreator d = new DbCreator();

            d.Create();
        }