Rights management System of Web development framework

Source: Internet
Author: User

Rights management System of Web development framework

Remember when I started to introduce my WinForm development framework and my WCF development framework early on, I gave the following view of a framework that I've compiled, which includes the WinForm development framework and my web development framework, Since the previous period has been busy WinForm development framework refining and optimization, and a unified collation of many WinForm development framework and the WCF Development framework of the essay. With my WinForm gradually improve, finally have time to organize the introduction of my web development framework of the matter, the following first introduce my latest optimization of the Web development framework of the Rights Management system, wherein the rights management system can be said to be a lot of love in one, in addition to the consistent and code generation tool integration, Can generate basic framework code, but also integrate WinForm development framework inherited multi-database support, in the interface layer, that is, web rights management system, integration of jquery Easy-ui interface components, powerful ztree controls, Kindeditor online editing controls, interface layer to get data and save using jquery-based JSON data operations, data local refresh and so on, which provides two different menu layout operations, it is very convenient to apply to other business system interface.

First of all, before the introduction, we have to post a few web rights system images for perceptual understanding first.

1) Simple interface layout effect. This effect on the top of the banner is relatively compact, there are some common buttons on the left, suitable for the menu function of small business systems, such as my web rights system.

2) powerful interface for enterprise business system layout. This interface effect is suitable for many functions, menu display for classification management and other business systems. The menu at the top of the frame is a one-level menu, and clicking on the Level menu can show a level two menu on the left, which does not have to list all the functions of the system at once, but instead provides a hierarchical display of functionality.

At the Top tab tab, each time you open the page, add a tab page, the page can be double-clicked to close, or you can right-click the pop-up menu to do more, as shown in.

If you need to know the effect of the whole system, you can also download "Web rights system Operation Video" for a comprehensive understanding.

In refining the process of optimizing this web permission framework, encountered a lot of problems, one after the resolution, is summarized part of the introduction.

1) construct Ztree using JSON data

Using Ztree is really a lot better than Easy-ui's own tree, and it's a lot more powerful, because in my web permissions, almost every module needs a tree control to show the relevant data, such as functions, organizations, and so on. After comparing my own traditional tree, Easy-ui tree controls, and ztree, I found that using Ztree can improve the interface score a lot. But their own examples, as well as examples on the web, mostly use pre-made tree data, and I need to dynamically use ASHX for tree data acquisition and generation, which is really a bit of a hassle to debug.

The first thing to prepare is the tree data generated from the ASHX handler, which uses the data in JSON format. The tree data as defined by the feature is shown below.

        <summary>///recursion get tree information///</summary> private string Gettreejson (int PID, str ing Foldericon, string leaficon) {string condition = string.            Format ("pid={0}", PID); list<functioninfo> nodeList = Bllfactory<function>.            Instance.find (condition);            StringBuilder content = new StringBuilder (); foreach (Functioninfo model in nodeList) {int parentid = (model. PID = =-1? 0:model.                PID); String Tempmenu = String. Format ("{{id:{0}, pid:{1}, name:\" {2}\ ", icon:\" {3}\ "}},", Model.id, ParentID, model. Name, IMGSRC); The simple practice of string submenu = this.                Gettreejson (Model.id, Foldericon, Leaficon); String Parentmenu = String. Format ("{{\" "id\": {0}, \ "Pid\": {1}, \ "name\": \ "{2}\" ", Model.id, ParentID, model.                Name); if (string. IsNullOrEmpty (submenu)) {if (!string.   IsNullOrEmpty (Leaficon))                 {Parentmenu + = string.                    Format (", \" icon\ ": \" {0}\ "}},", Leaficon);                    } else {parentmenu + = "},"; }} else {if (!string. IsNullOrEmpty (Foldericon)) {Parentmenu + = string.                    Format (", \" icon\ ": \" {0}\ "}},", Foldericon);                    } else {parentmenu + = "},"; }} content.                Appendline (Parentmenu.trim ()); Content.            Appendline (Submenu.trim ()); } return content. ToString ().        Trim ();  }

Then there is the page call, which is to enhance the experience, using JavaScript-based jquery asynchronous operations for data processing, rather than based on the processing of ASPX background pages, as shown below.

        Reloads the tree structure (async)        function Reloadtree () {            $ ("#loading"). Show ();            $.getjson ("http://www.cnblogs.com/AjaxHandler/FunctionJson.ashx?r=" + math.random () + "&op=tree", function (JSON {                $.fn.ztree.init ($ ("#treeDemo"), setting, JSON);                $.fn.ztree.getztreeobj ("Treedemo"). ExpandAll (true);                var treeobj = $.fn.ztree.getztreeobj ("Treedemo");                var treenodes = Treeobj.getnodes ();                if (treenodes! = null) {                    loaddata (treenodes[0].id);                }            });            $ ("#loading"). FadeOut (+);        }

The effect of this process is that the page is just a partial refresh and the experience is good.

2) Data loading and saving operation based on jquery

