树后台数据存储(採用webmethod)
树后台数据存储
关于后台数据存储将集中在此篇解说
/*
*作者:方浩然
*日期:2015-05-26
*版本号:1.0
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BF.IBLL.MedicalTreatmentCombination;
using Base.Core.UnityFactory;
using System.Collections;
using BF.Model;
using LitJson;
using System.Web.Services;
using System.Linq.Expressions; namespace BF.Web.pages.MedicalTreatmentCombination
{
public partial class ZtreeForm : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
private static readonly Isys_OrganizeBLL iORGBLL = IOCFactory.GetIOCResolve<Isys_OrganizeBLL>();
private static readonly string iconOpen = HttpUtility.UrlEncode(@"zTree-zTree_v3-master/zTree_v3/css/zTreeStyle/img/diy/1_open.png");
private static readonly string iconClose = HttpUtility.UrlEncode(@"zTree-zTree_v3-master/zTree_v3/css/zTreeStyle/img/diy/1_close.png"); /// <summary>
/// 节点类
/// </summary>
public class Node
{
/// <summary>
/// 子节点
/// </summary>
public List<Node> children;
/// <summary>
/// 展开图标
/// </summary>
public string iconOpen;
/// <summary>
/// 收缩图标
/// </summary>
public string iconClose;
/// <summary>
/// 是否是父级节点
/// </summary>
public bool isParent;
/// <summary>
/// 地区gID
/// </summary>
public Guid? gID;
/// <summary>
/// 地区父gPID
/// </summary>
public Guid? gPID;
/// <summary>
/// 地区编码
/// </summary>
public string sAreaCode;
/// <summary>
/// 地区级别
/// </summary>
public int? iJB;
/// <summary>
/// 地区名称
/// </summary>
public string name;
/// <summary>
/// 删除标识
/// </summary>
public int? iDeleteMark;
/// <summary>
/// 创建日期
/// </summary>
public DateTime? dCreateDate;
/// <summary>
/// 创建人编码
/// </summary>
public Guid? gCreateUserId;
/// <summary>
/// 创建人姓名
/// </summary>
public string sCreateUserRealname;
/// <summary>
/// 改动日期
/// </summary>
public DateTime? dModifyDate;
/// <summary>
/// 改动人编码
/// </summary>
public Guid? gModifyUserId;
/// <summary>
/// 改动人姓名
/// </summary>
public string sModifyUserRealname;
} /// <summary>
/// 节点类--【仅供EasyUITree使用:标识id text state checked attributes children】
/// </summary>
public class NodeTree
{
/// <summary>
/// 子节点
/// </summary>
public List<NodeTree> children;
/// <summary>
/// 图标
/// </summary>
public string iconCls;
/// <summary>
/// 是否是父级节点 默觉得'open'. 当为‘closed’时说明此节点下有子节点否则此节点为叶子节点
/// </summary>
public string state;
/// <summary>
/// 地区gID
/// </summary>
public Guid? id;
/// <summary>
/// 地区父gPID
/// </summary>
public Guid? gPID;
/// <summary>
/// 地区编码
/// </summary>
public string sAreaCode;
/// <summary>
/// 地区级别
/// </summary>
public int? iJB;
/// <summary>
/// 地区名称
/// </summary>
public string text;
/// <summary>
/// 删除标识
/// </summary>
public int? iDeleteMark;
/// <summary>
/// 创建日期
/// </summary>
public DateTime? dCreateDate;
/// <summary>
/// 创建人编码
/// </summary>
public Guid? gCreateUserId;
/// <summary>
/// 创建人姓名
/// </summary>
public string sCreateUserRealname;
/// <summary>
/// 改动日期
/// </summary>
public DateTime? dModifyDate;
/// <summary>
/// 改动人编码
/// </summary>
public Guid? gModifyUserId;
/// <summary>
/// 改动人姓名
/// </summary>
public string sModifyUserRealname;
} public class attributes
{ } /// <summary>
/// 读取地区列表【EasyUITree】--青海省民政厅以下一级
/// </summary>
/// <returns></returns>
[WebMethod]
public static string GetEasyUITreeRootList()
{
List<NodeTree> list = new List<NodeTree>();//全部节点
list = GetTreeGenNode();//将全部一级节点放到list中
GetTreeThirdChilds(ref list);
return JsonHelper<NodeTree>.ListToJsonString(list);
} /// <summary>
/// 读取地区列表--青海省民政厅以下一级
/// </summary>
/// <returns></returns>
[WebMethod]
public static string GetZtreeRootList()
{
List<Node> list = new List<Node>();//全部节点
list = GetGenNode();//将全部一级节点放到list中
GetThirdChilds(ref list);
return JsonHelper<Node>.ListToJsonString(list);
} /// <summary>
/// 读取地区列表【EasyUITree】
/// </summary>
/// <returns></returns>
[WebMethod]
public static string GetTreeList()
{
List<NodeTree> list = new List<NodeTree>();//全部节点
list = GetTreeGenNode();//将全部一级节点放到list中
GetTreeChilds(ref list);
return JsonHelper<NodeTree>.ListToJsonString(list);
} /// <summary>
/// 读取地区列表
/// </summary>
/// <returns></returns>
[WebMethod]
public static string GetZtreeList()
{
List<Node> list = new List<Node>();//全部节点
list = GetGenNode();//将全部一级节点放到list中
GetChilds(ref list);
return JsonHelper<Node>.ListToJsonString(list);
} /// <summary>
/// 读取子集节点【EasyUITree】--青海省民政厅以下一级
/// </summary>
/// <param name="list"></param>
[WebMethod]
public static void GetTreeThirdChilds(ref List<NodeTree> list)
{
foreach (NodeTree node in list)
{
List<NodeTree> nodeList = GetTreeThirdChildsID(node.id);
if (nodeList.Count > 0)
{
if (node.iJB <= 0)
node.children = nodeList;
GetTreeThirdChilds(ref nodeList);
}
break;
}
} /// <summary>
/// 读取子集节点--青海省民政厅以下一级
/// </summary>
/// <param name="list"></param>
[WebMethod]
public static void GetThirdChilds(ref List<Node> list)
{
foreach (Node node in list)
{
List<Node> nodeList = GetThirdChildsID(node.gID);
if (nodeList.Count > 0)
{
if (node.iJB <= 0)
node.children = nodeList;
GetThirdChilds(ref nodeList);
}
break;
}
} /// <summary>
/// 获全部的一级节点【EasyUITree】
/// </summary>
/// <param name="nodeList"></param>
/// <returns></returns>
[WebMethod]
public static List<NodeTree> GetTreeGenNode()
{
List<NodeTree> nodeList = new List<NodeTree>();
List<NodeTree> childrenList = new List<NodeTree>();
NodeTree node = new NodeTree();
NodeTree children = new NodeTree();
List<sys_Organize> genList = iORGBLL.GetList(P => P.iJB == -1 && P.iDeleteMark == 0);
if (genList != null && genList.Count > 0)
{
foreach (sys_Organize genItem in genList)
{
//根节点 node
node.id = genItem.gID;
node.gPID = genItem.gPID;
node.sAreaCode = genItem.sAreaCode;
node.iJB = genItem.iJB;
node.text = genItem.sFullName;
node.iDeleteMark = genItem.iDeleteMark;
node.dCreateDate = genItem.dCreateDate;
node.gCreateUserId = genItem.gCreateUserId;
node.sCreateUserRealname = genItem.sCreateUserRealname;
node.dModifyDate = genItem.dModifyDate;
node.gModifyUserId = genItem.gModifyUserId;
node.sModifyUserRealname = genItem.sModifyUserRealname;
if (iORGBLL.GetList(P => P.gPID == genItem.gID && P.iDeleteMark == 0).Count > 0)
{
node.state = "closed";
node.iconCls = iconOpen;
} childrenList.Add(children);
}
if (childrenList.Count > 0)
node.children = childrenList;
nodeList.Add(node);
}
return nodeList;
} /// <summary>
/// 获全部的一级节点
/// </summary>
/// <param name="nodeList"></param>
/// <returns></returns>
[WebMethod]
public static List<Node> GetGenNode()
{
List<Node> nodeList = new List<Node>();
List<Node> childrenList = new List<Node>();
Node node = new Node();
Node children = new Node();
List<sys_Organize> genList = iORGBLL.GetList(P => P.iJB == -1 && P.iDeleteMark == 0);
if (genList != null && genList.Count > 0)
{
foreach (sys_Organize genItem in genList)
{
//根节点 node
node.gID = genItem.gID;
node.gPID = genItem.gPID;
node.sAreaCode = genItem.sAreaCode;
node.iJB = genItem.iJB;
node.name = genItem.sFullName;
node.iDeleteMark = genItem.iDeleteMark;
node.dCreateDate = genItem.dCreateDate;
node.gCreateUserId = genItem.gCreateUserId;
node.sCreateUserRealname = genItem.sCreateUserRealname;
node.dModifyDate = genItem.dModifyDate;
node.gModifyUserId = genItem.gModifyUserId;
node.sModifyUserRealname = genItem.sModifyUserRealname;
if (iORGBLL.GetList(P => P.gPID == genItem.gID && P.iDeleteMark == 0).Count > 0)
{
node.isParent = true;
node.iconOpen = iconOpen;
node.iconClose = iconClose;
} childrenList.Add(children);
}
if (childrenList.Count > 0)
node.children = childrenList;
nodeList.Add(node);
}
return nodeList;
} /// <summary>
/// 将获取的全部的子节点放到list中【EasyUITree】
/// </summary>
/// <param name="list">按引用传值,当控制权传递回调用方法时,在方法中对參数所做的不论什么更改都将反映在该变量中</param>
/// <returns></returns>
[WebMethod]
public static void GetTreeChilds(ref List<NodeTree> list)
{
foreach (NodeTree node in list)
{
List<NodeTree> nodeList = GetTreeThirdChildsID(node.id);
if (nodeList.Count > 0)
{
node.children = nodeList;//载入子节点
//採用递归的形式
GetTreeChilds(ref nodeList);
}
}
} /// <summary>
/// 将获取的全部的子节点放到list中
/// </summary>
/// <param name="list">按引用传值,当控制权传递回调用方法时,在方法中对參数所做的不论什么更改都将反映在该变量中</param>
/// <returns></returns>
[WebMethod]
public static void GetChilds(ref List<Node> list)
{
foreach (Node node in list)
{
List<Node> nodeList = GetChildsID(node.gID);
if (nodeList.Count > 0)
{
node.children = nodeList;//载入子节点
//採用递归的形式
GetChilds(ref nodeList);
}
}
} /// <summary>
/// 依据父节点的id获取子节点
/// </summary>
/// <param name="list">父节点id</param>
/// <returns>异步调用返回List<Node></returns>
[WebMethod]
public static string GetRootByChildsID(string gid)
{
Guid id = new Guid();
Guid.TryParse(gid, out id);
List<Node> list = GetThirdChildsID(id);
return JsonHelper<Node>.ListToJsonString(list);
} /// <summary>
/// 依据父节点的id获取子节点
/// </summary>
/// <param name="list">父节点id</param>
/// <returns></returns>
[WebMethod]
public static List<NodeTree> GetTreeThirdChildsID(Guid? gid)
{
List<NodeTree> childrenList = new List<NodeTree>();
foreach (sys_Organize childrenItem in iORGBLL.GetList(P => P.gPID == gid && P.iDeleteMark == 0))
{
NodeTree children = new NodeTree();
//仿造子节点【child】属性
//推断叶子节点是否含有子节点并设置属性
if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0)
{
children.state = "closed";//默认 true
children.iconCls = iconOpen;//默认图标
}
children.id = childrenItem.gID;
children.gPID = childrenItem.gPID;
children.sAreaCode = childrenItem.sAreaCode;
children.iJB = childrenItem.iJB;
children.text = childrenItem.sFullName;
children.iDeleteMark = childrenItem.iDeleteMark;
children.dCreateDate = childrenItem.dCreateDate;
children.gCreateUserId = childrenItem.gCreateUserId;
children.sCreateUserRealname = childrenItem.sCreateUserRealname;
children.dModifyDate = childrenItem.dModifyDate;
children.gModifyUserId = childrenItem.gModifyUserId;
children.sModifyUserRealname = childrenItem.sModifyUserRealname; childrenList.Add(children);
}
return childrenList;
} /// <summary>
/// 依据父节点的id获取子节点
/// </summary>
/// <param name="list">父节点id</param>
/// <returns></returns>
[WebMethod]
public static List<Node> GetThirdChildsID(Guid? gid)
{
List<Node> childrenList = new List<Node>();
foreach (sys_Organize childrenItem in iORGBLL.GetList(P => P.gPID == gid && P.iDeleteMark == 0))
{
Node children = new Node();
//仿造子节点【child】属性
//推断叶子节点是否含有子节点并设置属性
if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0)
{
children.isParent = true;//默认 true
children.iconOpen = iconOpen;//默认 展开属性
children.iconClose = iconClose;//默认 收缩属性
}
children.gID = childrenItem.gID;
children.gPID = childrenItem.gPID;
children.sAreaCode = childrenItem.sAreaCode;
children.iJB = childrenItem.iJB;
children.name = childrenItem.sFullName;
children.iDeleteMark = childrenItem.iDeleteMark;
children.dCreateDate = childrenItem.dCreateDate;
children.gCreateUserId = childrenItem.gCreateUserId;
children.sCreateUserRealname = childrenItem.sCreateUserRealname;
children.dModifyDate = childrenItem.dModifyDate;
children.gModifyUserId = childrenItem.gModifyUserId;
children.sModifyUserRealname = childrenItem.sModifyUserRealname; childrenList.Add(children);
}
return childrenList;
} /// <summary>
/// 依据父节点的id获取子节点
/// </summary>
/// <param name="list">父节点id</param>
/// <returns></returns>
[WebMethod]
public static List<Node> GetChildsID(Guid? gid)
{
List<Node> childrenList = new List<Node>();
foreach (sys_Organize childrenItem in iORGBLL.GetList(P => P.gPID == gid && P.iDeleteMark == 0))
{
Node children = new Node();
//仿造子节点【child】属性
//推断叶子节点是否含有子节点并设置属性
if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0)
{
children.isParent = true;//默认 true
children.iconOpen = iconOpen;//默认 展开属性
children.iconClose = iconClose;//默认 收缩属性
}
children.gID = childrenItem.gID;
children.gPID = childrenItem.gPID;
children.sAreaCode = childrenItem.sAreaCode;
children.iJB = childrenItem.iJB;
children.name = childrenItem.sFullName;
children.iDeleteMark = childrenItem.iDeleteMark;
children.dCreateDate = childrenItem.dCreateDate;
children.gCreateUserId = childrenItem.gCreateUserId;
children.sCreateUserRealname = childrenItem.sCreateUserRealname;
children.dModifyDate = childrenItem.dModifyDate;
children.gModifyUserId = childrenItem.gModifyUserId;
children.sModifyUserRealname = childrenItem.sModifyUserRealname; childrenList.Add(children);
}
return childrenList;
}
}
}
树后台数据存储(採用webmethod)的更多相关文章
- OpenStack Ceilometer -- 后台数据存储优化之MongoDB的分片存储设置
https://xiaofandh12.github.io/Mongo-Shard 关于MongoDB MongoDB中的概念与关系型数据库之间的对应: Database --> Databas ...
- 通俗易懂理解 MySQL B+树、数据存储、索引等知识
文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247485630&idx=1&sn=681c9c0d ...
- Berkeley DB的数据存储结构——哈希表(Hash Table)、B树(BTree)、队列(Queue)、记录号(Recno)
Berkeley DB的数据存储结构 BDB支持四种数据存储结构及相应算法,官方称为访问方法(Access Method),分别是哈希表(Hash Table).B树(BTree).队列(Queue) ...
- SSIS 数据流的执行树和数据管道
数据流组件的设计愿景是快速处理海量的数据,为了实现该目标,SSIS数据源引擎需要创建执行树和数据管道这两个数据结构,而用户为了快速处理数据流,必须知道各个转换组件的阻塞性,充分利用流式处理流程,利用更 ...
- 重新学习MySQL数据库3:Mysql存储引擎与数据存储原理
重新学习Mysql数据库3:Mysql存储引擎与数据存储原理 数据库的定义 很多开发者在最开始时其实都对数据库有一个比较模糊的认识,觉得数据库就是一堆数据的集合,但是实际却比这复杂的多,数据库领域中有 ...
- Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考
Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考 在计算机世界中经常需要与数据打交道,这也是我们戏称CURD工程师的原因之 ...
- 【转帖】LSM树 和 TSM存储引擎 简介
LSM树 和 TSM存储引擎 简介 2019-03-08 11:45:23 长烟慢慢 阅读数 461 收藏 更多 分类专栏: 时序数据库 版权声明:本文为博主原创文章,遵循CC 4.0 BY-S ...
- 循序渐进VUE+Element 前端应用开发(27)--- 数据表的动态表单设计和数据存储
在我们一些系统里面,有时候会需要一些让用户自定义的数据信息,一般这些可以使用扩展JSON进行存储,不过每个业务表的显示项目可能不一样,因此需要根据不同的表单进行设计,然后进行对应的数据存储.本篇随笔结 ...
- Android——几种数据存储应用浅谈
(1)android中的数据存储主要有五种方式: 第一种.sharedPreferences存储数据, 适用范围:保存少量的数据,且这些数据的格式非常简单:字符串型.基本类型的值.比如应用程序的各种配 ...
随机推荐
- ThinkPHP - URL - 伪静态 - 路由 - 重写
URL: 一.URL规则 1.默认是区分大小写,可以修改(配置文件)为不区分大小写. 2. //修改URL大小写问题 'URL_CASE_INSENSITIVE' =>true, 如果模块名为 ...
- java String 怎么看里面有几个指定字符
我现在有一个String 字符串,我想看一下这个字符串里有几个指定的字符,比如指定字符是div求解 public class Main { public static void main(String ...
- ThinkPHP文件上传类
TP框架自带文件上传类使用: 类文件在ThinkPHP/Library/Think/默认在目录下 public function upload(){ $upload = new \Think\Uplo ...
- Java -- WeakHashMap
一.引言 Java中的引用类型由四种情况,强引用.软引用.弱引用.虚引用.关于这些的介绍可以参见鄙人另外一篇博文. ...
- CodeForces 276D – Little Girl and Maximum XOR 贪心
整整10个月后第二次搞这个问题才搞懂........第一次还是太随意了. 解题思路: 经过打表可得规律答案要么是0 要么是2的N次 - 1 要得到最大的XOR值,其值一定是2的N次 - 1 即在 l ...
- Xcode6项目运行在真机上未铺满整个屏幕
如图 解决见图: 再次运行:
- ASP.NET MVC 5 学习教程:数据迁移之添加字段
原文 ASP.NET MVC 5 学习教程:数据迁移之添加字段 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符 ...
- Clojure学习05:谓词函数
谓词函数是一个判断式,一个返回bool值的函数. clojure中(lisp习惯)有个规定:对于判断功能的函数,函数名后面都有一个“?”号.所以只要看到后面带问号的函数名,就知道这一定是一个判断函数. ...
- 测试DOM0级事件和DOM2级事件的堆叠
1. 问题 如果大家看过北风网CJ讲师的Javascript视频教程,就可以看到其封装了一个很强的事件添加和删除函数,如下所示 function addEvent(obj, evtype, fn) { ...
- JMS开源比较
Java开源JMS消息中间件 mom4j mom4j是一个完全实现JMS1.1规范的消息中间件并且向下兼容JMS1.0与1.02.它提供了自己的消息处理存储使它独立于关系数据与语言,所以它的客户端可以 ...