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); }
public Dictionary <int, bool> CheckRelationSecurity(int contentId, int[] ids, bool isDeletable) { return(ArticleService.CheckRelationSecurity(contentId, ids, isDeletable)); }
private int?CloneProductImpl( int productId, Models.Configuration.Content contentDefinition, Dictionary <string, string> actionParameters) { _cacheItemWatcher.TrackChanges(); DoWithLogging( () => ArticleService.LoadStructureCache(), "Loading structure cache" ); var article = DoWithLogging( () => ArticleService.Read(productId), "Reading root article for product {id}", productId ); if (!Filter(article)) { return(null); } var checkResult = DoWithLogging( () => ArticleService.CheckRelationSecurity(article.ContentId, new[] { productId }, false), "Checking relation security for product {id}", productId ); if (!checkResult[productId]) { throw new ProductException(productId, nameof(TaskStrings.NoRelationAccess)); } if (contentDefinition == null) { contentDefinition = _definitionService.GetDefinitionForContent(0, article.ContentId); } if (actionParameters == null) { actionParameters = new Dictionary <string, string>(); } var productDefinition = new ProductDefinition { StorageSchema = contentDefinition }; UpdateDefinition(article, productDefinition, actionParameters); var productsById = DoWithLogging( () => GetProductsToBeProcessed( article, productDefinition, ef => ef.CloningMode, CloningMode.Copy, Filter, true), "Receving articles to be cloned for product {id}", productId ); var clearFieldIds = actionParameters.GetClearFieldIds(); var missedAggArticles = PrepareProducts(productsById, clearFieldIds); MapProducts(productsById[productId], productsById); var result = DoWithLogging( () => SaveProducts(productId, productsById, missedAggArticles), "Cloning {count} articles for product {id}", productsById.Count, productId ); return(result); }