Exemple #1
0
    public static BsonDocument get_max_from_two_match(string start_time1, string host1, string client1, string start_time2, string host2, string client2, int max_count, ArrayList list_websites)
    {
        string sql = "select * from europe_500 where start_time='{0}' and host='{1}' and client='{2}'";

        sql = string.Format(sql, start_time1, host1, client1);
        DataTable dt1 = SQLServerHelper.get_table(sql);

        sql = "select * from europe_500 where start_time='{0}' and host='{1}' and client='{2}'";
        sql = string.Format(sql, start_time2, host2, client2);
        DataTable dt2 = SQLServerHelper.get_table(sql);



        double[] max = new double[9] {
            -999999, -999999, -999999, -999999, -999999, -999999, -999999, -999999, -999999
        };
        string[] websites = new string[9] {
            "", "", "", "", "", "", "", "", ""
        };

        for (int i = 0; i < dt1.Rows.Count; i++)
        {
            bool is_in_websites = false;
            foreach (string website in list_websites)
            {
                if (website == dt1.Rows[i]["website"].ToString())
                {
                    is_in_websites = true;
                }
            }
            if (is_in_websites == false)
            {
                continue;
            }



            int row_no = -1;
            for (int j = 0; j < dt2.Rows.Count; j++)
            {
                if (dt1.Rows[i]["website"].ToString() == dt2.Rows[j]["website"].ToString())
                {
                    row_no = j;
                    break;
                }
            }

            if (row_no != -1)
            {
                double ww = Convert.ToDouble(dt1.Rows[i]["odd_win"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_win"].ToString());
                double wd = Convert.ToDouble(dt1.Rows[i]["odd_win"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_draw"].ToString());
                double wl = Convert.ToDouble(dt1.Rows[i]["odd_win"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_lose"].ToString());
                double dw = Convert.ToDouble(dt1.Rows[i]["odd_draw"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_win"].ToString());
                double dd = Convert.ToDouble(dt1.Rows[i]["odd_draw"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_draw"].ToString());
                double dl = Convert.ToDouble(dt1.Rows[i]["odd_draw"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_lose"].ToString());
                double lw = Convert.ToDouble(dt1.Rows[i]["odd_lose"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_win"].ToString());
                double ld = Convert.ToDouble(dt1.Rows[i]["odd_lose"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_draw"].ToString());
                double ll = Convert.ToDouble(dt1.Rows[i]["odd_lose"].ToString()) * Convert.ToDouble(dt2.Rows[row_no]["odd_lose"].ToString());

                if (ww > max[0])
                {
                    max[0] = ww; websites[0] = dt1.Rows[i]["website"].ToString();
                }
                if (wd > max[1])
                {
                    max[1] = wd; websites[1] = dt1.Rows[i]["website"].ToString();
                }
                if (wl > max[2])
                {
                    max[2] = wl; websites[2] = dt1.Rows[i]["website"].ToString();
                }
                if (dw > max[3])
                {
                    max[3] = dw; websites[3] = dt1.Rows[i]["website"].ToString();
                }
                if (dd > max[4])
                {
                    max[4] = dd; websites[4] = dt1.Rows[i]["website"].ToString();
                }
                if (dl > max[5])
                {
                    max[5] = dl; websites[5] = dt1.Rows[i]["website"].ToString();
                }
                if (lw > max[6])
                {
                    max[6] = lw; websites[6] = dt1.Rows[i]["website"].ToString();
                }
                if (ld > max[7])
                {
                    max[7] = ld; websites[7] = dt1.Rows[i]["website"].ToString();
                }
                if (ll > max[8])
                {
                    max[8] = ll; websites[8] = dt1.Rows[i]["website"].ToString();
                }
            }
        }


        BsonDocument doc_max = Match500Analyse.get_min_by_wave(max, max_count);



        BsonDocument doc = new BsonDocument();

        doc.Add("doc_id", DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString());
        doc.Add("start_time1", start_time1);
        doc.Add("host1", host1);
        doc.Add("client1", client1);
        doc.Add("start_time2", start_time2);
        doc.Add("host2", host2);
        doc.Add("client2", client2);
        doc.Add("type", "two-match-max");
        doc.Add("bid_count", doc_max["bid_count"].ToString());
        doc.Add("min_value", doc_max["min_value"].ToString());
        doc.Add("max_value", doc_max["max_value"].ToString());

        BsonArray array_websites = new BsonArray();

        foreach (string website in websites)
        {
            array_websites.Add(website);
        }
        doc.Add("websites", array_websites);

        BsonArray array_orign_odds = new BsonArray();

        foreach (double odd in max)
        {
            array_orign_odds.Add(odd.ToString("f2"));
        }
        doc.Add("orign_odds", array_orign_odds);


        //Detail website Odds
        BsonArray website_odds = new BsonArray();

        foreach (string website in websites)
        {
            bool is_has = false;

            foreach (BsonDocument doc_item in website_odds)
            {
                if (doc_item["website"].ToString() == website)
                {
                    is_has = true;
                }
            }
            if (is_has == false)
            {
                BsonDocument doc_item = new BsonDocument();
                doc_item.Add("website", website);
                string odd_win1  = "";
                string odd_draw1 = "";
                string odd_lose1 = "";
                string odd_win2  = "";
                string odd_draw2 = "";
                string odd_lose2 = "";
                foreach (DataRow row in dt1.Rows)
                {
                    if (row["website"].ToString() == website)
                    {
                        odd_win1  = row["odd_win"].ToString();
                        odd_draw1 = row["odd_draw"].ToString();
                        odd_lose1 = row["odd_lose"].ToString();
                    }
                }
                foreach (DataRow row in dt2.Rows)
                {
                    if (row["website"].ToString() == website)
                    {
                        odd_win2  = row["odd_win"].ToString();
                        odd_draw2 = row["odd_draw"].ToString();
                        odd_lose2 = row["odd_lose"].ToString();
                    }
                }
                doc_item.Add("odd_win1", odd_win1);
                doc_item.Add("odd_draw1", odd_draw1);
                doc_item.Add("odd_lose1", odd_lose1);
                doc_item.Add("odd_win2", odd_win2);
                doc_item.Add("odd_draw2", odd_draw2);
                doc_item.Add("odd_lose2", odd_lose2);

                website_odds.Add(doc_item.AsBsonDocument);
            }
        }
        doc.Add("website_odds", website_odds);



        doc.Add("order_nos", doc_max["order_nos"].AsBsonArray);
        doc.Add("bids", doc_max["bids"].AsBsonArray);
        doc.Add("odds", doc_max["odds"].AsBsonArray);
        return(doc);
    }
Exemple #2
0
    public static BsonDocument get_max_from_single_match(string start_time, string host, string client, int max_count, ArrayList list_websites)
    {
        string sql = "select * from europe_500 where start_time='{0}' and host='{1}' and client='{2}'";

        sql = string.Format(sql, start_time, host, client);
        DataTable dt = SQLServerHelper.get_table(sql);

        //ArrayList list_fix_websites = new ArrayList();

        double[] max = new double[3] {
            -999999, -999999, -99999
        };
        string[] websites = new string[3] {
            "", "", ""
        };

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            //bool is_fix_website = false;
            //foreach (string website in ArrayList)
            //{
            //    if (website == dt.Rows[i]["website"].ToString()) is_fix_website = true;
            //}
            //if (is_fix_website == false) continue;

            bool is_in_websites = false;
            foreach (string website in list_websites)
            {
                if (website == dt.Rows[i]["website"].ToString())
                {
                    is_in_websites = true;
                }
            }
            if (is_in_websites == false)
            {
                continue;
            }
            double[] input = new double[3] {
                Convert.ToDouble(dt.Rows[i]["odd_win"].ToString()),
                Convert.ToDouble(dt.Rows[i]["odd_draw"].ToString()),
                Convert.ToDouble(dt.Rows[i]["odd_lose"].ToString())
            };
            if (input[0] > max[0])
            {
                max[0] = input[0]; websites[0] = dt.Rows[i]["website"].ToString();
            }
            if (input[1] > max[1])
            {
                max[1] = input[1]; websites[1] = dt.Rows[i]["website"].ToString();
            }
            if (input[2] > max[2])
            {
                max[2] = input[2]; websites[2] = dt.Rows[i]["website"].ToString();
            }
        }


        BsonDocument doc_max = Match500Analyse.get_min_by_wave(max, max_count);



        BsonDocument doc = new BsonDocument();

        doc.Add("doc_id", DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString());
        doc.Add("start_time", start_time);
        doc.Add("host", host);
        doc.Add("client", client);
        doc.Add("type", "single-match-max");
        doc.Add("bid_count", doc_max["bid_count"].ToString());
        doc.Add("min_value", doc_max["min_value"].ToString());
        doc.Add("max_value", doc_max["max_value"].ToString());

        BsonArray array_websites = new BsonArray();

        foreach (string website in websites)
        {
            array_websites.Add(website);
        }
        doc.Add("websites", array_websites);

        BsonArray array_orign_odds = new BsonArray();

        foreach (double odd in max)
        {
            array_orign_odds.Add(odd.ToString("f2"));
        }
        doc.Add("orign_odds", array_orign_odds);


        BsonArray website_odds = new BsonArray();

        foreach (string website in websites)
        {
            bool is_has = false;

            foreach (BsonDocument doc_item in website_odds)
            {
                if (doc_item["website"].ToString() == website)
                {
                    is_has = true;
                }
            }
            if (is_has == false)
            {
                BsonDocument doc_item = new BsonDocument();
                doc_item.Add("website", website);
                string odd_win  = "";
                string odd_draw = "";
                string odd_lose = "";
                foreach (DataRow row in dt.Rows)
                {
                    if (row["website"].ToString() == website)
                    {
                        odd_win  = row["odd_win"].ToString();
                        odd_draw = row["odd_draw"].ToString();
                        odd_lose = row["odd_lose"].ToString();
                    }
                }
                doc_item.Add("odd_win", odd_win);
                doc_item.Add("odd_draw", odd_draw);
                doc_item.Add("odd_lose", odd_lose);

                website_odds.Add(doc_item.AsBsonDocument);
            }
        }
        doc.Add("website_odds", website_odds);

        doc.Add("order_nos", doc_max["order_nos"].AsBsonArray);
        doc.Add("bids", doc_max["bids"].AsBsonArray);
        doc.Add("odds", doc_max["odds"].AsBsonArray);


        return(doc);
    }