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

95 lines
3.8 KiB
C#
Raw 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 DataService.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VRS.Handler.ZHC
{
/// <summary>
/// 指挥车 根据参数fault_id或tree_id 获取整棵故障树
/// 参数fault_id按照故障列表id返回故障树
/// 参数tree_id 值 all:获取树根结点的字典、10001按照树结点id获取具体故障树
/// </summary>
public class Fault_Tree_Get : BasePage, IHttpHandler
{
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
DataService.BLL.zhc_fault_tree bll_tree = new DataService.BLL.zhc_fault_tree();
DataService.BLL.zhc_fault_tree fault_tree = new DataService.BLL.zhc_fault_tree();
public override void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string fault_id = context.Request.Params["fault_id"];
if (!string.IsNullOrEmpty(fault_id))
{
var list= fault_tree.GetModelList(string.Format(" fault_list_id ='{0}' ", fault_id));
if (list.Count<=0)
{
context.Response.Write(GetJsonWithCode(APICode.Fail, new { error = "故障树不存在故障id "+ fault_id + "" }));
context.Response.End();
}
var model = list[0];
//调用递归函数,传入数据源,根节点
var tree_node = new zhc_fault_tree_node();
tree_node.tree_id = model.tree_id;
tree_node.name = model.name;
tree_node.dsc = model.dsc;
tree_node.logic_gate = model.logic_gate;
tree_node.position = model.position.Value;
tree_node.fault_list_id = model.fault_list_id;
tree_node.parent_id = model.parent_id;
var dt_tree = bll_tree.GetList("").Tables[0];
zhc_fault_tree_node.BindTree(dt_tree, tree_node);
context.Response.Write(GetJsonWithCode(APICode.Success, tree_node));
context.Response.End();
}
string tree_id = context.Request.Params["tree_id"];//故障树id
if (string.IsNullOrEmpty(tree_id))
{
context.Response.Write(GetJsonWithCode(APICode.Fail, new { error = "参数 tree_id 没赋值!" }));
context.Response.End();
}
if (tree_id.ToUpper() == "ALL")
{
var list_tree = bll_tree.GetList("tree_id,parent_id,name,fault_list_id", " parent_id is null or parent_id ='' ").Tables[0];
context.Response.Write(GetJsonWithCode(APICode.Success, list_tree));
context.Response.End();
}
var model_tree = bll_tree.GetModel(tree_id);
if (null == model_tree)
{
context.Response.Write(GetJsonWithCode(APICode.Fail, "故障树不存在tree_id:" + tree_id));
context.Response.End();
}
//调用递归函数,传入数据源,根节点
var tree = new zhc_fault_tree_node();
tree.tree_id = model_tree.tree_id;
tree.name = model_tree.name;
tree.dsc = model_tree.dsc;
tree.logic_gate = model_tree.logic_gate;
tree.position = model_tree.position.Value;
tree.fault_list_id = model_tree.fault_list_id;
tree.parent_id = model_tree.parent_id;
var dt = bll_tree.GetList("").Tables[0];
zhc_fault_tree_node.BindTree(dt, tree);
context.Response.Write(GetJsonWithCode(APICode.Success, tree));
context.Response.End();
}
public new bool IsReusable
{
get
{
return false;
}
}
}
}