コード例 #1
0
 protected virtual PlayerList GetPlayerList(HandHistory handHistory, GameInfo gameInfo)
 {
     return(handHistory.Players);
 }
コード例 #2
0
        /// <summary>
        /// Processes the specified hand history text
        /// </summary>
        /// <param name="handHistory">Hand history to process</param>
        /// <param name="gameInfo"></param>
        protected virtual void ProcessHand(string handHistory, GameInfo gameInfo)
        {
            var importer = ServiceLocator.Current.GetInstance <IFileImporter>();
            var progress = new DHProgress();

            IEnumerable <ParsingResult> parsingResult = null;

            if (gameInfo.GameNumber != 0)
            {
                LogProvider.Log.Info(this, $"Hand {gameInfo.GameNumber} processed. [{SiteString}]");
            }

            try
            {
                parsingResult = ImportHand(handHistory, gameInfo, importer, progress);
            }
            catch (DHLicenseNotSupportedException)
            {
                LogProvider.Log.Error(this, $"Hand(s) has not been imported. License issue. [{SiteString}]");

                var windowHwnd = new IntPtr(gameInfo.WindowHandle);

                if (windowHwnd != IntPtr.Zero && WinApi.IsWindow(windowHwnd))
                {
                    SendPreImporedData("Notifications_HudLayout_PreLoadingText_NoLicense", windowHwnd);
                }
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(gameInfo.FullFileName))
                {
                    LogProvider.Log.Error(this, $"Hand(s) from '{gameInfo.FullFileName}' has not been imported. [{SiteString}]", e);
                }
                else
                {
                    LogProvider.Log.Error(this, $"Hand(s) has not been imported. [{SiteString}]", e);
                }
            }

            if (parsingResult == null)
            {
                return;
            }

            foreach (var result in parsingResult)
            {
                if (result.HandHistory == null)
                {
                    continue;
                }

                if (!SupportDuplicates && result.IsDuplicate)
                {
                    LogProvider.Log.Info(this, string.Format("Hand {0} has not been imported. Duplicate. [{1}]", result.HandHistory.Gamenumber, SiteString));
                    continue;
                }

                if (!result.WasImported)
                {
                    LogProvider.Log.Info(this, string.Format("Hand {0} has not been imported. [{1}]", result.HandHistory.Gamenumber, SiteString));
                    continue;
                }

                LogProvider.Log.Info(this, string.Format("Hand {0} has been imported in {2}ms. [{1}]", result.HandHistory.Gamenumber, SiteString, result.Duration));

                if (gameInfo.WindowHandle == 0 || !WinApi.IsWindow(new IntPtr(gameInfo.WindowHandle)))
                {
                    gameInfo.WindowHandle = FindWindow(result).ToInt32();
                }

                gameInfo.GameFormat = ParseGameFormat(result);
                gameInfo.GameType   = ParseGameType(result);
                gameInfo.TableType  = ParseTableType(result, gameInfo);
                gameInfo.GameNumber = result.HandHistory.Gamenumber;

                var playerList = GetPlayerList(result.Source, gameInfo);

                var dataImportedArgs = new DataImportedEventArgs(playerList, gameInfo, result.Source?.Hero, result.HandHistory.Gamenumber);

                PublishImportedResults(dataImportedArgs);
            }
        }
コード例 #3
0
 protected virtual IEnumerable <ParsingResult> ImportHand(string handHistory, GameInfo gameInfo, IFileImporter importer, DHProgress progress)
 {
     return(importer.Import(handHistory, progress, gameInfo));
 }