public ProgressViewModel() { cancellationTokerSource = new CancellationTokenSource(); progress = new DHProgress(cancellationTokerSource.Token); progress.ProgressChanged += OnProgressChanged; StopCommand = ReactiveCommand.Create(() => Stop()); }
public SplashWindowViewModel() { progress = new DHProgress(); progress.ProgressChanged += OnProgressChanged; }
protected override IEnumerable <ParsingResult> ImportHand(string handHistory, GameInfo gameInfo, IFileImporter dbImporter, DHProgress progress) { // client window contains some additional information about the game, so add it to the HH if possible handHistory = AddAdditionalData(handHistory, gameInfo); return(dbImporter.Import(handHistory, progress, gameInfo)); }
/// <summary> /// Import results in DB /// </summary> /// <param name="convertedResult"></param> private void ImportResult(ConvertedResult convertedResult) { // send data to file importer var dbImporter = ServiceLocator.Current.GetInstance <IFileImporter>(); var progress = new DHProgress(); IEnumerable <ParsingResult> parsingResult = null; LogProvider.Log.Info(this, $"Hand {convertedResult.HandNumber} processed. [{Identifier}]"); try { parsingResult = dbImporter.Import(convertedResult.ConvertedXml, progress, convertedResult.GameInfo); } catch (DHLicenseNotSupportedException) { LogProvider.Log.Error(this, $"Hand {convertedResult.HandNumber} has not been imported. License issue. [{Identifier}]"); var windowHwnd = new IntPtr(convertedResult.GameInfo.WindowHandle); if (windowHwnd != IntPtr.Zero && WinApi.IsWindow(windowHwnd)) { var preImportedArgs = new PreImportedDataEventArgs(convertedResult.GameInfo, CommonResourceManager.Instance.GetResourceString("Notifications_HudLayout_PreLoadingText_NoLicense")); eventAggregator.GetEvent <PreImportedDataEvent>().Publish(preImportedArgs); } return; } catch (Exception e) { LogProvider.Log.Error(this, string.Format("Hand {0} has not been imported. [{1}]", convertedResult.HandNumber, Identifier), e); } if (parsingResult == null) { return; } foreach (var result in parsingResult) { if (result.HandHistory == null) { continue; } if (result.IsDuplicate) { LogProvider.Log.Info(this, string.Format("Hand {0} has not been imported. Duplicate. [{1}]", result.HandHistory.Gamenumber, Identifier)); continue; } if (!result.WasImported) { LogProvider.Log.Info(this, string.Format("Hand {0} has not been imported. [{1}]", result.HandHistory.Gamenumber, Identifier)); continue; } LogProvider.Log.Info(this, string.Format("Hand {0} has been imported in {2}ms. [{1}]", result.HandHistory.Gamenumber, Identifier, result.Duration)); if (result.Source.GameDescription.TableTypeDescriptors.Contains(TableTypeDescription.FastFold)) { var preImportedArgs = new PreImportedDataEventArgs(convertedResult.GameInfo, CommonResourceManager.Instance.GetResourceString("Notifications_HudLayout_PreLoadingText_NotSupportedFastFold")); eventAggregator.GetEvent <PreImportedDataEvent>().Publish(preImportedArgs); return; } var dataImportedArgs = new DataImportedEventArgs(result.Source.Players, convertedResult.GameInfo, result.Source.Hero, result.Source.HandId); eventAggregator.GetEvent <DataImportedEvent>().Publish(dataImportedArgs); } }
protected override IEnumerable <ParsingResult> ImportHand(string handHistory, GameInfo gameInfo, IFileImporter dbImporter, DHProgress progress) { var parsingResults = dbImporter.Import(handHistory, progress, gameInfo); IPokerFileInfo importedFileInfo = null; if (importedHandsHistory.ContainsKey(gameInfo.FullFileName)) { importedFileInfo = importedHandsHistory[gameInfo.FullFileName]; } else { importedFileInfo = new IPokerFileInfo(); importedHandsHistory.Add(gameInfo.FullFileName, importedFileInfo); } foreach (var parsingResult in parsingResults) { if (parsingResult != null && parsingResult.HandHistory != null && !importedFileInfo.ImportedHands.Contains(parsingResult.HandHistory.Gamenumber)) { importedFileInfo.ImportedHands.Add(parsingResult.HandHistory.Gamenumber); } } return(parsingResults); }
/// <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); } }
protected virtual IEnumerable <ParsingResult> ImportHand(string handHistory, GameInfo gameInfo, IFileImporter importer, DHProgress progress) { return(importer.Import(handHistory, progress, gameInfo)); }