public void get_single_by_website_desc(List <BsonDocument> list) { StringBuilder sb = new StringBuilder(); sb.Append("BY website DESC:" + Environment.NewLine); DataTable dt = new DataTable(); DataColumn order = new DataColumn("order"); order.DataType = Type.GetType("System.Int32"); dt.Columns.Add(order); DataColumn count = new DataColumn("count"); count.DataType = Type.GetType("System.Int32"); dt.Columns.Add(count); for (int i = 0; i < list.Count; i++) { DataRow row_new = dt.NewRow(); row_new["order"] = i; BsonArray array = list[i]["websites"].AsBsonArray; ArrayList al = new ArrayList(); foreach (BsonValue value in array) { bool is_has = false; foreach (string name in al) { if (name == value.ToString()) { is_has = true; } } if (is_has == false) { al.Add(value.ToString()); } } row_new["count"] = al.Count; dt.Rows.Add(row_new); } dt.DefaultView.Sort = "count desc"; dt = dt.DefaultView.ToTable(); foreach (DataRow row in dt.Rows) { BsonDocument doc = list[Convert.ToInt32(row["order"].ToString())]; sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); sb.Append(Match100Analyse2.get_info_from_doc(doc)); } sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); this.txt_result.Text = sb.ToString(); Match100Helper.create_log_result(sb.ToString()); Application.DoEvents(); }
public void get_single_by_start_time_desc(List <BsonDocument> list) { StringBuilder sb = new StringBuilder(); sb.Append("BY START TIME ASC:" + Environment.NewLine); DataTable dt = new DataTable(); DataColumn order = new DataColumn("order"); order.DataType = Type.GetType("System.Int32"); dt.Columns.Add(order); DataColumn persent = new DataColumn("start_time"); persent.DataType = Type.GetType("System.String"); dt.Columns.Add(persent); for (int i = 0; i < list.Count; i++) { DataRow row_new = dt.NewRow(); row_new["order"] = i; row_new["start_time"] = list[i]["start_time"].ToString(); dt.Rows.Add(row_new); } dt.DefaultView.Sort = "start_time desc"; dt = dt.DefaultView.ToTable(); foreach (DataRow row in dt.Rows) { BsonDocument doc = list[Convert.ToInt32(row["order"].ToString())]; sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); sb.Append(Match100Analyse2.get_info_from_doc(doc)); } sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); this.txt_result.Text = sb.ToString(); Match100Helper.create_log_result(sb.ToString()); Application.DoEvents(); }
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_100 where start_time='{0}' and host='{1}' and client='{2}' and id in (select max(id) from europe_100 where start_time>'{3}' group by website,start_time,host,client)"; sql = string.Format(sql, start_time, host, client, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); 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_result = Match100Analyse2.get_single_match_result(max[0].ToString(), max[1].ToString(), max[2].ToString()); 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", "50"); doc.Add("min_value", doc_result["count_return"].ToString()); doc.Add("result", doc_result); 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("max_odds", array_orign_odds); BsonArray website_details = new BsonArray(); foreach (string website in websites) { bool is_has = false; foreach (BsonDocument doc_item in website_details) { 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 = ""; string odd_timespan = ""; string odd_id = ""; string odd_league = ""; 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(); odd_timespan = row["timespan"].ToString(); odd_id = row["id"].ToString(); odd_league = row["league"].ToString(); } } doc_item.Add("odd_win", odd_win); doc_item.Add("odd_draw", odd_draw); doc_item.Add("odd_lose", odd_lose); doc_item.Add("timespan", odd_timespan); doc_item.Add("id", odd_id); doc_item.Add("league", odd_league); website_details.Add(doc_item.AsBsonDocument); } } doc.Add("website_details", website_details); return(doc); }
private void btn_single_match_Click(object sender, EventArgs e) { ArrayList list_websites = new ArrayList(); foreach (DataGridViewRow row in dgv_website.Rows) { if (Convert.ToBoolean(row.Cells["selected"].Value) == true) { string website = row.Cells["website"].Value.ToString(); list_websites.Add(website); } } StringBuilder sb = new StringBuilder(); List <BsonDocument> list = new List <BsonDocument>(); foreach (DataGridViewRow row in dgv_match.Rows) { if (Convert.ToBoolean(row.Cells["selected"].Value) == true) { string start_time = row.Cells["start_time"].Value.ToString(); string host = row.Cells["host"].Value.ToString(); string client = row.Cells["client"].Value.ToString(); BsonDocument doc = Match100Analyse2.get_max_from_single_match(start_time, host, client, 50, list_websites); list.Add(doc); sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); sb.Append(Match100Analyse2.get_info_from_doc(doc)); this.txt_result.Text = sb.ToString(); Application.DoEvents(); } } sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); this.txt_result.Text = sb.ToString(); Application.DoEvents(); if (cb_persent_asc.Checked) { get_single_by_persent_asc(list); } if (cb_persent_desc.Checked) { get_single_by_persent_desc(list); } if (cb_website_asc.Checked) { get_single_by_website_asc(list); } if (cb_website_desc.Checked) { get_single_by_website_desc(list); } if (cb_start_time_asc.Checked) { get_single_by_start_time_asc(list); } if (cb_start_time_desc.Checked) { get_single_by_start_time_desc(list); } }