I have some (of my first ;)) rapid prototype code. What /should/ be happening here is:
1. Create a Document (this will create as a child)
2. Move Document (too the root)
3. Stage the Document
What I am seeing is that functionally everything works, but the document gets staged as a child to "/test1" and not "/". Any ideas?
private static bool CreateDocument(CMS.SiteProvider.SiteInfo siteInfo)
{
// Create an instance of the Tree provider first
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get the parent node - the API Example folder
TreeNode parentNode = tree.SelectSingleNode(siteInfo.SiteName, "/test1", "en-us");
TreeNode rootNode = tree.SelectSingleNode(siteInfo.SiteName, "/", "en-us");
if ((rootNode != null) && (parentNode != null))
{
// Create a new instance of the Tree node
TreeNode newNode = TreeNode.New("CMS.MenuItem", tree);
// Set the document's properties
newNode.DocumentName = "test1-API-copy " + DateTime.Now.ToString();
newNode.DocumentCulture = "en-us";
// Insert the document into the content tree
newNode.Insert(parentNode);
tree.MoveNode(newNode, rootNode.NodeID);
return true;
}
return false;
}
private static bool GetAndSynchronizeTasks(CMS.SiteProvider.SiteInfo siteInfo)
{
// Get server
ServerInfo server = ServerInfoProvider.GetServerInfo("stage2", siteInfo.SiteID);
if (server != null)
{
// Get tasks for the server
DataSet tasks = TaskInfoProvider.SelectTaskList(siteInfo.SiteID, server.ServerID, null, null);
if (!DataHelper.DataSourceIsEmpty(tasks))
{
foreach (DataRow taskDr in tasks.Tables[0].Rows)
{
// Create task info object from data row
TaskInfo task = new TaskInfo(taskDr);
Console.WriteLine(task.TaskID + "\t" + task.TaskTitle);
// Synchronize the task
if (!string.IsNullOrEmpty(StagingHelper.RunSynchronization(task.TaskID, server.ServerID)))
{
Console.WriteLine("GetAndSynchronizeTasks return false");
return false;
}
}
return true;
}
Console.WriteLine("GetAndSynchronizeTasks no tasks found");
}
return false;
}