how can i list the branch offices? and then get all the jobsite of one branch office , can you give me a hint???
thanks!!!
how can i list the branch offices? and then get all the jobsite of one branch office , can you give me a hint???
thanks!!!
Hi Marveen. I’m unsure of what you’re asking. Do you simply want to get a single jobsite?
sorry , i got this configuration
USA (corpotate struture)
USA FLORIDA (corpotate struture)
USA OHIO (corpotate struture)
i need to list all de JOB SITES For Each Corporate Structure
i have this code now , but only return me the FIRST ONE Structure an job site list
AvontusUser AvUser = AvontusUser.GetUser(StrUsrQtfy);
BusinessPartnerComboList BpatList = BusinessPartnerComboList.GetCustomerComboList(Guid.Empty, ActiveStatus.Active, ActiveStatus.Active, false, false);
// System.Web.UI.WebControls.TreeView tvOrganization = new System.Web.UI.WebControls.TreeView();
System.Windows.Forms.TreeView tvOrganization = new System.Windows.Forms.TreeView();
StockingLocationOrganization orgTree = StockingLocationOrganization.GetOrganization(ActiveStatus.Active);
orgTree.BuildTreeView(tvOrganization, OrgViewGrouping.ByJob, JobTreeNodeDisplayType.Name, AvUser.RelatedID, AvUser.UserID, AvUser.PrimaryTradingPartnerID);
please give a hint !
Marveen,
I would suggest flattening the TreeView into a list to make it easier to work with. The following method can help with that:
static void flattenTreeView(TreeNode currentNode, List<TreeNode> nodes)
{
if (currentNode is null) { return; }
nodes.Add(currentNode);
foreach (TreeNode child in currentNode.Nodes)
{
flattenTreeView(child, nodes);
}
}
This method will take the top node and an empty List of TreeNodes and recursively populate the list with all of the nodes from the tree. Then you can use LINQ to filter out for Job Sites, with something like the following in your main method:
AvontusUser AvUser = AvontusUser.GetUser(StrUsrQtfy);
TreeView tvOrganization = new System.Windows.Forms.TreeView();
StockingLocationOrganization orgTree = StockingLocationOrganization.GetOrganization(ActiveStatus.Active);
orgTree.BuildTreeView(tvOrganization, OrgViewGrouping.ByJob, JobTreeNodeDisplayType.Name, AvUser.RelatedID, AvUser.UserID, AvUser.PrimaryTradingPartnerID);
List<TreeNode> listOfNodes = new List<TreeNode>();
flattenTreeView(tvOrganization.Nodes[0], listOfNodes);
// Using LINQ to filter for job sites
listOfNodes = listOfNodes.Where(x => (x.Tag as NodeTag).Type == PartnerTypes.JobSite).ToList();
foreach (TreeNode node in listOfNodes)
{
String[] jobSitePathSplit = node.FullPath.Split('\\');
//Console.WriteLine(node.FullPath);
Console.Write(jobSitePathSplit[1]+'\t'); //print corporate structure
Console.WriteLine(jobSitePathSplit.Last()); // print jobsite
}
You will have all the Job Site nodes, so you can traverse up the parent nodes and get what you need (name, id, etc.) from the that way as well.
Hopefully that gets you going in the right direction!