Beispiel #1
0
        /// <summary>
        /// 使用学习卡
        /// </summary>
        /// <param name="context"></param>
        private void useCode(HttpContext context)
        {
            //学习卡的编码与密钥
            string code  = WeiSha.Common.Request.Form["card"].String;
            string state = "\"state\":{0},\"info\":\"{1}\",";
            string json  = "\"items\":[";

            //没有传入充值码
            if (!string.IsNullOrWhiteSpace(code))
            {
                try
                {
                    //开始验证
                    Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardCheck(code);
                    if (card != null)
                    {
                        Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser;
                        if (st != null)
                        {
                            Business.Do <ILearningCard>().CardUse(card, st);
                            Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                            //输出关联的课程
                            Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesForCard(card.Lc_Code, card.Lc_Pw);
                            for (int i = 0; i < courses.Length; i++)
                            {
                                Song.Entities.Course c = courses[i];
                                json += c.ToJson("Cou_ID,Cou_Name", null, null) + ",";
                            }
                            if (json.EndsWith(","))
                            {
                                json = json.Substring(0, json.Length - 1);
                            }
                        }
                    }
                    state = string.Format(state, 1, "成功");
                }
                catch (Exception ex)
                {
                    state = string.Format(state, 0, ex.Message);
                }
            }
            json += "]";
            Response.Write("({" + state + json + "})");
            this.Response.End();
        }
Beispiel #2
0
        protected void ddlTeacher_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            //教师下拉列表
            DropDownList ddl = (DropDownList)sender;
            //取当前课程
            GridViewRow gr = (GridViewRow)(ddl).Parent.Parent;
            int         id = Convert.ToInt32(this.GridView1.DataKeys[gr.RowIndex].Value);

            Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id);
            //设置教师
            int thid;

            int.TryParse(ddl.SelectedValue.ToString(), out thid);
            cou.Th_ID   = thid;
            cou.Th_Name = ddl.SelectedItem.Text;
            Business.Do <ICourse>().CourseSave(cou);
            BindData(null, null);
        }
Beispiel #3
0
        public bool StudyAllow(int couid)
        {
            Song.Entities.Accounts acc = this.Student;
            bool isBuy = Business.Do <ICourse>().StudyIsCourse(acc.Ac_ID, couid);

            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            bool canStudy = isBuy || course.Cou_IsFree || course.Cou_IsLimitFree || course.Cou_IsTry;

            return(canStudy);
        }
 protected override void InitPageTemplate(HttpContext context)
 {
     //当前试卷
     Song.Entities.TestPaper paper = null;
     paper = Business.Do <ITestPaper>().PagerSingle(tpid);
     if (paper != null)
     {
         paper.Tp_Logo = string.IsNullOrWhiteSpace(paper.Tp_Logo) ? paper.Tp_Logo : Upload.Get["TestPaper"].Virtual + paper.Tp_Logo;
         //判断Logo是否存在
         string hylogo = WeiSha.Common.Server.MapPath(paper.Tp_Logo);
         if (!System.IO.File.Exists(hylogo))
         {
             paper.Tp_Logo = string.Empty;
         }
         this.Document.SetValue("pager", paper);
         //试卷所属课程
         Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(paper.Cou_ID);
         this.Document.SetValue("course", course);
     }
 }
