Ejemplo n.º 1
0
 public List<AriticleViewModel> SimplifyAriticle(List<Ariticle> list)
 {
     List<AriticleViewModel> result = new List<AriticleViewModel>();
     PraiseRepository  pr =  new PraiseRepository();
     //AriticleViewModel avm = new AriticleViewModel();
     for (int i = 0; i < list.Count; i++)
     {
         AriticleViewModel avm = new AriticleViewModel(list[i]);
         if (list[i].Approve.ApproveStatus == EnumAriticleApproveStatus.Approved)
         {
             avm.Id = list[i].Id;
             avm.Title = list[i].Title;
             //if (list[i].UGC.Length > 300)
             //{
             //    avm.UGC = list[i].UGC.Substring(0, 300);
             //}
             //else
             //{
                 avm.UGC = list[i].UGC;
             //}
             avm.author = list[i].User.NickName;
             avm.ApproveStatus = list[i].Approve.ApproveStatus;
             avm.Createtime = list[i].Createtime.ToString();
             //avm.PraiseCount = pr.FindByAriticleID((list[i].Id)).PraiseCount;
             result.Add(avm);
         }
     }
     return result;
 }
 public List<AriticleViewModel> SimplifyAriticle(List<Ariticle> list)
 {
     List<AriticleViewModel> result = new List<AriticleViewModel>();
     for (int i = 0; i < list.Count; i++)
     {
         AriticleViewModel avm = new AriticleViewModel(list[i]);
         avm.Id = list[i].Id;
         avm.Title = list[i].Title;
         if (list[i].UGC.Length > 300)
         {
             avm.UGC = list[i].UGC.Substring(0, 300);
         }
         else
         {
             avm.UGC = list[i].UGC;
         }
         avm.author = list[i].User.NickName;
         avm.ApproveStatus = list[i].Approve.ApproveStatus;
         result.Add(avm);
     }
     return result;
 }
Ejemplo n.º 3
0
 //参数 用户名 每页条数  页码
 public ActionResult ShowOwnKnowledgeItem(string userId, int numOnePage, int pageIndex)
 {
     using (RRDLEntities db = new RRDLEntities())
     {              
         AriticleService articleService = new AriticleService();
         List<Ariticle> list = new List<Ariticle>();
         list = articleService.FindAriticlesByUser(userId, numOnePage, pageIndex, db);
         int n = list.Count;
         AriticleService articleService1 = new AriticleService();
         int totalCount = articleService1.GetAriticleCount(userId);
         List<AriticleViewModel> ariticleList = new List<AriticleViewModel>();
         for (int i = 0; i < n; i++)
         {
             AriticleViewModel temp = new AriticleViewModel(list[i]);
             temp.ApproveStatus = list[i].Approve.ApproveStatus;
             temp.Id = list[i].Id;
             string time1 = list[i].Createtime.ToLongDateString();
             string time2 = list[i].Createtime.ToLongTimeString();
             temp.Createtime = time1 + "  " + time2;
             temp.Title = list[i].Title;
             if (list[i].UGC.Length > 300)
             {
                 temp.UGC = list[i].UGC.Substring(0, 300);
             }
             else
             {
                 temp.UGC = list[i].UGC;
             }
             // temp.Tags = list[i].Tags;
             temp.Title = list[i].Title;
             temp.User = null;
             ariticleList.Add(temp);
         }
         string length = (ariticleList.Count).ToString();
         string result = JsonConvert.SerializeObject(ariticleList);
         result = result + "ContentAndCount" + totalCount;
         return Content(result);
     }
 }
Ejemplo n.º 4
0
 /// <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");
         }
     }
 }
Ejemplo n.º 5
0
 public ActionResult ToKnowledgeModify(string ariticleId)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         AriticleService ars = new AriticleService(db);
         Ariticle ariticle = ars.FindById(ariticleId);
         AriticleViewModel avm = new AriticleViewModel(ariticle);
         List<AriticleVisibility> visibilityList = ars.GetAriticleVisibility(ariticle.Id);
         avm.Id = ariticle.Id;
         string result = JsonConvert.SerializeObject(avm);
         ViewBag.Ariticle = result;
         UserGroupService ugs = new UserGroupService();
         List<UserGroup> list = ugs.FindAll();
         List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
         UserGroupViewModel ugv;
         for (int i = 0; i < list.Count; i++)
         {
             ugv = new UserGroupViewModel(list[i]);
             ugvlist.Add(ugv);
         }
         string resultlist = JsonConvert.SerializeObject(ugvlist);
         ViewBag.OpenString = resultlist;
         Tree tree = new Tree();
         TreeNode treeNode = tree.SearchByAriticle(ariticle.Id);
         List<TreeNode> treelist = tree.GetTreeNodePath(treeNode);
         string treeresult = "";
         for (int i = treelist.Count - 1; i >= 0; i--)
         {
             treeresult = treeresult + treelist[i].Title + "TreePathSplit";
         }
         ViewBag.TreeId = treeNode.ParentId;
         ViewBag.TreePath = treeresult;
         VisibilityViewModel vvm = new VisibilityViewModel();
         List<VisibilityViewModel> vvlist = new List<VisibilityViewModel>();
         int count = ugs.FindAll().Count;
         if (count == visibilityList.Count)
         {
             ViewBag.visibilityList = "all";
         }
         else
         {
             for (int i = 0; i < visibilityList.Count; i++)
             {
                 vvm = new VisibilityViewModel();
                 vvm.Id = visibilityList[i].Id;
                 vvm.UserGroupId = visibilityList[i].UserGroupId;
                 vvlist.Add(vvm);
             }
             string vlist = JsonConvert.SerializeObject(vvlist);
             ViewBag.visibilityList = vlist;
         }
         string author = ariticle.User.NickName;
         string createTime = ariticle.Createtime.ToString();
         ViewBag.author = author;
         ViewBag.createTime = createTime;
         return View();
     }
 }
