Winform development framework-permission management system improvement-winform development framework-permission management system

Source: Internet
Author: User
Document directory
  • 1. system type management
  • 2. menu management
  • 3. Function Management
  • 4. Log Management

Permission management systems have always been required by many MIS systems and some common management systems. Therefore, they can be developed as independent modules and integrated as needed, you do not need to start development from scratch unless you have special system requirements. In my essay on the winform development framework, I wrote some introductions about my general permission management system in winform Development Framework's permission management system, at that time, this version was still traditional style, and the interface was as follows.

 

Due to the needs of my winform development framework, I have extended the permission management system, dictionary management module, and paging controls to support traditional styles, dotnetbar control styles, and devexpress control styles. Many of these styles have been introduced before. This article mainly introduces the permission management system using the devexpress control style, and extends and improves some new functions, including system type management, menu management, function management, login log management and other modules.

This permission management system includes user management, organization management, role management, system type definition, function management, menu management, and user logon log management, and permission Control and Management for corresponding objects. The entire permission management system is based on RBAC (Role-Based Access Control) for permission control. It is an independent permission management system that can be integrated with the business system when necessary, to achieve efficient use and unified management of common modules.

1. system type management

The system type is a system classification defined in the permission system. For different systems, we use this definition to differentiate, you can manage multiple business systems (although we generally manage only one system ). The system type management interface is as follows.

The management of this object has been in the permission system and initialized by modifying the database. However, I think it is maintained as an independent data, it is convenient to set and manage the data associated with the system type, such as the function definition, menu, and login log.

This is because the function definition is based on the definition of a series of function control IDs added by a system, which facilitates the basis of button-level and data-level permission control.

The menu definition is used to implement menus based on the dynamic configuration function module. The original intention of this module is to facilitate the dynamic configuration of winform or Web function menus, different systems must have different menus.

Login log management is used to easily record the calls of important interfaces from the Business System to the permission system interfaces, such as login and password modification operations. Generally, we use different business systems to differentiate their data.

2. menu management

As mentioned earlier, the menu management here refers to the menu that is used to implement the menu based on the dynamic configuration function module and to achieve the integration and unification of winform and web menus. For different systems, menu definitions are different, so they are based on data management under a system type.

To effectively manage menu data, I use a tree control to display the menu relationship and use the splitcontainer control to reasonably split the layout. This allows for free drag. The interface effect is shown below.

The menu data is displayed, and the tree control is used on the left. The data is recursively bound. The data on the right side is bound to data through my paging control, and the bound data is formatted through hierarchical indentation.

The core recursive code bound to the tree menu is as follows.

/// <Summary> /// bind the tree data /// </Summary> private void inittree () {treeview1.nodes. clear (); treeview1.beginupdate (); cursor. current = cursors. waitcursor; // first obtain the system type, and then bind the menus of different system types to display list <systemtypeinfo> typelist = bllfactory <systemtype>. instance. getall (); foreach (systemtypeinfo typeinfo in typelist) {treenode pnode = new treenode (); pnode. TEXT = typeinfo. name; // system type node pnode. name = typeinfo. oid; Pnode. imageindex = 0; pnode. selectedimageindex = 0; this. treeview1.nodes. add (pnode); string systemtype = typeinfo. oid; // System ID // bind the tree control // in general, for the ribbon style, the level-1 menu indicates ribbonpage, And the level-2 menu indicates pagegroup; the third-level menu is the final menu item of barbuttonitem. List <menunodeinfo> menulist = bllfactory <sysmenu>. instance. gettree (systemtype); foreach (menunodeinfo info in menulist) {treenode item = new treenode (); item. name = info. ID; item. TEXT = info. name; // level-1 menu node item. tag = Info; // For the menu, record its menunodeinfo to the tag, which serves as the basis for judging the item. imageindex = 1; item. selectedimageindex = 1; pnode. nodes. add (item); addchildnode (info. children, item) ;}} cursor. current = cursors. defau Lt; treeview1.endupdate (); this. treeview1.expandall ();} private void addchildnode (list <menunodeinfo> list, treenode fnode) {foreach (menunodeinfo info in list) {treenode item = new treenode (); item. name = info. ID; item. TEXT = info. name; // level 2 and level 3 menu node item. tag = Info; // For the menu, record its menunodeinfo to the tag, and use it as the judgment basis int Index = (fnode. imageindex + 1> 3 )? 3: fnode. imageindex + 1; item. imageindex = index; item. selectedimageindex = index; fnode. nodes. Add (item); addchildnode (info. Children, item );}}

