当前位置:网站首页>树后台数据存储(採用webmethod)[通俗易懂]
树后台数据存储(採用webmethod)[通俗易懂]
2022-07-07 21:51:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
树后台数据存储
关于后台数据存储将集中在此篇解说
/*
*作者:方浩然
*日期: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; } }}
*/发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116211.html原文链接:https://javaforall.cn
边栏推荐
- Matlab 信号处理【问答随笔·2】
- The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
- Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
- Brush question 5
- Installing vmtools is gray
- Unity dynamically merges mesh textures
- UE4_UE5结合罗技手柄(F710)使用记录
- Adrnoid Development Series (XXV): create various types of dialog boxes using alertdialog
- Circumvention Technology: Registry
- USB (十七)2022-04-15
猜你喜欢

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

ArcGIS: field assignment_ The attribute table field calculator assigns values to fields based on conditions

leetcode-520. 检测大写字母-js

成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚

Brush question 4

JMeter-接口自动化测试读取用例,执行并结果回写

Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020

Comparison of various development methods of applets - cross end? Low code? Native? Or cloud development?

数据库每日一题---第22天:最后一次登录

UE4_UE5结合罗技手柄(F710)使用记录
随机推荐
QT graphicsview graphical view usage summary with flow chart development case prototype
Mitsubishi PLC SLmP (MC) protocol
Why does the market need low code?
Wechat forum exchange applet system graduation design completion (4) opening report
网络安全-安装CentOS
解决:信息中插入avi格式的视频时,提示“unsupported video format”
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
Guessing game (read data from file)
网格(Grid)
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
2022 words for yourself
消息队列与快递柜之间妙不可言的关系
成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚
[language programming] exe virus code example
Brush question 5
Brush question 3
Line test - graphic reasoning - 1 - Chinese character class
Grid
智慧社區和智慧城市之間有什麼异同
USB (十七)2022-04-15