public IHttpActionResult DoScan() { var message = string.Empty; try { using (var repository = new MongoRepository()) { var lastUpdatedTime = repository.FindLastUpdatedDateTime(); var timeSinceLastUpdate = DateTime.UtcNow.Subtract(lastUpdatedTime); if (timeSinceLastUpdate > TimeSpan.FromMinutes(3)) { ForumScanner scanner = new ForumScanner(repository); scanner.DoWholeUpdate(); message = "Scan was successful."; } else { message = $"Did not scan because the previous scan was only {timeSinceLastUpdate.TotalSeconds} seconds ago."; } } } catch (Exception e) { return(this.InternalServerError(e)); } return(this.Ok(message)); }
internal static void DoScan(IRepository repository) { try { var scanner = new ForumScanner(repository); scanner.DoWholeUpdate(); Log.Info("Scan complete!"); } catch (Exception exception) { var message = string.Format(CultureInfo.InvariantCulture, "Exception thrown when attempting to update repository from the forum: {0}", exception.Message); Log.Error(message); repository.LogMessage(message); } }
public ActionResult Index() { var message = string.Empty; using (var repository = new MongoRepository()) { try { var lastUpdatedTime = repository.FindLastUpdatedDateTime(); var timeSinceLastUpdate = DateTime.UtcNow.Subtract(lastUpdatedTime); if (timeSinceLastUpdate > TimeSpan.FromMinutes(4)) { ForumScanner scanner = new ForumScanner(repository); scanner.DoWholeUpdate(); message = "Scan was successful."; } else { message = $"Did not scan because the previous scan was only {timeSinceLastUpdate.TotalMinutes.ToString("F1")} minutes ago."; } } catch (Exception e) { message = $"Error: Could not scan the forum."; repository.LogMessage($"Error scanning forum: {e.Message}"); } } TempData["HomepageMessage"] = message; return(RedirectToAction("index", "home")); }
public void DoEndOfGameScan() { ForumScanner scanner = new ForumScanner(new MongoRepository()); scanner.DoEndOfGameScan(); }
public void DoWholeUpdateTest() { ForumScanner scanner = new ForumScanner(new MongoRepository()); scanner.DoWholeUpdate(); }