コード例 #1
0
        public void Sweep()
        {
            DateTime?nextUpdate = _cache.Get <string, DateTime?>(NEXT_UPDATE_CACHE_KEY, ctx =>
            {
                ctx.Monitor(_signals.When(NEXT_UPDATE_CACHE_KEY));
                return(_clock.UtcNow.AddHours(6));
            });

            string oldFiles = _cache.Get <string, string>(MODEL_FILES_HASH_CACHE_KEY, ctx =>
            {
                ctx.Monitor(_signals.When(MODEL_FILES_HASH_CACHE_KEY));
                return(getNewBlockModelFilesHash());
            });

            if (_clock.UtcNow > nextUpdate.GetValueOrDefault())
            {
                _signals.Trigger(NEXT_UPDATE_CACHE_KEY);
                _modelService.CheckModels(); //Removes models over 3 months (set in SQL SP)
                string newfiles = getNewBlockModelFilesHash();
                if (oldFiles != newfiles)
                {
                    _signals.Trigger(MODEL_FILES_HASH_CACHE_KEY);
                    _projectService.EmailAllProjectOwners("New Model Uploaded", "A new model has been uploaded, and is ready for import into a project into NKD.");
                }
                Logger.Information(string.Format("Successfully updated old models (synchronisation completed).", DateTime.UtcNow.ToLongDateString()));
            }
        }