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.
372 lines
14 KiB
372 lines
14 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// TrainingLiveHandler 的摘要说明
|
|
/// </summary>
|
|
public class TrainingLiveHandler : IHttpHandler
|
|
{
|
|
|
|
BLL.TRAIN.T_TRAININGLIVE bLL = new BLL.TRAIN.T_TRAININGLIVE();
|
|
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 "List":
|
|
returnstr = List(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Add(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edit(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Del(context);
|
|
break;
|
|
case "AppGetList":
|
|
returnstr = AppGetList(context);
|
|
break;
|
|
case "AppGetModel":
|
|
returnstr = AppGetModel(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string List(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string type = context.Request.Params["type"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = "1=1";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and ORG_ID = '" + OrgId + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( ltitle like '%" + keyword + "%' )";
|
|
}
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = 0;
|
|
List<FangYar.Model.T_TRAININGLIVE> list = bLL.PageList(pageIndex, pageSize, where, " ltime desc", ref count);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "培训操作请求", "查询异常:" + ex);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "培训操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string Add(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = Guid.NewGuid().ToString("N");//
|
|
string ORG_ID = context.Request.Params["ORG_ID"];//
|
|
string lbt = context.Request.Params["lbt"];//标题
|
|
string lzy = context.Request.Params["lzy"];//摘要
|
|
string lfbr = context.Request.Params["lfbr"]; //发布人
|
|
string lsj = context.Request.Params["lsj"]; //时间
|
|
string lnr = context.Request.Params["lnr"]; //内容
|
|
string llx = context.Request.Params["llx"];//类型
|
|
string lly = context.Request.Params["lly"];//来源
|
|
string ltp = context.Request.Params["ltp"];//封面图
|
|
string lfj = context.Request.Params["lfj"];//附件
|
|
byte[] outputb = Convert.FromBase64String(lnr);
|
|
string orgStr = Encoding.Default.GetString(outputb);
|
|
string text = HttpUtility.UrlDecode(orgStr);
|
|
FangYar.Model.T_TRAININGLIVE model = new Model.T_TRAININGLIVE();
|
|
|
|
model.ID = id;
|
|
model.LTITLE = lbt;
|
|
model.LABSTRACT = lzy;
|
|
model.LCONTENT = text;
|
|
model.LAUTHOR = lfbr;
|
|
if (!string.IsNullOrEmpty(lsj))
|
|
{
|
|
model.LTIME = DateTime.Parse(lsj);
|
|
}
|
|
|
|
model.LTYPE = llx;
|
|
model.LFROM = lly;
|
|
model.LIMG = ltp;
|
|
model.LENCLOSURE = lfj;
|
|
model.ORG_ID = ORG_ID;
|
|
model.A_PER = "";
|
|
model.A_TIME = DateTime.Now;
|
|
|
|
if (bLL.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "培训操作请求", "添加异常;" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "培训操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string Edit(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];//
|
|
string ORG_ID = context.Request.Params["ORG_ID"];//
|
|
string lbt = context.Request.Params["lbt"];//标题
|
|
string lzy = context.Request.Params["lzy"];//摘要
|
|
string lfbr = context.Request.Params["lfbr"]; //发布人
|
|
string lsj = context.Request.Params["lsj"]; //时间
|
|
string lnr = context.Request.Params["lnr"]; //内容
|
|
string llx = context.Request.Params["llx"];//类型
|
|
string lly = context.Request.Params["lly"];//来源
|
|
string ltp = context.Request.Params["ltp"];//封面图
|
|
string lfj = context.Request.Params["lfj"];//附件
|
|
byte[] outputb = Convert.FromBase64String(lnr);
|
|
string orgStr = Encoding.Default.GetString(outputb);
|
|
string text = HttpUtility.UrlDecode(orgStr);
|
|
|
|
//
|
|
FangYar.Model.T_TRAININGLIVE model = bLL.GetModel(ID);
|
|
if (model != null)
|
|
{
|
|
|
|
model.LTITLE = lbt;
|
|
model.LABSTRACT = lzy;
|
|
model.LCONTENT = text;
|
|
model.LAUTHOR = lfbr;
|
|
if (!string.IsNullOrEmpty(lsj))
|
|
{
|
|
model.LTIME = DateTime.Parse(lsj);
|
|
}
|
|
|
|
model.LTYPE = llx;
|
|
model.LFROM = lly;
|
|
model.LIMG = ltp;
|
|
model.LENCLOSURE = lfj;
|
|
|
|
if (bLL.Update(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
else
|
|
{
|
|
msg = "记录不存在!";
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "培训操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "培训操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
//删除
|
|
private string Del(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string EmpList = context.Request.Params["cameraList"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
if (bLL.DeleteList(EmpListString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "培训操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "培训操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
//查询
|
|
private string AppGetList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string type = context.Request.Params["type"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = "1=1";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and ORG_ID = '" + OrgId + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( mtitle like '%" + keyword + "%' or mADDR like '%" + keyword + "%')";
|
|
}
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = 0;
|
|
List<FangYar.Model.T_TRAININGLIVE> list = bLL.PageList(pageIndex, pageSize, where, " mdate desc", ref count);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "培训操作请求", "查询异常:" + ex);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "培训操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
//查询
|
|
private string AppGetModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\": 1,\"data\":";
|
|
FangYar.Model.T_TRAININGLIVE model = bLL.GetModel(id);
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|