/// <summary> /// 保存一个树节点 /// </summary> /// <param name="p_folder"></param> /// <returns></returns> public CodeFolder SaveTree(CodeFolder p_folder) { if (String.IsNullOrEmpty(p_folder.Id)) { p_folder.Id = Guid.NewGuid().ToString(); var id = Db.Insert(p_folder); p_folder.Id = id; } else { var x = Db.Get <CodeFolder>(p_folder.Id); if (x == null) { Db.Insert(p_folder); } else { if (Db.Update(p_folder)) { return(p_folder); } else { return(null); } } } return(p_folder); }
/// <summary> /// 删除一个文件夹。 /// 同时会删除子节点的所有文件夹 /// 同时会删除所有文件夹下面的代码。 /// </summary> /// <param name="codeFolder"></param> /// <returns></returns> public bool DeleteFolder(CodeFolder codeFolder) { if (codeFolder == null) { return(false); } var id = codeFolder.Id; var tree = Db.Get <CodeFolder>(id); if (tree == null) { throw new Exception("Id is not valid"); } _wholeFolderList.Clear(); _wholeCodeList.Clear(); _wholeFolderList.Add(tree); Db.BeginTransaction(); GetWholeCodeFolder(tree.Id); Db.Commit(); Db.BeginTransaction(); foreach (var item in _wholeFolderList) { Db.Delete(item); } Db.Commit(); this.DeleteCodeList2(_wholeCodeList); return(true); }
public void SaveCodeTreeTest() { SAPINTDB.CodeManager.CodeFolder codetree = new SAPINTDB.CodeManager.CodeFolder(); codetree.Text = "Code"; codetree.Type = "Document"; db.SaveTree(codetree); }