当前位置:网站首页>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
边栏推荐
- 微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT
- Exploratory data analysis of heartbeat signal
- The text editor of markdown class should add colors to fonts (including typora, CSDN, etc.)
- 漏洞复现----49、Apache Airflow 身份验证绕过 (CVE-2020-17526)
- Network security - install CentOS
- 13、 System optimization
- 微信论坛交流小程序系统毕业设计毕设(4)开题报告
- How to generate unique file names
- oc 可变參数传递
- UE4_UE5蓝图command节点的使用(开启关闭屏幕响应-log-发布全屏显示)
猜你喜欢

LeeCode -- 6. Zigzag transformation

十四、数据库的导出和导入的两种方法

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

re1攻防世界逆向

Brush question 4

Brush question 3

LDO稳压芯片-内部框图及选型参数

Wechat forum exchange applet system graduation design completion (8) graduation design thesis template

Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid

Software test classification
随机推荐
Circumvention Technology: Registry
STL标准模板库(Standard Template Library)一周学习总结
成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚
The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
Adrnoid开发系列(二十五):使用AlertDialog创建各种类型的对话框
Puce à tension stabilisée LDO - schéma de bloc interne et paramètres de sélection du modèle
Inftnews | web5 vs Web3: the future is a process, not a destination
LDO稳压芯片-内部框图及选型参数
位运算(Bit Operation)
Install a new version of idea. Double click it to open it
GEE(四):计算两个变量(影像)之间的相关性并绘制散点图
LDO穩壓芯片-內部框圖及選型參數
Dynamics 365 查找字段过滤
Kubernetes' simplified data storage storageclass (creation, deletion and initial use)
Introduction to redis and jedis and redis things
云原生正在吞噬一切,开发者该如何应对?
Installing vmtools is gray
Dynamics 365 find field filtering
VS扩展工具笔记
oc 可变參数传递