当前位置: 首页>>代码示例>>C#>>正文


C# Tree.GetTreeNodeById方法代码示例

本文整理汇总了C#中Tree.GetTreeNodeById方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.GetTreeNodeById方法的具体用法?C# Tree.GetTreeNodeById怎么用?C# Tree.GetTreeNodeById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.GetTreeNodeById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OperateTreeNode

 //// NodeId: id, NodeInfo: nodeInfo, XmlUrl: temp.xmlUrl 
 public ActionResult OperateTreeNode(string modeType, string _modeType, string nodeId, string nodeInfo, string xmlUrl)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         Tree tree = new Tree();
         TreeNode treeNode = null;
         switch (modeType)
         {
             case "rename":
                 string id = nodeId;
                 string name = nodeInfo;
                 treeNode = tree.GetTreeNodeById(Int32.Parse(id));
                 treeNode.Title = name;
                 tree.UpdateTreeNode(treeNode);
                 returnStr = "ok&" + treeNode.ParentId;
                 break;
             case "delete":
                 returnStr = DeleteNode(_modeType, nodeId, xmlUrl);                        
                 break;
             case "insert":
                 //List<NodeInfo> nodeList = this.GetListFromJson(nodeInfo);
                 //returnStr = this.InserNode(_modeType, nodeId, xmlUrl, nodeList);
                 //bool flag = true;
                 Tree tree2 = new Tree(db);
                 List<TreeNode> list = tree2.GetTreeNodeChild(Int32.Parse(nodeId));
                 //for (int i = 0; i < list.Count;i++ )
                 //{
                 //    if(list[i].Ariticle != null){
                 //        flag = false; 
                 //    }
                 //}
                 //if (flag)
                 //{
                     treeNode = new TreeNode(Int32.Parse(nodeId), "新建节点");
                     tree.AddTreeNode(treeNode);
                     returnStr = "ok";
                 //}
                 //else {
                 //    returnStr = "该节点下存在文章,不能添加文件夹!";
                 //}
                 break;
         }
         return Content(returnStr);
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:46,代码来源:TreeViewController.cs

