/// <summary>
        /// 获取当前专业的上级专业
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        protected string getSubjectPath(object[] para)
        {
            int sbjid = 0;

            if (para.Length > 0 && para[0] is int)
            {
                int.TryParse(para[0].ToString(), out sbjid);
            }
            string sbjstr = "";

            Song.Entities.Subject s = Business.Do <ISubject>().SubjectSingle(sbjid);
            if (s != null)
            {
                sbjstr += s.Sbj_Name;
                while (s.Sbj_PID != 0)
                {
                    s = Business.Do <ISubject>().SubjectSingle(s.Sbj_PID);
                    if (s == null)
                    {
                        break;
                    }
                    sbjstr = s.Sbj_Name + " &gt;&gt; " + sbjstr;
                }
            }
            return(sbjstr);
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //判断,如果已经购买,则直接跳转
            if (Extend.LoginState.Accounts.IsLogin)
            {
                int accid = Extend.LoginState.Accounts.CurrentUser.Ac_ID;
                Song.Entities.Course buyCou = Business.Do <ICourse>().IsBuyCourse(couid, accid, 1);
                if (buyCou != null)
                {
                    Extend.LoginState.Accounts.Course(buyCou);
                    this.Response.Redirect("default.ashx");
                    return;
                }
            }
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            this.Document.Variables.SetValue("course", course);
            //所属专业
            Song.Entities.Subject subject = Business.Do <ISubject>().SubjectSingle(course.Sbj_ID);
            this.Document.Variables.SetValue("subject", subject);
            //章节数
            int olCount = Business.Do <IOutline>().OutlineOfCount(course.Cou_ID, 0, true);

            this.Document.Variables.SetValue("olCount", olCount);
            //试题数
            int quesCount = Business.Do <IQuestions>().QuesOfCount(this.Organ.Org_ID, course.Sbj_ID, course.Cou_ID, 0, 0, true);

            this.Document.Variables.SetValue("quesCount", quesCount);
            //价格
            Song.Entities.CoursePrice[] prices = Business.Do <ICourse>().PriceCount(-1, course.Cou_UID, true, 0);
            this.Document.Variables.SetValue("prices", prices);
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //判断,如果已经购买,则直接跳转
            if (Extend.LoginState.Accounts.IsLogin)
            {
                bool isBuy = Business.Do <ICourse>().IsBuy(couid, Extend.LoginState.Accounts.CurrentUser.Ac_ID);
                if (isBuy)
                {
                    this.Response.Redirect("/CourseStudy.ashx?couid=" + couid);
                    return;
                }
            }
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            if (course != null)
            {
                course.Cou_Logo      = Upload.Get["Course"].Virtual + course.Cou_Logo;
                course.Cou_LogoSmall = Upload.Get["Course"].Virtual + course.Cou_LogoSmall;
            }
            //是否免费,或是限时免费
            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;
                }
            }
            if (course == null || !course.Cou_IsUse)
            {
                return;
            }
            this.Document.Variables.SetValue("course", course);

            //是否免费,限时免费也算
            this.Document.Variables.SetValue("isfree", course.Cou_IsFree || course.Cou_IsLimitFree);
            //所属专业
            Song.Entities.Subject subject = Business.Do <ISubject>().SubjectSingle(course.Sbj_ID);
            this.Document.Variables.SetValue("subject", subject);
            //章节数
            int olCount = Business.Do <IOutline>().OutlineOfCount(course.Cou_ID, 0, true);

            this.Document.Variables.SetValue("olCount", olCount);
            //试题数
            int quesCount = Business.Do <IQuestions>().QuesOfCount(this.Organ.Org_ID, course.Sbj_ID, course.Cou_ID, 0, 0, true);

            this.Document.Variables.SetValue("quesCount", quesCount);
            //价格
            Song.Entities.CoursePrice[] prices = Business.Do <ICourse>().PriceCount(-1, course.Cou_UID, true, 0);
            this.Document.Variables.SetValue("prices", prices);
            //上级专业
            List <Song.Entities.Subject> sbjs = Business.Do <ISubject>().Parents(course.Sbj_ID, true);

            this.Document.Variables.SetValue("sbjs", sbjs);
        }
        protected override void InitPageTemplate(HttpContext context)
        {
            //当前课程id写入cookies
            if (couid > 0)
            {
                context.Response.Cookies.Add(new HttpCookie("couid", couid.ToString()));
            }
            else
            {
                couid = WeiSha.Common.Request.Cookies["couid"].Int32 ?? 0;
            }
            this.Document.Variables.SetValue("couid", couid);
            //判断,如果已经购买,则直接跳转
            if (Extend.LoginState.Accounts.IsLogin)
            {
                int accid = Extend.LoginState.Accounts.CurrentUser.Ac_ID;
                Song.Entities.Course buyCou = Business.Do <ICourse>().IsBuyCourse(couid, accid, 1);
                if (buyCou != null)
                {
                    Extend.LoginState.Accounts.Course(buyCou);
                    this.Response.Redirect("default.ashx");
                    return;
                }
            }
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
            if (course == null || !course.Cou_IsUse)
            {
                return;
            }
            this.Document.Variables.SetValue("course", course);
            //所属专业
            Song.Entities.Subject subject = Business.Do <ISubject>().SubjectSingle(course.Sbj_ID);
            this.Document.Variables.SetValue("subject", subject);
            //章节数
            int olCount = Business.Do <IOutline>().OutlineOfCount(course.Cou_ID, 0, true);

            this.Document.Variables.SetValue("olCount", olCount);
            //试题数
            int quesCount = Business.Do <IQuestions>().QuesOfCount(this.Organ.Org_ID, course.Sbj_ID, course.Cou_ID, 0, 0, true);

            this.Document.Variables.SetValue("quesCount", quesCount);
            //价格
            Song.Entities.CoursePrice[] prices = Business.Do <ICourse>().PriceCount(-1, course.Cou_UID, true, 0);
            this.Document.Variables.SetValue("prices", prices);
            //支付接口
            Song.Entities.Organization   org = Business.Do <IOrganization>().OrganRoot();
            Song.Entities.PayInterface[] pis = Business.Do <IPayInterface>().PayAll(org.Org_ID, "mobi", true);
            this.Document.Variables.SetValue("pis", pis);
        }
