Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create fully custom Role, User, Event, Resource classes for use with the Security (old) and Scheduler modules

$
0
0

This example demonstrates how to create fully custom classes for use in our Security Module (with the 'old' DevExpress.ExpressApp.Security.SecurityComplex component) and Schedule Module:
    - Activity is an analog of our standard Event class that is used to represent appointments in the Scheduler Control.
    - Employee is an analog of the standard User class, which also supports the IResource interface to use objects of this class as resources in our custom appointment above.
    - Group is an analog of our standard Role class
To enable these two custom security classes in your application set the RoleType and UserType properties for the SecurityComplex component within the Application Designer.

Additionally, the two popular filtering tasks are implemented: filtering appointments by the current logged employee and also filtering resources to show only those owned by the current logged employee.
This functionality is provided by the SchedulerActivityListViewControllerBase class and its descendants as follows:
   a. Administrator account (Sam, to log on, leave the Password field empty) sees all the resources and appointments in the root scheduler view.
   b. Non-Administrator account (John, to log on, leave the Password field empty) sees only his own resources and appointments in the root scheduler view.
   c. Both Administrator and Non-Administrator accounts see their own resources and appointments in the nested scheduler view.
You can use SchedulerActivityListViewControllerBase  and related controllers for study purposes, since they demonstrate the most common filtering scenarios in the scheduler view. If you do not need all this specific functionality, simply remove these controllers and create your own ones (perhaps based on the provided example code) that will do only your specific task. For example, the controllers from this example are not suitable in the nested scheduler view because you miss some part of the default Link/Unlink functionality since the scheduler view is always filtered to show only its own resources and appointments.That may not be desired because you may want to have the capability to link appointments from other resources, but they won't be shown due to the above. Plus, these demo controllers are unnecessary for appointments filtering in the nested scheduler view, because by default, in this view only appointments from the current resources are shown.

Important notes

1. Example implementations are NOT designed for the 'new' security system components and scenarios (e.g., middle-tier application server or SecuredObjectSpaceProvider). To use the SecurityStrategyComplex component, provide fully custom implementations of the user and role classes as per the eXpressApp Framework > Task-Based Help > How to: Implement a Custom Security System User Based on an Existing Business Class article.

2. The Activity (appointment) and Employee (resource) classes' code was once created based on the code of the default Event and Resource classes from our DevExpress.Persistent.BaseImpl library. It is necessary to update their code based on the source ...\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\ library sources according to changes made in the latest XAF versions.

Question Comments

Added By: Ad de Rijke at: 5/19/2014 4:52:28 AM    

The Web project does not compile: 'The type or namespace name 'WinWebSolutionAspNetApplication' could not be found (are you missing a using directive or an assembly reference?)'

Added By: Dennis (DevExpress Support) at: 5/20/2014 3:31:16 AM    @Ad: For some reason the WebApplication.cs file was emptied. I have attached a working sample for your reference. I will also update this example as well.Added By: Ville Virtanen at: 12/4/2015 11:06:39 PM    

When trying to run it gives an error: Another rule with ID = 'EventIntervalValid' already exists.

When I commented following lines, it worked, but how I disable the BaseImpl rule?

//[NonPersistent]
       //[Browsable(false)]
       //[RuleFromBoolProperty("EventIntervalValid", DefaultContexts.Save, "The start date must be less than the end date", SkipNullOrEmptyValues = false, UsedProperties = "StartOn, EndOn")]
       //public bool IsIntervalValid { get { return StartOn <= EndOn; } }

Added By: Dennis (DevExpress Support) at: 12/7/2015 5:41:37 AM    

@Ville: You can simply rename this rule without commenting it out to avoid this error. Or, you would better not to use the default Event class from the DevExpress.Persistent.BaseImpl library in your project.

Added By: Nate Laff at: 2/17/2016 7:43:43 AM    Can we see an update to this for 15.2? Things are currently pretty broken. In Activity.UpdateEmployees() the XML is coming back much different than it previously did.Added By: Dennis (DevExpress Support) at: 2/17/2016 8:09:23 AM    

@Nate: We will unlikely update this code for v15.2 for the reasons described in point #2 of the important notes to this example. The example's Activity class code is pretty much the same as the code of the Event class (similarly, Employee is an analog of the Event's Resource and security User classes) and we would like to avoid synchronization and maintenance problems for our users going forward.

In the future, I will probably rework this article to be more like a codeless KB article that would focus not on specific implementations, which are different for each concrete business scenario, but rather on the main points of such an integration, which are the same for all cases. I hope this makes sense.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>