//当数据源为SQL时调用 //ModeType: "view", IsLoadLeaf: isLoadLeaf, NodeId: pId, XmlUrl: xmlUrl //public ActionResult GetTreeByRootId(string ModeType, string IsLoadLeaf, string NodeId) //{ // Tree tree = new Tree("开发技术"); // string result = ""; // if (NodeId != "") // { // int rootId = Int32.Parse(NodeId); // List<TreeNode> list = tree.GetTreeNodeChild(rootId); // result = JsonConvert.SerializeObject(list); // } // else // { // //"[{\"Ariticle\":null,\"Id\":6,\"Title\":\"Html\",\"Deepth\":2,\"ParentId\":1,\"IsLeaf\":true}] // result = "[{\"Ariticle\":\"null\",\"Id\":\"" + tree.RootNode.Id + "\",\"Title\":\"" + tree.RootNode.Title + "\",\"Deepth\":\"" + tree.RootNode.Deepth + "\",\"ParentId\":\"null\",\"IsLeaf\":\"" + tree.RootNode.IsLeaf + "\"}]"; // //result = JsonConvert.SerializeObject(result); // } // // List<TreeNode> // return Content(result); //} public string AddAriticle(string title, string userId, string visibility, string tag, string content, string treeNodeParentId) { Ariticle ariticle = new Ariticle(); //添加标题 ariticle.Title = title; //添加内容 //ariticle.UGC = System.Web.HttpUtility.UrlDecode(content); content = System.Web.HttpUtility.UrlDecode(content); content = content.Replace("CodeReplacePlus", "+"); ariticle.UGC = content; //ariticle.UGC = content; //添加标签 string[] tlist = tag.Split(new char[] { ',' }); List<AriticleTag> Tags = new List<AriticleTag>(); AriticleTag ariticletag = new AriticleTag(); for (int i = 0; i < tlist.Length; i++) { ariticletag = new AriticleTag(); ariticletag.Title = tlist[i]; // ariticletag.Article = ariticle; Tags.Add(ariticletag); } ariticle.Tags = Tags; //创建一个新节点 TreeNode treeNode = new TreeNode(Int32.Parse(treeNodeParentId), title); //创建不可见分组信息数组 string[] inlist = visibility.Split(new char[] { ';' }); List<int> visiblityGroup = new List<int>(); for (int i = 0; i < inlist.Length - 1; i++) { visiblityGroup.Add(Int32.Parse(inlist[i])); } AriticleService ariticleService = new AriticleService(); ariticleService.NewAriticle(ariticle, visiblityGroup,userId,treeNode); return "success"; }