. NET general rights design source code

Source: Internet
Author: User

After more than a year of design coding and testing, the company's universal access system to the business sector provides a relatively stable, convenient and flexible support.

The system is divided into two parts: the configuration interface and the WCF service.

Interface: Permissions system administrators can configure the interface to the various departments or organizations of personnel to conduct business rights assignment operations.

WCF services: Business developers can obtain business privilege data and develop business systems through the interface services provided by the rights system.

The advantage of this design is that the privilege system is more portable, the privilege system can be deployed separately, the service interface is released externally, and the coupling between the business systems is lower, thus achieving the core value of the design pattern is high cohesion and low coupling.

The IIS deployment example is as follows:

Permission System development Environment:

Development tools: Microsoft Visual Studio 2012 (2010) Chinese flagship edition

Database: Sql server2008\2012 (Oracle)

Frame: Spring.net+nhibernate+mvc

System functions:

1, Organization: User Maintenance page is mainly used to manage the system organization structure. After entering the page, the left Stump menu shows the organizational structure and hierarchy, clicking on the organization name of a level node. The right side shows the details of the organization, as well as the users who belong to the organization.

2, User maintenance: User Maintenance page is mainly used to manage the users of the system. After entering the page, display all visible users according to the permissions of the logged-in user, pagination display. At the same time, according to the organization, real name, login name of three conditions for fuzzy screening.

User authorization: Role authorization for the selected user, one user can select multiple roles to authorize,

3. Application Maintenance: The Application Maintenance page is mainly used to manage the related information of system sub-application (System or application).

After entering the page, all visible apps are displayed by the logged in user's permission and displayed in tabular form.

4, Role maintenance: Role Maintenance page is mainly used to manage the role of the system. When you enter the page, all visible roles are displayed by the login user's permissions, and pagination is displayed. At the same time, according to the application, role coding two criteria for fuzzy screening. (Roles and apps are a many-to-one relationship, each role can belong to only one app)

Page Authorization: Page authorization control for a role, tick the page menu for the Role authorization menu,

Data authorization: To manage and authorize the system atomic data,

5, User authorization: User authorization, is used to give permission to some series of roles, granted to a user. Make the user have these permissions. The page is divided into the left user area, and the right attribution role area.

Users can switch between tabs to enable filtering filtering by organization to select specific users, or to enable the ability to grant certain roles to all users under an organization

6, Page Maintenance: page maintenance is mainly used for each sub-page under each application and the hierarchical relationship between pages to manage. Manage and assign page addresses to the menus and pages of the subsystem, where the user manages whether the page is visible or accesses its address according to the role authorization.

7, page Resource maintenance: User resource maintenance is mainly used for each page of the page resources and the hierarchical relationship between resources to manage. (Each control on a page is called a resource) a background user can manage it further based on the resources on that page, such as a page that can query a user on that page only for management that cannot be changed.

8, permission query: Used to query the specific user, a role, the corresponding type of permissions

WCF Service Interfaces:

    • User Login Authentication Interface

Form:

Upuserscomm loginverify (String userId, string passWord);

Description:

User for login verification.

Incoming parameters:

USERID: User login ID.

PassWord: Login password.

return value:

Upuserscomm custom type, with user information stored

    • Get app Permissions Information

Form:

Upuserscomm getsystempermission (string userId);

Description:

Gets the permissions that the user has access to the Business system module, based on the current user ID.

Incoming parameters:

USERID: User ID. The string type.

return value:

Upuserscomm, a collection of system application modules that users can access.

    • Get permission to access a page

Form:

Upuserscomm getpagepermission (String userId, long Systemidentifierid)

Description:

Based on the current user ID, gets the page that the user can access, returns the mapped object of the page table, and has a cascade relationship, and the business module can form a tree structure on its own.

Incoming parameters:

UserId: User name. The string type.

Systemidentifierid: The system represents the ID. The string type.

return value:

Upuserscomm, which contains a collection of page objects that the user can access.

    • Get permission to access a page

Form:

Upuserscomm getpagepermission (String userId, String systemidentifiername)

Description:

Based on the current user ID, gets the page that the user can access, returns the mapped object of the page table, and has a cascade relationship, and the business module can form a tree structure on its own.

Incoming parameters:

UserId: User name. The string type.

Systemidentifiername: Apply the system name. The string type.

return value:

Upuserscomm, which contains a collection of page objects that the user can access.

    • Get permission to access a page resource

Form:

Upuserscomm getpagesourcepermission (String userId, String systemidentifiername, string pageName);

Description:

Returns a collection of page resources based on the current user ID, application name, and page name, and gets the resources that the user can access to the specific page.

Incoming parameters:

UserId: User name. The string type.

Systemidentifiername: Apply the system name. The string type.

PageName: page name

return value:

Upuserscomm, which contains a collection of page resource objects that the user can access.

    • Get permission to access a page resource

Form:

