Ejemplo n.º 1
0
        protected override void ProcessProduct(int productId, Dictionary <string, string> actionParameters)
        {
            ClearFieldIds = actionParameters.GetClearFieldIds();

            _cacheItemWatcher.TrackChanges();

            ArticleService.LoadStructureCache();

            bool doNotCloneArticle      = actionParameters.ContainsKey(DoNotCloneArchiceKey) && bool.Parse(actionParameters[DoNotCloneArchiceKey]);
            Func <Article, bool> filter = a => !doNotCloneArticle;

            var article = ArticleService.Read(productId);

            if (!ArticleService.CheckRelationSecurity(article.ContentId, new int[] { productId }, false)[productId])
            {
                throw new ProductException(productId, nameof(TaskStrings.NoRelationAccess));
            }

            var definition = Productservice.GetProductDefinition(0, article.ContentId);
            var dictionary = GetProductsToBeProcessed(article, definition, ef => ef.CloningMode, CloningMode.Copy, filter, true);

            PrepareProducts(dictionary);
            MapProducts(dictionary[productId], dictionary);
            SaveProducts(dictionary);
        }
Ejemplo n.º 2
0
        protected override void ProcessProduct(int productId, Dictionary <string, string> actionParameters)
        {
            Dictionary <int, Product <DeletingMode> > dictionary;

            QA.Core.Models.Entities.Article[] notificationProducts = null;
            bool doNotSendNotifications = actionParameters.ContainsKey(DoNotSendNotificationsKey) && bool.Parse(actionParameters[DoNotSendNotificationsKey]);
            bool excludeArchive         = NeedToArchive;
            var  product = ArticleService.Read(productId, excludeArchive);

            if (product == null)
            {
                throw new ProductException(productId, nameof(TaskStrings.ProductsNotFound));
            }
            var definition = Productservice.GetProductDefinition(0, product.ContentId);

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
            {
                dictionary = DoWithLogging(
                    () => GetProductsToBeProcessed(product, definition, ef => ef.DeletingMode, DeletingMode.Delete, excludeArchive),
                    "Getting products to be processed for product {id}", productId
                    );

                if (!doNotSendNotifications)
                {
                    notificationProducts = GetNotificationProducts(productId);
                }
            }

            var articleIds = dictionary.Values
                             .Where(p => p.Article.Id != product.Id && p.Article.Archived != NeedToArchive)
                             .Select(p => p.Article.Id)
                             .ToArray();

            var result = DoWithLogging(
                () => ArticleService.SetArchiveFlag(product.ContentId, new[] { product.Id }, NeedToArchive),
                "Set archive flag in {flag} for product {id}", NeedToArchive, product.Id
                );

            ValidateMessageResult(product.Id, result);

            if (articleIds.Any())
            {
                DoWithLogging(
                    () => ArticleService.SimpleSetArchiveFlag(articleIds, NeedToArchive),
                    "Set archive flag in {flag} for articles {ids}", NeedToArchive, articleIds
                    );
            }

            if (!doNotSendNotifications)
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
                {
                    string[] channels = actionParameters.GetChannels();
                    SendNotification(notificationProducts, productId, channels);
                }
            }
        }
Ejemplo n.º 3
0
        protected override void ProcessProduct(int productId, Dictionary <string, string> actionParameters)
        {
            string[] channels = actionParameters.GetChannels();
            var      product  = ArticleService.Read(productId, false);

            if (product == null)
            {
                throw new ProductException(productId, nameof(TaskStrings.ProductsNotFound));
            }

            var  definition             = Productservice.GetProductDefinition(0, product.ContentId);
            bool doNotSendNotifications = actionParameters.ContainsKey(DoNotSendNotificationsKey) && bool.Parse(actionParameters[DoNotSendNotificationsKey]);

            DeleteProduct(product, definition, doNotSendNotifications, true, channels);
        }