Rdiframework.net Development example-use of table constraint permissions-web
in the previous article, "Rdiframework.net Development example-the use of table constraint permissions-winform" We explained the use of the table constraint permissions under WinForm, let's look at the use under the Web.
In the actual application, the customer often has this demand, the specified user or role can look at the data under the specified conditions, where the "specified conditions" in the rdiframework.net framework, we call the "user or role of the constraint expression." To accomplish this, you can do this by rdiframework.net the constraints permission Settings feature of the user or role in the framework, and then invoking our constraint expression interface for the user or role in your business form.
You can invoke the following interfaces provided by the framework to complete the access to user or role constraints.
1, RDIFrameworkService.Instance.TableColumnsService.GetConstraint2, RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint
Below we use the example to show the constraint permission setting, which can be referenced by the user.
To use constraint permissions, you first need to set the user or role's constraint expression in the user or role permissions. The user's constraint permission settings are as follows:
You can open the above window in the system management → user Rights management → permissions settings → constraints permission settings. In the Table Constraints Settings window, you can choose the constraints we need to set the table, and click "Set conditional Expressions" to set them. As shown in the following:
The settings for role constraints are similar to user constraint settings, which refer to the user constraint settings above, and the Role Constraint Settings window as follows:
With the above settings, we can now use "constraints", which are simple to use, simply by providing a service interface through the framework where the data needs to be presented. Below we demonstrate constraint permissions with product management.
The user's constraints can be obtained by invoking the following interface in the product management main interface's code to get paged data
1, RDIFrameworkService.Instance.TableColumnsService.GetConstraint (this. UserInfo, Piusertable.tablename, this. Userinfo.id, Productinfotable.tablename); Get data by Table constraint (per current user). 2, RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint (this. UserInfo, Productinfotable.tablename); Data is obtained by table constraints (user and role constraints are obtained).
The complete code is as follows:
private void Getpagedata (requestparammodel<case_productinfoentity> rpm, HttpContext ctx) { var manager = new Case_productinfomanager (this.dbhelper); int RecordCount = 0; string sort = rpm. Sort; string order = RPM. Order; if (String. IsNullOrEmpty (sort)) { sort = CASE_ Productinfotable.fieldcreateon; } if (String. IsNullOrEmpty (order)) { order = "DESC"; } string filter = RPM. Filter; if (String. IsNullOrEmpty (filter)) { filter = CASE_ Productinfotable.fielddeletemark + "= 0"; } userinfo cUser = Utils.UseRinfo; //string userconstraintexpress = RDIFrameworkService.Instance.TableColumnsService.GetConstraint (Cuser, Piusertable.tablename, Cuser.id, Case_ Productinfotable.tablename); Get data by Table constraint (per current user). string userconstraintexpress = RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint (Cuser, case_productinfotable.tablename); Data is obtained by table constraints (user and role constraints are obtained). if (!string. IsNullOrEmpty (userconstraintexpress)) { Filter + = "and" + userconstraintexpress; } var dttemp = Manager. Getdtbypage (out RecordCount, RPM.) Pageindex, RPM. Pagesize, filter, (sort + "" + Order)); ctx. Response.Write (Jsonhelper.formatjsonforeasyuidatagrid (RecordCount, dttemp));}
We set a constraint on the user "Yonghu", and now we look at the data he can see with the "Yonghu" Login system:
our user "Yonghu" setting constraints are more than 10000 unit price, in, you can see that the system has automatically filtered the data a total of 143 data. We re-login to the Super Admin user to see as shown in:
the data logged in as a Super administrator is 8,971.
the above is just a simple example show, but also can be more flexible application to other practical occasions.
Erichu Source: http://www.cnblogs.com/huyongEmail: [Email protected]qq Exchange: 406590790QQ Group: 237326100 Platform Blog: "CSDN"/HTTP/ Blog.csdn.net/chinahuyong "Cnblogs" Http://www.cnblogs.com/huyong about senior engineer, information System Project Manager, DBA. Focus on Microsoft Platform Project architecture, management and enterprise solutions, multi-year project development and management experience, has organized and developed several large projects, proficient in dotnet,db (SQL Server, Oracle, etc.) technology. Familiar with Java, DELHPI and Linux operating system, have solid network knowledge. has some attainments in object-oriented, service-oriented and database fields. Currently engaged in DB management and development, WinForm, WCF, WebService, Web page Data capture and ASP, such as project management, development, architecture and other work. If you have any questions or suggestions, please enlighten me! This article is copyright to the author and Cnblogs blog, welcome to reprint, but without the author's consent must retain this paragraph statement, and in the article page obvious location to the original connection, if there is a problem, you can contact me by email or QQ, thank you very much.
Rdiframework.net Development Instance-use of table constraint permissions-web