Beispiel #5
0
 /// <summary>
 /// 保存当前课程
 /// </summary>
 /// <returns></returns>
 private Song.Entities.Course Save()
 {
     Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(couid);
     if (cou == null)
     {
         return(null);
     }
     //是否免费,是否试用,以及试题数
     cou.Cou_IsFree = cbIsFree.Checked;
     cou.Cou_IsTry  = cbIsTry.Checked;
     try
     {
         Business.Do <ICourse>().CourseSave(cou);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(cou);
 }
Beispiel #6
0
 /// <summary>
 /// 获取当前学习的课程
 /// </summary>
 /// <returns></returns>
 public Song.Entities.Course Course()
 {
     Song.Entities.Course   c  = null;
     Song.Entities.Accounts st = this.CurrentUser;
     if (st != null && st.Ac_CurrCourse > 0)
     {
         //是否购买
         bool isBuy = false, istry = false;
         isBuy = Business.Do <ICourse>().StudyIsCourse(st.Ac_ID, st.Ac_CurrCourse);
         if (!isBuy)
         {
             istry = Business.Do <ICourse>().IsTryout(st.Ac_ID, st.Ac_CurrCourse);
         }
         if (isBuy || istry)
         {
             c = Business.Do <ICourse>().CourseSingle(st.Ac_CurrCourse);
         }
     }
     return(c);
 }
 /// <summary>
 /// 界面的初始绑定
 /// </summary>
 private void InitBind()
 {
     SortSelect1.InitBind();
     if (couid > 0)
     {
         Song.Entities.Course cour = Business.Do <ICourse>().CourseSingle(couid);
         if (cour != null)
         {
             SortSelect1.SbjID = cour.Sbj_ID;
             SortSelect1.CouID = couid;
         }
     }
     //题型
     ddlType.DataSource = typeStr;
     ddlType.DataBind();
     if (type > 0)
     {
         ddlType.SelectedIndex = type - 1;
     }
 }
Beispiel #8
0
        /// <summary>
        /// 分页获取课程
        /// </summary>
        /// <param name="orgid">机构id</param>
        /// <param name="sbjids">章节id,可以为多个,以逗号分隔</param>
        /// <param name="search">检索字符,按课程名称</param>
        /// <param name="size">每页几条</param>
        /// <param name="index">第几页</param>
        /// <returns></returns>
        public ListResult ShowPager(int orgid, string sbjids, string search, int size, int index)
        {
            int count = 0;
            List <Song.Entities.Course> eas = null;

            eas = Business.Do <ICourse>().CoursePager(orgid, sbjids, true, search, "", size, index, out count);
            string vpath = WeiSha.Common.Upload.Get["Course"].Virtual;

            for (int i = 0; i < eas.Count; i++)
            {
                Song.Entities.Course c = eas[i];
                //图片和缩略图
                c.Cou_Logo      = vpath + c.Cou_Logo;
                c.Cou_LogoSmall = vpath + c.Cou_LogoSmall;
                if (!System.IO.File.Exists(c.Cou_Logo))
                {
                    c.Cou_Logo = "";
                }
                if (!System.IO.File.Exists(c.Cou_LogoSmall))
                {
                    c.Cou_LogoSmall = "";
                }
                //是否免费,或是限时免费
                if (c.Cou_IsLimitFree)
                {
                    DateTime freeEnd = c.Cou_FreeEnd.AddDays(1).Date;
                    if (!(c.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                    {
                        c.Cou_IsLimitFree = false;
                    }
                }
                c.Cou_Intro = c.Cou_Target = c.Cou_Content = "";
                c.Cou_Name  = c.Cou_Name.Replace("\"", "&quot;");
            }
            ListResult result = new ListResult(eas);

            result.Index = index;
            result.Size  = size;
            result.Total = count;
            return(result);
        }
        /// <summary>
        /// 获取课程
        /// </summary>
        /// <param name="fmt">输出字符的格式</param>
        /// <returns></returns>
        protected string getCourse(string fmt)
        {
            int cid = mb.Cou_ID;

            if (cid == 0)
            {
                return("");
            }
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(cid);
            if (course == null)
            {
                return("");
            }
            Type type = course.GetType();

            foreach (PropertyInfo pi in type.GetProperties())
            {
                object o = type.GetProperty(pi.Name).GetValue(course, null);
                fmt = fmt.Replace("{" + pi.Name + "}", o == null ? "" : o.ToString());
            }
            return(fmt);
        }
Beispiel #10
0
        /// <summary>
        /// 判断当前课程是否允许切换浏览器时视频暂停
        /// </summary>
        /// <param name="course"></param>
        /// <param name="acc"></param>
        /// <param name="organ"></param>
        /// <returns>true,则允许浏览器失去焦点时,视频仍然播放</returns>
        private bool getSwitchPlay(Song.Entities.Course course, Song.Entities.Accounts acc, Song.Entities.Organization organ)
        {
            if (acc == null)
            {
                return(false);
            }
            //自定义配置项
            WeiSha.Common.CustomConfig config = CustomConfig.Load(organ.Org_Config);
            bool isstop = config["IsSwitchPlay"].Value.Boolean ?? false;

            if (isstop)
            {
                return(true);
            }
            //如果机构设置中为false,继续判断学员组的设置
            Song.Entities.StudentSort sort = Business.Do <IStudent>().SortSingle(acc.Sts_ID);
            if (sort == null || !sort.Sts_IsUse)
            {
                return(isstop);
            }
            return(sort.Sts_SwitchPlay);
        }
Beispiel #11
0
        /// <summary>
        /// 处理课程信息,图片转为全路径,并生成clone对象
        /// </summary>
        /// <param name="cour">课程对象的clone</param>
        /// <returns></returns>
        private Song.Entities.Course _tran(Song.Entities.Course cour)
        {
            if (cour == null)
            {
                return(cour);
            }
            //是否免费,或是限时免费
            if (cour.Cou_IsLimitFree)
            {
                DateTime freeEnd = cour.Cou_FreeEnd.AddDays(1).Date;
                if (!(cour.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    cour.Cou_IsLimitFree = false;
                }
            }
            string vpath = WeiSha.Common.Upload.Get["Course"].Virtual;
            string hpath = WeiSha.Common.Upload.Get["Course"].Physics;

            Song.Entities.Course curr = cour.Clone <Song.Entities.Course>();
            curr.Cou_Logo      = System.IO.File.Exists(hpath + curr.Cou_Logo) ?  vpath + curr.Cou_Logo : "";
            curr.Cou_LogoSmall = System.IO.File.Exists(hpath + curr.Cou_LogoSmall) ? vpath + curr.Cou_LogoSmall : "";
            return(curr);
        }
Beispiel #12
0
 /// <summary>
 /// 绑定价格信息的列表
 /// </summary>
 protected void BindPriceData()
 {
     Song.Entities.Course cou = couid < 1 ? new Song.Entities.Course() : Business.Do <ICourse>().CourseSingle(couid);
     if (cou == null)
     {
         return;
     }
     //课程名称
     lbName.Text = cou.Cou_Name;
     //是否免费
     cbIsFree.Checked = cou.Cou_IsFree;
     Cou_IsFree_CheckedChanged(null, null);
     //是否允许试用
     cbIsTry.Checked = cou.Cou_IsTry;
     ////每个章节,试用的试题数
     //tbTryNum.Text = cou.Cou_TryNum > 0 ? cou.Cou_TryNum.ToString() : "";
     //全局UID
     ViewState["UID"] = string.IsNullOrWhiteSpace(cou.Cou_UID) ? getUID() : cou.Cou_UID;
     Song.Entities.CoursePrice[] prices = Business.Do <ICourse>().PriceCount(0, cou.Cou_UID, null, -1);
     gvPrice.DataSource   = prices;
     gvPrice.DataKeyNames = new string[] { "CP_ID" };
     gvPrice.DataBind();
 }
Beispiel #13
0
        /// <summary>
        /// 保存当前课程
        /// </summary>
        /// <returns></returns>
        private Song.Entities.Course Save()
        {
            Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(couid);
            if (cou == null)
            {
                return(null);
            }
            //是否免费,是否试用,以及试题数
            cou.Cou_IsFree = cbIsFree.Checked;
            cou.Cou_IsTry  = cbIsTry.Checked;
            int tryNum = 0;

            int.TryParse(tbTryNum.Text, out tryNum);
            cou.Cou_TryNum = tryNum;
            try
            {
                Business.Do <ICourse>().CourseSave(cou);
            }
            catch
            {
                throw;
            }
            return(cou);
        }
Beispiel #14
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //服务器端时间
            string time = new WeiSha.Common.Param.Method.ConvertToAnyValue(DateTime.Now.ToString()).JavascriptTime;

            this.Document.Variables.SetValue("Time", time);
            //当前试卷
            Song.Entities.TestPaper paper = null;
            paper = Business.Do <ITestPaper>().PagerSingle(tpid);
            if (paper != null)
            {
                paper.Tp_Logo = string.IsNullOrWhiteSpace(paper.Tp_Logo) ? paper.Tp_Logo : Upload.Get["TestPaper"].Virtual + paper.Tp_Logo;
                //判断Logo是否存在
                string hylogo = WeiSha.Common.Server.MapPath(paper.Tp_Logo);
                if (!System.IO.File.Exists(hylogo))
                {
                    paper.Tp_Logo = string.Empty;
                }
                this.Document.SetValue("pager", paper);
                //试卷所属课程
                Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(paper.Cou_ID);
                this.Document.SetValue("course", course);
            }
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前选中的课程
            Song.Entities.Course currCourse = Extend.LoginState.Accounts.Course();
            this.Document.SetValue("currCourse", currCourse);
            //微信登录
            this.Document.SetValue("WeixinLoginIsUse", Business.Do <ISystemPara>()["WeixinLoginIsUse"].Boolean ?? false);

            //已经购买的课程
            int stid = this.Account != null ? this.Account.Ac_ID : 0;

            if (stid > 0)
            {
                //新闻列表
                Tag tag   = this.Document.GetChildTagById("buyCou");
                int count = int.Parse(tag.Attributes.GetValue("count", "3"));
                List <Song.Entities.Course> buyCou = Business.Do <ICourse>().CourseForStudent(stid, null, 1, false, count);
                for (int i = 0; i < buyCou.Count; i++)
                {
                    buyCou[i].Cou_Intro = string.Empty;
                }
                this.Document.SetValue("buyCou", buyCou);
            }
        }
Beispiel #16
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            if (course == null || !course.Cou_IsUse)
            {
                return;
            }
            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            this.Document.Variables.SetValue("course", course);
            //是否学习当前课程,如果没有学习且课程处于免费,则创建关联
            if (this.Account != null)
            {
                isStudy = Business.Do <ICourse>().Study(course.Cou_ID, this.Account.Ac_ID);
                isBuy   = course.Cou_IsFree || course.Cou_IsLimitFree ? true : Business.Do <ICourse>().IsBuy(course.Cou_ID, this.Account.Ac_ID);
            }
            this.Document.Variables.SetValue("isStudy", isStudy);
            this.Document.Variables.SetValue("isBuy", isBuy);
            //记录学员当前学习的课程
            if (isStudy)
            {
                Extend.LoginState.Accounts.Course(course);
            }
            //当前章节
            Song.Entities.Outline ol = olid < 1 ?
                                       Business.Do <IOutline>().OutlineFirst(couid, true)
                : Business.Do <IOutline>().OutlineSingle(olid);
            if (ol == null)
            {
                return;
            }
            this.Document.Variables.SetValue("outline", ol);
            this.Document.Variables.SetValue("olid", ol.Ol_ID.ToString());
            //入写章节id的cookie,当播放视频时会判断此处
            Response.Cookies.Add(new HttpCookie("olid", ol.Ol_ID.ToString()));
            //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
            bool canStudy = isBuy || (isStudy && ol.Ol_IsUse && ol.Ol_IsFinish && course.Cou_IsTry && ol.Ol_IsFree);

            this.Document.Variables.SetValue("canStudy", canStudy);

            #region 章节输出
            // 当前课程的所有章节
            Song.Entities.Outline[] outlines = Business.Do <IOutline>().OutlineAll(ol.Cou_ID, true);
            //课程章节列表
            this.Document.Variables.SetValue("outlines", outlines);
            //树形章节输出
            if (outlines.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outlines));
            }
            #endregion

            //视频
            Song.Entities.Accessory video = Song.Site.CourseStudy.getVideo(ol.Ol_UID);
            this.Document.Variables.SetValue("video", video);
            if (Extend.LoginState.Accounts.IsLogin)
            {
                Song.Entities.LogForStudentStudy studyLog = Business.Do <IStudent>().LogForStudySingle(this.Account.Ac_ID, ol.Ol_ID);
                if (studyLog != null)
                {
                    this.Document.Variables.SetValue("studyLog", studyLog);
                    double historyPlay = (double)studyLog.Lss_PlayTime / 1000;
                    this.Document.Variables.SetValue("historyPlay", historyPlay);
                }
            }
            //附件
            List <Song.Entities.Accessory> access = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "Course");
            if (access.Count > 0)
            {
                foreach (Accessory ac in access)
                {
                    ac.As_FileName = Upload.Get["Course"].Virtual + ac.As_FileName;
                }
                this.Document.Variables.SetValue("access", access);
            }
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前章节,如果章节id,则取课程第一个章节
            Song.Entities.Outline ol = id < 1 ?
                                       Business.Do <IOutline>().OutlineFirst(couid, true)
                : Business.Do <IOutline>().OutlineSingle(id);
            couid = couid > 0 ? couid : (ol != null ? ol.Cou_ID : 0);
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            if (course == null || !course.Cou_IsUse)
            {
                return;
            }
            this.Document.Variables.SetValue("course", course);
            //如果章节为空,则不再后面的了
            if (ol == null)
            {
                return;
            }
            this.Document.Variables.SetValue("outline", ol);
            this.Document.Variables.SetValue("olid", ol.Ol_ID.ToString());
            //上级章节
            this.Document.Variables.SetValue("pat", Business.Do <IOutline>().OutlineSingle(ol.Ol_PID));
            Response.Cookies.Add(new HttpCookie("olid", ol.Ol_ID.ToString()));
            //当前课程
            //Song.Entities.Course course = Business.Do<ICourse>().CourseSingle(couid >0 ? couid : ol.Cou_ID);
            //if (course == null || !course.Cou_IsUse) return;
            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            this.Document.Variables.SetValue("course", course);
            //判断是否允许在桌面应用中学习
            this.Document.Variables.SetValue("StudyForDeskapp", getForDeskapp(course, ol));
            //是否学习当前课程,如果没有学习且课程处于免费,则创建关联
            if (this.Account != null)
            {
                isStudy = Business.Do <ICourse>().Study(course.Cou_ID, this.Account.Ac_ID);
                isBuy   = course.Cou_IsFree || course.Cou_IsLimitFree ? true : Business.Do <ICourse>().IsBuy(course.Cou_ID, this.Account.Ac_ID);
            }
            this.Document.Variables.SetValue("isStudy", isStudy);
            this.Document.Variables.SetValue("isBuy", isBuy);
            //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
            bool canStudy = isBuy || (isStudy && ol.Ol_IsUse && ol.Ol_IsFinish && course.Cou_IsTry && ol.Ol_IsFree);

            this.Document.Variables.SetValue("canStudy", canStudy);
            //记录学员当前学习的课程
            if (isStudy)
            {
                Extend.LoginState.Accounts.Course(course);
            }

            #region 章节输出
            // 当前课程的所有章节
            Song.Entities.Outline[] outlines = Business.Do <IOutline>().OutlineAll(ol.Cou_ID, true);
            //课程章节列表
            this.Document.Variables.SetValue("outlines", outlines);
            //树形章节输出
            if (outlines.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outlines));
            }
            #endregion

            #region 内容输出
            CourseContext_State state = new CourseContext_State();
            //视频
            Song.Entities.Accessory video = getVideo(ol.Ol_UID);
            this.Document.Variables.SetValue("video", video);
            if (video != null)
            {
                state.Video = canStudy ? true : false;
            }
            if (Extend.LoginState.Accounts.IsLogin)
            {
                Song.Entities.LogForStudentStudy studyLog = Business.Do <IStudent>().LogForStudySingle(this.Account.Ac_ID, ol.Ol_ID);
                if (studyLog != null)
                {
                    this.Document.Variables.SetValue("studyLog", studyLog);
                    double historyPlay = (double)studyLog.Lss_PlayTime / 1000;
                    this.Document.Variables.SetValue("historyPlay", historyPlay);
                }
            }
            //内容
            if (!string.IsNullOrWhiteSpace(ol.Ol_Intro))
            {
                state.Context = canStudy ? true : false;
            }
            //附件
            List <Song.Entities.Accessory> access = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "Course");
            if (access.Count > 0)
            {
                foreach (Accessory ac in access)
                {
                    ac.As_FileName = Upload.Get["Course"].Virtual + ac.As_FileName;
                }
                this.Document.Variables.SetValue("access", access);
                state.Attachment = canStudy ? true : false;
            }
            //当前章节是否有试题
            if (canStudy)
            {
                bool isQues = Business.Do <IOutline>().OutlineIsQues(ol.Ol_ID, true);
                if (isQues)
                {
                    state.Questions = canStudy ? true : false;
                }
                ;
            }
            state.JudgeNull(stateVal);
            this.Document.Variables.SetValue("state", state);
            #endregion

            //章节事件
            OutlineEvent[] events = Business.Do <IOutline>().EventAll(-1, ol.Ol_ID, -1, true);
            this.Document.Variables.SetValue("events", events);
            this.Document.RegisterGlobalFunction(this.getEventQues);
            this.Document.RegisterGlobalFunction(this.getEventFeedback);
            this.Document.RegisterGlobalFunction(this.GetOrder);
        }
