public override void DataBind() { VTemplate.Engine.RepeatTag tag = this.Tag as VTemplate.Engine.RepeatTag; if (tag == null) { return; } // int count = tag.Count; int start = int.Parse(this.Tag.Attributes.GetValue("start", "0")); //起始索引号 string search = this.Tag.Attributes.GetValue("search", ""); //检索字符 //上级专业的id int pid = 0; int.TryParse(this.Tag.Attributes.GetValue("pid", "-1"), out pid); //排序方式,def默认排序(先推荐,后排序号),tax按排序号,rec按推荐 string order = this.Tag.Attributes.GetValue("order", "def"); //数据来源 Song.Entities.Subject[] sbjs = Business.Do <ISubject>().SubjectCount(this.Organ.Org_ID, search, true, pid, order, start, count); foreach (Song.Entities.Subject c in sbjs) { c.Sbj_Logo = Upload.Get["Subject"].Virtual + c.Sbj_Logo; c.Sbj_LogoSmall = Upload.Get["Subject"].Virtual + c.Sbj_LogoSmall; c.Sbj_Intro = HTML.ClearTag(c.Sbj_Intro); } List <Song.Template.Tags.TreeObject> list = Song.Template.Tags.TreeObject.Bulder(sbjs, "Sbj_PID", "0", "Sbj_ID"); tag.DataSourse = list; }
/// <summary> /// 获取课程 /// </summary> /// <param name="para">两个参数,一个是专业id,第二个为数量</param> /// <returns></returns> protected static List <Song.Entities.Course> getCourses(object[] para) { Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); //专业id int sbj = 0, count = 0; if (para.Length > 0 && para[0] is int) { int.TryParse(para[0].ToString(), out sbj); } //数量 if (para.Length > 1 && para[1] is int) { int.TryParse(para[1].ToString(), out count); } //排序方式,排序方式,默认null按排序顺序,flux流量最大优先,def推荐、流量,tax排序号,new最新,rec推荐 string order = "def"; if (para.Length > 2) { order = para[2].ToString(); } List <Song.Entities.Course> cour = Business.Do <ICourse>().CourseCount(org.Org_ID, sbj, null, true, order, count); 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); } return(cour); }
public override void DataBind() { VTemplate.Engine.ListTag tag = this.Tag as VTemplate.Engine.ListTag; if (tag == null) { return; } // int count = int.Parse(this.Tag.Attributes.GetValue("count", "10")); //要取的记录数 int sbjid = int.Parse(this.Tag.Attributes.GetValue("sbjid", "-1")); //所属专业的id //int thid = int.Parse(this.ListTag.Attributes.GetValue("thid", "-1")); //教师id //int pid = int.Parse(this.ListTag.Attributes.GetValue("pid", "-1")); //上级课程 string search = this.Tag.Attributes.GetValue("search", ""); //按课程名检索 string order = this.Tag.Attributes.GetValue("order", ""); //排序方式,flux流量最大优先,def推荐、流量,tax排序号,new最新,rec推荐 object from = this.Tag.Attributes.GetValue("from", null); if (from == null) { List <Song.Entities.Course> cours = Business.Do <ICourse>().CourseCount(this.Organ.Org_ID, sbjid, search, true, order, count); foreach (Song.Entities.Course c in cours) { c.Cou_LogoSmall = string.IsNullOrWhiteSpace(c.Cou_LogoSmall) ? "" : Upload.Get["Course"].Virtual + c.Cou_LogoSmall; c.Cou_Logo = string.IsNullOrWhiteSpace(c.Cou_Logo) ? "" : Upload.Get["Course"].Virtual + c.Cou_Logo; c.Cou_Intro = HTML.ClearTag(c.Cou_Intro); } tag.DataSourse = cours; } }
/// <summary> /// 去除HTML标签,并返回指定长度 /// </summary> /// <param name="html"></param> /// <param name="length"></param> /// <returns></returns> public string ReplaceHtmlTag(string html, int length = 0) { string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", ""); strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", ""); strText = HTML.ClearTag(strText); if (length > 0 && strText.Length > length) { return(strText.Substring(0, length)); } return(strText); }
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); } }
public override void DataBind() { VTemplate.Engine.ListTag tag = this.Tag as VTemplate.Engine.ListTag; if (tag == null) { return; } // int count = tag.Count; int start = int.Parse(this.Tag.Attributes.GetValue("start", "0")); //起始索引号 string search = this.Tag.Attributes.GetValue("search", ""); //检索字符 //上级专业的id int pid = 0; int.TryParse(this.Tag.Attributes.GetValue("pid", "0"), out pid); //排序方式,def默认排序(先推荐,后排序号),tax按排序号,rec按推荐 string order = this.Tag.Attributes.GetValue("order", "def"); //取上传标签的数据源 if (this.Tag.Parent != null) { VTemplate.Engine.ListTag t = this.Tag.Parent as VTemplate.Engine.ListTag; if (t != null && t.DataSourse != null) { Song.Entities.Subject[] sbjt = t.DataSourse as Song.Entities.Subject[]; int sid = sbjt[0].Sbj_ID; object o = tag.Index.Value; } } //数据来源 string from = this.Tag.Attributes.GetValue("from"); //如果没有指定数据来源(如果指定了但值为空,仍然认为已经指定),才会读取数据库。 if (string.IsNullOrWhiteSpace(from)) { Song.Entities.Subject[] sbjs = Business.Do <ISubject>().SubjectCount(this.Organ.Org_ID, search, true, pid, order, start, count); //sbjs[0].child = 3; foreach (Song.Entities.Subject c in sbjs) { c.Sbj_Logo = Upload.Get["Subject"].Virtual + c.Sbj_Logo; c.Sbj_LogoSmall = Upload.Get["Subject"].Virtual + c.Sbj_LogoSmall; c.Sbj_Intro = HTML.ClearTag(c.Sbj_Intro); } tag.DataSourse = sbjs; } }
/// <summary> /// 供前端显示的专业最顶级分类 /// </summary> /// <param name="orgid"></param> /// <param name="count"></param> /// <returns></returns> public Song.Entities.Subject[] ShowRoot(int orgid, int count) { Song.Entities.Subject[] sbjs = Business.Do <ISubject>().SubjectCount(orgid, string.Empty, true, 0, count); string path = Upload.Get["Subject"].Virtual; foreach (Song.Entities.Subject c in sbjs) { c.Sbj_Logo = path + c.Sbj_Logo; c.Sbj_LogoSmall = path + c.Sbj_LogoSmall; //如果别名为空,则别名等于专业名称 if (string.IsNullOrWhiteSpace(c.Sbj_ByName) || c.Sbj_ByName.Trim() == "") { c.Sbj_ByName = c.Sbj_Name; } c.Sbj_Intro = HTML.ClearTag(c.Sbj_Intro); } return(sbjs); }
protected override void InitPageTemplate(HttpContext context) { //课程列表 Tag couTag = this.Document.GetChildTagById("courseList"); if (couTag != null) { int count = int.Parse(couTag.Attributes.GetValue("count", "10")); List <Song.Entities.Course> cour = Business.Do <ICourse>().CourseCount(this.Organ.Org_ID, -1, -1, -1, null, true, count); 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("courseList", cour); } //各种数据 if (Extend.LoginState.Admin.IsLogin) { //专业数 int sbjcount = Business.Do <ISubject>().SubjectOfCount(this.Organ.Org_ID, true, -1); this.Document.SetValue("sbjcount", sbjcount); //课程数 int couCount = Business.Do <ICourse>().CourseOfCount(this.Organ.Org_ID, -1, -1); this.Document.SetValue("couCount", couCount); //考试数 int testCount = Business.Do <ITestPaper>().PagerOfCount(this.Organ.Org_ID, -1, -1, -1, true); this.Document.SetValue("testCount", testCount); //试题数 int quesCount = Business.Do <IQuestions>().QuesOfCount(this.Organ.Org_ID, -1, -1, -1, -1, true); this.Document.SetValue("quesCount", quesCount); //学员数 int stCount = Business.Do <IAccounts>().AccountsOfCount(this.Organ.Org_ID, null); this.Document.SetValue("stCount", stCount); //资讯数 int newsCount = Business.Do <IContents>().ArticleOfCount(this.Organ.Org_ID, -1); this.Document.SetValue("newsCount", newsCount); } }
protected override void InitPageTemplate(HttpContext context) { //正在直播的章节 List <Song.Entities.Outline> lives = Business.Do <IOutline>().OutlineLiving(Organ.Org_ID, 10); if (lives != null) { this.Document.SetValue("lives", lives); } this.Document.RegisterGlobalFunction(this.GetSnapshot); this.Document.RegisterGlobalFunction(this.GetCourse); //课程列表 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, "", true, true, string.Empty, "rec", 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); } }