Search This Blog

Tuesday, October 27, 2015

Conditional Formatting for WinForms Tree List Editor

This is merely a follow up to my previous post:
How to enable the Conditional Formatting feature of the WinForms GridControl in the XAF GridListEditor and preserve ListView formatting settings between runs?

I want to share a similar solution for the TreeListEditor, which I coded and updated according to great customer feedback recently. You can learn more on this feature from the WinForms Controls > Controls and Libraries > Tree List > Conditional Formatting and TreeListOptionsMenu.ShowConditionalFormattingItem documentation.

Here are the steps needed to use the TreeListEditor in your XAF project:
1. In the Module Designer invoked for YourSolutionName.Module.Win/Module.xx file, add the Tree List Editor module to allow Visual Studio to automatically add required assembly references;
2. Copy and include this C# source file into YourSolutionName.Module.Win project (vb.net guys can either use this approach OR convert this code into their language using free tools).

Please track the corresponding Support Center thread to be automatically notified of any changes or other improvements in this regard.

As always, I am looking forward to hearing from you on whether you find this feature helpful for your apps.


Thursday, October 22, 2015

Avoiding the GetObjectsNonReenterant error for security permissions with complex criteria

UPDATE2

UPDATE1
During further testing we found that the new solution is not appropriate for certain scenarios (e.g., when new objects are created and saved under certain scenarios) and eventually decided not to make this new mode as default in v15.2. We will also mark the CanCheckModifiedObject option as obsolete for now. We will try to approach this problem from another angle at a lower XPO level. As always, we will keep you posted of our results once have anything to share. We apologize for all the inconvenience here.



OUTDATED
Let me quote myself from the Security - Avoid the GetObjectsNonReenterant error while evaluating security permission criteria involving collections during the object saving procedure thread in our Support Center:

We have provided the new CanCheckModifiedObject property in the DevExpress.ExpressApp.Security.SecurityRule class, which can be used to avoid loading additional collections and thus throwing the "GetObjectsNonReenterant" error from XPO internals while evaluating security permission criteria during the object saving procedure.


If CanCheckModifiedObject = True, both currently modified and existing database records are validated by security rules (the current behavior leading to the error).

Otherwise, if CanCheckModifiedObject = False, only the existing database records are validated by security rules. The latter configuration should be suitable in most business scenarios we are aware of and this will be the default configuration in v15.2.

Thus, to avoid the "Entering state 'GetObjectsNonReenterant' from state 'CommitTransactionNonReenterant, CommitChangesToDataLayer' is prohibited due to state 'CommitChangesToDataLayer' for 'DevExpress.Xpo.UnitOfWork(35)'" error in v15.1.8+
set the static DevExpress.ExpressApp.Security.SecurityRule.CanCheckModifiedObject property to False in the entry point of your application; e.g., within the constructor of your platform-agnostic module (YourSolutionName.Module/Module.xx) OR within the Main method of the WinForms app (YourSolutionName.Win/Program.xx) OR within the Application_Start method of the ASP.NET app (YourSolutionName.Web/Global.xx).

For instance, below is the code I added in the MainDemo.Module/Module.cs file of the project from the E4045: 
How to separate data between employees and managers of different departments using security permissions example while testing this improvement locally:

Friday, October 9, 2015

Improving performance when a large portion of data matches a workflow activity criterion

Here is a real customer scenario from a related Support Center thread

"Hi, I have an application with several workflows that work ok in my local computer (testing with few records), but when I deploy the workflows to a server and the workflow gets approximately 1,500,000 records that match the criteria the workflow service crashes...
I've done some testing and this only happens when the workflow needs to deal with a lot of data, workflows that deal with less records don't have a problem. I've been looking for an alternative like XPCursor or something similar to ask the workflow to page the records that meet the criteria but I haven't found any."


After some time, we could replicate this behavior locally and found that it could be easily improved upon on our side. In short, our solution is in using XafDataView + a sort of paging  when first querying and processing records that match a certain workflow activity definition criteria in the workflow service. 

A minor improvement to the Object Property Editors that represent aggregated object references in the UI


Starting with version 15.1.8, you can easily specify a custom DetailView for ObjectPropertyEditor via the Model Editor at the DetailView | Items or ListView | Columns node levels in the Application Model:


Thus,  the IModelMemberViewItem.View  attribute now helps you specify custom Views for all object reference property editors used in both ListView and DetailView.

Previously, this task required a custom-tailored code solution like in the How to change ASPxObjectPropertyEditor's DetailView thread.  So, I hope you find this addition helpful.

Tuesday, October 6, 2015

Confirm unsaved changes to avoid losing data when navigating to another web page - YOUR FEEDBACK IS NEEDED

Scenario

Imagine you are in an XAF ASP.NET app context and just edited a record in the DetailView or ListView directly (e.g., linked or unlinked related details, typed something in the text box, changed drop downs, etc.) and then accidentally clicked a navigation item or some other link within the app...If the Save Action was not explicitly executed before that accidental action took place, there is a risk of losing your recent edits...and sadly this sometimes happens. Thankfully, this is not the case for the WinForms platform, where it is already handled.

Current solutions

There are some custom-tailored solutions available in the Support Center (onetwo), but they far from being ideal, to be honest.

Good news

As part of our continuous effort to improve the XAF Web UI (be sure to check it), the new v15.2 (should be out around December, as always) will contain a built-in solution for the aforementioned problem. 

More good news

Friday, October 2, 2015

Avoiding repetitive customizations for Views of the same type or subclasses via the Model Editor - YOUR FEEDBACK IS NEEDED

Prerequisites

Imagine you have the following data model classes:

class Party {...}

class Person : Party {...}
class Organization: Party {...}



XAF automatically generated several default root and nested Views for them in the Application Model. You can also create custom Views via the Model Editor on your own. For instance, you might end up with the following list under the Views node:


    Party_ListView
    Person_ListView1
    Person_ListViewN
    Organization_ListView1
    Organization_ListViewN



Scenario


Imagine your first goal is to customize the appearance of the ListView for the base class - Party_ListView according to your client needs.To accomplish this, you locate the Party_ListView node in the Model Editor and make various customizations to its columns. In particular, 1. edit captions for the Photo, Address1, Address2 columns; moved the Photo column after the Address1 and Address2 ones; 2. made changes to the ListView node properties such as set IsGroupPanelVisible, AllowEdit and other options in the property grid.


What if your second goal is to have a similar appearance for other ListViews where Party records are shown, e.g., Person_ListView, Organization_ListView1, Party_LookupListView or even Company_Persons_ListView (see the poll questions in the end)?