Пример #1
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var user = _wca.GetContext().CurrentUser;

            // Not doing anything on the admin or for anonymous users, and also
            if (AdminFilter.IsApplied(filterContext.RequestContext) || user == null)
            {
                return;
            }

            var notificationsUserPart = user.As <NotificationsUserPart>();

            // Not checking if CheckIntervalMinutes hasn't passed yet since the last update.
            if (notificationsUserPart.LastCheckedUtc >= _clock.UtcNow.AddMinutes(-1 * Constants.NewNotificationCheckIntervalMinutes))
            {
                return;
            }

            notificationsUserPart.LastCheckedUtc = _clock.UtcNow;

            // Using the processing engine to do the update after the request has executed so the user experience is not impacted.
            var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();

            _processingEngine.AddTask(
                _shellSettings,
                shellDescriptor,
                "IUserNotificationsUpdaterEventHandler.UpdateNotificationsForUser",
                new Dictionary <string, object> {
                { "userId", user.ContentItem.Id }
            }
                );
        }
Пример #2
0
        public void UpdateTerms(ContentItem contentItem, IEnumerable <TermPart> terms, string field)
        {
            var termsPart = contentItem.As <TermsPart>();

            // removing current terms for specific field
            var termList = termsPart.Terms.Select((t, i) => new { Term = t, Index = i })
                           .Where(x => x.Term.Field == field)
                           .Select(x => x)
                           .OrderByDescending(i => i.Index)
                           .ToList();

            foreach (var x in termList)
            {
                termsPart.Terms.RemoveAt(x.Index);
            }

            // adding new terms list
            foreach (var term in terms)
            {
                // Remove the newly added terms because they will get processed by the Published-Event
                termList.RemoveAll(t => t.Term.Id == term.Id);
                termsPart.Terms.Add(
                    new TermContentItem {
                    TermsPartRecord = termsPart.Record,
                    TermRecord      = term.Record, Field = field
                });
            }

            var termPartRecordIds = termList.Select(t => t.Term.TermRecord.Id).ToArray();

            _processingEngine.AddTask(_shellSettings, _shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary <string, object> {
                { "termPartRecordIds", termPartRecordIds }
            });
        }
Пример #3
0
        private void FireApplyChangesIfNeeded()
        {
            var shellState = _stateManager.GetShellState();

            if (shellState.Features.Any(FeatureIsChanging))
            {
                var descriptor = new ShellDescriptor
                {
                    Features = shellState.Features
                               .Where(FeatureShouldBeLoadedForStateChangeNotifications)
                               .Select(x => new ShellFeature
                    {
                        Name = x.Name
                    })
                               .ToArray()
                };

                Logger.Information("Adding pending task 'ApplyChanges' for shell '{0}'", _settings.Name);
                _processingEngine.AddTask(
                    _settings,
                    descriptor,
                    "IShellStateManagerEventHandler.ApplyChanges",
                    new Dictionary <string, object>());
            }
        }
Пример #4
0
        // Fires off a processing engine task to run the count processing after the request so it's non-blocking.
        private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part)
        {
            var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();

            processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary <string, object> {
                { "termPartRecordIds", termPartRecordIds }
            });
        }
Пример #5
0
 public void ProcessCasePostsCount(int cAsePartId)
 {
     if (!_processedCaseParts.Contains(cAsePartId))
     {
         _processedCaseParts.Add(cAsePartId);
         _processingEngine.AddTask(_shellSettings, _shellDescriptorManager.GetShellDescriptor(), "ICasePostsCountProcessor.Process", new Dictionary <string, object> {
             { "cAsePartId", cAsePartId }
         });
     }
 }
 public void QueuePackageUninstall(string packageId)
 {
     _processingEngine.AddTask(
         _shellSettings,
         _shellDescriptorManager.GetShellDescriptor(),
         "IPackageUninstallHandler.UninstallPackage",
         new Dictionary <string, object> {
         { "packageId", packageId }
     });
 }
Пример #7
0
 public void ProcessBidsCount(int bidsPartId)
 {
     if (!_processedBidsParts.Contains(bidsPartId))
     {
         _processedBidsParts.Add(bidsPartId);
         _processingEngine.AddTask(_shellSettings, _shellDescriptorManager.GetShellDescriptor(), "IBidsCountProcessor.Process", new Dictionary <string, object> {
             { "BidsPartId", bidsPartId }
         });
     }
 }
