/// <summary> /// Instantiates a new <see cref="DatabaseMigrator"/> class /// </summary> public DatabaseMigrator() { _metadataRepository = new MetadataRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); // Create the metadata table _metadataRepository.ExecuteSql(Strings.SQL_CREATE_TABLE_METADATA); // Get current version from metadata table var dbVersion = GetMetadata("DB_VERSION").ConfigureAwait(false) .GetAwaiter() .GetResult(); var currentVersion = int.Parse(dbVersion?.Value ?? "0"); // Get newest version from migration files var newestVersion = GetNewestDbVersion(); _logger.LogInformation($"Current: {currentVersion}, Latest: {newestVersion}"); // Attempt to migrate the database if (currentVersion < newestVersion) { // Wait 30 seconds and let user know we are about to migrate the database and for them to make // a backup until we handle backups and rollbacks. _logger.LogInformation("MIGRATION IS ABOUT TO START IN 30 SECONDS, PLEASE MAKE SURE YOU HAVE A BACKUP!!!"); Thread.Sleep(30 * 1000); } Migrate(currentVersion, newestVersion).GetAwaiter().GetResult(); }
public GeofenceController() { _geofences = new Dictionary <string, Geofence>(); _geofenceRepository = new GeofenceRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); //_logger = new Logger<IVListController>(LoggerFactory.Create(x => x.AddConsole())); Reload().ConfigureAwait(false).GetAwaiter().GetResult(); }
public SpawnpointFinderInstanceController() { _spawnpointRepository = new SpawnpointRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _logger = new Logger <SpawnpointFinderInstanceController>(LoggerFactory.Create(x => x.AddConsole())); _lastIndex = 0; SpawnpointCoordinates = new List <Coordinate>(); }
public InstanceController() { _devices = new Dictionary <string, Device>(); _instances = new Dictionary <string, IJobController>(); _deviceRepository = new DeviceRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _instanceRepository = new InstanceRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _logger = new Logger <InstanceController>(LoggerFactory.Create(x => x.AddConsole())); _logger.LogInformation("Starting instances..."); }
public AutoInstanceController(string name, List <MultiPolygon> multiPolygon, AutoType type, int timezoneOffset, ushort minLevel, ushort maxLevel, int spinLimit, byte retryLimit, bool ignoreBootstrap, string groupName = null, bool isEvent = false) { Name = name; MultiPolygon = multiPolygon; Type = type; TimezoneOffset = timezoneOffset; MinimumLevel = minLevel; MaximumLevel = maxLevel; SpinLimit = spinLimit; RetryLimit = retryLimit; IgnoreS2CellBootstrap = ignoreBootstrap; GroupName = groupName; IsEvent = isEvent; _logger = new Logger <AutoInstanceController>(LoggerFactory.Create(x => x.AddConsole())); _allStops = new List <Pokestop>(); _todayStops = new Dictionary <string, Pokestop>(); _todayStopsTries = new Dictionary <string, int>(); _bootstrapCellIds = new List <ulong>(); _accountRepository = new AccountRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _pokestopRepository = new PokestopRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _cellRepository = new CellRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); var timeLeft = DateTime.Now.SecondsUntilMidnight(); _timer = new System.Timers.Timer(timeLeft * 1000); _timer.Elapsed += async(sender, e) => await ClearQuests().ConfigureAwait(false); _timer.Start(); // TODO: Get 12am DateTime _logger.LogInformation($"[{Name}] Clearing Quests in {timeLeft:N0}s at 12:00 AM (Currently: {DateTime.Now})"); Update().ConfigureAwait(false) .GetAwaiter() .GetResult(); if (!IgnoreS2CellBootstrap) { Bootstrap().ConfigureAwait(false) .GetAwaiter() .GetResult(); } }
public AssignmentController() { _assignments = new List <Assignment>(); _initialized = false; _lastUpdated = -2; _logger = new Logger <AssignmentController>(LoggerFactory.Create(x => x.AddConsole())); _assignmentRepository = new AssignmentRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _deviceRepository = new DeviceRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _deviceGroupRepository = new DeviceGroupRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _timer = new System.Timers.Timer { Interval = 5000 }; _timer.Elapsed += async(sender, e) => await CheckAssignments().ConfigureAwait(false); Start().ConfigureAwait(false) .GetAwaiter() .GetResult(); }
public IVInstanceController(string name, List <MultiPolygon> multiPolygon, List <uint> pokemonList, ushort minLevel, ushort maxLevel, int ivQueueLimit, string groupName = null, bool isEvent = false) { Name = name; MultiPolygon = multiPolygon; PokemonList = pokemonList; MinimumLevel = minLevel; MaximumLevel = maxLevel; IVQueueLimit = ivQueueLimit; GroupName = groupName; IsEvent = isEvent; _logger = new Logger <IVInstanceController>(LoggerFactory.Create(x => x.AddConsole())); _pokemonRepository = new PokemonRepository(DbContextFactory.CreateDeviceControllerContext(Startup.DbConfig.ToString())); _pokemonQueue = new List <Pokemon>(); _scannedPokemon = new List <ScannedPokemon>(); _timer = new System.Timers.Timer { Interval = 1000 }; _timer.Elapsed += (sender, e) => ThreadPool.QueueUserWorkItem(_ => LoopCache()); _timer.Start(); }