当前位置:网站首页>Tree background data storage (using webmethod) [easy to understand]
Tree background data storage (using webmethod) [easy to understand]
2022-07-07 23:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Tree backstage data Storage
The background data storage will be explained in this article
/*
* author : Fang Haoran
* date :2015-05-26
* Version number :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>
/// Node class
/// </summary>
public class Node
{
/// <summary>
/// Child node
/// </summary>
public List<Node> children;
/// <summary>
/// Expand the icon
/// </summary>
public string iconOpen;
/// <summary>
/// Shrink icon
/// </summary>
public string iconClose;
/// <summary>
/// Whether it is a parent node
/// </summary>
public bool isParent;
/// <summary>
/// region gID
/// </summary>
public Guid? gID;
/// <summary>
/// Region parent gPID
/// </summary>
/*
* Tips : This line of code is too long , The system automatically comments without highlighting . One click Copy removes system comments
* public Guid? gPID; /// <summary> /// Area code /// </summary> public string sAreaCode; /// <summary> /// Regional level /// </summary> public int? iJB; /// <summary> /// Area name /// </summary> public string name; /// <summary> /// Delete logo /// </summary> public int? iDeleteMark; /// <summary> /// Date of creation /// </summary> public DateTime? dCreateDate; /// <summary> /// Creator code /// </summary> public Guid? gCreateUserId; /// <summary> /// Name of Creator /// </summary> public string sCreateUserRealname; /// <summary> /// Date of change /// </summary> public DateTime? dModifyDate; /// <summary> /// Change the moving code /// </summary> public Guid? gModifyUserId; /// <summary> /// Change the name of the person /// </summary> public string sModifyUserRealname; } /// <summary> /// Node class --【 Only for EasyUITree Use : identification id text state checked attributes children】 /// </summary> public class NodeTree { /// <summary> /// Child node /// </summary> public List<NodeTree> children; /// <summary> /// Icon /// </summary> public string iconCls; /// <summary> /// Whether it is a parent node Tacit feeling 'open'. When it comes to ‘closed’ It means that there are child nodes under this node, otherwise this node is a leaf node /// </summary> public string state; /// <summary> /// region gID /// </summary> public Guid? id; /// <summary> /// Region parent gPID /// </summary> public Guid? gPID; /// <summary> /// Area code /// </summary> public string sAreaCode; /// <summary> /// Regional level /// </summary> public int? iJB; /// <summary> /// Area name /// </summary> public string text; /// <summary> /// Delete logo /// </summary> public int? iDeleteMark; /// <summary> /// Date of creation /// </summary> public DateTime? dCreateDate; /// <summary> /// Creator code /// </summary> public Guid? gCreateUserId; /// <summary> /// Name of Creator /// </summary> public string sCreateUserRealname; /// <summary> /// Date of change /// </summary> public DateTime? dModifyDate; /// <summary> /// Change the moving code /// </summary> public Guid? gModifyUserId; /// <summary> /// Change the name of the person /// </summary> public string sModifyUserRealname; } public class attributes { } /// <summary> /// Read the list of regions 【EasyUITree】-- Below the Civil Affairs Department of Qinghai Province /// </summary> /// <returns></returns> [WebMethod] public static string GetEasyUITreeRootList() { List<NodeTree> list = new List<NodeTree>();// All nodes list = GetTreeGenNode();// Put all primary nodes into list in GetTreeThirdChilds(ref list); return JsonHelper<NodeTree>.ListToJsonString(list); } /// <summary> /// Read the list of regions -- Below the Civil Affairs Department of Qinghai Province /// </summary> /// <returns></returns> [WebMethod] public static string GetZtreeRootList() { List<Node> list = new List<Node>();// All nodes list = GetGenNode();// Put all primary nodes into list in GetThirdChilds(ref list); return JsonHelper<Node>.ListToJsonString(list); } /// <summary> /// Read the list of regions 【EasyUITree】 /// </summary> /// <returns></returns> [WebMethod] public static string GetTreeList() { List<NodeTree> list = new List<NodeTree>();// All nodes list = GetTreeGenNode();// Put all primary nodes into list in GetTreeChilds(ref list); return JsonHelper<NodeTree>.ListToJsonString(list); } /// <summary> /// Read the list of regions /// </summary> /// <returns></returns> [WebMethod] public static string GetZtreeList() { List<Node> list = new List<Node>();// All nodes list = GetGenNode();// Put all primary nodes into list in GetChilds(ref list); return JsonHelper<Node>.ListToJsonString(list); } /// <summary> /// Read subset nodes 【EasyUITree】-- Below the Civil Affairs Department of Qinghai Province /// </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> /// Read subset nodes -- Below the Civil Affairs Department of Qinghai Province /// </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> /// Get all the primary nodes 【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) { // The root node 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> /// Get all the primary nodes /// </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) { // The root node 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> /// Put all the obtained child nodes into list in 【EasyUITree】 /// </summary> /// <param name="list"> Pass values by reference , When control is passed back to the calling method , Any changes made to the parameters in the method will be reflected in the variable </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;// Load child nodes // In the form of recursion GetTreeChilds(ref nodeList); } } } /// <summary> /// Put all the obtained child nodes into list in /// </summary> /// <param name="list"> Pass values by reference , When control is passed back to the calling method , Any changes made to the parameters in the method will be reflected in the variable </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;// Load child nodes // In the form of recursion GetChilds(ref nodeList); } } } /// <summary> /// According to the parent node id Get child nodes /// </summary> /// <param name="list"> Parent node id</param> /// <returns> The asynchronous call 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> /// According to the parent node id Get child nodes /// </summary> /// <param name="list"> Parent node 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(); // Imitate child nodes 【child】 attribute // Infer whether the leaf node contains child nodes and set attributes if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0) { children.state = "closed";// Default true children.iconCls = iconOpen;// Default icon } 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> /// According to the parent node id Get child nodes /// </summary> /// <param name="list"> Parent node 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(); // Imitate child nodes 【child】 attribute // Infer whether the leaf node contains child nodes and set attributes if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0) { children.isParent = true;// Default true children.iconOpen = iconOpen;// Default Expand properties children.iconClose = iconClose;// Default Shrink properties } 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> /// According to the parent node id Get child nodes /// </summary> /// <param name="list"> Parent node 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(); // Imitate child nodes 【child】 attribute // Infer whether the leaf node contains child nodes and set attributes if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0) { children.isParent = true;// Default true children.iconOpen = iconOpen;// Default Expand properties children.iconClose = iconClose;// Default Shrink properties } 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; } }}
*/Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116211.html Link to the original text :https://javaforall.cn
边栏推荐
- 经纬度PLT文件格式说明
- Network security - information query of operating system
- FreeLink开源呼叫中心设计思想
- kubernetes的简单化数据存储StorageClass(建立和删除以及初步使用)
- Brush question 4
- Wechat forum exchange applet system graduation design completion (4) opening report
- Wechat forum exchange applet system graduation design completion (7) Interim inspection report
- opencv scalar传入三个参数只能显示黑白灰问题解决
- The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
- 力扣解法汇总648-单词替换
猜你喜欢

