ZhiYeJianKang_PeiXun/Song.Site/Student/SubjectApi.ashx.cs
2025-02-20 15:41:53 +08:00

65 lines
2.0 KiB
C#

using Song.ServiceInterfaces;
using Newtonsoft.Json;
using System.Web;
using WeiSha.Common;
using System.Data;
namespace Song.Site.Student
{
/// <summary>
/// SubjectApi 的摘要说明
/// </summary>
public class SubjectApi : IHttpHandler
{
Song.Entities.Organization org = null;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
org = Business.Do<IOrganization>().OrganCurrent();
if (context.Request["action"] == "get")
{
get(context);
}
}
/// <summary>
/// 获取专业数据
/// </summary>
private void get(HttpContext context)
{
//Song.Entities.Subject[] sbj = Business.Do<ISubject>().SubjectCount(true, -1);
Song.Entities.Subject[] eas = null;
eas = Business.Do<ISubject>().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;
}
}
}
}