Beispiel #18
0
        protected override void InitPageTemplate(HttpContext context)
        {
            this.Document.Variables.SetValue("couid", couid);
            if (Request.ServerVariables["REQUEST_METHOD"] == "GET")
            {
                Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
                if (course == null)
                {
                    return;
                }
                this.Document.Variables.SetValue("course", course);
                //是否学习当前课程
                if (this.Account != null)
                {
                    //是否购买当前课程
                    bool isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, course.Cou_ID);
                    this.Document.Variables.SetValue("isBuy", isBuy);
                    //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
                    bool canStudy = isBuy || course.Cou_IsFree || course.Cou_IsLimitFree;
                    this.Document.Variables.SetValue("canStudy", canStudy);
                }
                //知识库栏目
                Song.Entities.KnowledgeSort[] kns = Business.Do <IKnowledge>().GetSortAll(-1, couid, -1, true);
                DataTable dt = WeiSha.WebControl.Tree.ObjectArrayToDataTable.To(kns);
                WeiSha.WebControl.Tree.DataTableTree tree = new WeiSha.WebControl.Tree.DataTableTree();
                tree.IdKeyName       = "Kns_ID";
                tree.ParentIdKeyName = "Kns_PID";
                tree.TaxKeyName      = "Kns_Tax";
                tree.Root            = 0;
                dt = tree.BuilderTree(dt);
                this.Document.Variables.SetValue("kns", dt);
                this.Document.Variables.SetValue("couid", couid);
                //当前知识库栏目
                int sorts = WeiSha.Common.Request.QueryString["sorts"].Int32 ?? 0;  //栏目分类id
                Song.Entities.KnowledgeSort sort = Business.Do <IKnowledge>().SortSingle(sorts);
                this.Document.Variables.SetValue("sort", sort);
            }
            //此页面的ajax提交,全部采用了POST方式
            if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                int    size   = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条
                int    index  = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页
                string sorts  = WeiSha.Common.Request.Form["sorts"].String;     //栏目分类id
                string search = WeiSha.Common.Request.Form["sear"].String;      //要检索的字符

                int sumcount = 0;
                //信息列表
                Song.Entities.Knowledge[] kls = null;
                kls = Business.Do <IKnowledge>().KnowledgePager(couid, sorts, search, size, index, out sumcount);
                string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ",";
                json += "\"items\":[";
                for (int n = 0; n < kls.Length; n++)
                {
                    json += kls[n].ToJson("Kn_ID,Kn_Title", "Kn_Details") + ",";
                }
                if (json.EndsWith(","))
                {
                    json = json.Substring(0, json.Length - 1);
                }
                json += "]}";
                Response.Write(json);
                Response.End();
            }
        }
