#region 获取部门列表树集合
/// <summary>
/// 获取部门列表树集合
/// </summary>
/// <returns></returns>
public string GetOrganizationList()
{
System.Collections.IList orgainList = organizationibll.GetList();//获取部门方法
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
List<SYS_Organization> listtree = SysManager.Common.Utilities.IListHelper.IListToList<SYS_Organization>(orgainList);//将IList 转化成List
SYS_Organization orgobj = listtree.Find(org => org.ParentId == "0");//构造顶级节点//(数据库中用的是O)
LEFTTREE lefttree = new LEFTTREE();
lefttree.ID = orgobj.OrganizationId;
lefttree.TEXT = orgobj.FullName;
lefttree.CHILDREN = new List<LEFTTREE>();
TreeDiGui(lefttree.ID, lefttree, listtree);
return "["+JsonConvert.SerializeObject(lefttree).Replace("TEXT", "text").Replace("ID", "id").Replace("CHILDREN", "children")+"]";
}
#endregion
#region 查找树的子节点
/// <summary>
/// 查找树的子节点
/// </summary>
/// <param name="sb"></param>
/// <param name="ParentId"></param>
/// <returns></returns>
public LEFTTREE TreeDiGui(string ParentId, LEFTTREE LEFTTREE, IEnumerable<SYS_Organization> ALLTREE)
{
//
IEnumerable<SYS_Organization> FindTree = ALLTREE.Where(new Func<SYS_Organization, bool>(d => d.ParentId == ParentId));
foreach (SYS_Organization item in FindTree)
{
LEFTTREE ChildTree = new LEFTTREE();
ChildTree.ID = item.OrganizationId;
ChildTree.TEXT = item.FullName;
ChildTree.CHILDREN = new List<LEFTTREE>();
// ChildTree.CHILDREN.Add(ChildTree);
LEFTTREE.CHILDREN.Add(ChildTree);
TreeDiGui(ChildTree.ID, ChildTree, ALLTREE);
}
return LEFTTREE;
}
#endregion