Search This Blog

Friday, July 31, 2015

Refreshing UI according to the security permission changes done through the application or directly in the database

Starting with version 15.1.7, the DevExpress.ExpressApp.Security.Adapters.IsGrantedAdapter class provides the following overloads of the Enable method:

    Enable(ISecurityAdapterProvider securityAdapterProvider) - here ReloadPermissionStrategy  = NoCache is used by default
    Enable(ISecurityAdapterProvider securityAdapterProvider, ReloadPermissionStrategy reloadPermissionStrategy)
    Enable(IEnumerable<ISecurityAdapterProvider> securityAdapterProviders)    Enable(IEnumerable<ISecurityAdapterProvider> securityAdapterProviders, ReloadPermissionStrategy reloadPermissionStrategy)

Here is an example: 

using DevExpress.ExpressApp.Security.Adapters; using DevExpress.ExpressApp.Security.Xpo.Adapters; IsGrantedAdapter.Enable(new XpoIntegratedCachedRequestSecurityAdapterProvider(), ReloadPermissionStrategy.CacheOnFirstAccess);

Take special note that to use these features, you must reference the new DevExpress.ExpressApp.Security.EF and DevExpress.ExpressApp.Security.Xpo assemblies to your projects.

The ReloadPermissionStrategy enumeration has the following values:
    CacheOnFirstAccess  - the latest security permissions are loaded from the database only once, on the logon, and are used until the log off or next logon event. Permission request behavior is the same as in the previous mode. This helps avoid extra queries to the database while keeping the correct evaluation of object access permissions.
    NoCache  - the latest security permissions are loaded from the database for each new XPO Session or EF DbContext. Based on this info, permission request results are calculated and cached. Subsequent permission requests are evaluated using the cache if the XPO Session or EF DbContext object was not changed.

By default, we provide several built-in implementations of the ISecurityAdapterProvider object, which you can use depending on the used security configuration:
    XpoUICachedRequestSecurityAdapterProvider - for Client-Side Security (XPO UI-level mode)
    XpoIntegratedCachedRequestSecurityAdapterProvider - for Client-Side Security (XPO integrated mode)
    XpoClientServerCachedRequestSecurityAdapterProvider - for Middle Tier Security (XPO)
    EFCachedRequestSecurityAdapterProvider - for Client-Side Security (Entity Framework UI-level mode) 

For older versions, please visit this Support Center thread.

Thursday, July 23, 2015

Making the AuditTrail functionality operate correctly with several XPObjectSpaceProviders when storing data in separate databases (15.1.6)

I wanted to inform the community of a solution we have just finished testing for the next XAF version in response to the following customer's business scenario:

"i followed this instruction to work with two databases in one application. so far so good. 
i also managed to include the security module and get it working, but now i don't know how to use the "audit trail" module! it doesn't seem to matter in which project i include it, but it will not save anything to the database."

As you probably know, XAF supports connecting to several databases and even using both Entity Framework (EF) and eXpress Persistent Objects (XPO) at the same time (examples: onetwothree), although it is not the primary scenario, to be honest. 

In short, if you were in need of such a configuration and wanted to have AuditTrail capabilities, it would "just work" starting with v15.1.6. If you feel confident to check technical details on this, see my description in the T263982 - AuditTrail - Ensure support for scenarios with several XPObjectSpaceProviders ticket.
By providing support for this module, we continue working in the direction we took in the past, which I also discussed in the past blog. As always, our team is looking forward to hearing your feedback in this regard.

Usability improvements to the Localization Tool in the Model Editor (v15.1.6)

Take special note of a small improvement we have added into the next minor update (15.1.6) based on the real customer story, which we greatly appreciate. So, if you are developing multilingual apps and have to localize them using the Localization Tool, check out the 
T266560: Localization Tool - Usability improvements thread in the Support Center for details. In short:

We have extended the Export command with a new item allowing you to export all the records. This is now the default choice, in addition to the other option of exporting the currently selected record only. 

We also provided a separate Save button in this dialog to make saving translated items more atomic.