Пример #8
0
 private void Queue(string industry, Func <WorkContext, IAtomicWorker> executorResolver)
 {
     _processingEngine.AddTask(
         _shellSettings,
         _shellDescriptorManager.GetShellDescriptor(),
         "IAtomicJobExecutor.Execute",
         new Dictionary <string, object> {
         { "industry", industry }, { "executorResolver", executorResolver }
     }
         );
 }
        public void Schedule(string indexName)
        {
            var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();

            _processingEngine.AddTask(
                _shellSettings,
                shellDescriptor,
                "IIndexNotifierHandler.UpdateIndex",
                new Dictionary <string, object> {
                { "indexName", indexName }
            }
                );
        }
Пример #10
0
        public void Schedule(bool force)
        {
            var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();

            _processingEngine.AddTask(
                _shellSettings,
                shellDescriptor,
                "IWarmupEventHandler.Generate",
                new Dictionary <string, object> {
                { "force", force }
            }
                );
        }
Пример #11
0
        public void ScheduleWork(string executionId)
        {
            var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();

            // TODO: this task entry may need to become appdata folder backed if it isn't already
            _processingEngine.AddTask(
                _shellSettings,
                shellDescriptor,
                "IRecipeSchedulerEventHandler.ExecuteWork",
                new Dictionary <string, object> {
                { "executionId", executionId }
            });
        }
Пример #12
0
        public void Queue <TAtomicWorker>(string industry) where TAtomicWorker : IAtomicWorker
        {
            var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();
            Func <WorkContext, IAtomicWorker> executorResolver = (workContext) => workContext.Resolve <TAtomicWorker>();

            _processingEngine.AddTask(
                _shellSettings,
                shellDescriptor,
                "IAtomicJobExecutor.Execute",
                new Dictionary <string, object> {
                { "industry", industry }, { "executorResolver", executorResolver }
            }
                );
        }
 public void AddTask(HiddenStringFieldUpdateProcessVariant variant, HiddenStringFieldSettings settings, ContentPartFieldDefinitionBuilder builder)
 {
     if (variant != HiddenStringFieldUpdateProcessVariant.None)
     {
         _processingEngine
         .AddTask(_shellSettings,
                  _shellDescriptorManager.GetShellDescriptor(),
                  "IHiddenStringFieldUpdateProcessor.Process",
                  new Dictionary <string, object> {
             { "contentItemIds", GetIdsToProcess(variant, builder) },
             { "partName", builder.PartName },
             { "fieldName", builder.Name },
             { "settings", settings }
         });
     }
 }
Пример #14
0
        // Fires off a processing engine task to run the count processing after the request so it's non-blocking.
        private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part)
        {
            var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();

            if (termPartRecordIds.Any())
            {
                if (!_processedTermParts.Any())
                {
                    processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary <string, object> {
                        { "termPartRecordIds", _processedTermParts }
                    });
                }
                foreach (var termPartRecordId in termPartRecordIds)
                {
                    _processedTermParts.Add(termPartRecordId);
                }
            }
        }
Пример #15
0
        private void ImportPostsInBatches(ImportSettings importSettings, IContent parentContentItem, ICollection <Post> posts)
        {
            _contentManager.Clear();
            const int batchSize = 100;
            int       batchNo   = 1;

            for (var i = 0; i < posts.Count; i += batchSize)
            {
                var postBatch = posts.Skip(i).Take(batchSize).ToList();
                _processingEngine.AddTask(
                    _shellSettings,
                    _shellDescriptorManager.GetShellDescriptor(),
                    "IScheduledBlogPostCollectionImport.Import",
                    new Dictionary <string, object> {
                    { "importSettings", importSettings },
                    { "parentContentItem", parentContentItem },
                    { "posts", postBatch },
                    { "batchNumber", batchNo }
                });

                batchNo++;
            }
        }
        // Fires off a processing engine task to run the count processing after the request so it's non-blocking.
        private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) {
            var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();
            processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary<string, object> { { "termPartRecordIds", termPartRecordIds } });

        }
Пример #17
0
         // Fires off a processing engine task to run the count processing after the request so it's non-blocking.
 private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) {
     var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();
     if (termPartRecordIds.Any()) {
         if (!_processedTermParts.Any()) {
             processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary<string, object> { { "termPartRecordIds", _processedTermParts } });
         }
         foreach (var termPartRecordId in termPartRecordIds) {
             _processedTermParts.Add(termPartRecordId);                    
         }
     }
 }