public override void Run() { Trace.TraceInformation("Branch.Service.Halo4 entry point called"); #if RELEASE try { #endif // Update Stuff var tasks = _storage.Table.RetrieveMultipleEntities <TaskEntity>(TaskEntity.PartitionKeyString, _storage.Table.Halo4CloudTable); #region Check to Execute Tasks foreach (var task in tasks.Where(task => DateTime.UtcNow >= (task.LastRun.AddSeconds(task.Interval)))) { var updateLastRun = true; switch (task.Type) { case TaskEntity.TaskType.Playlist: _h4WaypointManager.UpdatePlaylists(); break; case TaskEntity.TaskType.Auth: I343.UpdateAuthentication(_storage); break; case TaskEntity.TaskType.Metadata: _h4WaypointManager.UpdateMetadata(); break; case TaskEntity.TaskType.Challenge: _h4WaypointManager.UpdateChallenges(); break; } task.Interval = (int)_tasks.First(t => t.Key == task.Type).Value.TotalSeconds; if (updateLastRun) { task.LastRun = DateTime.UtcNow; } _storage.Table.ReplaceSingleEntity(task, _storage.Table.Halo4CloudTable); } #endregion #if RELEASE } catch (Exception ex) { Trace.TraceError(ex.ToString()); } #endif // Sleep for 10 minutes until we need to update stuff again. yolo Thread.Sleep(TimeSpan.FromMinutes(10)); }
public Manager(AzureStorage storage, bool updateAuthentication = false) { _storage = storage; RegisterWebApp(); if (updateAuthentication) { I343.UpdateAuthentication(_storage); } GetMetadata(); GetPlaylists(); GetChallenges(); }