本文整理汇总了C#中Tree.Drop方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Drop方法的具体用法?C# Tree.Drop怎么用?C# Tree.Drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Drop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KnowledgeModify
public string KnowledgeModify(string ariticleJson)
{
using (RRDLEntities db = new RRDLEntities())
{
AriticleJson ariticlejson = (AriticleJson)JsonConvert.DeserializeObject(ariticleJson, typeof(AriticleJson));
AriticleService ars = new AriticleService(db);
Ariticle ariticle = ars.FindById(ariticlejson.Id);
//添加标题
ariticle.Title = ariticlejson.title;
//添加内容
//ariticle.UGC = System.Web.HttpUtility.UrlDecode(ariticlejson.UGC);
ariticlejson.UGC = System.Web.HttpUtility.UrlDecode(ariticlejson.UGC);
ariticlejson.UGC = ariticlejson.UGC.Replace("CodeReplacePlus", "+");
ariticle.UGC = ariticlejson.UGC;
//添加标签
string[] tlist = ariticlejson.tag.Split(new char[] { ',' });
List<AriticleTag> tagList = new List<AriticleTag>();
for (int i = 0; i < tlist.Length; i++)
{
AriticleTag ariticletag = new AriticleTag();
ariticletag.Title = tlist[i];
ariticletag.AriticleId = ariticlejson.Id;
// ariticletag.Article = ariticle;
tagList.Add(ariticletag);
}
AriticleTagRepository tagRepository = new AriticleTagRepository(db);
tagRepository.UpdateAllRelatedAriticleId(ariticle.Id, tagList);
//创建一个新节点
TreeNode treeNode = new TreeNode(Int32.Parse(ariticlejson.treeNodeParentId), ariticlejson.title);
treeNode.Ariticle = ariticle;
Tree tree = new Tree(db);
tree.AddTreeNode(treeNode);
//删除旧节点
TreeNode oldtreeNode = tree.SearchByAriticle(ariticle.Id);
tree.Drop(oldtreeNode);
//创建不可见分组信息数组
string[] inlist = ariticlejson.invisibility.Split(new char[] { ';' });
List<int> invisiblityGroup = new List<int>();
for (int i = 0; i < inlist.Length - 1; i++)
{
invisiblityGroup.Add(Int32.Parse(inlist[i]));
}
//判断是否为管理员或超级管理员修改,审核状态保持已通过审核
UserService us = new UserService();
User user = us.FindById(ariticlejson.UserId);
if (user.AuthorityCategory != EnumUserCategory.Administrator && user.AuthorityCategory != EnumUserCategory.Superman)
{
ariticle.Approve.ApproveStatus = EnumAriticleApproveStatus.UnApproved;
}
else {
ariticle.Approve.ApproveStatus = EnumAriticleApproveStatus.Approved;
}
ars.UpdateAriticle(ariticle, invisiblityGroup);
db.SaveChanges();
return "success";
}
}
示例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;
}
示例3: KnowledgeModify
public string KnowledgeModify(string title, string userId, string invisibility, string tag, string content, string ariticleId, string treeNodeParentId)
{
using (RRDLEntities db = new RRDLEntities())
{
AriticleService ars = new AriticleService(db);
Ariticle ariticle = ars.FindById(ariticleId);
//添加标题
ariticle.Title = title;
//添加内容
//ariticle.UGC = System.Web.HttpUtility.UrlDecode(content);
content = System.Web.HttpUtility.UrlDecode(content);
content = content.Replace("CodeReplacePlus", "+");
ariticle.UGC = content;
//添加标签
string[] tlist = tag.Split(new char[] { ',' });
List<AriticleTag> tagList = new List<AriticleTag>();
for (int i = 0; i < tlist.Length; i++)
{
AriticleTag ariticletag = new AriticleTag();
ariticletag.Title = tlist[i];
ariticletag.AriticleId = ariticleId;
// ariticletag.Article = ariticle;
tagList.Add(ariticletag);
}
AriticleTagRepository tagRepository = new AriticleTagRepository(db);
tagRepository.UpdateAllRelatedAriticleId(ariticle.Id, tagList);
//创建一个新节点
TreeNode treeNode = new TreeNode(Int32.Parse(treeNodeParentId), title);
treeNode.Ariticle = ariticle;
Tree tree = new Tree(db);
tree.AddTreeNode(treeNode);
//删除旧节点
TreeNode oldtreeNode = tree.SearchByAriticle(ariticle.Id);
tree.Drop(oldtreeNode);
//创建不可见分组信息数组
string[] inlist = invisibility.Split(new char[] { ';' });
List<int> invisiblityGroup = new List<int>();
for (int i = 0; i < inlist.Length - 1; i++)
{
invisiblityGroup.Add(Int32.Parse(inlist[i]));
}
ariticle.Approve.ApproveStatus = EnumAriticleApproveStatus.Approved;
ars.UpdateAriticle(ariticle, invisiblityGroup);
db.SaveChanges();
return "success";
}
}