private async void LoadOpponentReportHands() { if (!(ReportSelectedItem is OpponentReportIndicators report) || report.HasAllHands || report.ReportHands.Count >= filterAmountDictionarySelectedItem) { FilterReportSelectedItemStatisticsCollection(); return; } var opponentReportService = ServiceLocator.Current.GetInstance <IOpponentReportService>(); IsHandGridBusy = true; if (!ReferenceEquals(report.ReportHands, ReportSelectedItemStatisticsCollection)) { ReportSelectedItemStatisticsCollection?.Clear(); GC.Collect(); } await Task.Run(() => { try { var statistic = opponentReportService.LoadPlayerHands(report.PlayerId, filterAmountDictionarySelectedItem); ReportSelectedItemStatisticsCollection = new ObservableCollection <ReportHandViewModel>(statistic.Select(x => new ReportHandViewModel(x))); } catch (Exception e) { LogProvider.Log.Error(this, "Could not load player hands for opponent report", e); } }); IsHandGridBusy = false; }
private void DeleteHands() { var handsToDelete = SelectedReportHands?.Select(x => new { x.GameNumber, x.PokerSiteId }).ToArray(); if (handsToDelete == null || handsToDelete.Length == 0) { return; } var notification = new PopupBaseNotification() { Title = handsToDelete.Length == 1 ? CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_SingleTitle") : string.Format(CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_MultipleTitle"), handsToDelete.Length), CancelButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_Cancel"), ConfirmButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_Yes"), Content = handsToDelete.Length == 1 ? CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_SingleContent") : CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_MultipleContent"), IsDisplayH1Text = true }; PopupRequest.Raise(notification, confirmation => { if (confirmation.Confirmed) { var dataservice = ServiceLocator.Current.GetInstance <IDataService>(); handsToDelete.ForEach(x => dataservice.DeleteHandHistory(x.GameNumber, x.PokerSiteId)); SelectedReportHands.ForEach(x => { ReportSelectedItemStatisticsCollection.Remove(x); ReportSelectedItem.ReportHands.Remove(x); StorageModel.RemoveStatistic(s => s.GameNumber == x.GameNumber && s.PokersiteId == x.PokerSiteId); }); eventAggregator.GetEvent <UpdateViewRequestedEvent>().Publish(new UpdateViewRequestedEventArgs { IsUpdateReportRequested = true }); } }); }
private void FilterReportSelectedItemStatisticsCollection() { if (ReportSelectedItemStatisticsCollection == null) { return; } var predicate = PredicateBuilder.True <ReportHandViewModel>(); if (FilterTaggedHands_IsChecked && FilterHandTagSelectedItem != EnumHandTag.None) { predicate = predicate.And(GetHandTagPredicate()); } var filteredCollection = ReportSelectedItemStatisticsCollection .AsQueryable() .Where(predicate) .OrderByDescending(x => x.Time) .Take(FilterAmountDictionarySelectedItem); FilteredReportSelectedItemStatisticsCollection.Reset(filteredCollection); }