public string GeTeamRank() { UserGroupService usergSerivice = new UserGroupService(); UserService userService = new UserService(); List<UserGroup> usergList = usergSerivice.FindAll(); List<RankListTeam> rankListTeam = new List<RankListTeam>(); List<User> userList = new List<User>(); for (int i = 2; i < usergList.Count; i++) { userList = userService.FindUsersByGroupId(usergList[i].Id); int count = 0; for (int j = 0; j < userList.Count; j++) { //获取每个用户的发表的知识数量,并求和 AriticleService ariticleService = new AriticleService(); int n = ariticleService.GetAriticleCount(userList[j].Id); count += n; } RankListTeam rlt = new RankListTeam(); rlt.Title = usergList[i].Title; rlt.AriticleCount = count; rankListTeam.Add(rlt); } //对结果排序 var queryResults = from n in rankListTeam orderby n.AriticleCount descending select n; List<RankListTeam> rktList = new List<RankListTeam>(); foreach (var n in queryResults) { rktList.Add(n); } string result = JsonConvert.SerializeObject(rktList); return result; }
//参数 用户名 每页条数 页码 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); } }
// // GET: /RankList/ //获取所有用户的发表知识数量的排行 public string GetMemberRank() { UserService userService = new UserService(); AriticleService ariticleSerivice = new AriticleService(); List<User> list = userService.GetMemerList(); List<RankListMember> rkmList = new List<RankListMember>(); for (int i = 0; i < list.Count; i++) { RankListMember t = new RankListMember(); t.RealName = list[i].RealName; t.ariticleCount = ariticleSerivice.GetAriticleCount(list[i].Id); rkmList.Add(t); } //对结果排序 var queryResults = from n in rkmList orderby n.ariticleCount descending select n; List<RankListMember> rkmList2 = new List<RankListMember>(); foreach (var n in queryResults) { rkmList2.Add(n); } string result = JsonConvert.SerializeObject(rkmList2); return result; }
public string GetUserById(string userId) { using (RRDLEntities db = new RRDLEntities()) { UserService us = new UserService(); User user = us.FindById(userId); UserViewModel uvm = new UserViewModel(); uvm.NickName = user.NickName; uvm.RealName = user.RealName; uvm.RegisterName = user.RegisterName; uvm.Category = getAuthorityCategory(user.AuthorityCategory); int ugid = (int)user.ContentGroupId; UserGroupService ugs = new UserGroupService(); UserGroup ug = ugs.FindById(ugid); uvm.UserGroup = ug.Title; uvm.CreateTime = user.Createtime.ToString(); int approvedcount = 0; int allcount = 0; AriticleService ariticleService = new AriticleService(); Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved && a.UserId == user.Id; approvedcount = ariticleService.GetAriticleCount(condition); condition = a => a.UserId == user.Id; allcount = ariticleService.GetAriticleCount(condition); uvm.approvedArticleCount = approvedcount; uvm.allArticleCount = allcount; string result = JsonConvert.SerializeObject(uvm); return result; } }
//public string getMemberById(string userId) { // UserService userservice = new UserService(); // User user = userservice.FindById(userId); // MemberViewModel mvm = new MemberViewModel(user); // UserGroupService ugs = new UserGroupService(); // List<UserGroup> list = ugs.FindAll(); // string memberResult = JsonConvert.SerializeObject(mvm); // 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 result = JsonConvert.SerializeObject(ugvlist); // return memberResult+"MemberAndGroupList"+result; //} public string getMemberById(string userId) { using (RRDLEntities db = new RRDLEntities()) { UserService userservice = new UserService(); User user = userservice.FindById(userId); MemberViewModel mvm = new MemberViewModel(user); int approvedcount = 0; int allcount = 0; AriticleService ariticleService = new AriticleService(); Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved && a.UserId == user.Id; approvedcount = ariticleService.GetAriticleCount(condition); condition = a => a.UserId == user.Id; allcount = ariticleService.GetAriticleCount(condition); mvm.approvedArticleCount = approvedcount; mvm.allArticleCount = allcount; UserGroupService ugs = new UserGroupService(); List<UserGroup> list = ugs.FindAll(); string memberResult = JsonConvert.SerializeObject(mvm); 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 result = JsonConvert.SerializeObject(ugvlist); return memberResult + "MemberAndGroupList" + result; } }
public int GetAriticleCount(string userId) { AriticleService ariticleService = new AriticleService(); int ariticleCount = ariticleService.GetAriticleCount(userId); return ariticleCount; }
public ActionResult KnowledgeManage(int numOnePage, int pageIndex, string state, string userGroupId) { using (RRDLEntities db = new RRDLEntities()) { AriticleService ariticleService = new AriticleService(); List<Ariticle> list = new List<Ariticle>(); string s = state; int count = 0; int id = 0; id = Int32.Parse(userGroupId); switch (state) { case null: case "all": if (userGroupId == "2") { Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved || a.Approve.ApproveStatus == EnumAriticleApproveStatus.FailedApprove; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } else { Expression<Func<Ariticle, bool>> condition = a => (a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved || a.Approve.ApproveStatus == EnumAriticleApproveStatus.FailedApprove) && a.User.ContentGroupId == id; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } case "AuditPass": if (userGroupId == "2") { //list = ariticleService.FindAriticlesByApproveStatus(EnumAriticleApproveStatus.Approved, //numOnePage, pageIndex, db); //count = ariticleService.GetAriticleCount(EnumAriticleApproveStatus.Approved); Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } else { Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved && a.User.ContentGroupId == id; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } case "AuditUnqualified": if (userGroupId == "2") { //list = ariticleService.FindAriticlesByApproveStatus( // EnumAriticleApproveStatus.FailedApprove, numOnePage, pageIndex, db); //count = ariticleService.GetAriticleCount(EnumAriticleApproveStatus.FailedApprove); Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.FailedApprove; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } else { Expression<Func<Ariticle, bool>> condition = a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.FailedApprove && a.User.ContentGroupId == id; list = ariticleService.FindAriticlesManage(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); break; } } List<AriticleViewModel> Viewlist = SimplifyAriticle(list); string result = JsonConvert.SerializeObject(Viewlist); result = result + "ContentAndCount" + count; return Content(result); } }
public ActionResult KnowledgeAudit(int numOnePage, int pageIndex, string userGroupId) { using (RRDLEntities db = new RRDLEntities()) { AriticleService ariticleService = new AriticleService(); List<Ariticle> list = new List<Ariticle>(); int count = 0; if (userGroupId == "2") { list = ariticleService.FindAriticlesByApproveStatus( EnumAriticleApproveStatus.UnApproved, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(EnumAriticleApproveStatus.UnApproved); } else { int id = Int32.Parse(userGroupId); Expression<Func<Ariticle, bool>> condition = a => a.User.ContentGroupId == id && a.Approve.ApproveStatus == EnumAriticleApproveStatus.UnApproved; list = ariticleService.FindAriticles(condition, numOnePage, pageIndex, db); count = ariticleService.GetAriticleCount(condition); } List<AriticleViewModel> Viewlist = SimplifyAriticle(list); string result = JsonConvert.SerializeObject(Viewlist); result = result + "ContentAndCount" + count; return Content(result); } }