public LinkOrphanGamesJobResult LinkOrphanGames() { var result = new LinkOrphanGamesJobResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); try { var orphanGames = GetOrphanGames(); result.OrphanGames = orphanGames.Count; foreach (var game in orphanGames) { CreateOrUpdateOrphanGames(game, result); } } catch (Exception ex) { result.Success = false; RollbarClient.SendException(ex); ex.ToExceptionless(); } stopwatch.Stop(); result.TimeEllapsed = stopwatch.Elapsed; return(result); }
public void when_calling_send_exception_task_returns_and_can_be_used() { var client = new RollbarClient(); Exception exception = new NotImplementedException(); var task = client.SendException(exception); Assert.IsNotNull(task); Assert.DoesNotThrow(() => task.Wait(0)); }
private async void ReportExceptionToRollbar(Exception exception) { #if DEBUG return; #endif try { var config = new Configuration(_rollbarAccessToken) { Environment = "Production", Platform = $"Platform: AutoPrintr.{_appType}. Version: {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}" }; var client = new RollbarClient(config); await client.SendException(exception, exception?.GetType()?.Name, "error", TransformRollbarDataModel); } catch { } }
public LinkOrphanGamesJobResult LinkOrphanGames() { var result = new LinkOrphanGamesJobResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); try { var orphanGames = GetOrphanGames(); result.OrphanGames = orphanGames.Count; foreach (var game in orphanGames) { var gameName = RemoveYear(game.Name); var existingGame = GetExistingBGGGameByName(gameName); if (existingGame != null) { UpdateGameDefinition(game, existingGame.Id, result); } else { var searchResult = _boardGameGeekApiClient.SearchBoardGames(gameName, true); if (searchResult.Any()) { var gameToAdd = GetGameToAddFromSearch(searchResult); if (gameToAdd != null) { existingGame = GetExistingBGGGameById(gameToAdd); if (existingGame != null) { UpdateGameDefinition(game, existingGame.Id, result); } else { var newRecord = CreateBGGGame(gameToAdd); UpdateGameDefinition(game, newRecord.Id, result); } } } } if (game.BoardGameGeekGameDefinitionId != null) { _dataContext.CommitAllChanges(); } else { result.StillOrphanGames.Add(new LinkOrphanGamesJobResult.OrphanGame() { Name = game.Name, Id = game.Id, GamingGroupId = game.GamingGroupId }); } } } catch (Exception ex) { result.Success = false; RollbarClient.SendException(ex); } stopwatch.Stop(); result.TimeEllapsed = stopwatch.Elapsed; return(result); }