Exemple #1
0
        public override MultistepActionSettings Setup(int siteId, int contentId, bool?boundToExternal)
        {
            if (ContentRepository.IsAnyAggregatedFields(contentId))
            {
                throw new ActionNotAllowedException(ContentStrings.OperationIsNotAllowedForAggregated);
            }

            if (ContentRepository.GetAggregatedContents(contentId).Any())
            {
                throw new ActionNotAllowedException(ContentStrings.OperationIsNotAllowedForRoot);
            }

            var content = ContentRepository.GetById(contentId);

            if (content == null)
            {
                throw new Exception(string.Format(ContentStrings.ContentNotFound, contentId));
            }

            if (!content.IsContentChangingActionsAllowed)
            {
                throw new ActionNotAllowedException(ContentStrings.ContentChangingIsProhibited);
            }

            var row         = ClearContentRepository.GetContentItemsInfo(contentId);
            var contentName = string.Empty;
            var itemCount   = 0;

            if (row != null)
            {
                itemCount   = row.Field <int>("ITEMS_COUNT");
                contentName = row.Field <string>("CONTENT_NAME");
            }

            Commands.Add(new ClearContentCommand(siteId, contentId, contentName, itemCount));
            return(base.Setup(siteId, contentId, boundToExternal));
        }
Exemple #2
0
        public override MultistepActionSettings Setup(int siteId, int contentId, bool?boundToExternal)
        {
            var content = ContentRepository.GetById(contentId);

            if (content == null)
            {
                throw new ApplicationException(string.Format(ContentStrings.ContentNotFound, contentId));
            }

            if (!content.IsAccessible(ActionTypeCode.Remove))
            {
                throw new ApplicationException(ArticleStrings.CannotRemoveBecauseOfSecurity);
            }

            var violationMessages = new List <string>();

            content.ValidateForRemove(violationMessages);
            if (violationMessages.Count > 0)
            {
                throw new ApplicationException(string.Join(Environment.NewLine, violationMessages));
            }

            var row         = ClearContentRepository.GetContentItemsInfo(contentId);
            var contentName = string.Empty;
            var itemCount   = 0;

            if (row != null)
            {
                itemCount   = row.Field <int>("ITEMS_COUNT");
                contentName = row.Field <string>("CONTENT_NAME");
            }

            _clearCommand  = new ClearContentCommand(siteId, contentId, contentName, itemCount);
            _removeCommand = new RemoveContentCommand(siteId, contentId, contentName);
            return(base.Setup(siteId, contentId, boundToExternal));
        }
Exemple #3
0
        public MultistepActionStepResult Step(int step)
        {
            var content = ContentRepository.GetById(ContentId);

            if (content == null)
            {
                throw new Exception(string.Format(ContentStrings.ContentNotFound, ContentId));
            }

            if (!content.IsContentChangingActionsAllowed)
            {
                throw new ActionNotAllowedException(ContentStrings.ContentChangingIsProhibited);
            }

            ClearContentRepository.RemoveContentItems(ContentId, ItemsPerStep);
            if (IsLastStep(step))
            {
                ClearContentRepository.ClearO2MRelations(ContentId);
            }

            return(new MultistepActionStepResult {
                ProcessedItemsCount = ItemsPerStep
            });
        }