示例#1
0
        /// <summary>
        /// 获取课程详细
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public ActionResult CourseDetial(int Id)
        {
            APIInvokeResult result = new APIInvokeResult();

            if (Id == 0)
            {
                result.Type    = ERRORCODE.Failed;
                result.Message = "请求错误";
                return(Json(result));
            }
            var userLoginId = LoginUserInfo();
            var course      = _courseRepository.GetCourserModel(Id, userLoginId);

            if (course == null)
            {
                result.Type    = ERRORCODE.Failed;
                result.Message = "课程已下线";
                return(Json(result));
            }
            var courseDownloadUrl = "";
            var coursePlayUrl     = _channelMmrRepository.Getfirst(course.Id).Mms.Replace("\\", "/");
            var videoLength       = _channelMmrRepository.Getfirst(Id);

            var len = videoLength.Video_Length > 0 ? videoLength.Video_Length : 100;

            string coursenumber = _courseRepository.GetEntity(p => p.COURSE_ID == Id).COURSE_NUMBER;

            if (_courseProcessRepository.IsAny(LoginUserInfo(), coursenumber) == "未选")
            {
                AICC_J_HIGH_SCORE pp = new AICC_J_HIGH_SCORE
                {
                    COURSE_ID        = coursenumber,
                    length           = int.Parse(len.ToString()),
                    OBJ_FIRST_DATE   = DateTime.Now,
                    OBJ_HIGH_SCORE   = "0",
                    OBJ_OBJECTIVE_ID = "1",
                    SESSION_ID       = "0",
                    STUDENT_ID       = LoginUserInfo(),
                    timems           = 1
                };
                _courseProcessRepository.Insert(pp);
            }

            var json = new CourseInfo
            {
                CourseId       = course.Id.ToString(),
                CourseName     = course.Name,
                CourseType     = coursePlayUrl.Contains("index.html") ? "H5" : "Mp4",
                RequiredFlag   = "1",
                Credit         = course.Credit.ToString("0.0"),
                CreateDate     = course.CreateDate,
                DownloadUrl    = courseDownloadUrl,
                DownloadUrlLow = courseDownloadUrl.Replace(".mp4", "_low.mp4"),
                OnlineUrl      = coursePlayUrl ?? "",
                Description    = course.Description,
                Duration       = ((decimal)len / 60).ToString("F0") + '.' + ((decimal)len % 60).ToString("F0"),
                TeacherName    = course.Teacher,
                CourseImg      = "http://www.cszsjy.com/Fwadmin/Manager/Admin/Lession/Save/" + course.Img,
                ExamId         = course.Exam,
                CommentCredit  = Convert.ToSingle(course.CommentCredit).ToString(),
                SelectFlag     = _courseProcessRepository.IsAny(userLoginId, coursenumber),
                BrowseScore    = course.Learning + "%",
                UserCount      = 0,
                //课程分类
                ChannelName = course.channelName,
                Remainder   = ""
            };
            //获取进度
            var entity      = _courseProcessRepository.GetEntity(m => m.COURSE_ID == coursenumber && m.STUDENT_ID == userLoginId);
            var lastpostion = entity != null ? entity.timems.Value : 0;
            var lastnodeid  = "S001";

            //最后的位置
            json.LastLocation = lastpostion;          ////TODO 2015-02-28 09:24:08 添加LastNodeID
            json.BrowseScore  = entity != null ? ((decimal)lastpostion / (decimal)len * 100).ToString("F2") + "%" : "0%";
            json.LastNodeId   = lastnodeid ?? "S001"; // lastnodeid,
            //评分
            json.AvgScore   = course.Score;
            json.CourseSize = course.CourseSize ?? "0";
            json.ClickCount = course.ClickCount.ToString();
            result.Data     = json;
            return(View(json));
        }
示例#2
0
        public ActionResult UploadTimeNode(Mp4CourseProcessDataModel model)
        {
            APIInvokeResult result   = new APIInvokeResult();
            var             courseid = model.CourseId;
            //string playingCourseKey = string.Format(CacheKey.PlayingCourseKey, LoginUserId);

            //JYCache.OneCacheMananger().Add(playingCourseKey, courseid);
            //var course = ServicesItems.CourseServices.GetCourse(courseid);
            var     course        = _courseRepository.GetEntity(m => m.COURSE_ID == courseid);
            string  coruse_number = course.COURSE_NUMBER;
            var     userid        = LoginUserInfo();
            var     userNm        = _userRepository.GetEntity(j => j.USER_ID == userid).USER_NM;
            decimal time          = 0;
            var     videoLength   = _channelMmrRepository.GetEntity(n => n.CourseID == courseid);
            var     len           = videoLength.Video_Length > 0 ? videoLength.Video_Length : 100;

            if (course != null && !string.IsNullOrEmpty(model.TimeNode))
            {
                var h = Convert.ToDecimal(model.TimeNode.Substring(0, 2));
                var m = Convert.ToDecimal(model.TimeNode.Substring(2, 2));
                var s = Convert.ToDecimal(model.TimeNode.Substring(4, 2));
                time = h * 3600 + m * 60 + s;
                //Debug.WriteLine(time);
                //  Console.WriteLine(time + ":::::");
                CourseProcess process = new CourseProcess
                {
                    //PortalId = PortalId,
                    PortalId = "",
                    UserId   = LoginUserInfo(),
                    Position = time,
                    CourseId = courseid
                };

                var courseProcess = _courseProcessRepository.GetEntity(mm => mm.COURSE_ID == coruse_number && mm.STUDENT_ID == userid);
                if (courseProcess != null)
                {
                    courseProcess.timems = int.Parse(time.ToString());
                    _courseProcessRepository.Update(courseProcess);
                }
                else
                {
                    AICC_J_HIGH_SCORE pp = new AICC_J_HIGH_SCORE
                    {
                        COURSE_ID        = coruse_number,
                        length           = int.Parse(len.ToString()),
                        OBJ_FIRST_DATE   = DateTime.Now,
                        OBJ_HIGH_SCORE   = "0",
                        OBJ_OBJECTIVE_ID = "1",
                        SESSION_ID       = "0",
                        STUDENT_ID       = userid,
                        timems           = int.Parse(time.ToString())
                    };
                    _courseProcessRepository.Insert(pp);
                }
            }
            var courseProcesss = _courseProcessRepository.GetEntity(mm => mm.COURSE_ID == coruse_number && mm.STUDENT_ID == userid);

            UserStudyInfo usi = new UserStudyInfo();

            usi.CourseId  = courseid.ToString();
            usi.StartTime = courseProcesss.OBJ_FIRST_DATE != null?Convert.ToDateTime(courseProcesss.OBJ_FIRST_DATE) : Convert.ToDateTime("1900-01-01");

            usi.CurrentProgress = ((decimal)courseProcesss.timems.Value / (decimal)videoLength.Video_Length.Value).ToString("F2");
            usi.LastLoation     = courseProcesss.timems.ToString();
            usi.LastNodeId      = "0";
            usi.NodeList        = new List <NodeInfo>();
            result.Data         = usi;
            return(Json(result));
        }