public void HdlAGIN(string name) { try { string file_path = Path.Combine(CONFIG_DAFANBA_DIR_PRINT, name); if (File.Exists(file_path)) { AGIN_3840x2160_Baccarat agin_3840x2160_baccarat = null; ImageHelper.AnalysisImg_AGIN_3840x2160(file_path, out agin_3840x2160_baccarat); List <DB_AGIN_Baccarat> agins_img = DB_AGIN_Baccarat.ExtractImg(agin_3840x2160_baccarat, name, DateTime.Now, 0, DateTime.Now, 0); foreach (DB_AGIN_Baccarat agin_img in agins_img) { DB_AGIN_Baccarat agin_latest = LatestAGINs.Where(x => x.CoordinateX == agin_img.CoordinateX && x.CoordinateY == agin_img.CoordinateY).FirstOrDefault(); #region For: Save/Clean baccarat if (!new int[3] { 0, 203, 204 }.Contains(agin_img.DataAnalysis.TotalInvalid)) { agin_img.SaveDbTrack(ConnHelper); } if (0 != agin_img.DataAnalysis.TotalInvalid) { continue; } agin_img.Id = 0; agin_img.DataAnalysis.DelEmpty(); #endregion #region For: Merge baccarat bool merged = false; if (null != agin_latest) { int dist = DB_AGIN_Baccarat_Tbl.DistMerge( agin_latest.DataAnalysis, agin_img.DataAnalysis, DB_AGIN_Baccarat_Tbl.DistMax(agin_latest.DataAnalysis, agin_img.DataAnalysis)); if (-1 != dist) { DB_AGIN_Baccarat_Tbl.ExecMerge(agin_latest.DataAnalysis, agin_img.DataAnalysis, dist); agin_latest.FileNames = Regex.Replace(agin_latest.FileNames + agin_img.FileNames, @"(;;)", ";"); agin_latest.LastModifiedOn = agin_img.LastModifiedOn; agin_latest.LastModifiedBy = agin_img.LastModifiedBy; merged = true; } } #endregion #region For: Add baccarat if (!merged) { if (null != agin_latest) { LatestAGINs.Remove(agin_latest); } LatestAGINs.Add(agin_img); agin_latest = LatestAGINs.Single(x => x.CoordinateX == agin_img.CoordinateX && x.CoordinateY == agin_img.CoordinateY); } #endregion #region For: Order baccarat agin_latest.DataAnalysis.UpdOrder( agin_latest.DataAnalysis.LatestOrder, agin_latest.DataAnalysis.LatestOrderCircle, agin_latest.DataAnalysis.LatestOrderX, agin_latest.DataAnalysis.LatestOrderY, agin_latest.DataAnalysis.LatestOrderXR, agin_latest.DataAnalysis.LatestOrderYR); #endregion #region For: Save baccarat agin_latest.SaveDb(ConnHelper); #endregion #region For: Alert via pattern(s) #region For: Baccarat pattern IEnumerable <DB_AGIN_Baccarat_Check_RstItem> pattern = agin_latest.ChkPattern(CONFIG_DAFANBA_ALERT_BACCARAT_PATTERN); foreach (DB_AGIN_Baccarat_Check_RstItem item in pattern) { AlertBaccaratPattern(agin_latest.CoordinateX, agin_latest.CoordinateY, item.NFreq, item.CellsFreq.Count, item.CellsSub.Count, item.ColorsFreq, file_path); } #endregion #endregion } } } catch (Exception ex) { throw new Exception(string.Format("{0}{1}", ex.Message, ex.StackTrace), ex); } }