示例2: DeleteNode

 //The Function Bllew is Added By ZHAOs ,2013年11月14日10:02:13,used to Delete A TreeNode in 目录树管理
 public string DeleteNode(string _modeType, string nodeId, string xmlUrl) {
     // _modeType = "deleteFolder"  ,modeId = "6" ,xmlUrl = ""  传入的参数大致形式如此
     Tree tree = new Tree();
     TreeNode treeNode = tree.GetTreeNodeById(Convert.ToInt32(nodeId));
     string returnStr = "";
     /*
     如果这个节点是叶子节点
         如果是空文件夹  --文件夹(ariticleID为空且isLeaf属性为True),为空文件夹 ===> 可删除
         如果是知识   --不能删除知识  (此时 ariticleID属性不为NULL  且 idLeaf属性为 True即是)
     如果这个节点不是叶子节点(即非空文件夹,里面可能有知识或者 为空不为空的 文件夹)(ariticleID为空且isLeaf属性为false)====> 不能删除
     PS:但是这里不显示知识,所以只可能有 叶子节点文件夹 和 非叶子节点文件夹。
      * 叶子节点文件夹内部一定没有知识,可以直接删除 ===>有知识的情况 以后版本考虑
      * 非叶子节点文件夹内容一定有文件夹或知识,不能删除。
      * 逻辑较简单。
      * 只是只能从叶子节点删起      
      * PS:如果一个父节点其下的所有子节点都被删除,则该父节点的IsLeaf属性变为True
      */
     if (treeNode.IsLeaf == true)
     {   
         //如果是根目录
         if (treeNode.ParentId == null)
         {
             returnStr = "根目录不可删除!";
         }
         else {//若果其父节点下只有这一个子节点,则删除此子节点并把父节点isLeaf属性设为True
             TreeNode parentNode = tree.GetTreeNodeById(Convert.ToInt32(treeNode.ParentId));
             List<TreeNode> parentChildList = tree.GetTreeNodeChild(Convert.ToInt32(treeNode.ParentId));
             if (parentChildList.Count == 1)
             {
                 parentNode.IsLeaf = true;
             }
             tree.UpdateTreeNode(parentNode);//改变父节点isLeaf属性
             tree.Drop(treeNode);//删除子节点
             returnStr = "ok";
         }
         
     }
     else {
         returnStr = "该节点下存在子文件夹或知识,不能删除!";
     }
     return returnStr;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:43,代码来源:TreeViewController.cs

示例3: getTreePath

 //获取树的路径
 public string getTreePath(string treeNode) {
     Tree tree = new Tree();
     TreeNode tn = tree.GetTreeNodeById(Int32.Parse(treeNode));
     List<TreeNode> list = tree.GetTreeNodePath(tn);
     string result = "";
     for (int i = list.Count-1; i >= 0 ;i-- )
     {
         result = result + list[i].Title + "TreeSplit";
     }
     return result;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:12,代码来源:TreeViewController.cs

示例4: GetAriticleByTreeNodeId

 /// <summary>
 ///     通过TreeNodeId获取Ariticle
 /// </summary>
 /// <param name="_modeType"></param>
 /// <param name="_nodeId"></param>
 /// <param name="_xmlUrl"></param>
 /// <param name="_nodeInfo"></param>
 /// <returns></returns>
 public ActionResult GetAriticleByTreeNodeId(string treeNodeId,string userId) 
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         Tree tree = new Tree(db);
         Ariticle ariticle = tree.GetTreeNodeById(Int32.Parse(treeNodeId)).Ariticle;
         PraiseRepository pr = new PraiseRepository();
         //如果是叶子节点,传递知识内容到前台
         if (ariticle != null)
         {
             AriticleViewModel avm = new AriticleViewModel(ariticle);
             UserService us = new UserService();
             User author = us.FindById(ariticle.UserId);
             avm.author = author.NickName;
             string time1 = ariticle.Createtime.ToLongDateString();
             string time2 = ariticle.Createtime.ToLongTimeString();
             avm.Createtime = time1 + "  " + time2;
             //avm.PraiseCount = pr.FindByAriticleID(ariticle.Id).PraiseCount;
             avm.Id = ariticle.Id;
             AriticleService ars = new AriticleService();
             string isShow = "";
                 if(userId == "vistor"){
                     userId = null;
                 }
                 if (ars.GetAriticleVisibilityByUser(ariticle.Id, userId))
                 {
                     bool falg = ars.GetAriticleVisibilityByUser(ariticle.Id, userId);
                     isShow = "true";
                 }
                 else
                 {
                     bool falg = ars.GetAriticleVisibilityByUser(ariticle.Id, userId);
                     isShow = "false";
                 }
             User user = us.FindById(userId);
             if(user!=null && user.ContentGroupId == 2){
                 isShow = "true";
             }
             string result = JsonConvert.SerializeObject(avm);
             result = result + "ThisAriticleIsShowForThisUser" + isShow;
             return Content(result);
         }
         else
         {
             return Content("NotLeaf");
         }
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:56,代码来源:TreeViewController.cs

示例5: ReadTreeNodes

 public List<ClassifyTreeNodes> ReadTreeNodes(List<ClassifyTreeNodes> treeNodes, int? id)
 {
     Tree tree = new Tree();
     List<TreeNode> newTreeNodes = tree.GetParentsTreeNodes(id);
     List<ClassifyTreeNodes> treeNodeLists = new List<ClassifyTreeNodes>();
     for (int i = 0; i < newTreeNodes.Count; i++)
     {
         ClassifyTreeNodes treeNode = new ClassifyTreeNodes();
         treeNode.Title = newTreeNodes[i].Title;
         //treeNode.AriticleId = newTreeNodes[i].Ariticle.Id;
         
         treeNode.Id = newTreeNodes[i].Id;
         treeNode.ParentId = newTreeNodes[i].ParentId;
         treeNode.IsLeaf = newTreeNodes[i].IsLeaf;
         if (treeNode.ParentId == null) {
             treeNodes.Add(treeNode);
             treeNodeLists.Add(treeNode);
         }
         //if (treeNode.IsLeaf == false)
         //{
         //    ReadTreeNodes(treeNodes, treeNode.Id);
         //}
     }
     for (int j = 0; j < treeNodes.Count; j++)
     {
          List<TreeNode> tns = new List<TreeNode>();
          tns = tree.GetTreeNodeChild(Int32.Parse(treeNodes[j].Id.ToString()));
          for (int k = 0; k < tns.Count; k++) {
              TreeNode treeNode = tree.GetTreeNodeById(Int32.Parse(tns[k].Id.ToString()));
              ClassifyTreeNodes classifyTreeNodes = new ClassifyTreeNodes();
              classifyTreeNodes.Id = treeNode.Id;
              classifyTreeNodes.IsLeaf = treeNode.IsLeaf;
              classifyTreeNodes.ParentId = treeNode.ParentId;
              classifyTreeNodes.Title = treeNode.Title;
              treeNodeLists.Add(classifyTreeNodes);
          }
     }
     return treeNodeLists;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:39,代码来源:RankListController.cs


注:本文中的Tree.GetTreeNodeById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。