Custom Package Action to MoveContent - help required
I am writing a custom package action to move content, as I want to move my package items from the root node to under "home". I have the permissions set by using the inbuilt package action.
Everything "kind of" works in that the content does get moved under the home node - but when I try and access the website URL it fails! However after I look at the page in the back office and click info I can see that it says Published, then I access the URL again and it works.
It is as if viewing the page(s) in the back office triggers something!?
Or is there some delay in the content move routes getting picked up by the front-end of the website?
The core of the package action source code is relatively simple:
var contentService = Current.Services.ContentService;
var contentToMove = contentService.GetRootContent().FirstOrDefault(x => x.ContentType.Alias == itemAlias);
var contentTarget = contentService.GetRootContent().FirstOrDefault(x => x.ContentType.Alias == parentAlias);
contentService.Move(contentToMove, contentTarget.Id);
contentService.SaveAndPublishBranch(contentToMove, true);
Another area of concern is that during the package action running I get an exception thrown The task runner has completed with stack trace:
at Umbraco.Web.Scheduling.BackgroundTaskRunner`1.Add(T task)
at Umbraco.Web.Search.ExamineComponent.DeferedReIndexForContent.Execute(ExamineComponent examineComponent, IContent content, Boolean isPublished)
at Umbraco.Web.Search.ExamineComponent.DeferedReIndexForContent.Execute()
at Umbraco.Web.Search.ExamineComponent.DeferedActions.Execute()
at Umbraco.Web.Search.ExamineComponent.DeferedActions.<>c.<Get>b__1_1(Boolean completed, DeferedActions actions)
at Umbraco.Core.Scoping.ScopeContext.EnlistedObject`1.Execute(Boolean completed) in C:\Projects\Umbraco-CMS-8-8.10\src\Umbraco.Core\Scoping\ScopeContext.cs:line 69
at Umbraco.Core.Scoping.ScopeContext.ScopeExit(Boolean completed)
in C:\Projects\Umbraco-CMS-8-8.10\src\Umbraco.Core\Scoping\ScopeContext.cs:line 26
Does anyone have any thoughts/ideas as to why the routes are not active until the page info is visited in the back-office?
Or why I am getting the exception during package action?
Am I moving the content correctly?
UPDATE:
On further investigation, the The task runner has completed exception appears to be caused by the ExamineComponent.Execute where the "examineComponent._indexItemTaskRunner.Add()" fails as the index task runner has already completed.
If I leave my Visual Studio Running (idle) after a minute or so I get another exception in Scope.RobustExit() on _scopeProvider.AmbientContext.ScopeExit(completed);
After I continue VS past this exception, so the site continues, I am then able to hit the URL successfully! Is the scope task runner exception during the package actions causing the issue?
Any thoughts on how to resolve the The task runner has completed exception during the running of the package actions?
Do I need to manually rebuild the indexes somehow?
Custom Package Action to MoveContent - help required
I am writing a custom package action to move content, as I want to move my package items from the root node to under "home". I have the permissions set by using the inbuilt package action.
Everything "kind of" works in that the content does get moved under the home node - but when I try and access the website URL it fails! However after I look at the page in the back office and click info I can see that it says Published, then I access the URL again and it works.
It is as if viewing the page(s) in the back office triggers something!?
Or is there some delay in the content move routes getting picked up by the front-end of the website?
The core of the package action source code is relatively simple:
Another area of concern is that during the package action running I get an exception thrown The task runner has completed with stack trace:
Does anyone have any thoughts/ideas as to why the routes are not active until the page info is visited in the back-office? Or why I am getting the exception during package action? Am I moving the content correctly?
UPDATE:
On further investigation, the The task runner has completed exception appears to be caused by the ExamineComponent.Execute where the "examineComponent._indexItemTaskRunner.Add()" fails as the index task runner has already completed.
If I leave my Visual Studio Running (idle) after a minute or so I get another exception in Scope.RobustExit() on _scopeProvider.AmbientContext.ScopeExit(completed);
After I continue VS past this exception, so the site continues, I am then able to hit the URL successfully! Is the scope task runner exception during the package actions causing the issue?
Any thoughts on how to resolve the The task runner has completed exception during the running of the package actions?
Do I need to manually rebuild the indexes somehow?
is working on a reply...