Exemplo n.º 1
0
        //当数据源为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";
        }
Exemplo n.º 2
0
        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";
            }
        }
Exemplo n.º 3
0
 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";
     }
 }