Beispiel #19
0
 /// <summary>
 /// 保存按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     Song.Entities.Course cou = this.Save();
     this.Alert("操作成功");
 }
 /// <summary>
 /// 将某一行数据加入到数据库
 /// </summary>
 /// <param name="dr"></param>
 /// <param name="dl"></param>
 private void _inputData(DataRow dr)
 {
     Song.Entities.Questions obj = new Song.Entities.Questions();
     obj.Qus_IsUse = true;
     obj.Qus_Type  = this.type;
     foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
     {
         //Excel的列的值
         string column = dr[rel.Key].ToString();
         //数据库字段的名称
         string field = rel.Value;
         if (field == "Qus_ID")
         {
             if (string.IsNullOrEmpty(column) || column.Trim() == "")
             {
                 continue;
             }
             int ques = Convert.ToInt32(column);
             Song.Entities.Questions isHavObj = Business.Do <IQuestions>().QuesSingle(ques);
             if (isHavObj != null)
             {
                 obj = isHavObj;
             }
         }
         //题干难度、专业、试题讲解
         if (field == "Qus_Title")
         {
             if (column == string.Empty || column.Trim() == "")
             {
                 return;
             }
             obj.Qus_Title = column;
         }
         if (field == "Qus_Diff")
         {
             obj.Qus_Diff = Convert.ToInt16(column);
         }
         if (field == "Sbj_Name")
         {
             Song.Entities.Subject subject = Business.Do <ISubject>().SubjectBatchAdd(org.Org_ID, column);
             if (subject != null)
             {
                 obj.Sbj_Name = subject.Sbj_Name;
                 obj.Sbj_ID   = subject.Sbj_ID;
             }
         }
         if (field == "Cou_Name")
         {
             Song.Entities.Course course = Business.Do <ICourse>().CourseBatchAdd(org.Org_ID, obj.Sbj_ID, column);
             if (course != null)
             {
                 obj.Cou_ID = course.Cou_ID;
             }
         }
         if (field == "Ol_Name")
         {
             Song.Entities.Outline outline = Business.Do <IOutline>().OutlineBatchAdd(org.Org_ID, obj.Sbj_ID, obj.Cou_ID, column);
             if (outline != null)
             {
                 obj.Ol_ID = outline.Ol_ID;
             }
         }
         if (field == "Qus_Explain")
         {
             obj.Qus_Explain = column;
         }
         //唯一值,正确答案,类型
         obj.Qus_UID = WeiSha.Common.Request.UniqueID();
         if (field == "Qus_Answer")
         {
             if (column == string.Empty || column.Trim() == "")
             {
                 obj.Qus_IsError = true;
             }
             obj.Qus_Answer = column;
         }
     }
     obj.Qus_ErrorInfo = "";
     if (obj.Sbj_ID == 0)
     {
         throw new Exception("当前试题所属专业并不存在");
     }
     if (obj.Cou_ID == 0)
     {
         throw new Exception("当前试题所在课程并不存在");
     }
     //if (obj.Ol_ID == 0) throw new Exception("当前试题所在章节并不存在");
     if (org != null)
     {
         obj.Org_ID = org.Org_ID;
     }
     Business.Do <IQuestions>().QuesInput(obj, null);
 }
Beispiel #21
0
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            Song.Entities.Outline ol = id < 1 ? new Song.Entities.Outline() : Business.Do <IOutline>().OutlineSingle(id);
            try
            {
                if (ol == null)
                {
                    return;
                }
                //名称
                if (string.IsNullOrWhiteSpace(Ol_Name.Text.Trim()))
                {
                    throw new Exception("名称不可以为空");
                }
                ol.Ol_Name = Ol_Name.Text.Trim();
                //简介
                ol.Ol_Intro = Ol_Intro.Text;
                //上级章节
                int pid = 0;
                int.TryParse(ddlOutline.SelectedValue, out pid);
                ol.Ol_PID = pid;

                ol.Ol_IsUse    = cbIsUse.Checked;    //是否启用
                ol.Ol_IsFree   = cbIsFree.Checked;   //免费
                ol.Ol_IsFinish = cbIsFinish.Checked; //完结
                //所属课程
                ol.Cou_ID = couid;
                Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(couid);
                if (cou != null)
                {
                    ol.Sbj_ID = cou.Sbj_ID;
                }
                //是否为直播
                ol.Ol_IsLive = cbIsLive.Checked;
                DateTime timeLive = DateTime.Now; //直播开始时间
                DateTime.TryParse(tbLiveTime.Text, out timeLive);
                ol.Ol_LiveTime = timeLive;        //
                int liveSpan = 0;                 //直播计划时长
                int.TryParse(tbLiveSpan.Text, out liveSpan);
                ol.Ol_LiveSpan = liveSpan;
                //排序号
                int tax = 0;
                if (Ol_Tax.Text.Trim() != "")
                {
                    int.TryParse(Ol_Tax.Text, out tax);
                    ol.Ol_Tax = tax;
                }
                ////全局唯一ID
                //ol.Ol_UID = getUID();
                try
                {
                    if (id < 1)
                    {
                        //新增
                        Business.Do <IOutline>().OutlineAdd(ol);
                    }
                    else
                    {
                        Business.Do <IOutline>().OutlineSave(ol);
                    }
                    Master.AlertCloseAndRefresh("操作完成");
                }
                catch
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                Alert(ex.Message);
            }
        }
