public JsonResult GetUnitPage(int unitid, bool isshow, string jy)
        {
            if (Encrypt.MD5Hash(unitid.ToString(), "jzxd") == jy)
            {
                DtoLessonUnit p   = null;
                LessonUnitBll bll = new LessonUnitBll();
                if (!isshow)
                {
                    p = bll.SelectUnit(unitid, 0);
                }
                else
                {
                    p = bll.GetUnitFromRadis(unitid);
                }
                List <int> mediaIDs = new List <int>();
                List <int> textIDs  = new List <int>();
                var        page     = new Page()
                {
                    pageId   = p.Id,
                    pageNum  = p.Index,
                    pageName = p.Name,
                    coinsKey = Encrypt.EncryptQueryString($"{p.Coins}_{p.Id}_{p.LessonId}_{p.CourseId}"),//金币加密串(加密内容为"单元金币数_单元id_课时id_课程id")//Remark1
                    steps    = p.Steps.Select(s => new Step()
                    {
                        stepNum = s.StepNum,
                        actions = s.Actions.Select(a => ActionTranslator.DataToViewData(a, mediaIDs, textIDs)).ToList()
                    }).ToList()
                };
                //如果媒体id或文本id有值的话
                if (mediaIDs.Count > 0 || textIDs.Count > 0)
                {
                    ResourceBll rbll   = new ResourceBll();
                    var         medias = rbll.GetMediaObjectByIdList(mediaIDs.Distinct().ToList(), true); //获取所有的媒体对象字典
                    var         texts  = rbll.GetTextObjectByIdList(textIDs.Distinct().ToList());         //获取文本对象字典

                    page.steps.ForEach(s =>
                    {
                        s.actions.ForEach(a =>
                        {
                            ActionTranslator.SetViewDataMedia(a, medias, texts);
                        });
                    });
                }
                return(Json(new JsonResponse <Page>
                {
                    State = true,
                    ErrorCode = 0,
                    ErrorMsg = "",
                    Data = page
                }));
            }
            else
            {
                throw new Exception("GetUnitPage服务端校验失败");
            }
        }
        public void TestMethod1()
        {
            int page     = 1;
            int pagesize = 5;
            int courseid = 10016;
            int lessonid = 10047;

            LessonUnitBll bll   = new LessonUnitBll();
            var           pager = new Code.Common.PagingObject()
            {
                PageIndex  = page,     //开始页(包含)
                PageSize   = pagesize, //条数
                TotalCount = 0
            };
            var pages = bll.SelectUnitByNext(new Domain.Dto.Request.DtoLessonUnitSearch()
            {
                CourseID   = courseid,
                LessonID   = lessonid,
                StudentID  = 10000,
                Pagination = pager
            });
            List <int> mediaIDs = new List <int>();
            List <int> textIDs  = new List <int>();
            var        list     = pages.Select(p => new Page()
            {
                pageId   = p.Id,
                pageNum  = p.Index,
                pageName = p.Name,
                steps    = p.Steps.Select(s => new Step()
                {
                    stepNum = s.StepNum,
                    actions = s.Actions.Select(a => ActionTranslator.DataToViewData(a, mediaIDs, textIDs)).ToList()
                }).ToList()
            }).ToList();

            //如果媒体id或文本id有值的话
            if (mediaIDs.Count > 0 || textIDs.Count > 0)
            {
                ResourceBll rbll   = new ResourceBll();
                var         medias = rbll.GetMediaObjectByIdList(mediaIDs.Distinct().ToList()); //获取所有的媒体对象字典
                var         texts  = rbll.GetTextObjectByIdList(textIDs.Distinct().ToList());   //获取文本对象字典

                list.ForEach(p =>
                {
                    p.steps.ForEach(s =>
                    {
                        s.actions.ForEach(a =>
                        {
                            ActionTranslator.SetViewDataMedia(a, medias, texts);
                        });
                    });
                });
            }
            var str = JsonConvert.SerializeObject(list);
        }
        public JsonResult GetLessonPage(DtoLessonUnitSearch search, bool isApprove = false)
        {
            LessonUnitBll bll = new LessonUnitBll();

            search.StudentID = GetCurrentUser().StudentId;//设置当前学生id
            if (isApprove)
            {
                search.Pagination.PageSize = 1;
            }                                                 //如果是审批的情况,只返回一条数据
            var        pages    = bll.SelectUnitByNext(search);
            List <int> mediaIDs = new List <int>();
            List <int> textIDs  = new List <int>();
            var        list     = pages.Select(p => new Page()
            {
                pageId   = p.Id,
                pageNum  = p.Index,
                pageName = p.Name,
                coinsKey = Encrypt.EncryptQueryString($"{p.Coins}_{p.Id}_{p.LessonId}_{p.CourseId}"),//金币加密串(加密内容为"单元金币数_单元id_课时id_课程id")//Remark1
                steps    = p.Steps.Select(s => new Step()
                {
                    stepNum = s.StepNum,
                    actions = s.Actions.Select(a => ActionTranslator.DataToViewData(a, mediaIDs, textIDs)).ToList()
                }).ToList()
            }).ToList();

            //如果媒体id或文本id有值的话
            if (mediaIDs.Count > 0 || textIDs.Count > 0)
            {
                ResourceBll rbll   = new ResourceBll();
                var         medias = rbll.GetMediaObjectByIdList(mediaIDs.Distinct().ToList(), true); //获取所有的媒体对象字典
                var         texts  = rbll.GetTextObjectByIdList(textIDs.Distinct().ToList());         //获取文本对象字典

                list.ForEach(p =>
                {
                    p.steps.ForEach(s =>
                    {
                        s.actions.ForEach(a =>
                        {
                            ActionTranslator.SetViewDataMedia(a, medias, texts);
                        });
                    });
                });
            }

            return(Json(new JsonResponse <List <Page> >
            {
                State = true,
                ErrorCode = 0,
                ErrorMsg = "",
                Data = list
            }));
        }
        public JsonResult GetPage(int pageid, int processid)
        {
            LessonUnitBll bll  = new LessonUnitBll();
            var           unit = bll.SelectUnit(pageid, processid);
            var           page = new Page();

            page.courseId = unit.CourseId;
            page.lessonId = unit.LessonId;
            page.id       = unit.Id;
            page.name     = unit.Name;
            page.pageNum  = unit.Index;
            ////定义媒体资源id数组和文本资源id数组
            List <int> mediaids = new List <int>(), textids = new List <int>();

            page.steps = unit.Steps.Select(s => new Models.CurriculumSetViewModel.Step
            {
                id      = s.id,
                stepNum = s.StepNum,
                actions = s.Actions.Select(a => ActionTranslator.DataToViewData(a, mediaids, textids)).ToList()
            }).ToList();
            //如果媒体id或文本id有值的话
            if (mediaids.Count > 0 || textids.Count > 0)
            {
                ResourceBll rbll   = new ResourceBll();
                var         medias = rbll.GetMediaObjectByIdList(mediaids.Distinct().ToList()); //获取所有的媒体对象字典
                var         texts  = rbll.GetTextObjectByIdList(textids.Distinct().ToList());   //获取文本对象字典
                page.steps.ForEach((s) =>
                {
                    s.actions.ForEach((a) =>
                    {
                        ActionTranslator.SetViewDataMedia(a, medias, texts); //设置动作的媒体属性
                    });                                                      //遍历每一个动作
                });                                                          //遍历每一个步骤
            }
            page.approveType = unit.ApproveStatus;
            page.approve     = unit.Approve;
            return(Json(new JsonResponse <Page> {
                State = true, ErrorCode = 0, ErrorMsg = "", Data = page
            }));
        }