当前位置:网站首页>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
边栏推荐
- 聊聊支付流程的设计与实现逻辑
- Installing vmtools is gray
- Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
- 网络安全-安装CentOS
- Wechat forum exchange applet system graduation design completion (6) opening defense ppt
- Installing spss25
- The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
- GEE(三):计算两个波段间的相关系数与相应的p值
- STL标准模板库(Standard Template Library)一周学习总结
- PMP project management exam pass Formula-1
猜你喜欢

iNFTnews | NFT技术的广泛应用及其存在的问题

When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK

leetcode-520. Detect capital letters -js

Wechat forum exchange applet system graduation design completion (4) opening report

Wechat forum exchange applet system graduation design completion (1) development outline

微信论坛交流小程序系统毕业设计毕设(5)任务书

经纬度PLT文件格式说明

云原生正在吞噬一切,开发者该如何应对?

Description of longitude and latitude PLT file format

Wechat forum exchange applet system graduation design (2) applet function
随机推荐
Introduction to anomaly detection
微信论坛交流小程序系统毕业设计毕设(7)中期检查报告
When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK
ArcGIS: two methods of attribute fusion of the same field of vector elements
Wechat forum exchange applet system graduation design completion (4) opening report
统计电影票房排名前10的电影并存入还有一个文件
Vs extension tool notes
The 19th Zhejiang Provincial Collegiate Programming Contest 2022浙江省赛 F.EasyFix 主席树
Guessing game (read data from file)
ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
GEE(三):计算两个波段间的相关系数与相应的p值
网格(Grid)
Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
微信论坛交流小程序系统毕业设计毕设(2)小程序功能
Wechat forum exchange applet system graduation design completion (7) Interim inspection report
为什么市场需要低代码?
Classification and prediction of heartbeat signal
Wechat forum exchange applet system graduation design completion (1) development outline
【微服务|SCG】gateway整合sentinel