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.
337 lines
14 KiB
337 lines
14 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 TPlanHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TRAIN.T_TRAININGPLAN bll = new BLL.TRAIN.T_TRAININGPLAN();
|
|
private FangYar.BLL.TRAIN.T_SUBJECT subject_bll = new BLL.TRAIN.T_SUBJECT();
|
|
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 "TPlanList":
|
|
returnstr = GettplanList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Addtplan(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edittplan(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Deltplan(context);
|
|
break;
|
|
case "GetSubject":
|
|
returnstr = GetSubject(context);
|
|
break;
|
|
case "getOrgTree":
|
|
returnstr = getOrgTreeList(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GettplanList(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 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 + "%'";
|
|
}
|
|
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 Addtplan(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string name = context.Request.Params["name"];
|
|
string SUBJECTCONTENT = context.Request.Params["SUBJECTCONTENT"];
|
|
string SUBJECTCONTENT_NAME = context.Request.Params["SUBJECTCONTENT_NAME"];
|
|
string ISDISTINGUISHGENDER = context.Request.Params["ISDISTINGUISHGENDER"];
|
|
string TRAININGPERSON = context.Request.Params["TRAININGPERSON"];
|
|
string TRAININGPERSON_NAME = context.Request.Params["TRAININGPERSON_NAME"];
|
|
|
|
string LEADTRAINING = context.Request.Params["LEADTRAINING"];
|
|
string LEADTRAINING_NAME = context.Request.Params["LEADTRAINING_NAME"];
|
|
|
|
string org_id = context.Request.Params["org_id"];
|
|
string org_name = context.Request.Params["org_name"];
|
|
|
|
FangYar.Model.TRAIN.T_TRAININGPLAN model = new Model.TRAIN.T_TRAININGPLAN();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.NAME = name;
|
|
model.SUBJECTCONTENT = SUBJECTCONTENT;
|
|
model.ISDISTINGUISHGENDER = ISDISTINGUISHGENDER;
|
|
model.TRAININGPERSON = TRAININGPERSON;
|
|
model.ORG_ID = org_id;
|
|
model.ORG_NAME = org_name;
|
|
model.SUBJECTCONTENT_NAME = SUBJECTCONTENT_NAME;
|
|
model.TRAININGPERSON_NAME = TRAININGPERSON_NAME;
|
|
|
|
model.LEADTRAINING = LEADTRAINING;
|
|
model.LEADTRAINING_NAME = LEADTRAINING_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 Edittplan(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["ID"];
|
|
string name = context.Request.Params["name"];
|
|
string SUBJECTCONTENT = context.Request.Params["SUBJECTCONTENT"];
|
|
string SUBJECTCONTENT_NAME = context.Request.Params["SUBJECTCONTENT_NAME"];
|
|
string ISDISTINGUISHGENDER = context.Request.Params["ISDISTINGUISHGENDER"];
|
|
string TRAININGPERSON = context.Request.Params["TRAININGPERSON"];
|
|
string TRAININGPERSON_NAME = context.Request.Params["TRAININGPERSON_NAME"];
|
|
string org_id = context.Request.Params["org_id"];
|
|
string org_name = context.Request.Params["org_name"];
|
|
|
|
string LEADTRAINING = context.Request.Params["LEADTRAINING"];
|
|
string LEADTRAINING_NAME = context.Request.Params["LEADTRAINING_NAME"];
|
|
|
|
FangYar.Model.TRAIN.T_TRAININGPLAN model = new Model.TRAIN.T_TRAININGPLAN();
|
|
model.ID = id;
|
|
model.NAME = name;
|
|
model.SUBJECTCONTENT = SUBJECTCONTENT;
|
|
model.ISDISTINGUISHGENDER = ISDISTINGUISHGENDER;
|
|
model.TRAININGPERSON = TRAININGPERSON;
|
|
model.ORG_ID = org_id;
|
|
model.ORG_NAME = org_name;
|
|
model.SUBJECTCONTENT_NAME = SUBJECTCONTENT_NAME;
|
|
model.TRAININGPERSON_NAME = TRAININGPERSON_NAME;
|
|
|
|
model.LEADTRAINING = LEADTRAINING;
|
|
model.LEADTRAINING_NAME = LEADTRAINING_NAME;
|
|
|
|
if (bll.Update(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.Update, "训练计划模板操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
//删除
|
|
private string Deltplan(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 GetSubject(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":1,\"成功\":\"error\",\"count\":0,\"data\":";
|
|
DataTable dt = subject_bll.GetList(" ORG_ID = '" + OrgId + "'").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;
|
|
}
|
|
|
|
//获取Tree 机构-部门-员工(获取UID)
|
|
private string getOrgTreeList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string type = context.Request.Params["type"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgTree(orgId);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
}
|
|
else
|
|
{
|
|
data.Rows[i]["nocheck"] = "true";
|
|
}
|
|
}
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练计划模板操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "训练计划模板操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|