Beispiel #1
0
        private async Task OnTransactionComplete(int pageDirectoryId)
        {
            _cache.Clear();

            await _messageAggregator.PublishAsync(new PageDirectoryAddedMessage()
            {
                PageDirectoryId = pageDirectoryId
            });
        }
        private Task OnTransactionComplete(DeletePageCommand command)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageDeletedMessage()
            {
                PageId = command.PageId
            }));
        }
 public void PublishAsync <T>(T message)
     where T : class
 {
     lock ( m_Padlock )
     {
         m_Aggregator.PublishAsync(m_Store,
                                   message);
     }
 }
Beispiel #4
0
        private Task OnTransactionComplete(UpdatePageDirectoryAccessRuleSetCommand command)
        {
            _pageDirectoryCache.Clear();

            return(_messageAggregator.PublishAsync(new PageDirectoryAccessRulesUpdatedMessage()
            {
                PageDirectoryId = command.PageDirectoryId
            }));
        }
        private Task OnTransactionComplete(DeleteImageAssetCommand command)
        {
            _imageAssetCache.Clear(command.ImageAssetId);

            return(_messageAggregator.PublishAsync(new ImageAssetDeletedMessage()
            {
                ImageAssetId = command.ImageAssetId
            }));
        }
        private Task OnTransactionComplete(UpdatePageUrlCommand command, bool isPublished)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageUrlChangedMessage()
            {
                PageId = command.PageId,
                HasPublishedVersionChanged = isPublished
            }));
        }
 private async Task OnTransactionComplete(UserSummary user, AddAuthorizedTaskCommand addAuthorizedTaskCommand)
 {
     await _messageAggregator.PublishAsync(new UserAccountRecoveryInitiatedMessage()
     {
         AuthorizedTaskId = addAuthorizedTaskCommand.OutputAuthorizedTaskId,
         UserAreaCode     = user.UserArea.UserAreaCode,
         UserId           = user.UserId,
         Token            = addAuthorizedTaskCommand.OutputToken
     });
 }
        private Task OnTransactionComplete(AddPageCommand command, Page page)
        {
            _pageCache.ClearRoutes();

            return(_messageAggregator.PublishAsync(new PageAddedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = command.Publish
            }));
        }
        private Task OnTransactionComplete(CustomEntityVersion version)
        {
            _customEntityCache.Clear(version.CustomEntity.CustomEntityDefinitionCode, version.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityPublishedMessage()
            {
                CustomEntityId = version.CustomEntityId,
                CustomEntityDefinitionCode = version.CustomEntity.CustomEntityDefinitionCode
            }));
        }
        private Task OnTransactionComplete(PageVersion pageVersion, PageVersionBlock newBlock)
        {
            _pageCache.Clear(pageVersion.PageId);

            return(_messageAggregator.PublishAsync(new PageVersionBlockAddedMessage()
            {
                PageId = pageVersion.PageId,
                PageVersionBlockId = newBlock.PageVersionBlockId
            }));
        }
        private Task OnTransactionComplete(int pageId, int pageVersionBlockId)
        {
            _pageCache.Clear(pageId);

            return(_messageAggregator.PublishAsync(new PageVersionBlockMovedMessage()
            {
                PageId = pageId,
                PageVersionBlockId = pageVersionBlockId
            }));
        }
        private Task OnTransactionComplete(Page page)
        {
            _pageCache.Clear(page.PageId);

            return(_messageAggregator.PublishAsync(new PageUpdatedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = page.PublishStatusCode == PublishStatusCode.Published
            }));
        }
        private Task OnTransactionComplete(DeleteCustomEntityCommand command, CustomEntity customEntity)
        {
            _customEntityCache.Clear(customEntity.CustomEntityDefinitionCode, command.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityDeletedMessage()
            {
                CustomEntityId = command.CustomEntityId,
                CustomEntityDefinitionCode = customEntity.CustomEntityDefinitionCode
            }));
        }
        private Task OnTransactionComplete(AddPageDraftVersionCommand command, int newVersionId)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageDraftVersionAddedMessage()
            {
                PageId = command.PageId,
                PageVersionId = newVersionId
            }));
        }