Beispiel #22
0
        /// <summary>
        /// 将某一行数据加入到数据库
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="dl"></param>
        private void _inputData(DataRow dr)
        {
            Song.Entities.Questions obj = new Song.Entities.Questions();
            obj.Qus_IsUse = true;
            obj.Qus_Type  = this.type;
            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //Excel的列的值
                string column = dr[rel.Key].ToString();
                //数据库字段的名称
                string field = rel.Value;
                if (field == "Qus_ID")
                {
                    if (column == string.Empty || column.Trim() == "")
                    {
                        continue;
                    }
                    int ques = Convert.ToInt32(column);
                    Song.Entities.Questions isHavObj = Business.Do <IQuestions>().QuesSingle(ques);
                    if (isHavObj != null)
                    {
                        obj = isHavObj;
                    }
                }
                //题干难度、专业、试题讲解
                if (field == "Qus_Title")
                {
                    if (string.IsNullOrEmpty(column) || column.Trim() == "")
                    {
                        return;
                    }
                    obj.Qus_Title = column;
                }
                if (field == "Qus_Diff")
                {
                    obj.Qus_Diff = Convert.ToInt16(column);
                }
                if (field == "Sbj_Name")
                {
                    Song.Entities.Subject subject = Business.Do <ISubject>().SubjectBatchAdd(org.Org_ID, column);
                    if (subject != null)
                    {
                        obj.Sbj_Name = subject.Sbj_Name;
                        obj.Sbj_ID   = subject.Sbj_ID;
                    }
                }
                if (field == "Cou_Name")
                {
                    Song.Entities.Course course = Business.Do <ICourse>().CourseBatchAdd(org.Org_ID, obj.Sbj_ID, column);
                    if (course != null)
                    {
                        obj.Cou_ID = course.Cou_ID;
                    }
                }
                if (field == "Ol_Name")
                {
                    Song.Entities.Outline outline = Business.Do <IOutline>().OutlineBatchAdd(org.Org_ID, obj.Sbj_ID, obj.Cou_ID, column);
                    if (outline != null)
                    {
                        obj.Ol_ID = outline.Ol_ID;
                    }
                }
                if (field == "Qus_Explain")
                {
                    obj.Qus_Explain = column;
                }
                //唯一值
                obj.Qus_UID = WeiSha.Common.Request.UniqueID();
            }
            //再遍历一遍,取答案
            int ansNum = 0;
            List <Song.Entities.QuesAnswer> ansItem = new List <QuesAnswer>();

            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //数据库字段的名称
                string field = rel.Value;
                Match  match = new Regex(@"(Ans_Context)(\d+)").Match(field);
                if (match.Success)
                {
                    //Excel的列的值
                    string column = dr[rel.Key].ToString();
                    if (column == string.Empty || column.Trim() == "")
                    {
                        continue;
                    }
                    Song.Entities.QuesAnswer ans = new Song.Entities.QuesAnswer();
                    ans.Ans_Context = column;
                    ans.Qus_UID     = obj.Qus_UID;
                    ansNum++;
                    ansItem.Add(ans);
                }
            }
            obj.Qus_Title = tranTxt(obj.Qus_Title);
            int bracketsCount = new Regex(@"([^)]+)").Matches(obj.Qus_Title).Count;
            //判断是否有错
            string error = "";

            if (bracketsCount <= 0)
            {
                error = "试题中缺少填空项!(填空项用括号标识)";
            }
            if (ansNum <= 0)
            {
                error = "缺少答案项";
            }
            if (ansNum < bracketsCount)
            {
                error = string.Format("答案项少于填空项;填空项{0}个,答案{1}个", bracketsCount, ansNum);
            }
            //
            obj.Qus_IsError   = error != "";
            obj.Qus_ErrorInfo = error;
            if (obj.Sbj_ID == 0)
            {
                throw new Exception("当前试题所属专业并不存在");
            }
            if (obj.Cou_ID == 0)
            {
                throw new Exception("当前试题所在课程并不存在");
            }
            //if (obj.Ol_ID == 0) throw new Exception("当前试题所在章节并不存在");
            if (org != null)
            {
                obj.Org_ID = org.Org_ID;
            }
            Business.Do <IQuestions>().QuesInput(obj, ansItem);
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //if (!Extend.LoginState.Accounts.IsLogin || this.Account==null)
            //    context.Response.Redirect(WeiSha.Common.Login.Get["Accounts"].NoLoginPath.String);
            //自定义配置项
            Song.Entities.Organization org    = Business.Do <IOrganization>().OrganCurrent();
            WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
            //
            //取当前章节
            ol = id < 1 ? Business.Do <IOutline>().OutlineFirst(couid, true)
                       : ol = Business.Do <IOutline>().OutlineSingle(id);
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(ol == null ? couid : ol.Cou_ID);
            if (course == null)
            {
                return;
            }
            #region 创建与学员的关联
            if (this.Account != null)
            {
                int  accid  = this.Account.Ac_ID;
                bool istudy = Business.Do <ICourse>().Study(course.Cou_ID, accid);
            }
            #endregion

            #region 章节输出

            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            this.Document.Variables.SetValue("course", course);
            Extend.LoginState.Accounts.Course(course);
            if (ol == null)
            {
                return;
            }
            //
            couid = ol.Cou_ID;
            id    = ol.Ol_ID;
            //入写章节id的cookie,当播放视频时会判断此处
            Response.Cookies.Add(new HttpCookie("olid", id.ToString()));
            outlines = Business.Do <IOutline>().OutlineAll(ol.Cou_ID, true);
            //是否学习当前课程
            if (course == null || this.Account == null)
            {
                isStudy = false;
            }
            else
            {
                isStudy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, course.Cou_ID);
            }
            this.Document.Variables.SetValue("isStudy", isStudy);
            //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
            bool canStudy = isStudy || course.Cou_IsFree || course.Cou_IsLimitFree ? true : (course.Cou_IsTry && ol.Ol_IsFree);
            canStudy = canStudy && ol.Ol_IsUse && ol.Ol_IsFinish && this.Account != null;
            this.Document.Variables.SetValue("canStudy", canStudy);
            //课程章节列表
            this.Document.Variables.SetValue("outlines", outlines);
            //树形章节输出
            if (outlines.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outlines));
            }
            this.Document.Variables.SetValue("outline", ol);
            #endregion
            //视频
            List <Song.Entities.Accessory> videos = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "CourseVideo");
            if (videos.Count > 0)
            {
                if (videos[0].As_IsOuter)
                {
                    //如果是外部链接
                    this.Document.Variables.SetValue("video", videos[0]);
                }
                else
                {
                    //如果是内部链接
                    videos[0].As_FileName = Upload.Get[videos[0].As_Type].Virtual + videos[0].As_FileName;
                    try
                    {
                        string fileHy = Server.MapPath(videos[0].As_FileName);
                        if (!System.IO.File.Exists(fileHy))
                        {
                            string ext = System.IO.Path.GetExtension(fileHy).ToLower();
                            if (ext == ".mp4")
                            {
                                videos[0].As_FileName = Path.ChangeExtension(videos[0].As_FileName, ".flv");
                            }
                            if (ext == ".flv")
                            {
                                videos[0].As_FileName = Path.ChangeExtension(videos[0].As_FileName, ".mp4");
                            }
                        }
                        this.Document.Variables.SetValue("video", videos[0]);
                        if (Extend.LoginState.Accounts.IsLogin)
                        {
                            Song.Entities.LogForStudentStudy studyLog = Business.Do <IStudent>().LogForStudySingle(this.Account.Ac_ID, ol.Ol_ID);
                            if (studyLog != null)
                            {
                                this.Document.Variables.SetValue("studyLog", studyLog);
                                double historyPlay = (double)studyLog.Lss_PlayTime / 1000;
                                this.Document.Variables.SetValue("historyPlay", historyPlay);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                this.Document.Variables.SetValue("IsVideoNoload", config["IsVideoNoload"].Value.Boolean ?? false);
                state = state < 1 ? 1 : state;
            }
            //内容
            if (!string.IsNullOrWhiteSpace(ol.Ol_Intro))
            {
                state = state < 1 ? 2 : state;
            }
            //上级章节
            if (ol != null)
            {
                Song.Entities.Outline pat = Business.Do <IOutline>().OutlineSingle(ol.Ol_PID);
                this.Document.Variables.SetValue("pat", pat);
            }
            //附件
            List <Song.Entities.Accessory> access = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "Course");
            if (access.Count > 0)
            {
                foreach (Accessory ac in access)
                {
                    ac.As_FileName = Upload.Get["Course"].Virtual + ac.As_FileName;
                }
                this.Document.Variables.SetValue("access", access);
                state = state < 1 ? 3 : state;
            }
            //当前章节是否有试题
            if (canStudy)
            {
                bool isQues = Business.Do <IOutline>().OutlineIsQues(ol.Ol_ID, true);
                this.Document.Variables.SetValue("isQues", isQues);
                if (isQues)
                {
                    state = state < 1 ? 4 : state;
                }
            }
            else
            {
                state = 0;
            }

            //章节事件
            OutlineEvent[] events = Business.Do <IOutline>().EventAll(-1, ol.Ol_ID, -1, true);
            this.Document.Variables.SetValue("events", events);
            this.Document.RegisterGlobalFunction(this.getEventQues);
            this.Document.RegisterGlobalFunction(this.getEventFeedback);
            this.Document.RegisterGlobalFunction(this.GetOrder);
            //状态
            this.Document.Variables.SetValue("state", state);
            this.Document.Variables.SetValue("olid", id);
        }
Beispiel #24
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前课程信息
            int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0;

            Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id);
            if (cou == null || !cou.Cou_IsUse)
            {
                return;
            }
            if (cou != null)
            {
                if ((WeiSha.Common.Request.Cookies["Course_" + cou.Cou_ID].Int32 ?? 0) == 0)
                {
                    Business.Do <ICourse>().CourseViewNum(cou, 1);
                    context.Response.Cookies["Course_" + cou.Cou_ID].Value = cou.Cou_ID.ToString();
                }
                //图片路径
                cou.Cou_Logo = string.IsNullOrWhiteSpace(cou.Cou_Logo) ? "" : Upload.Get["Course"].Virtual + cou.Cou_Logo;
                if (!System.IO.File.Exists(WeiSha.Common.Server.MapPath(cou.Cou_Logo)))
                {
                    cou.Cou_Logo = "";
                }
                cou.Cou_LogoSmall = string.IsNullOrWhiteSpace(cou.Cou_LogoSmall) ? "" : Upload.Get["Course"].Virtual + cou.Cou_LogoSmall;
                if (!System.IO.File.Exists(WeiSha.Common.Server.MapPath(cou.Cou_LogoSmall)))
                {
                    cou.Cou_LogoSmall = "";
                }
                //是否免费,或是限时免费
                if (cou.Cou_IsLimitFree)
                {
                    DateTime freeEnd = cou.Cou_FreeEnd.AddDays(1).Date;
                    if (!(cou.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                    {
                        cou.Cou_IsLimitFree = false;
                    }
                }
                this.Document.Variables.SetValue("course", cou);
            }
            //是否学习当前课程
            if (this.Account != null)
            {
                //是否购买
                isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID);
                this.Document.Variables.SetValue("isStudy", isBuy);
            }
            //课程章节列表
            outline = Business.Do <IOutline>().OutlineAll(cou.Cou_ID, true);
            this.Document.Variables.SetValue("Outline", outline);
            //树形章节输出
            if (outline.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outline));
            }
            //课程公告
            Song.Entities.Guide[] guides = Business.Do <IGuide>().GuideCount(-1, cou.Cou_ID, -1, 20);
            this.Document.Variables.SetValue("guides", guides);
            //当前课程的主讲老师
            Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(cou.Th_ID);
            if (teacher != null)
            {
                teacher.Th_Photo = Upload.Get["Teacher"].Virtual + teacher.Th_Photo;
                this.Document.Variables.SetValue("th", teacher);
            }
            //上级专业
            List <Subject> sbjs = Business.Do <ISubject>().Parents(cou.Sbj_ID, true);

            this.Document.Variables.SetValue("parentsbjs", sbjs);
            //当前课程的学员
            Tag stTag = this.Document.GetChildTagById("students");

            if (stTag != null)
            {
                int count = int.Parse(stTag.Attributes.GetValue("count", "5"));
                Song.Entities.Accounts[] eas = null;
                eas = Business.Do <ICourse>().Student4Course(cou.Cou_ID, null, null, count, 1, out count);
                this.Document.SetValue("students", eas);
            }
        }
