软测单独项目
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.
 
 
 
 
 
 

414 lines
18 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class OaAttendancePlanHandler : IHttpHandler
{
private FangYar.BLL.OA.OA_ATTENDANCE_PLAN bll = new FangYar.BLL.OA.OA_ATTENDANCE_PLAN();
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 = getPlanlist(context);
break;
case "Add":
returnstr = AddPlan(context);
break;
case "Edit":
returnstr = EditPlan(context);
break;
case "Del":
returnstr = DelPlan(context);
break;
case "PlanListByOrgId":
returnstr = GetPlanListByOrgId(context);
break;
case "PlanListByUID":
returnstr = GetPlanListByUID(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string getPlanlist(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"];
int pageIndex = 1;
int pageSize = 10;//
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = null;
if (!string.IsNullOrEmpty(treeID) && treeID != orgId)
{
orgId = treeID;
}
where = "ORG_ID = '" + orgId + "' ";
if (!string.IsNullOrEmpty(keyword))
{
where += " and PLAN_NAME like '%" + keyword + "%' ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.OA.OA_ATTENDANCE_PLAN> list = bll.QueryList(pageIndex, pageSize, where, null);
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 AddPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = Guid.NewGuid().ToString("N");
string PLAN_NAME = context.Request.Params["PLAN_NAME"];
string LOCATION = context.Request.Params["LOCATION"];
string UP_START_TIME = context.Request.Params["UP_START_TIME"];
string UP_END_TIME = context.Request.Params["UP_END_TIME"];
string DOWN_START_TIME = context.Request.Params["DOWN_START_TIME"];
string DOWN_END_TIME = context.Request.Params["DOWN_END_TIME"];
string UP_START_TIME2 = context.Request.Params["UP_START_TIME2"];
string UP_END_TIME2 = context.Request.Params["UP_END_TIME2"];
string DOWN_START_TIME2 = context.Request.Params["DOWN_START_TIME2"];
string DOWN_END_TIME2 = context.Request.Params["DOWN_END_TIME2"];
string WORK_DAY = context.Request.Params["WORK_DAY"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string ISSUEUID = context.Request.Params["ISSUEUID"];
string ISSUENAME = context.Request.Params["ISSUENAME"];
string STATE = context.Request.Params["STATE"];
string ATTENDANCE_USER = context.Request.Params["ATTENDANCE_USER"];
string ATTENDANCE_USER_UID = context.Request.Params["ATTENDANCE_USER_UID"];
string ATTENDANCE_USER_NAME = context.Request.Params["ATTENDANCE_USER_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 ATT_RULE1 = context.Request.Params["ATT_RULE1"];
string ATT_RULE2 = context.Request.Params["ATT_RULE2"];
string ATT_RULE3 = context.Request.Params["ATT_RULE3"];
string ATT_RULE4 = context.Request.Params["ATT_RULE4"];
string ATT_RULE5 = context.Request.Params["ATT_RULE5"];
string CLOCKINFREQUENCY = context.Request.Params["CLOCKINFREQUENCY"];
//考勤计划表
FangYar.Model.OA.OA_ATTENDANCE_PLAN model = new Model.OA.OA_ATTENDANCE_PLAN();
model.ID = ID;
model.PLAN_NAME = PLAN_NAME;
model.LOCATION = LOCATION;
model.UP_START_TIME = UP_START_TIME;
model.UP_END_TIME = UP_END_TIME;
model.DOWN_START_TIME = DOWN_START_TIME;
model.DOWN_END_TIME = DOWN_END_TIME;
model.UP_START_TIME2 = UP_START_TIME2;
model.UP_END_TIME2 = UP_END_TIME2;
model.DOWN_START_TIME2 = DOWN_START_TIME2;
model.DOWN_END_TIME2 = DOWN_END_TIME2;
model.WORK_DAY = WORK_DAY;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.ISSUEUID = ISSUEUID;
model.ISSUENAME = ISSUENAME;
model.STATE = STATE;
model.ATTENDANCE_USER = ATTENDANCE_USER;
model.ATTENDANCE_USER_UID = ATTENDANCE_USER_UID;
model.ATTENDANCE_USER_NAME = ATTENDANCE_USER_NAME;
model.REMARKS = REMARKS;
model.EXTEND1 = EXTEND1;
model.EXTEND2 = EXTEND2;
model.EXTEND3 = EXTEND3;
model.EXTEND4 = EXTEND4;
model.EXTEND5 = EXTEND5;
model.EXTEND6 = EXTEND6;
model.ATT_RULE1 = ATT_RULE1;
model.ATT_RULE2 = ATT_RULE2;
model.ATT_RULE3 = ATT_RULE3;
model.ATT_RULE4 = ATT_RULE4;
model.ATT_RULE5 = ATT_RULE5;
model.CLOCKINFREQUENCY = 0;
if (!CLOCKINFREQUENCY.IsNullOrEmpty())
model.CLOCKINFREQUENCY = int.Parse(CLOCKINFREQUENCY);
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 EditPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string PLAN_NAME = context.Request.Params["PLAN_NAME"];
string LOCATION = context.Request.Params["LOCATION"];
string UP_START_TIME = context.Request.Params["UP_START_TIME"];
string UP_END_TIME = context.Request.Params["UP_END_TIME"];
string DOWN_START_TIME = context.Request.Params["DOWN_START_TIME"];
string DOWN_END_TIME = context.Request.Params["DOWN_END_TIME"];
string UP_START_TIME2 = context.Request.Params["UP_START_TIME2"];
string UP_END_TIME2 = context.Request.Params["UP_END_TIME2"];
string DOWN_START_TIME2 = context.Request.Params["DOWN_START_TIME2"];
string DOWN_END_TIME2 = context.Request.Params["DOWN_END_TIME2"];
string WORK_DAY = context.Request.Params["WORK_DAY"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string ISSUEUID = context.Request.Params["ISSUEUID"];
string ISSUENAME = context.Request.Params["ISSUENAME"];
string STATE = context.Request.Params["STATE"];
string ATTENDANCE_USER = context.Request.Params["ATTENDANCE_USER"];
string ATTENDANCE_USER_UID = context.Request.Params["ATTENDANCE_USER_UID"];
string ATTENDANCE_USER_NAME = context.Request.Params["ATTENDANCE_USER_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 ATT_RULE1 = context.Request.Params["ATT_RULE1"];
string ATT_RULE2 = context.Request.Params["ATT_RULE2"];
string ATT_RULE3 = context.Request.Params["ATT_RULE3"];
string ATT_RULE4 = context.Request.Params["ATT_RULE4"];
string ATT_RULE5 = context.Request.Params["ATT_RULE5"];
string CLOCKINFREQUENCY = context.Request.Params["CLOCKINFREQUENCY"];
//考勤计划表
FangYar.Model.OA.OA_ATTENDANCE_PLAN model = new Model.OA.OA_ATTENDANCE_PLAN();
model.ID = ID;
model.PLAN_NAME = PLAN_NAME;
model.LOCATION = LOCATION;
model.UP_START_TIME = UP_START_TIME;
model.UP_END_TIME = UP_END_TIME;
model.DOWN_START_TIME = DOWN_START_TIME;
model.DOWN_END_TIME = DOWN_END_TIME;
model.UP_START_TIME2 = UP_START_TIME2;
model.UP_END_TIME2 = UP_END_TIME2;
model.DOWN_START_TIME2 = DOWN_START_TIME2;
model.DOWN_END_TIME2 = DOWN_END_TIME2;
model.WORK_DAY = WORK_DAY;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.ISSUEUID = ISSUEUID;
model.ISSUENAME = ISSUENAME;
model.STATE = STATE;
model.ATTENDANCE_USER = ATTENDANCE_USER;
model.ATTENDANCE_USER_UID = ATTENDANCE_USER_UID;
model.ATTENDANCE_USER_NAME = ATTENDANCE_USER_NAME;
model.REMARKS = REMARKS;
model.EXTEND1 = EXTEND1;
model.EXTEND2 = EXTEND2;
model.EXTEND3 = EXTEND3;
model.EXTEND4 = EXTEND4;
model.EXTEND5 = EXTEND5;
model.EXTEND6 = EXTEND6;
model.ATT_RULE1 = ATT_RULE1;
model.ATT_RULE2 = ATT_RULE2;
model.ATT_RULE3 = ATT_RULE3;
model.ATT_RULE4 = ATT_RULE4;
model.ATT_RULE5 = ATT_RULE5;
model.CLOCKINFREQUENCY = 0;
if (!CLOCKINFREQUENCY.IsNullOrEmpty())
model.CLOCKINFREQUENCY = int.Parse(CLOCKINFREQUENCY);
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 DelPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string PlanList = context.Request.Params["PlanList"];
string[] PlanArray = PlanList.Split(',');
string PlanListString = "";
for (int i = 0; i < PlanArray.Length; i++)
{
if (i == 0)
{
PlanListString = "'" + PlanArray[i] + "'";
}
else
{
PlanListString += ",'" + PlanArray[i] + "'";
}
}
if (bll.DeleteList(PlanListString))
{
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 GetPlanListByOrgId(HttpContext context)
{
string returnstr = "";
try
{
string ORG_ID = context.Request.Params["ORG_ID"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = bll.GetPlanListByOrgId(ORG_ID);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"data\":[] }";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "考勤计划操作请求", "按机构获取可用 考勤规则异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "考勤计划操作请求", "按机构获取可用 考勤规则");
return returnstr;
}
//按UID获取可用 考勤规则
private string GetPlanListByUID(HttpContext context)
{
string returnstr = "";
try
{
string USERS_UID = context.Request.Params["USERS_UID"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = bll.GetPlanListByUID(USERS_UID);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"data\":[] }";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "考勤计划操作请求", "按UID获取可用 考勤规则异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "考勤计划操作请求", "按UID获取可用 考勤规则");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}