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

138 lines
5.0 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;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class OaPerformanceBasicHandler : IHttpHandler
{
private FangYar.BLL.OA.OA_PERFORMANCE_BASIC bll = new FangYar.BLL.OA.OA_PERFORMANCE_BASIC();
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;
}
context.Response.Write(returnstr);
}
//获取列表
private string List(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
string data = "";
int count = 0;
string where = null;
try
{
string orgId = context.Request.Params["OrgId"];
where += " org_id = '" + orgId + "' ";
DataTable dt = bll.GetBaseList(where).Tables[0];
code = 0;
count = dt.Rows.Count;
data = FangYar.Common.JsonHelper.ToJson(dt);
}
catch (Exception e)
{
msg = "获取失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "基础分操作请求", "获取列表异常:" + e);
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":" + data + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "基础分操作请求", "获取列表");
return returnstr;
}
//添加
private string Add(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
int count = 0;
try
{
string orgId = context.Request.Params["OrgId"];
string tableJson = context.Request.Params["tableJson"];
byte[] outputb = Convert.FromBase64String(tableJson);
string orgStr = Encoding.Default.GetString(outputb);
string text = System.Web.HttpUtility.UrlDecode(orgStr);//将Url中的编码转换为简体汉字
List<FangYar.Model.OA.CommonSql> sqlList = new List<Model.OA.CommonSql>();
FangYar.Model.OA.CommonSql sqlModel = new Model.OA.CommonSql();
sqlModel = bll.getDelSql(orgId);
sqlList.Add(sqlModel);
JArray ppl_s = JsonConvert.DeserializeObject<JArray>(text);
foreach (JObject obj in ppl_s)
{
FangYar.Model.OA.OA_PERFORMANCE_BASIC model_basic = new Model.OA.OA_PERFORMANCE_BASIC();
model_basic.ID = Guid.NewGuid().ToString("N");
model_basic.USERUID = (string)obj["USERUID"];
model_basic.USERNAME = (string)obj["USERNAME"];
model_basic.FRACTION = (int)obj["FRACTION"];
model_basic.ORG_ID = (string)obj["ORG_ID"];
model_basic.ORG_NAME = (string)obj["ORG_NAME"];
sqlModel = bll.getAddSql(model_basic);
sqlList.Add(sqlModel);
}
bool flag = FangYar.Common.MySqlHelper.ExecuteSqlTranBool(sqlList);
if (flag)
{
code = 0;
msg = "保存成功!";
}
}
catch (Exception e)
{
msg = "保存失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "基础分操作请求", "添加异常:" + e);
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "基础分操作请求", "添加");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}