海内外技术人们“看”音视频技术的未来

LeeCode -- 6. Zigzag transformation

Wechat forum exchange applet system graduation design completion (7) Interim inspection report

STL标准模板库(Standard Template Library)一周学习总结

在软件工程领域,搞科研的这十年!

ArcGIS:矢量要素相同字段属性融合的两种方法

微信论坛交流小程序系统毕业设计毕设(3)后台功能

微信论坛交流小程序系统毕业设计毕设(2)小程序功能

Install a new version of idea. Double click it to open it

微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT
随机推荐
Description of longitude and latitude PLT file format
leetcode-520. 检测大写字母-js
Wechat forum exchange applet system graduation design completion (1) development outline
Matlab-SEIR传染病模型预测
Inftnews | web5 vs Web3: the future is a process, not a destination
2021-01-11
FreeLink开源呼叫中心设计思想
Oracle-数据库的备份与恢复
力扣解法汇总648-单词替换
Install Fedora under RedHat
网络安全-对操作系统进行信息查询
七月第一周
Conversion between commonsmultipartfile and file
U盘拷贝东西时,报错卷错误,请运行chkdsk
网络安全-安装CentOS
Advantages and disadvantages of rest ful API
USB(十四)2022-04-12
USB (十八)2022-04-17
网络安全-sqlmap与DVWA爆破
在软件工程领域,搞科研的这十年!