• C# 递归程序 获取某个节点下的全部子节点


            /// <summary>
            /// 获取组织结构树
            /// </summary>
            /// <param name="list"></param>
            /// <param name="id"></param>
            /// <param name="treeNodes"></param>
            /// <returns></returns>
            static void GetOrganizeSelectTreeNodes(List<BaseOrganizeEntity> list, string id, ref List<SelectTreeNode> treeNodes)
            {
                if (list == null)
                    return ;
                List<BaseOrganizeEntity> sublist;
                if (!string.IsNullOrWhiteSpace(id))
                {
                    sublist = list.Where(t => t.ParentId == id).ToList();
                }
                else
                {
                    sublist = list.Where(t => string.IsNullOrWhiteSpace(t.ParentId)).ToList();
                }
                if (!sublist.Any())
                    return;
                foreach (var item in sublist)
                {
                    treeNodes.Add(new SelectTreeNode() { id = item.Id, name = item.FullName, parentId = item.ParentId });
                    GetOrganizeSelectTreeNodes(list, item.Id, ref treeNodes);
                }
            }
    

      

            /// <summary>
            /// 获取公司树
            /// </summary>
            /// <returns></returns>
            public ActionResult GetOrganizesTree(string id = null, string name = null)
            {
                 // 使用程序递归 MySql用SQL语句递归比较暂时不支持,需要用存储过程处理
                List<SelectTreeNode> treeNodes = new List<SelectTreeNode>();
                GetOrganizeSelectTreeNodes(organizeManager.GetList<BaseOrganizeEntity>(), id, ref treeNodes);
                var result = new Hashtable { { "treeNodes", treeNodes } };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
    

      

  • 相关阅读:
    在IDEA通过Maven构建Scala项目
    6.Pair RDD操作
    5.RDD的Action操作和持久化persist()
    29.Spark SQL发展史
    AirFlow初始化的时候遇到 Global variable explicit_defaults_for_timestamp needs to be on (1) for mysql
    4.RDD操作之Transform
    3.RDD详解和创建RDD方式
    28.Spark中action的介绍
    2.Spark 2.x 集群部署和测试
    Repeater分页
  • 原文地址:https://www.cnblogs.com/mr-hu2009/p/10486672.html
Copyright © 2020-2023  润新知