Upuserscomm getpagesourcepermission (String userId, long pageId);

Description:

Returns a collection of page resources based on the current User ID and page ID, and gets the resources that the user can access to the specific page.

Incoming parameters:

UserId: User name. The string type.

PAGEID: Page ID. The string type.

return value:

Upuserscomm, which contains a collection of page resource objects that the user can access.

    • Permission to get raw data

Form:

Upuserscomm gedatapermission (String userId, String systemidentifiername, String datacategoryname)

Description:

Returns the original data collection based on the current user ID, the application name, and the data category name to get the user access to the original data resource.

Incoming parameters:

UserId: User name. The string type.

Systemidentifiername: Apply the system name. The string type.

Datacategoryname: The original data category name. The string type.

return value:

Upuserscomm, a collection of raw data that the user can access.

    • Permission to get raw data

Form:

Upuserscomm gedatapermission (String userId, long Datacategoryid)

Description:

Gets the raw data resource that the user can access based on the current user ID and data category ID, and returns the original data collection.

Incoming parameters:

UserId: User name. The string type.

Datacategoryid: Data category ID. Long integer type.

return Value:

Upuserscomm, a collection of raw data that the user can access.

    • Permission to get raw data

Form:

Upuserscomm getdenieddatapermission (String userId, String systemidentifiername, String datacategoryname)

Description:

Returns the original data collection based on the current user ID, the application name, and the original data name, which gets the user's access to the original data type of 1 resources.

Incoming parameters:

UserId: User name. The string type.

Systemidentifiername: Apply the system name. The string type.

Datacategoryname: Data category name. The string type.

return Value:

Upuserscomm, a collection of data with a raw data type of 1 that the user can access.

    • Permissions for paging to get raw data

Form:

Upuserscomm gedatapermissionbypage (String userId, String systemidentifiername, String Datacategoryname,int pageSize, int PageIndex)

Description:

Based on the current user ID, the application name, and the original data name, paging gets the original data that the user can access, returning the original data collection.

Incoming parameters:

UserId: User name. The string type.

Systemidentifiername: Apply the system name. The string type.

Datacategoryname: Data category name. The string type.

PageSize: Number of page lines. Integral type.

PageIndex: Page index. Integral type.

return Value:

Upuserscomm, a collection of raw data that the user can access.

    • Get a collection of roles based on the menu name

Form:

Upuserscomm Getrolesbymenu (String menuName)

Description:

Gets the role, based on the menu name, and returns the Role collection.

Incoming parameters:

MenuName: Menu name. The string type.

return Value:

Upuserscomm, a collection of roles.

    • based on user ID Get collection of roles

Form:

Ilist<uprolecomm> Getrolewhituserid (String userId)

Description:

Gets the role based on the user ID, returning the Role collection.

Incoming parameters:

USERID: User ID. The string type.

return Value:

Ilist<uprolecomm> A collection of roles that the user can access.

    • based on user ID Get user Information

Form:

Ilist<uprolecomm> Getrolewhituserid (String userId)

Description:

Based on the user ID, gets the user information and returns the user object.

Incoming parameters:

USERID: User ID. The string type.

return Value:

Upuserscomm, which contains user information that the user can access.

    • Create user

Form:

void CreateUser (Upmqusercomm user);

Description:

Create a user.

Incoming parameters:

Upmqusercomm: User Object.

return value: None

    • Modify User

Form:

void Updateuserinfo (upusers user);

Description:

Modify user information.

Incoming parameters:

Upusers: User Object.

return value: None

    • Modify User

Form:

void DeleteUser (String userId)

Description:

Deletes the user information based on the user ID.

Incoming parameters:

USERID: User ID.

return value: None

    • Determine if you are a super administrator

Form:

BOOL Iscaptain (String userId)

Description:

Based on the user ID, determine if the user has a super administrator.

Incoming parameters:

USERID: User ID.

return Value: True/false

    • get data type based on data type name ID

Form:

Long Getdatatypeidbyname (string name)

Description:

Gets the name of the data type, based on the data type name.

Incoming parameters:

Name: Data type names.

return Value: int

    • according to ID Get role Information

Form:

Uprolecomm Getrolebyid (Long ID)

Description:

Gets the role information based on the ID.

Incoming parameters:

ID: Role ID.

return Value:

Uprolecomm, role information.

    • based on user ID Get role Information

Form:

ArrayList Getrolebyuserid (String userId)

Description:

Gets a collection of roles based on the user ID.

Incoming parameters:

USERID: User ID.

return Value:

ArrayList, a collection of role information.

    • Change Password

Form:

int Updatepassword (string userid,string pwd,string oldpwd)

Description:

The user password is modified to return 1 successfully, otherwise 0 is returned.

Incoming parameters:

USERID: User ID.

PWD: New password.

OLDPWD: Old password

return Value: 1/0

probably functional, first organized to this, interested in qq:187386033 .

. NET general rights design source code

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.