Exemplo n.º 1
0
        public JsonResult GetMyPostAbilityCommentList(int postId, int abilityId, int pageIndex = 0, int pageSize = int.MaxValue)
        {
            int total;
            var list     = _abilityManager.GetPostAbilityCommentList(out total, postId, abilityId, pageIndex, pageSize);
            var dataList = new List <object>();

            foreach (var item in list)
            {
                dataList.Add(new
                {
                    item.PhotoStr,
                    item.RecommendId,
                    //item.ReTimeStr,
                    ReTimeStr = item.ReTime.Diff(),
                    item.Realname,
                    item.Content,
                    item.ReplyList,
                    item.UserId,
                    //自己不能关注;0:已关注;1:未关注
                    AttendStatus = item.UserId == CurrentUser.UserId ? -1 : (MyAttendUsers.Contains(item.UserId) ? 0 : 1)
                });
            }
            return(Json(new
            {
                dataList = dataList,
                recordCount = total
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取此培训中的人员
        /// </summary>
        /// <param name="classId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonResult GetTrainUserList(int classId, int pageIndex, int pageSize)
        {
            var userlist = _trainLearningManager.GetTrainUserList(classId);
            var dataList = userlist.Skip((pageIndex - 1) * pageSize).Take(pageSize).Select(p => new
            {
                PhotoUrl = Url.Addr(p.photoUrl),
                p.Realname,
                p.UserId,
                //自己不能关注;0:已关注;1:未关注
                AttendStatus = p.UserId == CurrentUser.UserId ? -1 : (MyAttendUsers.Contains(p.UserId) ? 0 : 1)
            });

            return(Json(new { dataList, recordCount = userlist.Count() }, JsonRequestBehavior.AllowGet));
            //  return Json(new { recordCount = 0 }, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 3
0
        public JsonResult GetPageActivity(int pageIndex)
        {
            var userActivities = activityService.GetUsersActivities(CurrentUser.UserId, pageIndex);
            var pariseList     = activityService.GetActivityPraises(userActivities.Select(p => p.ActivityId),
                                                                    CurrentUser.UserId);

            var paralls  = SystemUsers.AsParallel();
            var dataList = new object[userActivities.Count];

            for (int i = 0; i < userActivities.Count; i++)
            {
                var p = userActivities[i];
                p.UserInfo          = paralls.FirstOrDefault(u => u.UserId == p.UserId);
                p.CurrentUserParise = pariseList.Any(u => u.ActivityId == p.ActivityId);
                var title     = "";
                var url       = "";
                var imgUrl    = "";
                var shareType = "";

                switch (p.ActionType)
                {
                case ActionType.CourseShared:
                    shareType = RetechWing.LanguageResources.CourseLanguage.Course1;
                    title     = p.CourseShared.CourseName;
                    url       = Url.RetechAction("Course", "Learning", new { area = "Course", courseId = p.CourseShared.CourseId });
                    imgUrl    = p.CourseShared.FrontImage == "default.png" ||
                                string.IsNullOrWhiteSpace(p.CourseShared.FrontImage)
                            ? Url.Addr("~/UploadFiles/CourseFrontImages/default.png")
                            : Url.Addr(p.CourseShared.FrontImage);
                    break;

                case ActionType.KnowledgeShared:
                    shareType = RetechWing.LanguageResources.TalnetUI.UserAbility.Knowledge;
                    title     = p.KnowledgeShared.ResourceName;
                    url       = Url.RetechAction("ReadResource", "KnowledgeCenter", new { area = "Knowledge" }) + "?id=" + p.KnowledgeShared.ResourceId;
                    //imgUrl =Url.Addr(string.Format("~/themes/default/img/docs/{0}.png", p.KnowledgeShared.ExtendName));
                    break;

                case ActionType.StudyPlanShared:
                    shareType = RetechWing.LanguageResources.Learning.xuexijihua;
                    title     = p.StudyPlanShared.PlanName;
                    url       = Url.RetechAction("ShowPlanInfo", "Learning", new { area = "Course" }) + "?backflag=2&id=" + p.StudyPlanShared.PlanId;
                    imgUrl    = p.StudyPlanShared.FrontImage == "default.png" ||
                                string.IsNullOrWhiteSpace(p.StudyPlanShared.FrontImage)
                            ? Url.Addr("~/UploadFiles/CourseFrontImages/default.png")
                            : Url.Addr(p.StudyPlanShared.FrontImage);
                    break;

                case ActionType.UrlShared:
                    shareType = "网页";
                    title     = p.UrlShared.ResourceName;
                    url       = p.UrlShared.ResourceUrl;
                    break;
                }
                dataList[i] = new
                {
                    p.UserInfo.Realname,
                    content        = p.ResourceName,
                    time           = p.ActionTime.Diff(),
                    parise         = p.CurrentUserParise ? "已赞" : "赞",
                    praised        = p.CurrentUserParise ? 1 : 0,
                    praiseOperator = p.CurrentUserParise ? "" : "onclick='parise(" + p.ActivityId + ",this)",
                    pariseCount    = p.PraiseCount,
                    forwCount      = p.ForwardCount,
                    replyCount     = p.ReplyCount,
                    isMy           = p.UserId == CurrentUser.UserId ? 1 : 0,
                    activityId     = p.ActivityId,
                    photoUrl       = Url.Addr(p.UserInfo.photoUrl),
                    p.UserId,
                    IsShare     = p.ActionType == ActionType.Talk ? 0 : 1,
                    ShareType   = p.ActionType,
                    ShareTitle  = title,
                    ShareUrl    = url,
                    ShareImgUrl = imgUrl,
                    //自己不能关注;0:已关注;1:未关注
                    AttendStatus = p.UserId == CurrentUser.UserId ? -1 : (MyAttendUsers.Contains(p.UserId) ? 0 : 1),
                    shareType
                };
            }
            return(Json(new { dataList }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult ReadResource(int id, string backUrl = "", int keep = 0, int tabFlag = 0, int backFlag = 0)
        {
            if (keep == 0)
            {
                return(Redirect(string.Format(Url.RetechAction("ReadResource", "KnowledgeCenter") + "?keep=1&id={0}&tabFlag={1}&backFlag={2}&backUrl={3}", id, tabFlag, backFlag, Url.Encode(backUrl))));
            }
            KL_Resource resource = _resourceManager.GetModel(id);

            if (resource == null || resource.IsDeleted == 1)
            {
                ViewBag.Msg = RetechWing.LanguageResources.KnowledgeLanguage.ResourceNot;
                return(View("ReadResourceError"));
            }
            if (resource.Status == 0)
            {
                ViewBag.Msg = RetechWing.LanguageResources.KnowledgeLanguage.ResourceNotApproval;
                return(View("ReadResourceError"));
            }
            if (resource.Status == 2)
            {
                ViewBag.Msg = RetechWing.LanguageResources.KnowledgeLanguage.ResourceNotApprovalNotPass;
                return(View("ReadResourceError"));
            }
            if (resource.IsOpen == 0 && resource.UserId != CurrentUser.UserId)//私有
            {
                ViewBag.Msg = RetechWing.LanguageResources.KnowledgeLanguage.ResourseNotOpen;
                return(View("ReadResourceError"));
            }
            else if (resource.IsOpen == 2 && resource.UserId != CurrentUser.UserId)//只开放部分人群 与 他本人
            {
                if (!_resourceManager.IsMyHasResource(id, CurrentUser.UserId))
                {
                    ViewBag.Msg = RetechWing.LanguageResources.KnowledgeLanguage.ResourseNotIn;
                    return(View("ReadResourceError"));
                }
            }

            //获取/更新阅读记录
            var readRecord = _readRecordManager.GetRecord(CurrentUser.UserId, id);

            if (readRecord == null)
            {
                readRecord = new KL_ReadRecord
                {
                    CurrentPage = 0,
                    Progress    = 0,
                    UserId      = CurrentUser.UserId,
                    ResourceId  = id,
                    ReadTime    = DateTime.Now
                };
                _readRecordManager.Add(readRecord);
                _resourceManager.AddResourceCount(new int[] { id }, 0);
            }
            else
            {
                _readRecordManager.UpdateReadTime(readRecord.RecordId);
            }

            resource.IsMyCollect  = _resourceManager.IsMyCollect(id, CurrentUser.UserId) ? 1 : 0;
            resource.IsMyDownload = _resourceManager.IsMyDownload(id, CurrentUser.UserId) ? 1 : 0;

            ViewBag.CurrentPage = readRecord.CurrentPage;
            ViewBag.Progress    = readRecord.Progress;
            ViewBag.RecordId    = readRecord.RecordId;

            ViewBag.IsComment = _resourceManager.IsMyComment(id, CurrentUser.UserId);

            ViewBag.attends = MyAttendUsers.Contains(resource.UserId);

            return(View(resource));
        }