I need to build a Org Chart that prints from a web page and I have something like 19 to 32 entities on the second level and 3-7 entities on the third level.我尝试了http://www.orgchartcomponent.com/default.aspx的团队改进器提供的名为OrgChart component的解决方案,但他们在英格兰,没有回复他们的电子邮件。我还尝试了https://www.codeproject.com/Articles/18378/Organization-Chart-Generator的一个解决方案,它具有基本的树组织结构图。我通过Ling从数据库填充到SQL,没有问题。
Parent Entity - Level 1
|
|
---Child Entity Level 2
|
|
---Child Entity Level 2
|
|
---Child Entity Level 2
|
|
---Child Entity Level 2
|
|
---Child Entity Level 2
|
|
---Child Entity Level 2
|
|
Child Entity Level 3
|
|
Child Entity Level 3
|
|
Child Entity Level 3
|
|
Child Entity Level 3发布于 2021-10-11 19:20:49
// using recursive function.
static void Get_Geneology(Employee manager, int Level = 0) // find all genealogy (kid to great grandkids or employee under a manager down the pyramid)
{
string indentLines = new string(' ', Level * 2);
var managedEmployees = Employees.Where(e => e.Manager_ID == manager.Emp_ID); // 1st call. look all employees under a Manager. or all kids of a father.
Console.WriteLine($"{indentLines} {Level + 1}-{manager.FirstName}{(managedEmployees.Count() > 0 ? "*" : "")}"); // with * after name mean that person manage sombody or father have kid(s)
foreach (var employee in managedEmployees) Get_Geneology(employee, Level + 1); // recursive, find all under under (to the deapest of each people geneology for each manager)
}https://stackoverflow.com/questions/41645813
复制相似问题