Tree background data store (with WebMethod)

Source: Internet
Author: User
Tags call back urlencode

The Tree Collection chapter:

Sixth: Tree background data storage:

Todo:

The background data store will focus on this tutorial:

/* * Party Hao * Date: 2015-05-26 * Version: 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 (O Bject sender, EventArgs e) {} private static readonly isys_organizebll IORGBLL = Iocfactory.getiocre        Solve<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>/////</summary> Publ            IC list<node> Children;            <summary>///Expand Icon///</summary> public string Iconopen;            <summary>///Shrink icon///</summary> public string iconclose;            <summary>//Whether it is a parent node///</summary> public bool isparent; <summary>///regional GID///</summary> public Guid?            GID; <summary>///regional parent Gpid///</summary> public Guid?            Gpid;            <summary>///region code///</summary> public string Sareacode; <summary>///regional level//</summary> public int?            IJB;   <summary>         Region name///</summary> public string name; <summary>///delete identity///</summary> public int?            Ideletemark; <summary>//Creation date///</summary> public DateTime?            Dcreatedate; <summary>///Creator code///</summary> public Guid?            Gcreateuserid;            <summary>//Creator name///</summary> public string screateuserrealname; <summary>//modification date///</summary> public DateTime?            Dmodifydate; <summary>///modifier code///</summary> public Guid?            Gmodifyuserid;        <summary>//modifier name////</summary> public string smodifyuserrealname; }//<summary>// Node class--"for easyuitree use only: Identity ID text State checked attributes Children"///</summary> public class Nodetre e {//<summary>///Sub-node///</summary> public List<nod            Etree> children;            <summary>///icons///</summary> public string iconcls; <summary>//Whether the parent node defaults to ' open '.            When ' closed ' is indicated that there are child nodes under this node otherwise this node is a leaf node///</summary> public string State; <summary>///regional GID///</summary> public Guid?            Id <summary>///regional parent Gpid///</summary> public Guid?            Gpid;            <summary>///region code///</summary> public string Sareacode; <summary>///regional level//</summary> public int?   IJB;         <summary>///region name///</summary> public string text; <summary>///delete identity///</summary> public int?            Ideletemark; <summary>//Creation date///</summary> public DateTime?            Dcreatedate; <summary>///Creator code///</summary> public Guid?            Gcreateuserid;            <summary>//Creator name///</summary> public string screateuserrealname; <summary>//modification date///</summary> public DateTime?            Dmodifydate; <summary>///modifier code///</summary> public Guid?            Gmodifyuserid;        <summary>//modifier name////</summary> public string smodifyuserrealname;       } public class Attributes {}///<summary>///Read region list "Easyuitree"--Qinghai Provincial civil Affairs department at the following level// </summary>//<returns></returns> [WebMethod] public static string Geteasyuitreer Ootlist () {list<nodetree> list = new list<nodetree> ();//all nodes List = Gettreegenno            De ();//Place all first-level nodes in the list gettreethirdchilds (ref list); return jsonhelper<nodetree>.        Listtojsonstring (list); }///<summary>///Read Region list--Qinghai provincial civil Affairs department below level///</summary>//<returns></retu rns> [WebMethod] public static string Getztreerootlist () {list<node> List = new            List<node> ();//all nodes list = Getgennode ();//Place all first-level nodes in list getthirdchilds (ref list); return jsonhelper<node>.        Listtojsonstring (list); }///<summary>//Read the area list "Easyuitree"/</summary>//<returns></returns> [WebMethod] public static string Gettreelist ( {list<nodetree> list = new list<nodetree> ();//all nodes List = Gettreegennode ();//Will            All first-level nodes are placed in the list Gettreechilds (ref list); return jsonhelper<nodetree>.        Listtojsonstring (list);        }///<summary>//Read the area list//</summary>//<returns></returns> [WebMethod] public static string Getztreelist () {list<node> List = new List<node&gt            ;();//all nodes list = Getgennode ();//Place all first-level nodes in list getchilds (ref list); return jsonhelper<node>.        Listtojsonstring (list); }///<summary>//Read subset node "Easyuitree"--Qinghai Provincial civil Affairs department the following level///</summary>//<param NA Me= "List" ></param> [WebMethod] public static void Gettreethirdchilds (ref list&Lt Nodetree> list) {foreach (Nodetree node in list) {list<nodetree> No                Delist = Gettreethirdchildsid (node.id); if (Nodelist.count > 0) {if (node.ijb <= 0) Node.children                    = NodeList;                Gettreethirdchilds (ref nodeList);            } break; }}///<summary>//Read subset node--Qinghai provincial civil Affairs department the following level///</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>///For all first-level nodes "easyuitree"///</summary>//<param Nam E= "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)                    {//root 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>///For all first-level 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)                    {//root 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>///will get all the child nodes into the list "Easyuitree"///</summary>//<param Nam e= "List" > by reference, when control is passed back to the calling method, any changes to the parameters in the method are reflected in the variable </param>//<returns></returns> [We  Bmethod] 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 node//with Recursive                Form Gettreechilds (ref nodeList); }}}///<summary>///will get all child nodes in List////</summary>//&lt ;p Aram Name= "List" > by reference, when control is passed back to the calling method, any changes made to the parameter 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 node//with Recursive                Form Getchilds (ref nodeList); }}}////<summary>///For child nodes based on parent node ID///</summary>//<par        Am name= "List" > Parent node id</param>///<returns> Asynchronous Call back 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>///Get child nodes based on parent node ID///</summary>//<param name= "List" > parent node I d</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 ();  Copy the child node "Children" attribute//determine if the leaf node contains child nodes and set the property 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>///Get child nodes based on parent node ID///</summary>//<param name= "List" > parent node I d</param>//<returns></returns> [WebMethod] public static list<node> Getthi            Rdchildsid (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 ();  Copy the child node "Children" attribute//determine if the leaf node contains child nodes and set the property if (iorgbll.getlist (P = = P.gpid = = Childrenitem.gid && P.ideletemark = = 0). Count > 0) {children.isparent = true;//default True Children.iconopen = iconopen;//Default Unwind Property Children.iconclose = iconclose;//Default Shrink property} 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>///Get child nodes based on parent node ID///</summary>//<param name= "List" > parent node I d</param>//<returns></returns> [WebMethod] public static list<node> Getchi            Ldsid (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 ();  Copy the child node "Children" attribute//determine if the leaf node contains child nodes and set the property 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 property} Children.gid = Childreni                Tem.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; }    }}


Tree background data store (with WebMethod)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.