using Song.ServiceInterfaces; using Newtonsoft.Json; using System.Web; using WeiSha.Common; using System.Data; namespace Song.Site.Student { /// /// SubjectApi 的摘要说明 /// public class SubjectApi : IHttpHandler { Song.Entities.Organization org = null; public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; org = Business.Do().OrganCurrent(); if (context.Request["action"] == "get") { get(context); } } /// /// 获取专业数据 /// private void get(HttpContext context) { //Song.Entities.Subject[] sbj = Business.Do().SubjectCount(true, -1); Song.Entities.Subject[] eas = null; eas = Business.Do().SubjectCount(org.Org_ID, "", null, -1, 0); foreach (Song.Entities.Subject s in eas) { if (string.IsNullOrEmpty(s.Sbj_Intro) || s.Sbj_Intro.Trim() == "") continue; if (s.Sbj_Intro.Length > 20) { s.Sbj_Intro = s.Sbj_Intro.Substring(0, 20) + "..."; } } DataTable dt = WeiSha.WebControl.Tree.ObjectArrayToDataTable.To(eas); if (string.IsNullOrWhiteSpace("")) { WeiSha.WebControl.Tree.DataTableTree tree = new WeiSha.WebControl.Tree.DataTableTree(); tree.IdKeyName = "Sbj_ID"; tree.ParentIdKeyName = "Sbj_PID"; tree.TaxKeyName = "Sbj_Tax"; tree.Root = 0; dt = tree.BuilderTree(dt); } context.Response.Write(JsonConvert.SerializeObject(dt)); } public bool IsReusable { get { return false; } } } }