Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Tree node document publish state View modes: 
User avatar
Member
Member
enelson-drhorton - 7/27/2012 4:21:16 PM
   
Tree node document publish state
Hello

I am using 5.5.

I am programatically changing the 'publish to' date on a document on a webcontrol, updating and then publishing the document. So, the date should determine if the document shows as published in the tree node. The objective is to unpublish a document in this instance.

Immediately, I open the tree node and click down the children to the document in question. I view it on the 'Forms' tab and the 'publish to' date shows correctly, but the tree node object still shows incorrectly. The date is in the past, so I expect the node document to show unpublished.

User image

Is this a known issue in 5.5?

If you immediately save and publish in the tree, the state corrects.


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/27/2012 9:09:18 PM
   
RE:Tree node document publish state
Hi,

have you tried to use DocumentHelper class to update the document?
Versioning internals

How to update document is shown in this API example:
update document API example

As always, please make sure that you are using the latest hotfix.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
enelson-drhorton - 7/30/2012 10:47:42 AM
   
RE:Tree node document publish state
It's done here....pretty much verbatim from the examples.




       TreeProvider tree = new TreeProvider( CMSContext.CurrentUser );
VersionManager vm = new VersionManager( tree );
CMS.TreeEngine.TreeNode parentNode = tree.SelectSingleNode(PlansNode.NodeParentID);

parentnode.SetValue( "DocumentPublishFrom", publishfrom_dtp.DateTimeTextBox.Text );
parentnode.SetValue( "DocumentPublishTo", publishto_dtp.DateTimeTextBox.Text );

vm.CheckOut( parentnode );
DocumentHelper.UpdateDocument( parentnode, tree );
vm.CheckIn( parentnode, null, null );
PublishDocument( tree, parentnode );

/*
*
*/

public static void PublishDocument( TreeProvider tree, TreeNode node )
{
try
{
WorkflowManager wm = new WorkflowManager( tree );
WorkflowInfo wi = wm.GetNodeWorkflow( node );

if ( wi != null )
{
WorkflowStepInfo si = wm.GetStepInfo( node );
if ( si != null )
{
// Use the workflow step information to approve the document until it is published
while ( si.StepName.ToLower() != "published" )
{
si = wm.MoveToNextStep( node, "" );
if ( si == null )
{
break;
}
}
}
}
}
catch (Exception ex )
{ }
}


User avatar
Member
Member
enelson-drhorton - 7/30/2012 10:52:10 AM
   
RE:Tree node document publish state
Ignore that last code example. Was not right. This one is right.


TreeProvider tree = new TreeProvider( CMSContext.CurrentUser );
VersionManager vm = new VersionManager( tree );
CMS.TreeEngine.TreeNode parentNode = tree.SelectSingleNode(PlansNode.NodeParentID);
if (parentNode != null)
parentNode = DocumentHelper.GetDocument(parentNode, tree);

parentnode.SetValue( "DocumentPublishFrom", publishfrom_dtp.DateTimeTextBox.Text );
parentnode.SetValue( "DocumentPublishTo", publishto_dtp.DateTimeTextBox.Text );

vm.CheckOut( parentnode );
DocumentHelper.UpdateDocument( parentnode, tree );
vm.CheckIn( parentnode, null, null );
PublishDocument( tree, parentnode );
/*
*
*/
public static void PublishDocument( TreeProvider tree, TreeNode node )
{
try
{
WorkflowManager wm = new WorkflowManager( tree );
WorkflowInfo wi = wm.GetNodeWorkflow( node );

if ( wi != null )
{
WorkflowStepInfo si = wm.GetStepInfo( node );
if ( si != null )
{
// Use the workflow step information to approve the document until it is published
while ( si.StepName.ToLower() != "published" )
{
si = wm.MoveToNextStep( node, "" );
if ( si == null )
{
break;
}
}
}
}
}
catch (Exception ex )
{ }
}

User avatar
Member
Member
enelson-drhorton - 7/30/2012 1:18:01 PM
   
RE:Tree node document publish state
Nevermind. I figured it out.

On an unrelated comment, I am perplexed as to why the system does not actually look at the data to determine whether it should show as published or not - something is clearly out of synch in my example.

User avatar
Member
Member
enelson-drhorton - 7/31/2012 11:27:55 AM
   
RE:Tree node document publish state
Under what rules does the system decided to show a node as greyed or normal?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/2/2012 4:50:51 PM
   
RE:Tree node document publish state
Hi,
What do you mean by greyed?

Do you mean gray background in case you are using check-in/out functionality? In it gray in case the document is not checked - out for editing.

Best regards,
Ivana Tomanickova