Do not hesitate to address such things to our team, because this will make your everyday work easier. Adding a keyboard shortcut, changing the default item choice and other minor things are often not difficult to implement (e.g., this one took about 2 hours with tests), but they will greatly improve your overall experience with the product, which is also true for other XAF peers.

Happy XAFing and thanks for all your feedback!

Monday, July 20, 2015

What's New in XAF 15.1 Documentation

As you probably know, in addition to the new great features the version 15.1 introduced, there are also various improvements to the learning materials that will allow you get the most of DevExpress products and become a better developer. As always, the full list of What's New In Help for all products is waiting you here.

The XAF documentation changes we are the most interested in are listed HERE (I marked my favorite help topics in bold):

Hopefully, even people familiar with the framework will find something helpful here.

A third-party Twitter Bootstrap Add-on for XAF Web UI

I wanted to share a recent announcement of the open source project from our long-time customers from Kazakhstan:

Talgat Shalabayev, the tech lead of the team providing this custom XAF module said in our LinkedIn group (if you are not yet a member of this forum/group where XAF users share their experience, be sure to join it as interesting things are happening there recently):

"I am glad to inform that we have released XAF Bootstrap addon. It implements Twitter Bootstrap functionality for Web module. You can test and use it now. Project is licensed under open source.
Addon is used in a several our projects in production, but it was tested only with our production needs, not all XAF configuration options, and released "as is". For example, it works for now only with XPO (EF not supports for now), .Net 4.5 and there may be more configuration-specific issues. We plan gradually increase supported features, but we hope that interested community members will join to testing or developing this addon - it will speed up addon's way to production ready state."

You can also see the video guys posted at for more understanding of what this module provides and how to add it into an existing XAF Web project.

My own experience

I decided to test this module with our XCRM demo and first downloaded it from GitHub (they now provide compatible versions for both v14.2 and v15.1 of DevExpress assemblies). 
Since the module currently supports only XPO and .NET 4.5, the demo app required some adjustments to be usable with this module (because it is EF-based). Once I fixed this (by registering several ObjectSpaceProviders for XPO and EF within a single app and modifying the ModuleUpdater class code accordingly), the resultant Web app looked quite well (except for some visual glitches in the menu and other side effects):

Tuesday, July 7, 2015

Kart racing with the XAF team

Hopefully, you will not be disappointed by not receiving the usual technical blog and instead will not mind learning a bit more about our team and how we are doing (we are all people after all). I am putting this caution as I want to share a few photos from today's event we enjoyed with the majority of our team (several guys were absent due to vacations and sick leaves) at the nearest kart park:

How to load an icon for an XAF UI element from the database instead of using predefined images from assembly resources or file system

In my opinion, this is quite an advanced scenario, but I still want to share a simple solution for it using the built-in ImageLoader API provided by our framework. If you are interested in a real life scenario, then it is described in this Support Center ticket by one of our customers:

"I have a SingleChoiceAction which I'd like to use to set the status of the selected objects in a view. The possible status values come from a lookup table, which also contains a SmallIcon property which I'd like to use for the image of the items but the ChoiceActionItem only has an ImageName property to use an Embedded Resource. How do I use the images from the database instead? Putting the images as Embedded Resources defeats the object of storing them in the database - any new values would require the addition of a new Embedded Resource, a programming change."

Monday, July 6, 2015

How to easily register many predefined reports using the ReportsV2 module

I wanted to repost a solution for a scenario logged by our old customer Mario Blataric in the past:

"...Also, there is one more thing - report registration. Currently, every V2 report needs to be registered in Module.cs. That's also fine for 10-20 reports, but when you have 1000 lines of code for just registering reports ... not fun.
Give Report properties like Caption, IsInPlace, AutoRegister and other required properties and just do registration automagically if AutoRegister = true (if for some reason someone wants to add report which doesn't want to be accessible through Reports class). "

Here is a possible solution description from the corresponding Support Center ticket:

While in XAF we cannot add new properties like Caption, Category, IsInplace, ParametersObjectType to the base XtraReport class from our shared DevExpress XtraReports library (essentially because these properties will have meaning only in XAF solutions and will not make much sense in non-XAF applications), 
it is possible to implement a custom .NET code attribute with all the required options: