Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > select not published files in a folder View modes: 
User avatar
Member
Member
ramon.almarza-emtmadrid - 2/3/2010 6:10:49 AM
   
select not published files in a folder
I’m triying to publish all the files in a folder of Kentico system file. I’m using this code:

public static List<CMS.TreeEngine.TreeNode> SelectNodesByPath(string path, string className, bool selectHiddenPages)
{
List<CMS.TreeEngine.TreeNode> listaNodos = new List<CMS.TreeEngine.TreeNode>();
DataSet ds = Functions.GetTreeProvider().SelectNodes(GetSiteName(), path + "/%", Functions.GetPreferredCulture(), true, className, "", "NodeOrder", 1);
CMS.TreeEngine.TreeNode nodo;
if (ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
CMS.PortalEngine.PageInfo pi = new CMS.PortalEngine.PageInfo(dr);
nodo = new CMS.TreeEngine.TreeNode(dr, className);
if (!pi.DocumentMenuItemHideInNavigation || selectHiddenPages)
listaNodos.Add(new CMS.TreeEngine.TreeNode(dr, className));
}
}
return listaNodos;
}

public static void publicarFicheros(String path)
{
List<CMS.TreeEngine.TreeNode> listaNodos = new List<CMS.TreeEngine.TreeNode>();
DataSet ds = Functions.GetTreeProvider().SelectNodes(GetSiteName(), path + "/%", Functions.GetPreferredCulture(), true);
listaNodos = SelectNodesByPath(path, "CMS.File");
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");

TreeProvider tree = new TreeProvider(ui);
WorkflowManager wm = new WorkflowManager(tree);
WorkflowStepInfo currentStep ;
foreach (CMS.TreeEngine.TreeNode nodo in listaNodos)
{

// Approve until the step is publish
currentStep = wm.GetStepInfo(nodo);
while ((currentStep != null) && (currentStep.StepName.ToLower() != "published"))
{
currentStep = wm.MoveToNextStep(nodo, "");
}
}
}


But this doesn´t work fine because no select all CMS.File documents in the path. This only select the published files. What´s the problem?? What I need to do to obtain not published files??

Thanks in advance one more time.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/9/2010 2:24:15 AM
   
RE:select not published files in a folder
Hi Ramon,

Could you please try to specify 'selectOnlyPublished' parameter for SelectNodes method and set it to false? It's the first parameter behind 'maxRelativeLevel' parameter.

Best Regards,

Martin Dobsicek