Beispiel #25
0
 /// <summary>
 /// 下一步
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNext_Click(object sender, EventArgs e)
 {
     Song.Entities.Course cou = this.Save();
 }
Beispiel #26
0
        /// <summary>
        /// 填充数据
        /// </summary>
        private void fill()
        {
            Song.Entities.TestPaper mm;
            if (id != 0)
            {
                mm = Business.Do <ITestPaper>().PagerSingle(id);
                cbIsUse.Checked  = mm.Tp_IsUse; //是否使用
                cbIsRec.Checked  = mm.Tp_IsRec; //是否推荐
                ViewState["UID"] = mm.Tp_UID;   //唯一标识
                //所属专业
                ListItem liSubj = ddlSubject.Items.FindByValue(mm.Sbj_ID.ToString());
                if (liSubj != null)
                {
                    ddlSubject.SelectedIndex = -1;
                    liSubj.Selected          = true;
                    ddlSubject_SelectedIndexChanged(null, null);
                }
                //所属课程
                ListItem liCous = this.ddlCourse.Items.FindByValue(mm.Cou_ID.ToString());
                if (liCous != null)
                {
                    ddlCourse.SelectedIndex = -1;
                    liCous.Selected         = true;
                    ddlCourse_SelectedIndexChanged(null, null);
                }
                //难度
                ListItem liDiff = ddlDiff.Items.FindByValue(mm.Tp_Diff2.ToString());
                if (liDiff != null)
                {
                    ddlDiff.SelectedIndex = -1;
                    liDiff.Selected       = true;
                }
                //时长,总分,及格分
                tbSpan.Text       = mm.Tp_Span.ToString();
                tbTotal.Text      = mm.Tp_Total.ToString();
                tbPassScore_.Text = mm.Tp_PassScore.ToString();
            }
            else
            {
                //如果是新增
                mm = new Song.Entities.TestPaper();
                ViewState["UID"] = WeiSha.Common.Request.UniqueID();
                //当处在课程管理中时
                if (couid > 0)
                {
                    Song.Entities.Course cour = Business.Do <ICourse>().CourseSingle(couid);
                    if (cour != null)
                    {
                        //所属专业
                        ListItem liSubj = ddlSubject.Items.FindByValue(cour.Sbj_ID.ToString());
                        if (liSubj != null)
                        {
                            ddlSubject.SelectedIndex = -1;
                            liSubj.Selected          = true;
                            ddlSubject_SelectedIndexChanged(null, null);
                        }
                        //所属课程
                        ListItem liCous = this.ddlCourse.Items.FindByValue(cour.Cou_ID.ToString());
                        if (liCous != null)
                        {
                            ddlCourse.SelectedIndex = -1;
                            liCous.Selected         = true;
                        }
                    }
                }
                ddlCourse_SelectedIndexChanged(null, null);
            }
            tbName.Text    = mm.Tp_Name;    //标题
            tbSubName.Text = mm.Tp_SubName; //副标题
            tbAuthor.Text  = mm.Tp_Author;  //出卷人
            tbIntro.Text   = mm.Tp_Intro;   //试卷简介
            tbRemind.Text  = mm.Tp_Remind;  //注意事项
            //试卷Logo图片
            if (!string.IsNullOrEmpty(mm.Tp_Logo) && mm.Tp_Logo.Trim() != "")
            {
                this.imgShow.Src = Upload.Get[_uppath].Virtual + mm.Tp_Logo;
            }
            //试题范围
            ListItem liFrom = this.rblFromType.Items.FindByValue(mm.Tp_FromType.ToString());

            if (liFrom != null)
            {
                rblFromType.SelectedIndex = -1;
                liFrom.Selected           = true;
            }
            //各项题型分值
            _fillItemForAll(mm);     //按课程出题
            _fileItemForOutline(mm); //按章节出题
        }