Ejemplo n.º 6
0
 //根据传进来的id查到此条知识的详细信息,并返回JSON
 public string GetKnowledgeDetails(string ariticleId)
 {
     //using (RRDLEntities db = new RRDLEntities())
     //{
     //    AriticleService ariticleservice = new AriticleService();
     //    Ariticle ariticle = ariticleservice.FindById(ariticleId);
     //    AriticleViewModel art = new AriticleViewModel(ariticle);
     //    string result = JsonConvert.SerializeObject(art);
     //    return result;
     //}
     using (RRDLEntities db = new RRDLEntities())
     {
         AriticleService ars = new AriticleService(db);
         Ariticle ariticle = ars.FindById(ariticleId);
         AriticleViewModel avm = new AriticleViewModel(ariticle);
         //avm.Title = ariticle.Title;
         //avm.UGC = ariticle.UGC;
         string result = JsonConvert.SerializeObject(avm);
         return result;
     }
 }
Ejemplo n.º 7
0
        public List<AriticleViewModel> SimplifyAriticle(int count,List<Ariticle> list)
        {
            List<AriticleViewModel> result = new List<AriticleViewModel>();
            int listCount = result.Count;
            PraiseRepository pr = new PraiseRepository();

            int n = 0;
            if (result.Count >= count)
                n = count;
            else
                n = listCount;
            for (int i = 0; i < n; i++)
            {
                AriticleViewModel avm = new AriticleViewModel(list[i]);
                avm.Id = list[i].Id;
                avm.Title = list[i].Title;
                //if (list[i].UGC.Length > 300)
                //{
                //    avm.UGC = list[i].UGC.Substring(0, 300);
                //}
                //else
                //{
                    avm.UGC = list[i].UGC;
                //}
                avm.author = list[i].User.NickName;
                avm.ApproveStatus = list[i].Approve.ApproveStatus;
                //avm.PraiseCount = pr.FindByAriticleID((list[i].Id)).PraiseCount;
                result.Add(avm);
            }
            return result;
        }
Ejemplo n.º 8
0
 public ActionResult GetAriticleById(string ariticleId)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         AriticleService ars = new AriticleService(db);
         Ariticle ariticle = ars.FindById(ariticleId);
         AriticleViewModel avm = new AriticleViewModel(ariticle);
         avm.Title = ariticle.Title;
         avm.UGC = ariticle.UGC;
         avm.author = ariticle.User.NickName;
         avm.Createtime = ariticle.Createtime.ToString();
         Tree tree = new Tree();
         TreeNode treeNode = tree.SearchByAriticle(ariticle.Id);
         List<TreeNode> list = tree.GetTreeNodePath(treeNode);
         string result = "";
         for (int i = list.Count - 1; i >= 0; i--)
         {
             result = result + list[i].Title + "#";
         }
         string arrayList = "";
         List<AriticleVisibility> visibilityList = ars.GetAriticleVisibility(ariticle.Id);
         UserGroupService ugs = new UserGroupService();
         int count = ugs.FindAll().Count;
         if (0 == visibilityList.Count)
         {
             arrayList = JsonConvert.SerializeObject(avm) + "AriticleAndTreeNode" + result + "AriticleAndTreeNodeall";
         }
         else {
             VisibilityViewModel vvm = new VisibilityViewModel();
             List<VisibilityViewModel> vvlist = new List<VisibilityViewModel>();
             for (int i = 0; i < visibilityList.Count; i++)
             {
                 vvm = new VisibilityViewModel();
                 vvm.Id = visibilityList[i].Id;
                 vvm.UserGroupId = visibilityList[i].UserGroupId;
                 vvm.userGroupTitle = visibilityList[i].UserGroup.Title;
                 vvlist.Add(vvm);
             }
             string vlist = JsonConvert.SerializeObject(vvlist);
             arrayList = JsonConvert.SerializeObject(avm) + "AriticleAndTreeNode" + result + "AriticleAndTreeNode" + vlist;
         }
         return Content(arrayList);
     }
 }