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 { /// /// OaLeaveHandler 的摘要说明 /// public class OaAlreaHandler : IHttpHandler { private FangYar.BLL.OA_ALREADYPROCESSED bll = new FangYar.BLL.OA_ALREADYPROCESSED(); private FangYar.BLL.OA_WAITPROCESSED wbll = new FangYar.BLL.OA_WAITPROCESSED(); public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string action = context.Request.Params["Action"]; string returnstr = ""; switch (action) { case "List": returnstr = getAlreaList(context); break; case "getProcessedList": returnstr = getProcessedList(context); break; } context.Response.Write(returnstr); } //查询 private string getAlreaList(HttpContext context) { string returnstr = ""; try { string userId = context.Request.Params["userId"]; string keyword = context.Request.Params["keywords"]; string state = context.Request.Params["state"]; 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 = "PPL_ID = '" + userId + "'"; if (!string.IsNullOrEmpty(state)) { if (where != null) { where += " and "; } where += " TASK_TYPE = '" + state + "' "; } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += "( APPLE_NAME like '%" + keyword + "%' or A_OPINION like '%" + keyword + "%')"; } where += " order by a_time desc"; returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; } return returnstr; } //根据状态判断查询待办表还是已办表还是都查询 private string getProcessedList(HttpContext context) { string returnstr = ""; try { string userId = context.Request.Params["userId"]; string page = context.Request.Params["page"]; string type = context.Request.Params["type"]; 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 = "PPL_ID = '" + userId + "' order by a_time desc"; returnstr = "{\"code\":0,\"msg\":\"\","; if (type == "0") { int count = wbll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = wbll.QueryList(pageIndex, pageSize, where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } } else if (type == "1") { int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } } else { returnstr += "\"data\":"; DataTable data = bll.getProcesseList(pageIndex, pageSize, userId); returnstr += FangYar.Common.JsonHelper.ToJson(data); } returnstr += "}"; } catch { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; } return returnstr; } public bool IsReusable { get { return false; } } } }