コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: johndarv/MukMafiaTool
        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);
            }
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        public void DoEndOfGameScan()
        {
            ForumScanner scanner = new ForumScanner(new MongoRepository());

            scanner.DoEndOfGameScan();
        }
コード例 #5
0
        public void DoWholeUpdateTest()
        {
            ForumScanner scanner = new ForumScanner(new MongoRepository());

            scanner.DoWholeUpdate();
        }