当前位置:网站首页>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
边栏推荐
- Guessing game (read data from file)
- 14、 Two methods of database export and import
- USB(十六)2022-04-28
- Archlinux install MySQL
- Specific method example of V20 frequency converter manual automatic switching (local remote switching)
- The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
- Transform XL translation
- 二叉树(Binary Tree)
- 漏洞复现----49、Apache Airflow 身份验证绕过 (CVE-2020-17526)
- Two kinds of curves in embedded audio development
猜你喜欢
V20变频器手自动切换(就地远程切换)的具体方法示例
Wechat forum exchange applet system graduation design completion (6) opening defense ppt
微信论坛交流小程序系统毕业设计毕设(7)中期检查报告
re1攻防世界逆向
Add data analysis tools in Excel
LeeCode -- 6. Z 字形变换
In the field of software engineering, we have been doing scientific research for ten years!
UE4_UE5全景相机
JMeter interface automated test read case, execute and write back result
USB(十五)2022-04-14
随机推荐
统计电影票房排名前10的电影并存入还有一个文件
I wish you all the best and the year of the tiger
Kubernetes' simplified data storage storageclass (creation, deletion and initial use)
Exploratory data analysis of heartbeat signal
JS triangle
Brush question 4
What are the similarities and differences between smart communities and smart cities
UE4_UE5全景相机
Two kinds of curves in embedded audio development
re1攻防世界逆向
leetcode-520. Detect capital letters -js
Why does the market need low code?
RE1 attack and defense world reverse
Binary tree
The 19th Zhejiang Provincial Collegiate Programming Contest 2022浙江省赛 F.EasyFix 主席树
Circumvention Technology: Registry
位运算(Bit Operation)
Description of longitude and latitude PLT file format
嵌入式音频开发中的两种曲线
Dynamics 365 查找字段过滤