/// <summary> /// Api Controller /// </summary> /// <param name="context"></param> /// <param name="logger"></param> public ApiController(DeviceControllerContext context, ILogger <DeviceController> logger) { _context = context; _logger = logger; // TODO: Maybe use the DbContextFactory instead of relying on the same one per repo _accountRepository = new AccountRepository(_context); _deviceRepository = new DeviceRepository(_context); _instanceRepository = new InstanceRepository(_context); _assignmentRepository = new AssignmentRepository(_context); _geofenceRepository = new GeofenceRepository(_context); _webhookRepository = new WebhookRepository(_context); _deviceGroupRepository = new DeviceGroupRepository(_context); _ivListRepository = new IVListRepository(_context); }
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(); }