Because of the convenience of jquery and the good experience, I unified the data acquisition and preservation operations. The relevant processing code is given below for reference.

        Load the developed Object data function LoadData (ID) {$ ("#loading"). Show (); $.getjson ("http://www.cnblogs.com/AjaxHandler/FunctionJson.ashx?r=" + math.random () + "&op=findbyid&id=" +                ID, function (JSON) {$ ("#txtID"). Val (json.id); $ ("#txtName"). Val (JSON.                Name); $ ("#txtControlID"). Val (JSON.                ControlID); $ ("#txtPID"). Val (JSON.            PID);            });            $ (' #lbxRoles '). empty (); $.getjson ("http://www.cnblogs.com/AjaxHandler/RoleJson.ashx?r=" + math.random () + "&op=getrolesbyfunction& Id= "+ ID, function (JSON) {$.each (JSON, function (I, item) {$ (' #lbxRoles '). Append (' &L T;option value= "' + item.id + '" > ' + Item.                Name + ' </option> ');            });            });        $ ("#loading"). FadeOut (500); }//Save Object Data function SaveData () {$.ajax ({type: ' POST ', url: ' http: Www.cnblogs. com/ajaxhandler/functionjson.ashx?r= ' + math.random () + ' &op=insert ', async:false, dat                A: {ID: $ ("#txtID"). Val (), Name: $ ("#txtName"). Val (), ControlID: $ ("#txtControlID"). Val (), PID: $ ("#txtPID"). Val ()}, Success:function (ID) {alert ("Operation succeeded!                    ");                    Reloadtree ();                if (id! = "") LoadData (ID);                }, Error:function (XHR, status, error) {alert ("Operation failed");//xhr.responsetext        }            }); }
3) The loading effect is displayed in the middle of the page when data operation is waiting.

The whole system, in various requests operation, I have unified the practice, in the interface display loading wait effect, the task is closed, this effect in trouble operation, the user health checkup will be better, below to see its effect and implementation code.

Add the following JavaScript script

        The object centers the function, invoking the example: $ ("#loading"). Center ();        JQuery.fn.center = function () {            this.css ("position", "absolute");            This.css ("Top", Math.max (0, ($ (window). Height ()-this.outerheight ())/2) +                                                $ (window). scrolltop ()) + "px");            This.css ("Left", Math.max (0, (($ (window). Width ()-this.outerwidth ())/2) +                                                $ (window). ScrollLeft ()) + "px");            return this;        }        Initialize the object        $ (document). Ready (function () {            $ ("#loading"). Center ();//loading Display Center        });

Then add a line of code after the body of the page (the default loading picture does not show the OH).

    <div id= "Loading" style= "Display:none;" ></div>
4) Control Data vacuuming operation

Because of the addition and editing of common interface control elements, we need to empty or set the values of some controls when we want to add data, but our controls may be much more, and a good way to do this is to use the jquery selector feature for purposeful control emptying operations.

As shown in the following example.

        Added empty control        function AddData () {            $ ("#txtPID"). Val ($ ("#txtID"). Val ());            $ ("input[type=text][id*= ' txt ']"). Val ("");            $ ("textarea[id*= ' txt ']"). empty ();            $ ("select[id*= ' LBX ')". empty ();        }

Where $ ("#txtPID"). Val ($ ("#txtID"). Val ()); Is to add the current user as the ancestor of the data, the other is to empty the control's data, the different types of controls to empty the steps are somewhat different.

5) Security Considerations for ASHX processing programs

We in the system, most of the call ashx for data processing, although the general business system in the VPN or intranet running, but also to consider the user did not log in, do not run the call ASHX program, this can improve the security of the data.

The default ASHX handler is not a session operation, so we need to modify its inheritance interface (more inheritance of ireadonlysessionstate)

Before you can call the session to judge.

    <summary>    ///Permissions function operation class    ///</summary> [WebService (Namespace = "http://tempuri.org/")]    [WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)] public    class Functionjson:ihttphandler, Ireadonlysessionstate     {public                void ProcessRequest (HttpContext context)        {            //class object to explicitly implement an interface Ireadonlysessionstate to access the session data            if (context. session["Identity"] = = null)            {                throw new ArgumentException ("User not logged in! ");            }
6) Compatibility of tab interface layout.

The Web rights system provides two commonly used menu layouts for management, which is generally no problem for commonly used business systems.

Another effect is when the system is complex, you can define a level menu and an associated level two menu.

For the latter, when a menu is open, you can associate a new page and refresh the relationship of the level two menu.

        <!------------level navigation------------------> <ul class= "Navigation" style= "Display:block" >            <li><a href= "#" onclick= "Showsubmenu (' listuser.aspx ', ' User management ', ' Default ') > Rights Management </a></li> <li><a href= "#" onclick= "Showsubmenu ('. /commonpage/myjob.aspx ', ' Transaction Center development ... ', ' point ', ' Icon-organ ') ' > Affairs Center </a></li> <li><a HRE f= "#" onclick= "Showsubmenu ('.. /commonpage/building.htm ', ' Contract drafting development ... ', ') ' > Contract drafting </a></li> <li><a href= ' # ' onclick= ' sh Owsubmenu ('.. /commonpage/building.htm ', ' Contract management development ... ', ') ' > Contract management </a></li> <li><a href= "#" onclick= "sh Owsubmenu ('.. /commonpage/building.htm ', ' query printing in development ... ', ') ' > query print </a></li> <li><a href= "#" onclick= "sh Owsubmenu ('.. /commonpage/building.htm ', ' Knowledge management development ... ', ') ' > Knowledge management </a></li> <li><a href= "#" onclick= "sh Owsubmenu ('.. /commonpage/bUilding.htm ', ' System management Development ... ', ') ' > System Management </a></li> </ul> 

Well, a lot of other characteristics, continue to introduce, welcome a lot of valuable advice.

Rights management System of Web development framework

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.