Beispiel #15
0
        private async Task OnTransactionComplete(User user, AuthorizedTaskTokenValidationResult validationResult)
        {
            _userContextCache.Clear(user.UserId);

            await _userSecurityStampUpdateHelper.OnTransactionCompleteAsync(user);

            await _messageAggregator.PublishAsync(new UserAccountRecoveryCompletedMessage()
            {
                UserAreaCode     = user.UserAreaCode,
                UserId           = user.UserId,
                AuthorizedTaskId = validationResult.Data.AuthorizedTaskId
            });

            await _messageAggregator.PublishAsync(new UserPasswordUpdatedMessage()
            {
                UserAreaCode = user.UserAreaCode,
                UserId       = user.UserId
            });
        }
Beispiel #16
0
        private Task OnTransactionComplete(PageVersion draft)
        {
            _pageCache.Clear(draft.PageId);

            return(_messageAggregator.PublishAsync(new PageDraftVersionUpdatedMessage()
            {
                PageId = draft.PageId,
                PageVersionId = draft.PageVersionId
            }));
        }
        private Task OnTransactionComplete(CustomEntity entity)
        {
            _customEntityCache.Clear(entity.CustomEntityDefinitionCode, entity.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityUnPublishedMessage()
            {
                CustomEntityId = entity.CustomEntityId,
                CustomEntityDefinitionCode = entity.CustomEntityDefinitionCode
            }));
        }
        private async Task OnTransactionComplete(User user)
        {
            _userContextCache.Clear(user.UserId);

            await _messageAggregator.PublishAsync(new UserDeletedMessage()
            {
                UserAreaCode = user.UserAreaCode,
                UserId       = user.UserId
            });
        }
        private Task OnTransactionComplete(PageRoute page)
        {
            _pageCache.Clear(page.PageId);

            return(_messageAggregator.PublishAsync(new PageDeletedMessage()
            {
                PageId = page.PageId,
                FullUrlPath = page.FullUrlPath
            }));
        }
        private Task OnTransactionComplete(CustomEntityVersionPageBlock dbBlock)
        {
            _customEntityCache.Clear(dbBlock.CustomEntityVersion.CustomEntity.CustomEntityDefinitionCode, dbBlock.CustomEntityVersion.CustomEntity.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityVersionBlockUpdatedMessage()
            {
                CustomEntityId = dbBlock.CustomEntityVersion.CustomEntityId,
                CustomEntityDefinitionCode = dbBlock.CustomEntityVersion.CustomEntity.CustomEntityDefinitionCode,
                CustomEntityVersionBlockId = dbBlock.CustomEntityVersionPageBlockId
            }));
        }
Beispiel #21
0
        private Task OnTransactionComplete(CustomEntity entity)
        {
            _customEntityCache.Clear(entity.CustomEntityDefinitionCode, entity.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityUrlChangedMessage()
            {
                CustomEntityId = entity.CustomEntityId,
                CustomEntityDefinitionCode = entity.CustomEntityDefinitionCode,
                HasPublishedVersionChanged = entity.PublishStatusCode == PublishStatusCode.Published
            }));
        }
Beispiel #22
0
        private async Task OnTransactionComplete(User user)
        {
            _userContextCache.Clear(user.UserId);
            await _userSecurityStampUpdateHelper.OnTransactionCompleteAsync(user);

            await _messageAggregator.PublishAsync(new UserPasswordUpdatedMessage()
            {
                UserAreaCode = user.UserAreaCode,
                UserId       = user.UserId
            });
        }
Beispiel #23
0
        private async Task OnTransactionComplete(User user, UpdateUserAccountVerificationStatusCommand command)
        {
            _userContextCache.Clear();

            await _messageAggregator.PublishAsync(new UserAccountVerificationStatusUpdatedMessage()
            {
                UserAreaCode = user.UserAreaCode,
                UserId       = user.UserId,
                IsVerified   = command.IsAccountVerified
            });
        }
Beispiel #24
0
        private Task OnTransactionComplete(string customEntityDefinitionCode, int customEntityId, int customEntityVersionPageBlockId)
        {
            _customEntityCache.Clear(customEntityDefinitionCode, customEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityVersionBlockMovedMessage()
            {
                CustomEntityId = customEntityId,
                CustomEntityDefinitionCode = customEntityDefinitionCode,
                CustomEntityVersionBlockId = customEntityVersionPageBlockId
            }));
        }
Beispiel #25
0
        private Task OnTransactionComplete(AddCustomEntityDraftVersionCommand command, string definitionCode, int newVersionId)
        {
            _customEntityCache.Clear(definitionCode, command.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityDraftVersionAddedMessage()
            {
                CustomEntityId = command.CustomEntityId,
                CustomEntityVersionId = newVersionId,
                CustomEntityDefinitionCode = definitionCode
            }));
        }
