In working with Support here is what I came up with:
private int CreateStagingTasks(string nodeAliasPath)
{
int count = 0;
var pages = DocumentHelper.GetDocuments()
//.TopN(1)
.Culture("en-us")
.Path(nodeAliasPath, PathTypeEnum.Children)
.OrderBy("NodeLevel, NodeOrder");
if (!DataHelper.DataSourceIsEmpty(pages))
{
foreach (var page in pages)
{
if (!page.IsLink && page.HasUrl())
{
try
{
var pageUrlPath = page.GetPageUrlPath("en-us");
if (pageUrlPath != null)
{
string currentSlug = pageUrlPath.Slug.ToLower();
LogChangeSlugTask(page, currentSlug, page.DocumentCulture);
count++;
}
}
catch { }
}
}
}
return count;
}
private void LogChangeSlugTask(TreeNode page, string newSlug, string cultureCode)
{
var parameters = new TaskParameters();
parameters.SetParameter(SLUG_PARAM_NAME, newSlug);
parameters.SetParameter(CULTURE_PARAM_NAME, cultureCode);
DocumentSynchronizationHelper.LogDocumentChange(page, TaskTypeEnum.ChangePageUrlPathSlug, page.TreeProvider, SynchronizationInfoProvider.ENABLED_SERVERS, parameters, page.TreeProvider.AllowAsyncActions);
}