RDIFramework.NET Development Example ─ Use of Table Constraint Permissions-WinForm

RDIFramework.NET Development Example ─ Use of Table Constraint Permissions-WinForm

        

      In practical applications, customers often have such a requirement that a specified user or role can view data under specified conditions. In the RDIFramework.NET framework, the "specified condition" here is called "the constraint expression of the user or role". ". To complete such a function, you can complete it through the "constraint condition permission setting" function of the user or role in the RDIFramework.NET framework, and then call our interface to get the constraint condition expression of the user or role in your business form. can be completed.

       The following interfaces provided by the framework can be invoked to obtain user or role constraints.

1
2
1 、RDIFrameworkService.Instance.TableColumnsService.GetConstraint
2 、RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint

  Below we use an example to show the setting of the constraint condition permission for the user's reference.

      To use Constraint Privileges, you first need to set the Constraint expression of the user or role in the user privilege or role privilege. The user's "Constraints Permission Settings" are shown in the following figure:  

  In "System Management" → "User Rights Management" → "Permission Settings" → "Constraint Permission Settings", the above window can be opened. In the "Table Constraints" setting window, you can select the constraints we need to set the table, and click "Set Condition Expression" to set. As shown below:  

      In the above figure, we can verify whether the set constraint expression is correct, and we can also view the data set displayed by the constraint expression. "View constraint data set" is shown in the following figure:  

  "Role Constraint Settings" is similar to "User Constraint Settings", you can refer to the above "User Constraint Settings", the role constraint setting window is as follows:    After the above settings, we can now use "Constraints", It is very simple to use, just use the service interface provided by the framework where the data needs to be displayed. Below we use "Product Management" to demonstrate constraint permissions.

     The user's constraints can be obtained by calling the following interface in the FormOnLoad event code of the "Product Management" main interface:

1. RDIFrameworkService.Instance.TableColumnsService.GetConstraint(this.UserInfo, PiUserTable.TableName, this.UserInfo.Id, ProductInfoTable.TableName); //Get data according to table constraints (by current user).
2. RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint(this.UserInfo, ProductInfoTable.TableName); //Get data according to table constraints (get user and role constraints).

   The complete code is as follows:  

//userConstraintExpress = RDIFrameworkService.Instance.TableColumnsService.GetConstraint(this.UserInfo, PiUserTable.TableName, this.UserInfo.Id, ProductInfoTable.TableName); //Get data by table constraints (by current user).
userConstraintExpress = RDIFrameworkService.Instance.TableColumnsService.GetUserConstraint(this.UserInfo, ProductInfoTable.TableName); //Get data according to table constraints (get user and role constraints).
 
var recordCount = 0;
if (!string.IsNullOrEmpty(userConstraintExpress))
{
    if (!string.IsNullOrEmpty(this.searchValue))
    {
        this.searchValue += " AND " + userConstraintExpress;
    }
    else
    {
        this.searchValue = userConstraintExpress;
    }
}
this.DTProductInfo = GetData(out recordCount, ucPager.PageIndex, ucPager.PageSize, this.searchValue);
ucPager.RecordCount = recordCount;
ucPager.InitPageInfo();   

     In the above figure, we set constraints on the user "yonghu". Now we log in to the system with "yonghu" to see the data he can see:  

  The constraint we set for the user "yonghu" is that the unit price is greater than 10,000. In the figure above, you can see that the system has automatically filtered a total of 143 pieces of data. Let's log in as a super administrator user and see it, as shown in the following figure:   The data logged in as a super administrator is 8971.

      The above is just a simple example, and it can be more flexibly applied to other practical occasions.

Author: EricHu
Source: http://www.cnblogs.com/huyong
Email: [email protected]
QQ:406590790
Platform Blog:
      http://blog.csdn.net/chinahuyong
      http://www.cnblogs.com/huyong
About the author: Senior Engineer, Information Systems Project Manager, DBA. Focusing on Microsoft platform project architecture, management and enterprise solutions, with many years of project development and management experience, he has organized and developed many large-scale projects for many times, and is proficient in DotNet, DB (SqlServer, Oracle, etc.) technology. Familiar with Java, Delhpi and Linux operating systems, with solid network knowledge. In the object-oriented, service-oriented and database fields have certain attainments. Currently engaged in DB management and development, WinForm, WCF, WebService, web page data capture and ASP.NET and other project management, development, architecture and other work.
If you have any questions or suggestions, please let me know!
The copyright of this article belongs to the author and CNBLOGS blog. Reprinting is welcome, but this statement must be retained without the author's consent, and the original text link should be given in an obvious position on the article page. If you have any questions, you can contact me by email or QQ, thank you very much.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326429120&siteId=291194637