using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace VRS.Handler.ZHC { /// /// 获取任务接口 /// 参数 menu_id 按照菜单树id 获取任务列表 /// 参数 task_id 值 all:获取任务字典、10001:按照任务id值获取具体任务 /// public class Task_Get : BasePage, IHttpHandler { DataService.BLL.zhc_task bll_task = new DataService.BLL.zhc_task(); DataService.BLL.zhc_task_proc bll_task_proc = new DataService.BLL.zhc_task_proc(); DataService.BLL.admin_log log = new DataService.BLL.admin_log(); public override void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string menu_id = context.Request.Params["menu_id"]; if (!string.IsNullOrEmpty(menu_id)) { var task_list = bll_task.GetModelList(string.Format(" menu_tree_id ='{0}' ", menu_id)); if (task_list.Count <= 0) { context.Response.Write(GetJsonWithCode(APICode.Fail, new { error = "任务不存在,菜单树id: " + menu_id + "!" })); context.Response.End(); } List list_result = new List(); foreach(var temp in task_list) { var item = new task(); item.taskId = temp.taskId; item.taskName = temp.taskName; item.taskType = temp.taskType; item.taskEquipment = temp.taskEquipment; var task_proc_list = bll_task_proc.GetListOrderbyPosition(string.Format("taskId= '{0}' ", temp.taskId)); item.taskProcedure.AddRange(task_proc_list); list_result.Add(item); } context.Response.Write(GetJsonWithCode(APICode.Success, list_result)); context.Response.End(); /* var model = task_list[0]; var list = bll_task_proc.GetListOrderbyPosition(string.Format("taskId= '{0}' ", model.taskId)); var result = new { model.taskId, model.taskName, model.taskType, model.taskEquipment, taskProcedure = list }; context.Response.Write(GetJsonWithCode(APICode.Success, result)); context.Response.End();*/ } string taskId = context.Request.Params["task_id"]; if (string.IsNullOrEmpty(taskId)) { context.Response.Write(GetJsonWithCode(APICode.Fail, "参数task_id不能为空!")); context.Response.End(); } if (taskId.ToUpper() == "ALL") { var top_list = bll_task.GetList("taskId,menu_tree_id,taskName,taskType,taskEquipment", "").Tables[0]; context.Response.Write(GetJsonWithCode(APICode.Success, top_list)); context.Response.End(); } var task_model = bll_task.GetModel(taskId); if (null == task_model) { context.Response.Write(GetJsonWithCode(APICode.Fail, "任务不存在!,参数task_id:"+ taskId)); context.Response.End(); } var proc_list = bll_task_proc.GetListOrderbyPosition(string.Format("taskId= '{0}' ", taskId)); var obj = new { task_model.taskId, task_model.taskName, task_model.taskType, task_model.taskEquipment, taskProcedure= proc_list }; context.Response.Write(GetJsonWithCode(APICode.Success, obj)); context.Response.End(); } public new bool IsReusable { get { return false; } } public class task { public string taskId { get; set; } public string taskName { get; set; } public string taskType { get; set; } public string taskEquipment { get; set; } public List taskProcedure = new List(); } } }