private void InitAGINs() { LatestAGINs = new List <DB_AGIN_Baccarat>(); SQLiteCommand cmd = ConnHelper.ConnDb.CreateCommand(); try { #region SQLiteCommand: Initialize #region cmd.CommandText = string.Format(@"") cmd.CommandText = string.Format(@" SELECT A.* FROM AGIN A WHERE Id IN (SELECT MAX(Id) FROM AGIN GROUP BY CoordinateX, CoordinateY)"); #endregion cmd.CommandType = CommandType.Text; cmd.CommandTimeout = CONFIG_CONN_TIMEOUT; #endregion #region SQLiteCommand: Parameters #endregion #region SQLiteCommand: Connection DataSet ds = ConnHelper.ExecCmd(cmd); #endregion #region For: Retrieve DataTable dt = ds.Tables[0]; List <string> cols = ToCols(dt); foreach (DataRow dr in dt.Rows) { LatestAGINs.Add(DB_AGIN_Baccarat.ExtractDB(dr, cols)); } #endregion #region For: Clean dt.Clear(); ds.Clear(); dt.Dispose(); ds.Dispose(); #endregion } catch (Exception ex) { throw new Exception(string.Format("{0}{1}", ex.Message, ex.StackTrace), ex); } finally { cmd.Dispose(); } }
public void Analysis2_AGIN() { List <DB_AGIN_Baccarat> agins = new List <DB_AGIN_Baccarat>(); SQLiteCommand cmd = ConnHelper.ConnDb.CreateCommand(); try { #region SQLiteCommand: Initialize #region cmd.CommandText = string.Format(@"") cmd.CommandText = string.Format(@" SELECT ASUM.* FROM AGIN_SUMMARY ASUM WHERE ASUM.Id > 8281 ORDER BY ASUM.Id ASC"); #endregion cmd.CommandType = CommandType.Text; cmd.CommandTimeout = CONFIG_CONN_TIMEOUT; #endregion #region SQLiteCommand: Parameters #endregion #region SQLiteCommand: Connection DataSet ds = ConnHelper.ExecCmd(cmd); #endregion #region For: Retrieve DataTable dt = ds.Tables[0]; List <string> cols = ToCols(dt); foreach (DataRow dr in dt.Rows) { agins.Add(DB_AGIN_Baccarat.ExtractDB(dr, cols)); } #endregion #region For: Clean dt.Clear(); ds.Clear(); dt.Dispose(); ds.Dispose(); #endregion } catch (Exception ex) { throw new Exception(string.Format("{0}{1}", ex.Message, ex.StackTrace), ex); } finally { cmd.Dispose(); } int order_min = 1, idx = 1; List <List <object> > lst_vals = new List <List <object> >(); string cmd_text = string.Format(@"INSERT INTO AGIN_RESULT2 (SubId, LatestOrder, NumCircleRed, NumCircleBlue, Matches) VALUES (?, ?, ?, ?, ?)"); foreach (DB_AGIN_Baccarat agin in agins) { agin.DataAnalysis.UpdCoordinate(); int order = order_min - 1; while (agin.DataAnalysis.LatestOrder > order++) { List <DB_AGIN_Baccarat_Cell> cells = new List <DB_AGIN_Baccarat_Cell>(); agin.DataAnalysis.Cells.ForEach(x => { cells.AddRange(x.Where(y => order + 1 > y.Order)); }); cells = cells.OrderBy(x => x.Order).ToList(); lst_vals.Add(new List <object>() { agin.Id, order, cells.Count(x => x.Matches.Contains("circle-red")), cells.Count(x => x.Matches.Contains("circle-blue")), string.Format(";{0};", string.Join(";", cells[cells.Count - 1].Matches)) }); } System.Threading.Thread.Sleep(0); System.Windows.Forms.Application.DoEvents(); Console.Clear(); Console.WriteLine(string.Format("Information\t:: {0:P}", (double)idx++ / agins.Count)); } ConnHelper.ExecNonQueryCmdOptimizeMany(lst_vals, cmd_text); }
public void Analysis1_AGIN() { List <DB_AGIN_Baccarat> agins = new List <DB_AGIN_Baccarat>(); SQLiteCommand cmd = ConnHelper.ConnDb.CreateCommand(); try { #region SQLiteCommand: Initialize #region cmd.CommandText = string.Format(@"") cmd.CommandText = string.Format(@" SELECT ASUM.* FROM AGIN_SUMMARY ASUM WHERE ASUM.Id > 8281 ORDER BY ASUM.Id ASC"); #endregion cmd.CommandType = CommandType.Text; cmd.CommandTimeout = CONFIG_CONN_TIMEOUT; #endregion #region SQLiteCommand: Parameters #endregion #region SQLiteCommand: Connection DataSet ds = ConnHelper.ExecCmd(cmd); #endregion #region For: Retrieve DataTable dt = ds.Tables[0]; List <string> cols = ToCols(dt); foreach (DataRow dr in dt.Rows) { agins.Add(DB_AGIN_Baccarat.ExtractDB(dr, cols)); } #endregion #region For: Clean dt.Clear(); ds.Clear(); dt.Dispose(); ds.Dispose(); #endregion } catch (Exception ex) { throw new Exception(string.Format("{0}{1}", ex.Message, ex.StackTrace), ex); } finally { cmd.Dispose(); } int idx = 1; List <List <object> > lst_vals = new List <List <object> >(); string cmd_text = string.Format(@"INSERT INTO AGIN_RESULT1 (SubId, LatestOrder, FreqN, FreqL, FreqLSub, FreqColors) VALUES (?, ?, ?, ?, ?, ?)"); foreach (DB_AGIN_Baccarat agin in agins) { agin.DataAnalysis.UpdCoordinate(); int order = 0; while (agin.DataAnalysis.LatestOrder > order++) { DB_AGIN_Baccarat_Check baccarat_check = new DB_AGIN_Baccarat_Check(agin, 10, 1, new KeyValuePair <int, int>[10] { new KeyValuePair <int, int>(1, 1), new KeyValuePair <int, int>(2, 6), new KeyValuePair <int, int>(3, 9), new KeyValuePair <int, int>(4, 12), new KeyValuePair <int, int>(5, 15), new KeyValuePair <int, int>(6, 18), new KeyValuePair <int, int>(7, 21), new KeyValuePair <int, int>(8, 24), new KeyValuePair <int, int>(9, 27), new KeyValuePair <int, int>(10, 30) }); baccarat_check.Search(order).ForEach(x => { lst_vals.Add(new List <object>() { agin.Id, order, x.NFreq, x.CellsFreq.Count, x.CellsSub.Count, x.ColorsFreq }); }); } System.Threading.Thread.Sleep(0); System.Windows.Forms.Application.DoEvents(); Console.Clear(); Console.WriteLine(string.Format("Information\t:: {0:P}", (double)idx++ / agins.Count)); } ConnHelper.ExecNonQueryCmdOptimizeMany(lst_vals, cmd_text); }