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.
319 lines
13 KiB
319 lines
13 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Web.Script.Serialization;
|
|
using FangYar.Model;
|
|
using FangYar.BLL;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class ReportLocationHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA.OA_REPORT_LOCATION bll = new FangYar.BLL.OA.OA_REPORT_LOCATION();
|
|
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 "IsAallowed":
|
|
returnstr = IsAallowedByUsersUid(context);
|
|
break;
|
|
case "ReportLocationList":
|
|
returnstr = GetReportLocationList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddReportLocation(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditReportLocation(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelReportLocation(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据USERS_UID判断是否在请假时间段内
|
|
private string IsAallowedByUsersUid(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
where += " PPL_ID = '" + USERS_UID + "' ";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":-2,\"msg\":\"登录账号为空!\",\"count\":0,\"data\":[]}";
|
|
}
|
|
where += " and STATE = '1' and (IS_RETURN != '2' or IS_RETURN is null) ";
|
|
string time = DateTime.Now.ToString();
|
|
where += " and date_format('" + time + "','%Y-%m-%d %H:%i:%s') > date_format(S_TIME,'%Y-%m-%d %H:%i:%s')";
|
|
where += " and date_format('" + time + "','%Y-%m-%d %H:%i:%s') < date_format(E_TIME,'%Y-%m-%d %H:%i:%s')";
|
|
|
|
FangYar.BLL.OA_LEAVE lbll = new FangYar.BLL.OA_LEAVE();
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = lbll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"不在请假时间段内,无法打卡!\",\"count\":0,\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
where += " ORDER BY E_TIME desc ";
|
|
List<FangYar.Model.OA_LEAVE> list = lbll.GetModelList(where);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假打卡操作请求", "根据USERS_UID判断是否在请假时间段内异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假打卡操作请求", "根据USERS_UID判断是否在请假时间段内");
|
|
return returnstr;
|
|
}
|
|
|
|
//查询
|
|
private string GetReportLocationList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string LEAVE_ID = context.Request.Params["LEAVE_ID"];
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(LEAVE_ID))
|
|
{
|
|
where += " LEAVE_ID = '" + LEAVE_ID + "' ";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
where += " ORDER BY REPORT_TIME ";
|
|
List<FangYar.Model.OA.OA_REPORT_LOCATION> list = bll.GetModelList(where);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
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;
|
|
}
|
|
|
|
//添加请假期间打卡记录
|
|
private string AddReportLocation(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string LOCATION = context.Request.Params["LOCATION"];
|
|
string REPORT_TIME = context.Request.Params["REPORT_TIME"];
|
|
string USERS_NAME = context.Request.Params["USERS_NAME"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string ORG_NAME = context.Request.Params["ORG_NAME"];
|
|
string REMARKS = context.Request.Params["REMARKS"];
|
|
string EXTEND1 = context.Request.Params["EXTEND1"];
|
|
string EXTEND2 = context.Request.Params["EXTEND2"];
|
|
string EXTEND3 = context.Request.Params["EXTEND3"];
|
|
string EXTEND4 = context.Request.Params["EXTEND4"];
|
|
string EXTEND5 = context.Request.Params["EXTEND5"];
|
|
string EXTEND6 = context.Request.Params["EXTEND6"];
|
|
string LEAVE_ID = context.Request.Params["LEAVE_ID"];
|
|
|
|
//请假期间打卡记录表
|
|
FangYar.Model.OA.OA_REPORT_LOCATION model = new Model.OA.OA_REPORT_LOCATION();
|
|
model.ID = ID;
|
|
model.USERS_UID = USERS_UID;
|
|
model.LOCATION = LOCATION;
|
|
model.REPORT_TIME = REPORT_TIME;
|
|
model.USERS_NAME = USERS_NAME;
|
|
model.ORG_ID = ORG_ID;
|
|
model.ORG_NAME = ORG_NAME;
|
|
model.REMARKS = REMARKS;
|
|
model.EXTEND1 = EXTEND1;
|
|
model.EXTEND2 = EXTEND2;
|
|
model.EXTEND3 = EXTEND3;
|
|
model.EXTEND4 = EXTEND4;
|
|
model.EXTEND5 = EXTEND5;
|
|
model.EXTEND6 = EXTEND6;
|
|
model.LEAVE_ID = LEAVE_ID;
|
|
|
|
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 EditReportLocation(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string ID = context.Request.Params["ID"];
|
|
string LOCATION = context.Request.Params["LOCATION"];
|
|
string REPORT_TIME = context.Request.Params["REPORT_TIME"];
|
|
string USERS_NAME = context.Request.Params["USERS_NAME"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string ORG_NAME = context.Request.Params["ORG_NAME"];
|
|
string REMARKS = context.Request.Params["REMARKS"];
|
|
string EXTEND1 = context.Request.Params["EXTEND1"];
|
|
string EXTEND2 = context.Request.Params["EXTEND2"];
|
|
string EXTEND3 = context.Request.Params["EXTEND3"];
|
|
string EXTEND4 = context.Request.Params["EXTEND4"];
|
|
string EXTEND5 = context.Request.Params["EXTEND5"];
|
|
string EXTEND6 = context.Request.Params["EXTEND6"];
|
|
string LEAVE_ID = context.Request.Params["LEAVE_ID"];
|
|
|
|
//请假期间打卡记录表
|
|
FangYar.Model.OA.OA_REPORT_LOCATION model = new Model.OA.OA_REPORT_LOCATION();
|
|
model.ID = ID;
|
|
model.USERS_UID = USERS_UID;
|
|
model.LOCATION = LOCATION;
|
|
model.REPORT_TIME = REPORT_TIME;
|
|
model.USERS_NAME = USERS_NAME;
|
|
model.ORG_ID = ORG_ID;
|
|
model.ORG_NAME = ORG_NAME;
|
|
model.REMARKS = REMARKS;
|
|
model.EXTEND1 = EXTEND1;
|
|
model.EXTEND2 = EXTEND2;
|
|
model.EXTEND3 = EXTEND3;
|
|
model.EXTEND4 = EXTEND4;
|
|
model.EXTEND5 = EXTEND5;
|
|
model.EXTEND6 = EXTEND6;
|
|
model.LEAVE_ID = LEAVE_ID;
|
|
|
|
if (bll.Update(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.Update, "请假打卡操作请求", "修改请假期间打卡记录");
|
|
return returnstr;
|
|
}
|
|
|
|
//删除请假期间打卡记录
|
|
private string DelReportLocation(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ReportLocationList = context.Request.Params["ReportLocationList"];
|
|
string[] ReportLocationArray = ReportLocationList.Split(',');
|
|
string ReportLocationListString = "";
|
|
for (int i = 0; i < ReportLocationArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
ReportLocationListString = "'" + ReportLocationArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
ReportLocationListString += ",'" + ReportLocationArray[i] + "'";
|
|
}
|
|
}
|
|
if (bll.DeleteList(ReportLocationListString))
|
|
{
|
|
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;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|