using FangYar.Common; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace FangYar.WebUI.ashx { /// /// EmpSyncDiningHandler 的摘要说明 /// public class EmpSyncDiningHandler : IHttpHandler { 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 "EmpAllSync": returnstr = EmpAllSync(context); break; //全部信息删除 case "EmpAllDel": returnstr = EmpAllDel(context); break; } context.Response.Write(returnstr); } #region Icc一键授权操作 /// /// 人员一键同步 /// /// /// private string EmpAllSync(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string EmpList = context.Request.Params["EmpList"]; var EmpArray = EmpList.Split(',').ToList(); EmpSyncDiningHelper.EmpInfoSync(EmpArray); msg = "操作成功!"; code = 1; } catch (Exception e) { msg = e.Message; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员餐厅同步请求", "ICC人员信息添加异常:" + e); } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员餐厅同步请求", "ICC人员信息添加"); return returnstr; } /// /// 人员一键删除 /// /// /// private string EmpAllDel(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string EmpList = context.Request.Params["EmpList"]; string orgId = context.Request.Params["orgId"]; string[] EmpArray = EmpList.Split(','); for (int i = 0; i < EmpArray.Length; i++) { EmpSyncDiningHelper.EmpInfoDel(EmpArray[i]); } msg = "操作成功!"; code = 1; } catch (Exception e) { msg = e.Message; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员餐厅同步请求", "餐厅人员信息删除异常:" + e); } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员餐厅同步请求", "餐厅人员信息删除"); return returnstr; } #endregion public bool IsReusable { get { return false; } } } }