public static string test_2result_odd() { BsonDocument doc = Analyse2Result.get_best(1, 50); IWindow.write_break(); IWindow.write(Analyse2Result.get_info(doc)); IWindow.write_break(); return("COMPUTE OK!!!"); }
public static BsonDocument get_best(int param_odd_id, int max_count, ArrayList list_websites) { string sql = " select * from a_odd where id={0}"; sql = string.Format(sql, param_odd_id); DataTable dt_temp = SQLServerHelper.get_table(sql); if (dt_temp.Rows.Count == 0) { return(new BsonDocument()); } sql = " select b.start_time,b.team1,b.team2,c.name type_name,d.name website_name,a.r1,a.r2,a.o1,a.o2,a.timespan, a.id odd_id" + " from a_odd a" + " left join a_event b on a.event_id=b.id" + " left join a_type c on a.type_id=c.id" + " left join a_website d on a.website_id=d.id" + " where a.event_id={0} and a.type_id={1} " + " and a.m1='{2}' and a.m2='{3}' and a.m3='{4}' and a.m4='{5}' and a.m5='{6}' and a.m6='{7}' " + " and a.r1='{8}' and a.r2='{9}' and a.r3='{10}' and a.r4='{11}' and a.r5='{12}' and a.r6='{13}' "; sql = string.Format(sql, dt_temp.Rows[0]["event_id"].ToString(), dt_temp.Rows[0]["type_id"].ToString(), dt_temp.Rows[0]["m1"].ToString(), dt_temp.Rows[0]["m2"].ToString(), dt_temp.Rows[0]["m3"].ToString(), dt_temp.Rows[0]["m4"].ToString(), dt_temp.Rows[0]["m5"].ToString(), dt_temp.Rows[0]["m6"].ToString(), dt_temp.Rows[0]["r1"].ToString(), dt_temp.Rows[0]["r2"].ToString(), dt_temp.Rows[0]["r3"].ToString(), dt_temp.Rows[0]["r4"].ToString(), dt_temp.Rows[0]["r5"].ToString(), dt_temp.Rows[0]["r6"].ToString() ); DataTable dt = SQLServerHelper.get_table(sql); string start_time = ""; string host = ""; string client = ""; string type_name = ""; if (dt.Rows.Count > 0) { start_time = dt.Rows[0]["start_time"].ToString(); host = dt.Rows[0]["team1"].ToString(); client = dt.Rows[0]["team2"].ToString(); type_name = dt.Rows[0]["type_name"].ToString(); } double[] max = new double[2] { -999999, -999999 }; string[] websites = new string[2] { "", "" }; for (int i = 0; i < dt.Rows.Count; i++) { bool is_in_websites = false; foreach (string website in list_websites) { if (website == dt.Rows[i]["website_name"].ToString()) { is_in_websites = true; } } if (is_in_websites == false) { continue; } double[] input = new double[2] { Convert.ToDouble(dt.Rows[i]["o1"].ToString()), Convert.ToDouble(dt.Rows[i]["o2"].ToString()) }; if (input[0] > max[0]) { max[0] = input[0]; websites[0] = dt.Rows[i]["website_name"].ToString(); } if (input[1] > max[1]) { max[1] = input[1]; websites[1] = dt.Rows[i]["website_name"].ToString(); } } BsonDocument doc_result = Analyse2Result.get_result_list(max[0].ToString(), max[1].ToString()); BsonDocument doc = new BsonDocument(); doc.Add("doc_id", DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString()); doc.Add("type", "2result"); doc.Add("odd_type", type_name); doc.Add("start_time", start_time); doc.Add("host", host); doc.Add("client", client); 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 array_results = new BsonArray(); array_results.Add(dt.Rows[0]["r1"].ToString()); array_results.Add(dt.Rows[0]["r2"].ToString()); doc.Add("odd_results", array_results); 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_name"].ToString() == website) { odd_win = row["o1"].ToString(); odd_lose = row["o2"].ToString(); odd_timespan = row["timespan"].ToString(); odd_id = row["odd_id"].ToString(); // odd_league = row["league"].ToString(); } } doc_item.Add("odd_win", odd_win); 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); }
public static string test_all_2result_odd() { StringBuilder sb = new StringBuilder(); string sql = " select * from a_odd where type_id in (2,3,4)"; DataTable dt_temp = SQLServerHelper.get_table(sql); List <BsonDocument> list = new List <BsonDocument>(); foreach (DataRow row in dt_temp.Rows) { if (row["m5"].ToString() == "Y") { continue; } BsonDocument doc = Analyse2Result.get_best(Convert.ToInt32(row["id"].ToString()), 50); list.Add(doc); for (int i = 0; i < dt_temp.Rows.Count; i++) { if (dt_temp.Rows[i]["event_id"].ToString() == row["event_id"].ToString() && dt_temp.Rows[i]["type_id"].ToString() == row["type_id"].ToString() && dt_temp.Rows[i]["m1"].ToString() == row["m1"].ToString() && dt_temp.Rows[i]["m2"].ToString() == row["m2"].ToString() && dt_temp.Rows[i]["m3"].ToString() == row["m3"].ToString() && dt_temp.Rows[i]["m4"].ToString() == row["m4"].ToString() && dt_temp.Rows[i]["m5"].ToString() == row["m5"].ToString() && dt_temp.Rows[i]["m6"].ToString() == row["m6"].ToString() && dt_temp.Rows[i]["o1"].ToString() == row["o1"].ToString() && dt_temp.Rows[i]["o2"].ToString() == row["o2"].ToString() && dt_temp.Rows[i]["o3"].ToString() == row["o3"].ToString() && dt_temp.Rows[i]["o4"].ToString() == row["o4"].ToString() && dt_temp.Rows[i]["o5"].ToString() == row["o5"].ToString() && dt_temp.Rows[i]["o6"].ToString() == row["o6"].ToString()) { dt_temp.Rows[0]["m5"] = "Y"; } } } List <BsonDocument> list_result = get_list_by_persent_desc(list); sb.AppendLine("-------------------------------------------------------------------------------------------------------------"); foreach (BsonDocument doc_show in list_result) { sb.Append(Analyse2Result.get_info(doc_show)); sb.Append(""); sb.AppendLine("-------------------------------------------------------------------------------------------------------------"); } Log.create_log_file(sb.ToString()); IWindow.write_break(); int count = 0; foreach (BsonDocument doc_show in list_result) { count = count + 1; if (count == 11) { break; } IWindow.write(Analyse2Result.get_info(doc_show)); IWindow.write_break(); } return("COMPUTE OK!!!"); }