Organization hierarchy and Encompass development coding

The following code demonstrates how to display the entire organization hierarchy.

using System;
using System.IO;
using EllieMae.Encompass.Client;
using EllieMae.Encompass.BusinessObjects;
using EllieMae.Encompass.BusinessObjects.Users;

class UserManager
{
public static void Main()
{
// Open the session to the remote server. We will need to be logged
// in as an Administrator to modify the user accounts.
Session session = new Session();
session.Start(“myserver”, “admin”, “adminpwd”);

// Fetch the root organization
Organization root = session.Organizations.GetTopMostOrganization();

// Recursively display this organization and its children
displayOrgHierarchy(root, 0);

// End the session to gracefully disconnect from the server
session.End();
}

// Used to recursively generate the organization hierarchy
private static void displayOrgHierarchy(Organization parentOrg, int depth)
{
// Write out the parent organization’s name
Console.WriteLine(new string(‘-‘, depth * 2) + parentOrg.Name);

// Iterate over the organization’s children, recursively calling this function
foreach (Organization suborg in parentOrg.GetSuborganizations())
displayOrgHierarchy(suborg, depth + 1);
}
}

Please let me know if you want to know more.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.