gyhlw_dotnet/网站项目/VRS/Handler/ZHC/Task_Get.ashx.cs

118 lines
4.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VRS.Handler.ZHC
{
/// <summary>
/// 获取任务接口
/// 参数 menu_id 按照菜单树id 获取任务列表
/// 参数 task_id 值 all获取任务字典、10001按照任务id值获取具体任务
/// </summary>
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<task> list_result = new List<task>();
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<DataService.Model.zhc_task_proc> taskProcedure = new List<DataService.Model.zhc_task_proc>();
}
}
}