You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
316 lines
12 KiB
316 lines
12 KiB
using Spire.Xls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class TSubjectHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TRAIN.T_SUBJECT bll = new BLL.TRAIN.T_SUBJECT();
|
|
private FangYar.BLL.TRAIN.T_SUBJECTBCATEGORY cat_bll = new BLL.TRAIN.T_SUBJECTBCATEGORY();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "训练科目操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "TSubjectList":
|
|
returnstr = GetTSubjectList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddTSubject(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditTSubject(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelTSubject(context);
|
|
break;
|
|
case "GetCategory":
|
|
returnstr = GetCategory(context);
|
|
break;
|
|
case "GetSubjectModelById":
|
|
returnstr = GetSubjectModelById(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetTSubjectList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string category_id = context.Request.Params["category_id"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
int startIndex = 0;
|
|
int endIndex = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
startIndex = (pageIndex - 1) * pageSize;
|
|
endIndex = pageSize;
|
|
|
|
string where = "1=1";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where += " and org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids ) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ORG_ID = '" + treeID + "'";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where += " and org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ORG_ID = '" + OrgId + "'";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and ( NAME like '%" + keyword + "%' or DESCRIPTION like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(category_id))
|
|
{
|
|
where += " and CATEGORY_ID = '" + category_id + "'";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, "", startIndex, endIndex).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "训练科目操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string AddTSubject(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string name = context.Request.Params["name"];
|
|
string category_id = context.Request.Params["category_id"];
|
|
string category_name = context.Request.Params["category_name"];
|
|
string unitofmeasuremen = context.Request.Params["unitofmeasuremen"];
|
|
string org_id = context.Request.Params["org_id"];
|
|
string org_name = context.Request.Params["org_name"];
|
|
string description = context.Request.Params["description"];
|
|
string remark = context.Request.Params["remark"];
|
|
|
|
FangYar.Model.TRAIN.T_SUBJECT model = new Model.TRAIN.T_SUBJECT();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.NAME = name;
|
|
model.DESCRIPTION = description;
|
|
model.CATEGORY_ID = category_id;
|
|
model.UNITOFMEASUREMEN = unitofmeasuremen;
|
|
model.REMARK = remark;
|
|
model.ORG_ID = org_id;
|
|
model.ORG_NAME = org_name;
|
|
model.CATEGORY_NAME = category_name;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "训练科目操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string EditTSubject(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["ID"];
|
|
string name = context.Request.Params["name"];
|
|
string category_id = context.Request.Params["category_id"];
|
|
string category_name = context.Request.Params["category_name"];
|
|
string unitofmeasuremen = context.Request.Params["unitofmeasuremen"];
|
|
string org_id = context.Request.Params["org_id"];
|
|
string org_name = context.Request.Params["org_name"];
|
|
string description = context.Request.Params["description"];
|
|
string remark = context.Request.Params["remark"];
|
|
|
|
FangYar.Model.TRAIN.T_SUBJECT model = new Model.TRAIN.T_SUBJECT();
|
|
model.ID = id;
|
|
model.NAME = name;
|
|
model.DESCRIPTION = description;
|
|
model.CATEGORY_ID = category_id;
|
|
model.UNITOFMEASUREMEN = unitofmeasuremen;
|
|
model.REMARK = remark;
|
|
model.ORG_ID = org_id;
|
|
model.ORG_NAME = org_name;
|
|
model.CATEGORY_NAME = category_name;
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "修改");
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "训练科目操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//删除
|
|
private string DelTSubject(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
if (bll.Delete(id))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "训练科目操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//查询大类
|
|
private string GetCategory(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
returnstr = "{\"code\":1,\"成功\":\"error\",\"count\":0,\"data\":";
|
|
DataTable dt = cat_bll.GetAllList().Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "查询大类异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "训练科目操作请求", "查询大类");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据ID获取Model
|
|
private string GetSubjectModelById(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string subjectId = context.Request.Params["subjectId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
FangYar.Model.TRAIN.T_SUBJECT data = bll.GetModel(subjectId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练科目操作请求", "根据ID获取Model异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "训练科目操作请求", "根据ID获取Model");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|