public IDeployer Create() { var deployAgentProvider = new DeployAgentProvider(); var emailAlerter = new EmailAlerter(); var mappingEvaluator = new MappingEvaluator(); var mappingProcessor = new MappingProcessor(deployAgentProvider, _deploymentFolderSource, mappingEvaluator); return(new Deployer(_configurationReader, emailAlerter, _buildServer, mappingProcessor)); }
public async Task InitializeAsync(Location location) { var scanner = db.Locations.SingleOrDefault(l => l.Id == location.Id).Scanner; this.googleLogin = new GoogleLogin(); this.nianticClient = new NianticClient(location); this.emailAlerter = new EmailAlerter(scanner); await this.googleLogin.LoginAsync(scanner); await this.nianticClient.InitializeAsync(googleLogin.accessToken); }
public async Task ContinuousScanScanAsync(EmailAlerter alerter, CancellationToken cancelToken) { Trace.TraceInformation($"Start continous scanning at {this.scanLocation.Name}"); while (!cancelToken.IsCancellationRequested) { await this.ScanAsync(alerter, cancelToken); await Task.Delay(Constant.ScanDelayInSeconds * 1000); } }
public async Task ScanAsync(EmailAlerter alerter, CancellationToken cancelToken) { Trace.TraceInformation($"Scanning at {this.scanLocation.Name}"); await this.GetPokemonsAsync(this.scanLocation); this.Print(); this.SendEmailForSubscribedUsers(alerter); this.lastScannedPokemons = this.pokemonsMoreThanTwoStep.Select(p => p.EncounterId).ToList(); this.lastScannedPokemons.AddRange(this.nearByPokeStops.Select(p => p.LureInfo.EncounterId).ToList()); Trace.TraceInformation($"Found {this.pokemonsMoreThanTwoStep.Count} pokemons. Rescan in {Constant.ScanDelayInSeconds} seconds"); }
public void EmailAlerter_should_return_silently_if_mapping_notification_address_is_blank() { // Arrange var mapping = new Mapping(); var build = new BuildDetail(); var deployAgentResult = new DeployAgentResult(); var emailAlerter = new EmailAlerter(); mapping.NotificationAddress = string.Empty; // Act emailAlerter.Alert(mapping, build, deployAgentResult); // Assert // no exception }
private void SendEmailForSubscribedUsers(EmailAlerter alerter) { if (Constant.EnableEmailAlert) { var subscriptions = db.LocationSubscriptions.Where(l => l.LocationId == this.scanLocation.Id); var subscribedUsers = subscriptions.Where(sb => sb.User.IsActive).Select(s => s.User); foreach (var user in subscribedUsers) { var list = Utility.ConvertToPokemonIdList(user.IgnoreList); if (this.HasNewRarePokemonSpawned(list) || this.HasNewRarePokemonBeenLured(list)) { var html = PrintToHtml(list); alerter.Send($"{this.scanLocation.Name}", html, user.EmailForAlert); } } } }