Beispiel #27
0
        /// <summary>
        /// 章节的状态
        /// </summary>
        /// <param name="olid"></param>
        /// <returns></returns>
        public Dictionary <string, object> State(int olid)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            Song.Entities.Accounts acc = Extend.LoginState.Accounts.CurrentUser;
            dic.Add("isLogin", acc != null);    //学员是否登录
            //
            Song.Entities.Outline outline = Business.Do <IOutline>().OutlineSingle(olid);
            if (outline == null)
            {
                throw new Exception("章节不存在");
            }
            dic.Add("Name", outline.Ol_Name);
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(outline.Cou_ID);
            if (course == null)
            {
                throw new Exception("课程不存在");
            }
            dic.Add("Course", course.Cou_Name);
            Song.Entities.Organization orgin;
            //是否限制在桌面应用中打开
            dic.Add("DeskAllow", this.getDeskallow(course, outline, out orgin));
            //是否在切换浏览器时继续播放
            dic.Add("SwitchPlay", this.getSwitchPlay(course, acc, orgin));
            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            //是否可以学习,是否购买
            bool isStudy = false, isBuy = false, canStudy = false;

            if (acc != null)
            {
                isStudy = Business.Do <ICourse>().Study(course.Cou_ID, acc.Ac_ID);
                isBuy   = course.Cou_IsFree || course.Cou_IsLimitFree ? true : Business.Do <ICourse>().IsBuy(course.Cou_ID, acc.Ac_ID);
                //学习记录
                Song.Entities.LogForStudentStudy studyLog = Business.Do <IStudent>().LogForStudySingle(acc.Ac_ID, outline.Ol_ID);
                dic.Add("StudyTime", studyLog != null ? studyLog.Lss_StudyTime : 0);
                dic.Add("PlayTime", studyLog != null ? studyLog.Lss_PlayTime : 0);
            }
            dic.Add("isStudy", isStudy);
            dic.Add("isBuy", isBuy);
            //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
            canStudy = isBuy || (isStudy && outline.Ol_IsUse && outline.Ol_IsFinish && course.Cou_IsTry && outline.Ol_IsFree);
            dic.Add("canStudy", canStudy);
            //是否有知识库
            int knlCount = Business.Do <IKnowledge>().KnowledgeOfCount(-1, course.Cou_ID, -1, true);

            dic.Add("isKnl", knlCount > 0 && canStudy);

            //是否有视频,是否为外链视频

            List <Song.Entities.Accessory> videos = Business.Do <IAccessory>().GetAll(outline.Ol_UID, "CourseVideo");
            bool existVideo = videos.Count > 0;

            dic.Add("outerVideo", existVideo && (videos.Count > 0 && videos[0].As_IsOuter));    //站外视频,包括其它网站的视频,或是视频播放链接
            dic.Add("otherVideo", existVideo && (videos.Count > 0 && videos[0].As_IsOther));    //其它视频平台的链接
            if (videos.Count > 0)
            {
                string videoUrl = existVideo ? videos[0].As_FileName : string.Empty; //视频地址
                //如果是内部链接
                if (existVideo && !videos[0].As_IsOuter)
                {
                    videoUrl = Upload.Get[videos[0].As_Type].Virtual + videoUrl;
                    string ext = System.IO.Path.GetExtension(videoUrl).ToLower();
                    if (ext == ".flv")
                    {
                        videoUrl = Path.ChangeExtension(videoUrl, ".mp4");
                    }
                }
                dic.Add("urlVideo", canStudy ? videoUrl : string.Empty);
                outline.Ol_IsLive = false;
            }
            //直播
            bool isLive = outline.Ol_IsLive, isLiving = false;

            if (outline.Ol_IsLive)
            {
                string urlVideo = string.Empty;
                if (canStudy)
                {
                    //查询直播状态
                    pili_sdk.pili.StreamStatus status = Pili.API <IStream>().Status(outline.Ol_LiveID);
                    if (status != null)
                    {
                        pili_sdk.pili.Stream stream = status.Stream;
                        string proto = Business.Do <ILive>().GetProtocol; //协议,http还是https
                        urlVideo   = string.Format("{0}://{1}/{2}/{3}.m3u8", proto, stream.LiveHlsHost, stream.HubName, stream.Title);
                        isLiving   = status.Status == "connected";        //正在直播
                        existVideo = isLiving ? false : existVideo;
                    }
                }
                //直播播放地址
                if (!dic.ContainsKey("urlVideo"))
                {
                    dic.Add("urlVideo", urlVideo);
                }
                //直播开始或结束
                dic.Add("LiveStart", DateTime.Now > outline.Ol_LiveTime);
                dic.Add("LiveOver", outline.Ol_LiveTime.AddMinutes(outline.Ol_LiveSpan) < DateTime.Now);
            }
            dic.Add("isLive", outline.Ol_IsLive);      //是否为直播章节
            dic.Add("isLiving", isLiving && canStudy); //是否在直播中
            dic.Add("existVideo", existVideo && canStudy);

            //是否有课程内容
            bool isContext = !string.IsNullOrWhiteSpace(outline.Ol_Intro);

            dic.Add("isContext", isContext && canStudy);
            //是否有试题
            bool isQues = Business.Do <IOutline>().OutlineIsQues(outline.Ol_ID, true);

            dic.Add("isQues", isQues && canStudy);
            //是否有附件
            int accessCount = Business.Do <IAccessory>().OfCount(outline.Ol_UID, "Course");

            dic.Add("isAccess", accessCount > 0 && canStudy);
            //啥都没有(视频,内容,附件,试题,都没有)
            bool isNull = !(existVideo || isLive || isContext || isQues || isQues || accessCount > 0);

            dic.Add("isNull", isNull || !canStudy);
            return(dic);
        }
        /// <summary>
        /// 将某一行数据加入到数据库
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="dl"></param>
        private void _inputData(DataRow dr)
        {
            Song.Entities.Questions obj = new Song.Entities.Questions();
            obj.Qus_IsUse = true;
            obj.Qus_Type  = this.type;
            //正确答案
            string[] correct = null;
            //是否有答案
            bool isHavAns = false;

            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //Excel的列的值
                string column = dr[rel.Key].ToString();
                //数据库字段的名称
                string field = rel.Value;
                if (field == "Qus_ID")
                {
                    if (column == string.Empty || column.Trim() == "")
                    {
                        continue;
                    }
                    int ques = Convert.ToInt32(column);
                    Song.Entities.Questions isHavObj = Business.Do <IQuestions>().QuesSingle(ques);
                    if (isHavObj != null)
                    {
                        obj = isHavObj;
                    }
                }
                //题干难度、专业、试题讲解
                if (field == "Qus_Title")
                {
                    if (column == string.Empty || column.Trim() == "")
                    {
                        return;
                    }
                    obj.Qus_Title = tranTxt(column);
                }
                if (field == "Qus_Diff")
                {
                    obj.Qus_Diff = Convert.ToInt16(column);
                }
                if (field == "Sbj_Name")
                {
                    Song.Entities.Subject subject = Business.Do <ISubject>().SubjectBatchAdd(org.Org_ID, column);
                    if (subject != null)
                    {
                        obj.Sbj_Name = subject.Sbj_Name;
                        obj.Sbj_ID   = subject.Sbj_ID;
                    }
                }
                if (field == "Cou_Name")
                {
                    Song.Entities.Course course = Business.Do <ICourse>().CourseBatchAdd(org.Org_ID, obj.Sbj_ID, column);
                    if (course != null)
                    {
                        obj.Cou_ID = course.Cou_ID;
                    }
                }
                if (field == "Ol_Name")
                {
                    Song.Entities.Outline outline = Business.Do <IOutline>().OutlineBatchAdd(org.Org_ID, obj.Sbj_ID, obj.Cou_ID, column);
                    if (outline != null)
                    {
                        obj.Ol_ID = outline.Ol_ID;
                    }
                }
                if (field == "Qus_Explain")
                {
                    obj.Qus_Explain = column;
                }
                //唯一值,正确答案,类型
                obj.Qus_UID = WeiSha.Common.Request.UniqueID();
                if (field == "Ans_IsCorrect")
                {
                    column  = Regex.Replace(column, @"[^1-9]", ",");
                    correct = column.Split(',');
                }
            }
            //再遍历一遍,取答案
            List <Song.Entities.QuesAnswer> ansItem = new List <QuesAnswer>();

            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //数据库字段的名称
                string field = rel.Value;
                Match  match = new Regex(@"(Ans_Context)(\d+)").Match(field);
                if (match.Success)
                {
                    //Excel的列的值
                    string column = dr[rel.Key].ToString();
                    if (column == string.Empty || column.Trim() == "")
                    {
                        continue;
                    }
                    int index = Convert.ToInt16(match.Groups[2].Value);
                    Song.Entities.QuesAnswer ans = new Song.Entities.QuesAnswer();
                    ans.Ans_Context = column;
                    foreach (string s in correct)
                    {
                        if (s == string.Empty || s.Trim() == "")
                        {
                            continue;
                        }
                        if (index == Convert.ToInt32(s))
                        {
                            ans.Ans_IsCorrect = true;
                            isHavAns          = true;
                            break;
                        }
                    }
                    ans.Qus_UID = obj.Qus_UID;
                    ansItem.Add(ans);
                }
            }
            if (!isHavAns)
            {
                obj.Qus_IsError = true;
            }
            //判断是否有错
            string error = "";

            if (ansItem.Count < 1)
            {
                error = "缺少答案选项";
            }
            if (!isHavAns)
            {
                error = "没有设置正确答案";
            }
            obj.Qus_IsError   = error != "";
            obj.Qus_ErrorInfo = error;
            if (obj.Sbj_ID == 0)
            {
                throw new Exception("当前试题所属专业并不存在");
            }
            if (obj.Cou_ID == 0)
            {
                throw new Exception("当前试题所在课程并不存在");
            }
            //if (obj.Ol_ID == 0) throw new Exception("当前试题所在章节并不存在");
            if (org != null)
            {
                obj.Org_ID = org.Org_ID;
            }
            Business.Do <IQuestions>().QuesInput(obj, ansItem);
        }