Beispiel #26
0
        private Task OnTransactionComplete(PageRoute oldPageRoute, bool isPublished)
        {
            _pageCache.Clear(oldPageRoute.PageId);

            return(_messageAggregator.PublishAsync(new PageUrlChangedMessage()
            {
                PageId = oldPageRoute.PageId,
                OldFullUrlPath = oldPageRoute.FullUrlPath,
                HasPublishedVersionChanged = isPublished
            }));
        }
Beispiel #27
0
        private Task OnTransactionComplete(CustomEntityVersion customEntityVersion, CustomEntityVersionPageBlock newBlock)
        {
            _customEntityCache.Clear(customEntityVersion.CustomEntity.CustomEntityDefinitionCode, customEntityVersion.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityVersionBlockAddedMessage()
            {
                CustomEntityId = customEntityVersion.CustomEntityId,
                CustomEntityVersionPageBlockId = newBlock.CustomEntityVersionPageBlockId,
                CustomEntityDefinitionCode = customEntityVersion.CustomEntity.CustomEntityDefinitionCode
            }));
        }
        private Task OnUpdateDraftComplete(UpdateCustomEntityDraftVersionCommand command, CustomEntityVersion draft)
        {
            _customEntityCache.Clear(command.CustomEntityDefinitionCode, command.CustomEntityId);

            return(_messageAggregator.PublishAsync(new CustomEntityDraftVersionUpdatedMessage()
            {
                CustomEntityId = command.CustomEntityId,
                CustomEntityDefinitionCode = command.CustomEntityDefinitionCode,
                CustomEntityVersionId = draft.CustomEntityVersionId
            }));
        }
Beispiel #29
0
        public async Task ExecuteAsync(PublishCustomEntityCommand command, IExecutionContext executionContext)
        {
            // Prefer draft, but update published entity if no draft (only one draft permitted)
            var version = await _dbContext
                          .CustomEntityVersions
                          .Include(v => v.CustomEntity)
                          .Where(v => v.CustomEntityId == command.CustomEntityId && (v.WorkFlowStatusId == (int)WorkFlowStatus.Draft || v.WorkFlowStatusId == (int)WorkFlowStatus.Published))
                          .OrderByDescending(v => v.WorkFlowStatusId == (int)WorkFlowStatus.Draft)
                          .ThenByDescending(v => v.CreateDate)
                          .FirstOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(version, command.CustomEntityId);

            var definition = _customEntityDefinitionRepository.GetByCode(version.CustomEntity.CustomEntityDefinitionCode);

            EntityNotFoundException.ThrowIfNull(definition, version.CustomEntity.CustomEntityDefinitionCode);

            await _permissionValidationService.EnforceCustomEntityPermissionAsync <CustomEntityPublishPermission>(definition.CustomEntityDefinitionCode);

            UpdatePublishDate(command, executionContext, version);

            if (version.WorkFlowStatusId == (int)WorkFlowStatus.Published)
            {
                // only thing we can do with a published version is update the date
                await _dbContext.SaveChangesAsync();
            }
            else
            {
                await ValidateTitle(version, definition);

                using (var scope = _transactionScopeFactory.Create(_dbContext))
                {
                    await UpdateUrlSlugIfRequired(version, definition);

                    version.WorkFlowStatusId = (int)WorkFlowStatus.Published;
                    version.CustomEntity.PublishStatusCode = PublishStatusCode.Published;

                    await _dbContext.SaveChangesAsync();

                    await _customEntityStoredProcedures.UpdatePublishStatusQueryLookupAsync(command.CustomEntityId);

                    scope.Complete();
                }
            }

            _customEntityCache.Clear(version.CustomEntity.CustomEntityDefinitionCode, command.CustomEntityId);

            await _messageAggregator.PublishAsync(new CustomEntityPublishedMessage()
            {
                CustomEntityId             = command.CustomEntityId,
                CustomEntityDefinitionCode = version.CustomEntity.CustomEntityDefinitionCode
            });
        }
Beispiel #30
0
        private Task OnTransactionComplete(
            AddCustomEntityCommand command,
            CustomEntity entity
            )
        {
            _customEntityCache.ClearRoutes(entity.CustomEntityDefinitionCode);

            return(_messageAggregator.PublishAsync(new CustomEntityAddedMessage()
            {
                CustomEntityId = entity.CustomEntityId,
                CustomEntityDefinitionCode = entity.CustomEntityDefinitionCode,
                HasPublishedVersionChanged = command.Publish
            }));
        }