Search This Blog


Tuesday, August 25, 2015

Getting ready the ConditionalAppearance module infrastructure for custom options of the extended AppearanceAttribute (e.g., tooltip)

First of all, this piece of information is quite advanced, so be sure you are well-aware of the module's basic functions and main extensibility and customization points, at least through AppearanceController. If not, check out the related online documentation before reading further. 

Customer scenario

Would it be possible to add in the conditional appearance module the possibility to show a tooltip in the cell in listView when the 
condition is satisfied? (you get different color based on criteria and when you move to the cell a tooltip is shown telling you why the color is different ), example:

[Appearance("CategoryColoredInListView", AppearanceItemType = "ViewItem", TargetItems = "Category", Criteria = "Category = 'Seafood'", Context = "ListView",FontColor = "Blue", Priority = 1, ToolTip="the tooltiptext!!!!")]

Monday, August 24, 2015

A more straightforward and convenient way to query data using LINQ with ObjectSpace

First of all, it is important to note that the capability to query data using LINQ has been available for a long time in the current version of XAF (or better said, in the underlying Entity Framework and XPO ORM libraries). So, this improvement in v15.2 is all about improving developer usability by exposing a helper method for the IObjectSpace interface representing one of the main XAF entities (learn more...). 

As noted in the corresponding SC ticket (from here you can also learn on the current solution):

The IObjectSpace interface now declares the following method:

[C#]IQueryable<T> GetObjectsQuery<T>(Boolean inTransaction = false);
This method is implemented in the XPObjectSpaceEFObjectSpace and NonPersistentObjectSpace classes. 
The inTransaction parameter has effect in XPO only and enables the mode in which querying a data store for objects includes all in-memory changes into query results.
In the NonPersistentObjectSpace, the GetObjectsQuery method casts the collection of objects created in the ObjectsGetting event to IQueryable and returns the result.

For XPObjectSpace, this method just returns a new XPQuery<T> from the underlying Session, while for the EFObjectSpace, the GetObjectsQuery method returns a new instance of ObjectQuery<T> with the help of the associated DbContext.

Here are a few usage examples from our unit tests (using the method-based query syntax):
IQueryable<Product> objectsQuery = objectSpaceB.GetObjectsQuery<Product>().Where(p => (p.Supplier.ID == supplier_A.ID));
Assert.AreEqual(5, objectsQuery.Count());
Assert.AreEqual(3, objectsQuery.Where(p => (p.Name == "A")).Count());
Assert.AreEqual(2, objectsQuery.Where(p => (p.Name == "B")).Count());

IQueryable<TestObject> query = objectSpaceB.GetObjectsQuery<TestObject>();
Assert.AreEqual(5, query.Count());
Assert.AreEqual(3, query.Where(t => t.StringProperty == "A").Count());
Assert.AreEqual(2, query.Where(t => t.StringProperty == "B").Count());

I hope you will appreciate this minor improvement and it will save you from polluting your code by the casts to the XPObjectSpace/EFObjectSpace types to access the underlying ORM data context LINQ features.

How to place an Action in a different location programmatically

I think that many people know that they can control this visually by drag&drop under the ActionDesign | ActionToContainerMapping node in the Model Editor, but just a few know of the best code solution. A good scenario when it is necessary to handle this requirement in code is described by our customer in this Support Center ticket (more real user scenarios can be found here).

After receiving enough requests for this, we decided to put a full example solution in our docs. It is based on handling a single CustomizeContainerActions event of the built-in ActionControlsSiteController (or FillActionContainersController class, if your form template does not support the IActionControlsSite  interface).

Do not miss this new online documentation and hopefully, it will help you spend less effort on accomplishing your advanced business requirements in our framework.

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.6, the DevExpress.ExpressApp.Security.Adapters.IsGrantedAdapter class and its static Enable(ReloadPermissionStrategy reloadPermissionStrategy) method are used instead of the CanRefreshPermissions property, which became obsolete. The ReloadPermissionStrategy enumeration has the following values:
    OnEachTransaction - the latest security permissions are loaded from the database for each new Session. Based on this info, permission request results are calculated and cached. Subsequent permission requests are evaluated using the cache if the Session object was not changed.
    OnLogon - 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.

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.