Exemple #5
0
        protected override void InitPageTemplate(HttpContext context)
        {
            this.Document.SetValue("sbjid", sbjid);
            //专业列表
            Tag sbjTag = this.Document.GetChildTagById("subject");

            if (sbjTag != null)
            {
                Song.Entities.Subject[] subj = Business.Do <ISubject>().SubjectCount(Organ.Org_ID, null, true, sbjid, 0);
                this.Document.SetValue("subject", subj);
            }
            //当前专业
            Song.Entities.Subject sbj = Business.Do <ISubject>().SubjectSingle(sbjid);
            this.Document.SetValue("sbj", sbj);
            //上级专业
            if (sbj != null)
            {
                List <Song.Entities.Subject> sbjs = Business.Do <ISubject>().Parents(sbj.Sbj_ID, true);
                this.Document.Variables.SetValue("sbjs", sbjs);
            }
            //课程列表
            Tag couTag = this.Document.GetChildTagById("course");

            if (couTag != null)
            {
                int size  = int.Parse(couTag.Attributes.GetValue("size", "12"));
                int index = WeiSha.Common.Request.QueryString["index"].Int32 ?? 1;
                int sum   = 0;
                List <Song.Entities.Course> cour = Business.Do <ICourse>().CoursePager(Organ.Org_ID, sbjid, -1, true, search, "tax", size, index, out sum);
                foreach (Song.Entities.Course c in cour)
                {
                    c.Cou_LogoSmall = Upload.Get["Course"].Virtual + c.Cou_LogoSmall;
                    c.Cou_Logo      = Upload.Get["Course"].Virtual + c.Cou_Logo;
                    c.Cou_Intro     = HTML.ClearTag(c.Cou_Intro);
                }
                this.Document.SetValue("course", cour);
                //总页数
                int   pageSum    = (int)Math.Ceiling((double)sum / (double)size);
                int[] pageAmount = new int[pageSum];
                for (int i = 0; i < pageAmount.Length; i++)
                {
                    pageAmount[i] = i + 1;
                }
                this.Document.SetValue("pageAmount", pageAmount);
                this.Document.SetValue("pageIndex", index);
            }
        }
Exemple #6
0
        protected override void InitPageTemplate(HttpContext context)
        {
            this.Document.SetValue("search", search);
            //当前专业
            Song.Entities.Subject subject = Business.Do <ISubject>().SubjectSingle(sbjid);
            if (subject != null)
            {
                subject.Sbj_Logo      = string.IsNullOrWhiteSpace(subject.Sbj_Logo) ? subject.Sbj_Logo : Upload.Get["Subject"].Virtual + subject.Sbj_Logo;
                subject.Sbj_LogoSmall = string.IsNullOrWhiteSpace(subject.Sbj_LogoSmall) ? subject.Sbj_LogoSmall : Upload.Get["Subject"].Virtual + subject.Sbj_LogoSmall;
                //是否有子级,如果没有,则直接跳到课程选择页
                if (isChildren(new object[] { subject.Sbj_ID }).ToString() != "0")
                {
                    this.Response.Redirect("Courses.ashx?sbjid=" + subject.Sbj_ID);
                }
            }
            this.Document.SetValue("subject", subject);
            //当前专业下的子专业,如果是顶级,则显示所有顶级专业
            Song.Entities.Subject[] subjects;
            if (string.IsNullOrWhiteSpace(search))
            {
                subjects = Business.Do <ISubject>().SubjectCount(this.Organ.Org_ID, null, true, sbjid, 0);
            }
            else
            {
                subjects = Business.Do <ISubject>().SubjectCount(this.Organ.Org_ID, search, true, -1, 0);
            }

            foreach (Song.Entities.Subject s in subjects)
            {
                s.Sbj_Logo      = string.IsNullOrWhiteSpace(s.Sbj_Logo) ? s.Sbj_Logo : Upload.Get["Subject"].Virtual + s.Sbj_Logo;
                s.Sbj_LogoSmall = string.IsNullOrWhiteSpace(s.Sbj_LogoSmall) ? s.Sbj_LogoSmall : Upload.Get["Subject"].Virtual + s.Sbj_LogoSmall;
            }
            this.Document.SetValue("subjects", subjects);
            //是否拥有子级
            this.Document.RegisterGlobalFunction(this.isChildren);
        }