private void DeleteTournament(object obj) { if (!(obj is TournamentReportRecord tournament)) { return; } var notification = new PopupBaseNotification() { Title = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteTournament_Title"), CancelButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_Cancel"), ConfirmButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteHand_Yes"), Content = CommonResourceManager.Instance.GetResourceString("Notifications_DeleteTournament_Content"), IsDisplayH1Text = true }; PopupRequest.Raise(notification, confirmation => { if (confirmation.Confirmed) { var dataService = ServiceLocator.Current.GetInstance <IDataService>(); dataService.DeleteTournament(tournament.TournamentId, tournament.PokerSiteId); if (ReportSelectedItem != null) { ReportCollection.Remove(ReportSelectedItem); } eventAggregator.GetEvent <UpdateViewRequestedEvent>().Publish(new UpdateViewRequestedEventArgs { IsUpdateReportRequested = true }); } }); }
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 async Task ExportHandsTo3rdParty(HandExportInfo[] exportInfos) { var folderDialog = new FolderBrowserDialog(); var result = folderDialog.ShowDialog(); if (result != DialogResult.OK || !Directory.Exists(folderDialog.SelectedPath)) { return; } try { var sites = exportInfos .GroupBy(x => x.Site) .Select(x => x.Key) .ToArray(); var sitesInInternalFormat = sites .Where(x => x.IsStoredInInternalFormat()) .ToArray(); var useCommonExporter = false; if (sitesInInternalFormat.Length != 0) { var notification = new PopupBaseNotification() { Title = CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_ExportAsIPoker"), CancelButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_ExportAsIPokerNo"), ConfirmButtonCaption = CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_ExportAsIPokerYes"), Content = CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_ExportAsIPokerContent"), IsDisplayH1Text = true }; PopupRequest.Raise(notification, confirmation => { useCommonExporter = !confirmation.Confirmed; }); } var handExportService = ServiceLocator.Current.GetInstance <IHandExportService>(); var mainViewModel = App.GetMainViewModel(); try { await handExportService.ExportHands(folderDialog.SelectedPath, exportInfos, mainViewModel?.ProgressViewModel.Progress, useCommonExporter); } finally { if (mainViewModel != null) { mainViewModel.ProgressViewModel.IsActive = false; mainViewModel.ProgressViewModel.Reset(); } } if (sitesInInternalFormat.Length != 0 && !useCommonExporter || sites.Any(x => x.IsStoredInIPokerFormat())) { var sitesInIPokerFormat = sitesInInternalFormat.Concat(sites.Where(x => x.IsStoredInIPokerFormat())); RaiseNotification( string.Format(CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_SuccessContentInInternalFormat"), string.Join("/", sitesInIPokerFormat.Select(x => CommonResourceManager.Instance.GetEnumResource(x)))), CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_SuccessTitle")); return; } RaiseNotification(CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_SuccessContent"), CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_SuccessTitle")); } catch (Exception e) { RaiseNotification(CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_FailedContent"), CommonResourceManager.Instance.GetResourceString("Notifications_ExportHands_FailedTitle")); throw new DHInternalException(new NonLocalizableString("Failed to export hands to 3rd party."), e); } }