示例#1
0
        private static async Task ProcessFirstTimers(ApplicationDbContext dbContext, IScholarService scholarService)
        {
            // grab N random people who need sources setup first time
            var firstTimePeopleWithoutScholarSource = await dbContext.People.Where(p => !p.Sources.Any(s => s.Source == "scholar")).Take(20).ToArrayAsync();

            _log.Information("Processing {num} people without scholar sources", firstTimePeopleWithoutScholarSource.Length);

            foreach (var person in firstTimePeopleWithoutScholarSource)
            {
                try
                {
                    _log.Information("Processing {name} ({id})", person.FullName, person.Id);

                    await scholarService.SyncForPerson(person.Id);
                }
                catch (ApplicationException)
                {
                    _log.Warning("Could not process user {id}", person.Id);
                }
                finally
                {
                    // wait a little before trying the next one to make sure our data source is happy
                    await Task.Delay(_random.Next(1500, 3500));
                }
            }
        }
示例#2
0
        private static async Task ProcessExisting(ApplicationDbContext dbContext, IScholarService scholarService)
        {
            // grab N people with scholar who haven't been updated recently
            var oldestUpdatedScholarPeopleIds = await dbContext.PeopleSources
                                                .Where(s => s.Source == "scholar")
                                                .OrderBy(s => s.LastUpdate)
                                                .Select(s => s.PersonId).Take(20).ToArrayAsync();

            _log.Information("Updating scholar information for {num} people ", oldestUpdatedScholarPeopleIds.Length);

            foreach (var personId in oldestUpdatedScholarPeopleIds)
            {
                try
                {
                    _log.Information("Processing {id}", personId);

                    await scholarService.SyncForPerson(personId);
                }
                catch (ApplicationException)
                {
                    _log.Warning("Could not process user {id}", personId);
                }
                finally
                {
                    // wait a little before trying the next one to make sure our data source is happy
                    await Task.Delay(_random.Next(1500, 3500));
                }
            }
        }
示例#3
0
 public SystemController(ApplicationDbContext dbContext, IDirectoryPopulationService directoryPopulationService, IScholarService scholarService, ISiteFarmService siteFarmService)
 {
     this.dbContext = dbContext;
     this.directoryPopulationService = directoryPopulationService;
     this.scholarService             = scholarService;
     this.siteFarmService            = siteFarmService;
 }