The code bound to the menu list data through the paging control is as follows.

/// <Summary> /// construct a query statement based on the query conditions /// </Summary> private string getconditionsql () {searchcondition condition = new searchcondition (); condition. addcondition ("name", this.txt name. text, sqloperator. like); condition. addcondition ("functionid", this.txt functionid. text, sqloperator. like); condition. addcondition ("visible", this.txt visible. checked? 1: 0, sqloperator. equal); condition. addcondition ("winformtype", this.txt winformtype. text, sqloperator. like); condition. addcondition ("url", this.txt URL. text, sqloperator. like); string where = condition. buildconditionsql (). replace ("where", ""); return where ;}/// <summary> /// bind list data /// </Summary> private void binddata () {// entity this. wingridviewpager1.displaycolumns = "name, icon, seq, functionid, visible, winformtype, URL"; # Add alias resolution this for region. wingridviewpager1.addcolumnalias ("ID", ""); this. wingridviewpager1.addcolumnalias ("name", "display name"); this. wingridviewpager1.addcolumnalias ("icon", "icon"); this. wingridviewpager1.addcolumnalias ("seq", "sort"); this. wingridviewpager1.addcolumnalias ("functionid", "function ID"); this. wingridviewpager1.addcolumnalias ("visible", "menu visible"); this. wingridviewpager1.addcolumnalias ("winformtype", "winform type"); this. wingridviewpager1.addcolumnalias ("url", "Web interface URL"); # endregion string where = getconditionsql (); List <menuinfo> List = bllfactory <sysmenu>. instance. findwithpager (where, this. wingridviewpager1.pagerinfo); List = collectionhelper <menuinfo>. fill ("-1", 0, list, "PID", "ID", "name"); this. wingridviewpager1.datasource = new WHC. pager. wincontrol. sortablebindinglist <menuinfo> (list); this. wingridviewpager1.printtitle = "function menu Information Report ";}

The menu editing interface is as follows.

This article mainly introduces menu management. For Menu dynamic loading management, I will introduce it in another winform development framework. The Function Control ID in the menu definition data is the Function Control ID from the function module, which is used to control the menu resources that different users can access.

3. Function Management

The function definition is also based on a system type. For different business systems, we can focus on a permission management system for management, but the function definition, the goal is to achieve effective integration of multiple enterprise applications.

The management of functions is the core of the entire permission system, because the definition of them and permission allocation affect the functions accessible to users of various roles; the data defined by the functions, it is also a tree structure, which can be displayed using the tree control, as shown below.

 

4. Log Management

We know that permission systems are common for managing users. Therefore, a user's login log is generally recorded by the permission management system. For example, each time a user logs in, we record user login logs. If the user changes the password, we also make an important record, so that we do not need to manage their Login Events for the management of the business system.

Log Management is divided into two parts: one is to log on through the logon portal of the permission management system itself, and the other is to log on through the integrated business system through API call for verification, their logon interfaces are basically the same, but some data is different.

Try {// determine whether the user has successfully logged on. String IP = networkutil. getlocalip (); string macaddr = hardwareinfohelper. getmacaddress (); string identity = bllfactory <user>. instance.Verifyuser(This.txt login. Text, this.txt password. Text, "waremis", IP, macaddr); If (! String. isnullorempty (identity) {// further judge the user role if (bllfactory <user> .instance.userinrole(this.txt login. text, roleinfo. adminname) {messageutil. showtips (string. format ("User [{0}] authentication is correct", this.txt login. text);} else {messageutil. showwarning ("this user has no administrator permission"); Return ;}} else {messageutil. showwarning ("Incorrect username or password"); Return ;}catch (exception ERR) {messageutil. showerror (err. message );}

The permission management system manages and displays logs in a unified manner, as shown in the following figure.

The entire permission management system aims to improve the system development speed and efficiency. Therefore, we can maximize our production efficiency through independent development, module reuse, and easy integration.

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.