Beispiel #29
0
 public Song.Entities.Course ForID(int id)
 {
     Song.Entities.Course cur = Business.Do <ICourse>().CourseSingle(id);
     return(_tran(cur));
 }
Beispiel #30
0
 /// <summary>
 /// 保存当前课程
 /// </summary>
 /// <returns></returns>
 private Song.Entities.Course Save()
 {
     Song.Entities.Course cou = couid < 1 ? new Song.Entities.Course() : Business.Do <ICourse>().CourseSingle(couid);
     if (cou == null)
     {
         return(null);
     }
     //名称
     cou.Cou_Name = Cou_Name.Text.Trim();
     //所属专业
     cou.Sbj_ID   = Convert.ToInt32(ddlSubject.SelectedValue);
     cou.Sbj_Name = ddlSubject.SelectedText;
     //上级
     cou.Cou_PID = Convert.ToInt32(ddlTree.SelectedValue);
     //简介,学习目标
     cou.Cou_Intro  = tbIntro.Text;
     cou.Cou_Target = tbTarget.Text;
     //主图片
     if (fuLoad.PostedFile.FileName != "")
     {
         try
         {
             fuLoad.UpPath       = _uppath;
             fuLoad.IsMakeSmall  = true;
             fuLoad.IsConvertJpg = true;
             fuLoad.SmallWidth   = 400;
             fuLoad.SmallHeight  = 226;
             fuLoad.SaveAndDeleteOld(cou.Cou_Logo);
             //fuLoad.File.Server.ChangeSize(640, 362, true);
             cou.Cou_Logo      = fuLoad.File.Server.FileName;
             cou.Cou_LogoSmall = fuLoad.File.Server.SmallFileName;
             //
             imgShow.Src = fuLoad.File.Server.VirtualPath;
         }
         catch (Exception ex)
         {
             this.Alert(ex.Message);
         }
     }
     cou.Cou_IsUse = cbIsUse.Checked;    //启用
     cou.Cou_IsRec = cbIsRec.Checked;    //推荐
     cou.Cou_UID   = getUID();
     try
     {
         if (couid < 1)
         {
             //所属老师
             if (Extend.LoginState.Accounts.IsLogin)
             {
                 Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher;
                 if (th != null)
                 {
                     cou.Th_ID   = th.Th_ID;
                     cou.Th_Name = th.Th_Name;
                 }
             }
             Business.Do <ICourse>().CourseAdd(cou);
         }
         else
         {
             Business.Do <ICourse>().CourseSave(cou);
         }
         this.Alert("操作成功");
     }
     catch
     {
         throw;
     }
     return(cou);
 }