using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; namespace FangYar.WebUI.ashx { /// /// OaSealHandler 的摘要说明 /// public class OaSealHandler : 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 "List": returnstr = GetList(context); break; case "SaveFun": returnstr = SaveFun(context); break; case "Del": returnstr = Del(context); break; case "GetById": returnstr = GetById(context); break; } context.Response.Write(returnstr); } /// /// 查询集合 /// /// /// private string GetList(HttpContext context) { string returnstr = ""; try { string SEAL_TYPE = context.Request.Params["SEAL_TYPE"]; string is_content = context.Request.Params["is_content"]; string orgId = context.Request.Params["orgId"]; 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); } int startIndex = 0; int endIndex = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } startIndex = (pageIndex - 1) * pageSize; endIndex = pageSize; string where = " where STATE = '0' "; string sqlCount = " SELECT count(1) from oa_seal "; string sqlStr = " SELECT * from oa_seal "; //是否包含下级 if (is_content == "1") { where += " and find_in_set(org_id,cids) "; sqlCount += ",(select get_Org_child_list('" + orgId + "') cids ) s "; sqlStr += ",(select get_Org_child_list('" + orgId + "') cids ) s "; } else { where += " and org_id='" + orgId + "' "; } if (!string.IsNullOrWhiteSpace(SEAL_TYPE)) { where += " and SEAL_TYPE='" + SEAL_TYPE + "' "; } sqlCount = sqlCount + where; sqlStr = sqlStr + where + " LIMIT " + startIndex + " , " + endIndex; returnstr = "{\"code\":0,\"msg\":\"\","; int count = Convert.ToInt32(FangYar.Common.MySqlHelper.QueryTable(sqlCount).Rows[0][0] + ""); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr); returnstr += FangYar.Common.JsonHelper.ToJson(dt); } 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; } /// /// 根据ID查询 /// /// /// private string GetById(HttpContext context) { string returnstr = ""; try { string id = context.Request.Params["id"]; string sqlStr = " SELECT * from oa_seal where id = '" + id + "' "; returnstr = "{\"code\":0,\"msg\":\"\","; returnstr += "\"count\":" + 0 + ",\"data\":"; DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "印章管理操作请求", "根据ID查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "印章管理操作请求", "根据ID查询"); return returnstr; } /// /// 删除 /// /// /// private string Del(HttpContext context) { string returnstr = ""; try { string id = context.Request.Params["id"]; string sqlStr = " update oa_seal set STATE='-1' where id = '" + id + "' "; FangYar.Common.MySqlHelper.Execute(sqlStr); returnstr = "{\"code\":1,\"msg\":\"OK\",\"count\":0,\"data\":[]}"; } 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 SaveFun(HttpContext context) { string returnstr = ""; try { string id = context.Request.Params["id"]; string SEAL_TYPE = context.Request.Params["SEAL_TYPE"]; string SEAL_NAME = context.Request.Params["SEAL_NAME"]; string ORG_ID = context.Request.Params["ORG_ID"]; string USERS_NAME = context.Request.Params["USERS_NAME"]; string USERS_JSON = context.Request.Params["USERS_JSON"]; string USERS_UIDS = context.Request.Params["USERS_UIDS"]; string IMG_URL = context.Request.Params["IMG_URL"]; string sqlStr = " update oa_seal set SEAL_TYPE='" + SEAL_TYPE + "',SEAL_NAME='" + SEAL_NAME + "',USERS_NAME='" + USERS_NAME + "',USERS_JSON='" + USERS_JSON + "',USERS_UIDS='" + USERS_UIDS + "',IMG_URL='" + IMG_URL + "' where id = '" + id + "' "; if (string.IsNullOrWhiteSpace(id)) { sqlStr = " insert into oa_seal (ID,SEAL_TYPE,SEAL_NAME,ORG_ID,STATE,USERS_NAME,USERS_JSON,USERS_UIDS,IMG_URL) values(uuid(),'" + SEAL_TYPE + "','" + SEAL_NAME + "','" + ORG_ID + "',0,'" + USERS_NAME + "','" + USERS_JSON + "','" + USERS_UIDS + "','" + IMG_URL + "') "; } FangYar.Common.MySqlHelper.Execute(sqlStr); returnstr = "{\"code\":1,\"msg\":\"OK\",\"count\":0,\"data\":[]}"; } 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; } } } }