Quantcast
Channel: XAF Team Blog
Viewing all 148 articles
Browse latest View live

Oliver Sturm's Expert eXpress Persistent Objects (XPO) Class - Bad Ems, Germany + SMALL BONUS

$
0
0

Join Oliver Sturm in Bad Ems, Germany for 2 days (February 28 - March 01 2013) of expert DevExpress eXpress Persistent Objects (XPO) training:

“This class is a deep dive into DevExpress eXpress Persistent Objects, short XPO. XPO is an object/relational mapping (ORM) tool with a brilliant feature set, lending itself equally well to small and large development projects. With its broad database and platform compatibility, XPO is a valuable proposition for many scenarios that competing tools don't cover. As the basis of the eXpressApp Framework (XAF) product, a business application framework also made by DevExpress, XPO has additional credibility. The class starts with the basics, but moves on quickly to advanced scenarios. As much as the two-day timeframe allows, no question about XPO shall remain unanswered!”.

To learn more and register, visit Oliver's website at http://www.devexpress.com/Home/Training/


SMALL BONUS

There will be soon more great news from Oliver, but I would like to keep it secret for now, please stay tuned!:)

BTW, while we are talking about our frameworks, I would like point out the improvements we have made to these products in version 12.2.6 -  just released.

Here you can see the list of fixed issues (it is quite large so I will not post it here).

And below are the implemented suggestions:

eXpress Persistent Objects

  • S170602 - AdvantageConnectionProvider - Support Advantage Database 11.1 and .NET Framework 4.5
  • Q457118 - ORM Designer - Provide the capability to reorder fields
  • S170604 - ORM Designer - Provide the capability to set the UseAssociationNameAsIntermediateTableName property in the designer
  • S170549 - Provide a web service project template for creating an XPO OData Service that can also include a visual data model
  • S170635 - Support System.Data.SQLite v1.0.84.0

eXpressApp Framework

  • S170305 - BO Designer - Add a note to the ~.bo.designer.cs file that its modifications are prohibited
  • S170362 - Chart - Add Entity Framework support
  • Q458006 - Core - Add TargetObjectsCriteriaMode property to DevExpress.Persistent.Base.ActionAttribute
  • Q401329 - Deployment - Certain assemblies required for the deployment are missing in default project templates
  • S170364 - Pivot - Add Entity Framework support
  • S170227 - TreeList - Add Entity Framework support
  • Q442195 - Workflow - Ensure compatibility with WF 4.5 features

As you can see, we are continuing to polish the core, supporting new database engines and frameworks, improving designers and of course, empowering the Entity Framework support in XAF.
I hope you like these features. I look forward to hearing from you!


Domain Components+ Calculated properties + Application Model

$
0
0

Updated 2/9/2013
see end of post

Even though XAF does not support the idea of Domain Components + Calculated properties + Application Model out-of-the-box, XAF is still designed with the highest of standards. In this blog, I will demonstrate hot to achieve this concept of Domain Component + Calculated Properties + Application Model otherwise.

Domain Components

With XAF it is possible to design business objects from interfaces! Given those interface DC with smart algorithms create concrete persistent class at runtime. It is possible to explore the DC dynamic assembly by overriding the in solution’s WinApplication descendant as shown:

publicpartialclassDynamicMemberAliases2WindowsFormsApplication : WinApplication {

    protectedoverridestringGetDcAssemblyFilePath() {

        returnPath.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, DcAssemblyFileName);

    }

Exploring the DC assembly for the following DomainComponent1

[DomainComponent]

publicinterfaceDomainComponent1 {

    stringEmail { get; set; }

    stringTwitter { get; set; }

}

publicoverridevoidSetup(XafApplication application) {

    base.Setup(application);

    XafTypesInfo.Instance.RegisterEntity("Manager", typeof(DomainComponent1));

 

We find that XAF creates the next Manager class on the fly and that this class is a simple XPO persistent object and is specific to our DomainComponent1 (see the RegisterEntity method above).

 

 

image

This is really great! We already know how to create Dynamic member aliases though the Application Model and we can apply the same technique to the Manager class, which is very conveniently related only to the DomainComponent1. However, although the Dynamic member aliases can be successfully created in the Manager class, XAF would not know of their existence. In the next section we will discuss how to workaround this.

The TypesInfo system

  1. In XAF, everything is an object. To help resolve object types, we created a TypesInfo system. XAF uses it for creating UI and for all the metadata operations. Because of how XAF was designed and because of the way TypesInfo system was built, metadata modification could be done easily.
  2. By default, XAF supports two ORM framework, XPO and Entity/ In addition, it is possible to integrate a custom ORM system. To make this possible, a separate interface, the ITypeInfoSource, which holds all the type metadata is available.

UI + business logic <— TypesInfo–> XpoTypeInfoSource OR EFTypeInfoSource OR any ITypeInfoSource.

Now we know that the XpoTypeInfoSource will retrieve Type members for any class from XAF. Therefore, we only need to override the EnumsMembers method of the XpoTypeInfoSource to provide our own implementation! Bellow is an excerpt of this implementation you can find the rest in the sample at the end of the post.

publicclassXpandXpoTypeInfoSource : DevExpress.ExpressApp.DC.Xpo.XpoTypeInfoSource, ITypeInfoSource {

    voidITypeInfoSource.EnumMembers(TypeInfo info, EnumMembersHandler handler) {

        EnumMembers(info, handler);

        Type type = info.Type;

        if (TypeIsKnown(type)) {

            if (type.IsInterface) {

                EnumDCInterfaceMembers(info, handler);

            }

        }

    }

No doubt you too find this quick and simple? I always emphasize that XAF has 2 main advantages

  1. It is well architectured –> overridable.
  2. It is well architectured –> reusable.

And since it is overridable and reusable you can download and use the DynamicMemberAliasesForDC.zipWinking smile.

We are happy to read your input about this!. Remember that your questions are the best candidates for future posts.

P.S. : The eXpandFramework users only need to register the Core modules (see How to use an eXpand module with an existing XAF application)

Until next time, happy XAF’ing!

Updated 2/9/2013

In the next video, I demo how to create a calculated property in runtime.

Dashboards in the real world – A Scotland strike!

$
0
0

The DevExpress Universal Subscription now includes an interactive data visualization Dashboard for the Windows, Web and Mobile devices. The DevExpress Dashboard delivers solutions that allow any enterprise to visually explore business trends using stunning and easily understood performance indicators.

If you are an XAF user, you already know that a framework such as XAF provides reusable building blocks to quickly build feature-rich business applications for Windows and the Web. In this post, I’ll discuss how Stephen Manderson, an XAF user from Scotland merged the capabilities of XAF and DevExpress Dashboard to create a new reusable XAF Dashboard module.

To demonstrate this Dashboard integration, we’ll use our XVideoRental RWA demo. The sample is available for your review at the bottom of this post. 

XAF users already know that dashboard support is part of the shipped product.  A few days ago, I posted a Visiting Dashboards blog where I discussed possible native implementation, user case scenarios and extensions in order to deliver dashboard solutions that address real problems without writing any code!

Stephen Manderson was recently asked by a customer if it was possible for end users to create dashboards without going through IT to request changes and modifications to their system. The solution as you can imagine was the migration of the Dashboard Suite to his XAF application.

Stephen’s goals were simple.

  1. Create dashboards like any other BO at runtime.
  2. Pass any number of Target Persistent Object as data sources.
  3. Restrict access to dashboards based on Roles.

The DashboardDesigner

 

This step is rather simple, we only need to drag this DashboardDesigner component into an empty windows form:

 

image

 

Displaying custom forms in XAF requires no special skills and is well documented: How do I show a custom window?

 

Create dashboards like any other BO at runtime

Working with XAF is pretty straight forward. Let’s begin with a DX component (DashboardDesigner) that we wish to integrate. Almost all our components are serializable and the DashboardDesigner is no exception. This means that we need a Persistent object to host the Xml for the layout and a collection of XAF BO Types to be assigned as data sources.

To start we can use the following interface:

publicinterfaceIDashboardDefinition {

    intIndex { get; set; }

    stringName { get; set; }

    ImageIcon { get; set; }

    boolActive { get; set; }

    stringXml { get; set; }

    IList<ITypeWrapper> DashboardTypes { get; }

}

For the sake of simplicity I wont post the full implementation however you can grab it and follow its history in eXpand’s github repo or in the sample at the end of this post.

 

The Xml property along with the Designer’s LoadFromXml method can be used to load the Designer’s layout. So we need:

  1. To create a SimpleAction in a ViewController. We chose a ViewController instead of any other Controller simply because we are targeting a specific view and not the whole app.
  2. Then we configure the controller a bit further, to activate it only for the BO that implements the IDashboardDefinition.
  3. Finally we subscribe to the SimpleAction’s Execute event, and we load the Windows form with the Dashboard designer component.

publicclassDashboardDesignerController : ViewController {

    readonlySimpleAction_dashboardEdit;

 

    publicDashboardDesignerController() {

        _dashboardEdit = newSimpleAction(this, "DashboardEdit", PredefinedCategory.Edit);

        TargetObjectType = typeof(IDashboardDefinition);

        _dashboardEdit.Execute+=dashboardEdit_Execute;

    }

 

    publicSimpleActionDashboardEditAction {

        get { return_dashboardEdit; }

    }

 

    voiddashboardEdit_Execute(object sender, SimpleActionExecuteEventArgs e) {

        using (var form = newDashboardDesignerForm()) {

            newXPObjectSpaceAwareControlInitializer(form, Application);

            form.LoadTemplate(View.CurrentObjectasIDashboardDefinition);

            form.ShowDialog();

        }

    }

 

In snippet above we chose to implement the LoadTemplate method in the DashboardDesignerForm because the Dashboard’s XML loading is not of XAF concern. This form is another separate windows based layer.

Visualizing our business data in the designer

The dashboard designer allows us to see our XAF data and shape our dashboards in real time as shown:

 

image

 

This designer is similar to our Reports designer but does not offer support for dynamic members aliases, which we covered in depth in the Dynamic member aliases from Application Model blog.

 

Dashboards in action

 

To visualize our dashboards we have to:

  1. Dynamically populate the navigation menu items

    We wish to extend XAF’s functionality, we must locate the responsible built-in controller, which leads us to the ShowNavigationItemController where we can subscribe to its events and populate the navigation items from the DashboardDefinition persistent objects. A possible implementation can be found in WinDashboardNavigationController.cs or you can follow its history online.

  2. Modify XAF’s security system to restrict access to dashboards based on Roles.

    Since we truly care about making it easy for the business user, the sample is using the implementation discussed in depth in the User friendly way to add permissions blog.

  3. Display the dashboard using the built-in DashboardViewer control.

    Here we easily can follow an SDK sample: How to show custom forms and controls in XAF (Example). In short, we need to create and return a new DashboardViewer control by overriding the CreateControlCore method of a PropertyEditor. In case we want to access extra system info we may use a different class (and not the PropertyEditor discussed in Implement Custom Property Editors). 

Our active dashboards are linked in the “Dashboards” navigation group; this can be renamed and reordered so all changes are reflected within this group. The end result in the post’s sample looks like the following:

 

image

 

image

 

image

What’s next?

The great news is that Stephen has already started working on a State Machine designer and its integration with XAF’s KPI module which gives dashboard its full power according to the man himself! Forgot to mention that a web version of Dashboards is coming soon!

Big thanks to Stephen Manderson for sharing this cool XAF implementation with us, We welcome you to share your cool XAF stuff with the rest of us. Feel free to use our Support Center for this or our community project.

Please do not forget to drop us a line about what we discussed today. Your input is very important to us

Unit next time Happy XAF’ing as always!

Download the XVideoRental sample here. The sample contains the following modifications

  1. A User friendly way to add permission migrated to the Common.Win.General namespace.
  2. XVideorental references the DynamicMemberAliases.Module from the Domain Components+ Calculated properties + Application Model.
  3. XVideorental references the ProvidedAssociation.Module from the Modifying Business Objects using Attributes.
  4. XVideorental references eXpand’s/Stephen's Dashboard module.

XAF Core Improvements – The Entity Framework and XPO Data Models in One Application (Coming in 12.2.7)

$
0
0

XAF team is relentlessly working to improve Entity Framework (EF) support. In the previous minor update, we have extended the list of EF-compatible extra modules with the Chart, Pivot Grid and Tree List modules, so the most of popular modules are compatible now. In the upcoming 12.2.7 update, we introduce an option to use both the Entity Framework and XPO business models in one application. For instance, with this feature you can reuse the EF model from a non-XAF application in your existing XPO-based XAF project. As a result, your application will access two databases, the first one via XPO and the second - via EF. Let us see the example.

Add an EF Data Model in Code

In the module project, reference the System.Data.Entity.dll, EntityFramework.dll and DevExpress.ExpressApp.EF.v12.2.dll assemblies and implement the following EntityFrameworkSampleObject and MyDbContext classes.

using System.ComponentModel;

using System.Data.Entity;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.DC;
// ...
[DefaultClassOptions]
publicclass EntityFrameworkSampleObject {
[Browsable(false)]
publicint Id { get; protected set; }
publicstring Name { get; set; }
[FieldSize(FieldSizeAttribute.Unlimited)]
public String Description { get; set; }
}

publicclass MyDbContext : DbContext {
public MyDbContext(string connectionString) : base(connectionString) { }
public DbSet<EntityFrameworkSampleObject> SampleObjects { get; set; }
}

To enable the automatic collection of EF Code First entities, add the following code to the module's constructor located in the Module.cs file.

using DevExpress.ExpressApp.EF;
// ...
public MySolutionModule() {
// ...
ExportedTypeHelpers.AddExportedTypeHelper(new EFExportedTypeHelperCF());
}

Add an XPO Data Model in Code

In the module project, implement the following BaseObject descendant.

using DevExpress.Xpo;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.ExpressApp.DC;
// ...
[DefaultClassOptions]
publicclass XpoSampleObject : BaseObject {
public XpoSampleObject(Session session) : base(session) { }
privatestring name;
publicstring Name {
get { return name; }
set { SetPropertyValue("Name", ref name, value); }
}
privatestring description;
[Size(SizeAttribute.Unlimited)]
public String Description {
get {return description; }
set { SetPropertyValue("Description", ref description, value); }
}
}

Populate the DefaultObjectSpaceProviders Collection

By default, the CreateDefaultObjectSpaceProvider method implemented in the WinApplication.cs and WebApplication.cs files assigns an XPObjectSpaceProvider instance to the ObjectSpaceProvider parameter. Instead, you can add multiple Object Space Providers to the ObjectSpaceProviders parameter. XAF will automatically determine what Object Space Provider should be used to create an Object Space for each particular business object type. Modify the default implementation of the CreateDefaultObjectSpaceProvider method for both Windows Forms and ASP.NET application projects in the following manner.

using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.EF;
// ...
protectedoverridevoid CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
args.ObjectSpaceProviders.Add(new XPObjectSpaceProvider(
ConfigurationManager.ConnectionStrings["ConnectionStringXpo"].ConnectionString, null));
args.ObjectSpaceProviders.Add(new EFObjectSpaceProviderCF(
typeof(MyDbContext), (TypesInfo)TypesInfo, null,
ConfigurationManager.ConnectionStrings["ConnectionStringEF"].ConnectionString));
}


Specify Connection Strings for EF and XPO

The code in the previous section reads connection strings for each Object Space Provider from the configuration file (App.config in a Windows Forms application project and Web.config - in ASP.NET), so specify the ConnectionStringXpo and ConnectionStringEF connection strings in both files.

<connectionStrings>
<addname="ConnectionStringXpo"
connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(local);Initial Catalog=MultipleORMsExampleXpo"/>
<addname="ConnectionStringEF"
connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(local);Initial Catalog=MultipleORMsExampleEF"/>
</connectionStrings>


Run the Application

Now you can run the application (Windows Forms or ASP.NET) to see that both EF and XPO objects are accessible.

EF XPO_Office2013

 

The EntityFrameworkSampleObject objects are persisted to the MultipleORMsExampleEF database, and XpoSampleObject– to MultipleORMsExampleXpo.

EF XPO_DB

Hope this small feature will be helpful when you set yourself a task like Q433494.

Socialized XAF

$
0
0

XAF community is really active, there are many places where you can participate in XAF related conversations, ask for dedicated help from other devs etc. Depending on your choice, to follow anything new comes along you can subscribe to your favorite RSS or site for the following list.

XAF official RSSPosts from our blog.
XAF Facebook pageOfficial XAF Facebook page (includes blog posts).
XAF Facebook groupJoin other XAF users there and discuss anything XAF related with them.
XAF LinkedIn groupA XAF dedicated group.
XAF twitterTweets new posts. releases etc. (Follow us to get notified).
Other XAF bloggers RSSA list of several personal XAF related posts. (Apostolis Bekiaris, Dennis Garavsky, Manuel Grundner, Mike Calvert, Nathanial Wools, Robert Anderson, Martynas Dauciunas and more.

Let me know at apostolisb@devexpress.com if you want to ride this feed as well.
  
eXpand Twitter or TweeterfeedTweets everything in this list plus new eXpand releases plus new Git commits.
eXpand’s main RSSThe most complete XAF info source currently available. Contains everything is XAF/eXpand related from official XAF and community sites.
Samples forumA forum dedicated to community samples/ideas. Feel free to post anything interesting there. We will review it and add it to eXpand’s code base.

In addition if you or your company are doing XAF consultancy or trainings, feel free to contact us to get you listed in our XAF consultancy page.

Migrating a legacy real world application

$
0
0

Recently we made the decision to port our Winforms VideoRent real world application into XAF, thus was the XVideoRental app born. With my LEGO designer hat Smileon I will go through all migration steps.

The XVideoRental app utilizes XAF recourses –>Native modules, Code Central examples along with open sourced project and community contributed suggestions. To bring this app to fruition, we spent all of the production time gathering ready-to-use implemantations and placing them in a reusable project agnostic library. This will save you from having to write a lot of the code from scratch. In addition since all these ready-to-use implementations already existed in our community project (eXpand), we created a second open source version of XVideoRental where this project agnostic library does not exist, this spending even less resources for building it!

The overview post explained that the XVideoRental contains almost zero designed time code and everything is described declaratively in XAF’s Application Model xafml file, allowing for full customization upon distribution.

There are many demands on today’s Real world applications. Features, and lots of them, are what users want. Since we had to take the time to invent something entirely new, our first releases fell short of providing a rich-feature app. Creating from scratch especially for such comprehensive framework like XAF, takes time and resource, and we simply had to prepare a domain-specific language (DSL) that would bridge business requirements with our existing technical knowledge. But the basic app is now of the way. Using the application model and the Security System, XAF fully describes and configures the behavior of platform agnostic applications. Both the Application Model and the Security System are the technology abstractions that will serve to minimize development costs of real world applications.

We recommend:

1.  Watch the BUILDING A PROJECT MANAGER APPPLICATION IN 5 MIN video where we used the same LEGO designer approach as in the XVideoRental app in a simpler application our MainDemo.



2.  Go for a quick overview of the XVideoRental app by reading XVideoRental real world application (RWA) – The overview.
3.  Check out the next table, these simple statistics clearly illustrate the tremendous advantages of developing with XAF.

  Number of projects Classes Lines of code
Legacy VideoRent
Location:
Four non reusable projects  256 27965
XAF XVideoRental• 1 project agnostic library
• 1 non reusable module
• 1 front end application almost unmodified as  created from VS templates
-
77
5
-
806
126
Open Sourced XVideoRental • References open sourced libs (project agnostic lib not exist)
• 1 non reusable module
• 1 front end application almost unmodified as  created from VS templates
-
36
5
-
807
126

In short, the legacy app uses 256 classes. The XVideoRental app utilizes less 77 and 90% of them are simply concrete implementations from the referenced project agnostic library. I want to draw your attention to the 3rd row,with only 36 classes!

Legacy app location:               %Public%\Documents\DXperience 12.2 Demos\Common\DevExpress.VideoRent.Win\CS\
XAF app location:                   %Public%\Documents\DXperience 12.2 Demos\eXpressApp Framework\XVideoRental\CS\
Open source XAF app location:
http://www.expandframework.com/downloads/download.html–>Demos\XVideoRental\

4.  Finally go through the list below where we compare the legacy and XAF applications side by side.

Legacy VideoRent

XAF XVideoRental

Data Access 

• The legacy app uses ORM technology and our XPO to describe the video rent business. However, special skills are needed, as well as extra efforts, in order to create a clear separation from  other layers, this way many helper classes will exist even for very common tasks such as database connectivity.

• XAF has built-in support for both XPO and MS Entity Framework. We can utilize the legacy domain model by simply copying &- pasting the classes. Helper classes are of no use, because XAF can handle all common tasks transparently for us!

• In real world application, requires an importing mechanism for initial data. The legacy app imports data from xml files with the exactly the same schema as its business objects. Therefore, even for a small change in the BO design, we need to modify and retest this mechanism.

• The XVideoRental app plugs-in an abstract domain-agnostic importing engine described in Fast prototyping requires an initial data import mechanism blog and allows us to modify the structure of BO in the minimum time possible. In addition, Supplying Initial Data is well documented, saving us time when it comes to making architectural decisions.

• In a real world application, sequential number integration is essential. However, special design and knowledge is needed to be able to build something reliable.

• The XVideoRental app is an XAF app, and XAF already provides a solution to such a common developer task. For an example please see E2829. So  the developer only needs to integrate, and not think about the technical difficulties or showstoppers.

Architecture 

The legacy app has a design time modularization based on Forms/UserControls/(Business Concept). It is not possible, however to extend this modularization without adding new Forms and recompiling the whole application inside VS. In addition, due to a lack of documentation, determining the best place to write code for specific behavior can still cause big headaches.

Application life cycle is component centric and was invented on demand for the current application.

The XVideoRental demo is using XAF’s well-documented and simple to use MVC architecture. While the discussed application is a simple fat client app, demanding users looking for something more advanced may also find ready–to-use client-server solutions in XAF.

• VS templates to quickly create modules which by design are reusable and independent from the main application.
•  A well documentedApplication life cycle that guides us to where we need to write code (e.g.: Setup, Login, View Activation, etc.)
• A Simple to follow tutorial on how to Extend Functionality.
• A Detailed guide of all the main concepts for building business applications.

Data Validation 

A real world application without strong validation support is unstable and has huge support issues.
Building a validation engine is not a simple task and requires third party components, which raise the cost of a project. 
Therefore, the legacy application time frame and budget, along with the lack of validation support, wouldn’t allow any investment here.

Creating validation rules does not require you to be a developer, even end-users can create them, because it is simple, intuitive and not more difficult than creating a filtering rule in your Outlook. All that is needed is the installation of a built-in Validation module!

Data Representation 

The legacy application has a large number of components. Repetitive work was invested to:

XAF has native support for a large number of DX components and automatic UI generation (CRUD detail and list forms, navigation and menu systems - all based on data models).  This is a huge time saver because almost every typical business application contains a good percentage of list and detail forms, navigation and menu systems - all linked together without any effort on your side.

• Create a large number of data entry forms, drag & drop numerous controls on it, arrange their positions and configure data bindings
• Providing a consistent look and feel is not an easy job, and requires a deep knowledge of a large number of components, as well as a special design.
• Querying the database through XPO, creating CRUD operations, supporting transactions are hard tasks, so they exists in a basic version.
• In an agile real world, the navigation menu system should be controlled as declaratively as possible. However, the legacy app does not conform to this requirement resulting in huge update times for every customer request.
• Extend XtraReports for every Business object we want to create reports for.
• Design reports inside VS making their support  impossible in the real world.
• Design analysis views inside VS making their support impossible in the real world.

• We plugged-in a mechanism that allows you to control any component at runtime, starting with Dressing up our classes – Date with a model tonight!.
• A business rule driven Pivot editor borrowed from How to rule the Pivot page where we explained how to marry business requirements with a complex component like Pivot.
• Legacy code was converted on the spot to declarative as explained in Tooltips to the max - expressive UI.
• From Visiting dashboards, we add a ready-to-use extension that provides collaboration for our views.
• We met and exceeded over expectations by installing a community module like in Dashboards in the real world – A Scotland strike.

Application Configuration 

Although most of the components can persist their state, there is no application level integration by default. In addition, component serialization does not have a friendly design and is hard to edit and support. A legacy developer would have to create an integration mechanism deep in the application’s infrastructure. This is costly. Wrap-up was basic and targeted only a few major forms producing an inconsistent feeling.

The XVideoRental app is an XAF application which by design is described declaratively in XAF’s Application Model. Using the Model Editor at runtime an end user can modify any part of the app which is described in Application Model.

We could store that Application model in a database using the ModelDifference module but we chose not too because our job was to create a legacy app clone and not to reach the sky with the endless features of XAF.

Application Security 

The legacy developer tried to create a basic security implementation. However he soon realized building a reliable Security system was simply impossible with the current budget.

So, unfortunately there is no investment in implementing a security system.

In this case, we already have a mature plug n’ play Security module. This flexibility allows us to plugin more features such as User Friendly permissions and  metadata based permission policies

Reporting 

The major advantage of business applications is the ability to create and print reports.

Therefore, the legacy app must have a dedicated project for reporting. In this app, the developer had to use Visual Studio to design a report. As a result, he lost the opportunity to update it on demand(a common need) after project distribution.

At the same time, these reports are extended and bound to VideoRent business objects, making the whole implementation not reusable from any other project.

The XVideoRental app uses the built-inReports Module, which natively integrates our award winning XtraReports Suite and provides a runtime designer.

The module saves the reports in the database so our job was to copy & paste the Reports layout from the legacy app and distribute it as discussed in Distribute the Created Reports with the Application page.

Moreover, we provided collaboration/filtering with other views utilizing the usual a no code approach as discussed in Visiting dashboards blog.

Data Printing and Export 

A legacy developer would have to write special code for each component that he/she wished to print or export. Although this functionality is very useful, such a time commitment would not be practical in the real world.

The XVideoRental app can export data from the grid, pivot, chart, tree view, layout and others to a wide number of formats (PDF, RTF, TXT, CSV, HTML, MNT, XLS, XJSX, PNG, GIF, JPG, BMP, TIFF, WMF, EMF) without spending even a minute to install or configure the system! Of course, this is all thanks to XAF, which has a built-in generic mechanism for all controls out of the box!

Data Analysis 

The legacy app has a structure to support only a few data analysis views for the four major Business Objects which are Customer, Movie, Receipt and Rent. The large amount of code located inside UI form for each analysis view, makes the solution impossible to maintain. This occurs because for each new customer request, the developer must change the code, recompile and then redistribute the app again. A common example is a calculated value, which needs a UI for input and a special algorithm to create it.

XVideoRental uses the built-inPivot Chart Module, which shifts development to the runtime, allowing business users to modify the analysis display at any time. This app uses the extended Pivot from discussed in How to rule the Pivot. Empowering the app with the dashboard suite discussed in Dashboards in the real world – A Scotland strike! was as simple as dragiing & dropping the module from the VS toolbox!. Integration of runtime calculated members as in Domain Components+ Calculated properties + Application Model.

Localization 

Where there are techniques for localizing .NET applications via satellite assemblies, they don’t localize application specific data and are very time consuming. Thus, the legacy app does not really support localization.

XAF supports all standard localization approaches and also addresses the problems that occur with them. With XAF, it is always possible to localizeany part of your application at runtime (e.g., correct certain values from satellite assemblies). A convenient wizard provides the capability to use online translation services from MS, Google, etc. So, it is possible to leave the localization job to non-programmers who can easily import/export data without exiting the application.

Customizing Controls Appearance 

Even for the simplest operation, like making a bold grid column or hiding a control from a view, development time is needed to cover the recompilation and redistribution of the application.

The XVideoRental app addresses this declaratively using the Conditional appearance module and the technic described in Dressing up our classes – Date with a model tonight! blog, where any component can be serialized and controlled declaratively from XAF’s application model using the runtime Model editor.

This process is control-agnostic and we were spared from digging into the specifics of each control – XAF did everything for us!

Implementing Custom Business Requirements 

Lets go over a concrete example here. The legacy app uses tooltips to create a more expressive UI. However, even if the developer wrote a decoupled class at the end, he/she would have to attach it to various controls and forms. This makes the whole design not flexible, since changes require a developer’s presence.

XVideoRental can use the same decoupled class from the legacy application. However, it simply attaches the behavior to the application model, instead of attaching it to controls and forms. This solution is project agnostic and allows for later changesby a non-programmer at runtime! This process is discussed in detail in the Tooltips to the max - expressive UI article.

Getting Help and Support 

One cannot help but notice that application and its developer are simply married. If for any reason they separate, then everything would become very unstable and tricky. It would really be hard to find another developer to continue supporting a legacy app. Even if one manages to fin the right person, the cost would be overwelming, since the new developer would have no help docs or support of any kind with which to catch up.

The XVideoRental app uses bricks/samples from XAF’s code central and community project. Thus by design there is a large number of developers that can support its code base. Let’s not to forget the unmatched documentation and support we can get from the XAF team.

   

Conclusion

Even though XAF does not contain solutions to each and every business problem in the world,  the framework is very strong in provides its own extensibility ( "preventing the lock-in effect").  It is a quick and easy to plugin solutions to common business problems, after all, XAF is a Domain Specific Language that can bridge business requirements with our existing technical tools and/knowledge!

Until next time,

Happy XAF’ing!

Subscribe to XAF feed
Subscribe to community feed

Dressing up an Entity Framework model with a rich app UI in 5 min

$
0
0

Imagine that we have already built a mobile app, such as the DXSK8 demo, using DXTREME and already have a ready-to-use Entity Framework data model. Now we are faced with the task of providing a rich administrative application to be mainly used in the Intranet via the Windows desktop or web browser. This application must contain a typical CRUD UI for managing goods in an online shop, content on our main web site etc, and of course have the potential for future extensibility and customization as a result of a customer request. If you following the instructions in this post the whole process from scratch will take less than five minutes! (See a sample app at the end of this post).

1) Create a XAF Cross-platform application

Create a new XAF solution called DXSK8.Admin by using the DXperience v12.2 XAF Cross-Platform Applicationproject template as shown below.

image

Further down we see the created solution which contains two ready to run XAF applications (DXSK8.Admin.Win, DXSK8.Admin.Web) and three empty XAF modules where the DXSK8.Admin.Module is platform agnostic. We are going to work in the platform agnostic module because we want to minimize code duplication between our Win and Web XAF applications.

image

2) Adding Entity Framework model types to XAF

XAF auto generates rich CRUD UI for our data using our award-winning DevExpress visual components. However our Entity Framework model is located in an external library so in our platform agnostic module we need to reference the EF model container which is the DXSK8.Service assembly along with the System.Data.Entity and DevExpress.ExpressApp.EF assemblies.

image

The next step involves adding all the EF model entities in our application business model by using the following code in the constructor of this platform agnostic module.

image

publicsealedpartialclassAdminModule : ModuleBase {

    publicAdminModule() {

        InitializeComponent();

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Customer));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Address));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Brand));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Employee));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.ImageSource));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Login));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.NotificationChannel));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Order));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.OrderItem));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Person));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Product));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.ProductFlavor));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.ProductType));

        AdditionalExportedTypes.Add(typeof(DXSK8.Service.Store));

    }

As a result, the XAF Application Model now contains all EF model types and we are ready to modify the auto generated Views, define the navigation structure or empower our app with built-in or open source modules.

imageimage

For example in the sample app in the end of the post we used the Model Editor to modify the Application Model of the platform agnostic module and create a Navigation menu for both platforms as illustrated below:

image

Note: The creation of Navigation Items is fully described in XAF docs (Add an Item to the Navigation Control). In addition, you can find a detailed tutorial and a long list of How To’s that can help you get the most out of XAF really quickly!

3) Switch the Application to Using the Entity Framework

To utilize the EFObjectSpace instances to access data we must provide an IObjectSpaceProvider implementation designed for EF that is located in the DevExpress.ExpressApp.EF assembly. For this we need to modify our Module.cs codebehind class again as shown.

Note that the EFObjectSpaceProvider’s first parameter is Entity Framework’s ObjectContext implementation from the DXSK8.Service project.

    publicoverridevoidSetup(XafApplication application) {

        base.Setup(application);

        application.CreateCustomObjectSpaceProvider+=ApplicationOnCreateCustomObjectSpaceProvider;

    }

 

    voidApplicationOnCreateCustomObjectSpaceProvider(object sender, CreateCustomObjectSpaceProviderEventArgs e) {

        var typesInfo = (TypesInfo)Application.TypesInfo;

        conststringmetadata = "res://*/SK8Data.csdl|res://*/SK8Data.ssdl|res://*/SK8Data.msl";

        conststringprovider = "System.Data.SqlClient";

        var objectContextType = typeof(DXSK8.Service.SK8DataContainer);

        e.ObjectSpaceProvider = newEFObjectSpaceProvider(objectContextType, typesInfo, null, e.ConnectionString, metadata, provider);

    }

Note: XAF will not modify the schema of your existing database!

Conclusion

Microsoft recommends to use the Entity Framework when accessing data. Beginning with v5,the Entity Framework is open-sourced and has an unlimited list of add-ons and really large audience. We used this amazing technology to create the DXSK8 data service and in this post, we demoed how to use XAF with three simple steps for managing its content by creating rich CRUD UI views as demonstrated below. Therefore it should be clear that we can deliver app prototypes for our EF models quickly and our end users can enjoy access to their data with modern UI look & feel from day one! Note that XAF has a lot of built-in and open-sourced modules that can be installed with a simple drag and drop, and can save you months of work.

In the following images, we see two of the default auto generated XAF CRUD Views - one for each platform (Win and Web).

image

image

For those of you that have Entity Framework models and you wish to try these instructions on them, download an XAF trial from here.

Sample Download (contains the DXSK8.Service project as well).

In next post, we will continue with our discussion over reusable EF models in XAF, Stay tuned!

We would appreciate your feedback on this post. Has it been useful to you? Feel free to contact us with further questions.

Until next time,

Happy XAF’ing!

Subscribe to XAF feed
Subscribe to community feed

UI Annotation using Business Rules

$
0
0

XAF contains several kinds of modules, one of which is a Validation Module. Validation can be applied to the content of XAF objects when specific rules are applied to the Validation Module. In this post you can find a sample XAF application which extends the Validation to provide support for Warning/Information messages.

Today’s implementation can be used by any Validation Business Rule that exists in the XAF’s Application Model. Displayed below is the default list of these rules, applicable to custom business rules as well.

image

The sample code extends the Application Model of the IModelRuleBase. By using one more property like the RuleType, the Application Model marks the rule as a warning or as information shown below:

image

This will not raise exceptions for Warning and Information Rules when Validation occurs, but will change their notification icon accordingly.

Windows

image

Web

image

HOW TO APPLY THIS GREAT FUNCTIONALITY TO YOUR PROJECT?

  1. Download  RuleType.zip and open it in VS.
  2. Copy its only oneController located in the RuleTypeController.cs and spanned across three modules to your own platform agnostic and platform depended modules (Win/Web).

    image
  3. Hit F5 and profit!

Note: I “borrowed” the code for RuleType support from our community project expandframework I hope that this blog demonstrated once again just how flexible and powerful XAF is when it comes to providing reusable solutions!

Subscribe to XAF feed
Subscribe to community feed


Merge Changes when Two Users Edit the Same Record Simultaneously

$
0
0

In multi-user data-aware applications, there are times when one user edits a record while another user is editing the same record. As long as the changes being made do not affect the same field (e.g., one user modifies the task description while another user attaches a file), XAF can resolve the situation, and merge simultaneous changes made by different users. The following video demonstrates this scenario.

To try out this functionality (which will be available in version 13.1 of XAF), add the following code to your Program.cs file.

staticvoid Main() {
DevExpress.Xpo.XpoDefault.TrackPropertiesModifications = true;
// ...
}
 
Note that ASP.NET applications are not supported, because user interaction dialogs are currently only implemented for WinForms. The core helper classes are located in the DevExpress.ExpressApp.Xpo assembly so that support for ASP.NET can be added in the future.
 

Important note:

To support this functionality, persistent properties should be implemented in a specific manner. If you implement your business model in code, then follow XPO best practices and use either the SetPropertyValue or OnChanged method in persistent property setters. These methods have several overloads. Use the overloads that take both the old and new property values:

SetPropertyValue("PropertyName", ref propertyValueHolder, value);
 
OnChanged("PropertyName", propertyValueHolder, value)


If you use the Data Model Designer or Business Object Designer to create the data model, then you do not need to worry about implementing persistent properties. Designers automatically declare persistent properties in the proper manner.
 
If you have any questions about this functionality, feel free to leave a comment below.

Case Study: Meet XAFARI - a business platform from Galaktika Corp

$
0
0

I wanted to take a moment to profile an XAF customer and offer a real-world example of how the eXpressApp Framework (XAF) is used around the world.

 

Meet XAFARI (www.xafari.ru) from Galaktika - a business platform designed to quickly build advanced business applications with an n-tier architecture. 

This middleware class solution is fully based on the eXpressApp Framework (XAF), which is essentially a set of best patterns & practices for building desktop LOB apps using DevExpress controls for both Windows and the Web.

 

Technically, and like the community-driven eXpand Framework project, XAFARI is built on top of XAF and  provides many reusable modules and powerful tools for various verticals.

 

The following figure depicts how XAFARI is constructed internally:

 

Xafari_1

 

About Galaktika

Galaktika Corporation (http://galaktika.ru ) is an international software company that has more than 25 years of success developing control systems in Russia and CIS. According to the "Russia Enterprise Application Software 2011-2015 Forecast and 2010 Vendor Shares" study by IDC,  Galaktika Corporation is in the top five for enterprise management systems (others in this list include SAP, 1C, Oracle and Microsoft Dynamics).

 

 

The advantages of XAFARI

XAFARI has proven itself through the years across multiple production applications used by countless organizations around the world.  The following is a list of solutions built using the XAF-based development platform:

 

Galaktika EAM– enterprise asset management;

Galaktika AMM– production and project management (advanced manufacturing management);

Galaktika HR– human resources and talent management;

Galaktika SPM– training management university

Galaktika CnP– consolidation, planning and monitoring (consolidation and planning);

Galaktika IPMS– investment programs management system;

Galaktika Budjet– planning and monitoring budgets for the holdings.

 

You can learn more about these production systems at http://www.galaktika.ru/ where you can also find many screenshots and videos (example) demonstrating real-world use of these systems.

 

Business owners and end-users alike value XAF and XAFARI for the rich collection of pre-built vertical market solutions and for its extensibility and a number of generic extensions.

Most powerful examples include custom docking panels, advanced batch editing and security management, custom UI elements like Property Editors and new Action types (checked Action, aggregated Actions, etc.).

 

Another XAFARI advantage is its documentation. You can easily find detailed feature descriptions with many pictures and even videos for complex functionality:

 

Xafari_3

 

 

You’ve seen what Galaktika has done with XAF….Are you ready to evaluate XAF for yourself?

To explore the capabilities of the eXpressApp Framework and learn how you can save time and bring applications to market quicker and target both WinForms and ASP.NET, please visit our XAF page at www.devexpress.com/xaf

 

What Galaktika executives say about XAF’s role in their business?

Sergey Zaycev, head of development for the XAFARI platform:

 

clip_image005“I think that we use 100% of the XAF capabilities while implementing our projects. We mainly deliver Windows and Web solutions to our clients, and actively use the multi-database systems support provided by XAF and XPO. In particular, we deploy our solutions on Microsoft SQL Server and Oracle, while also using in-memory database support for creating demo versions of our apps. I want to note that the XAF’s architecture is well-thought in terms of the expansion the standard features of the platform – these are simply countess extensibility points and methods. Proper use of design patterns developed into the XAF platform itself allowed us to create a large number of custom modules and components that are easily and naturally integrated into the framework. It’s also worth mentioning that the XAF Workflow module allowed us to simplify the Microsoft WF integration (we use this in some of our projects) and served as a base for our custom tailored workflow solution for organizing documents flow.
Separately, it should be said about the
Domain Components (DC) technology. The proposed concept of describing data model together with the idea of ​​the modular construction of the final application, allows us to fully realize our ideas, absolutely. Defining business objects through interfaces instead of classes allowed us to use multiple inheritance, which is my opinion, is the key when implementing large projects with a large number of applications built on the same platform.
In general, the use XAF platform has significantly cut our costs and, in particular, to give up the need to develop our own  ORM system and framework.

I hope to prepare a case-study in the future, to provide more technical details and information on our experience with DevExpress.”

 

Alexander Burgardt, Vice President at Galaktika:

 

clip_image006“As the leader and curator of Galaktika EAM, I can confirm that the DevExpress XAF platform is very comfortable, modern and advanced, can really quickly build solutions, and in addition, a lot of changes in the system can be made by the end-users, even without programming, but simply by configuring forms, algorithms and business processes. Finally, I want to say that in addition to the existing systems the Galaktika Corporation will develop its new products on the XAFARI platform.”

 

Learn more about XAFARI

To learn more about XAFARI, make sure to visit their website. Please note that the site is in Russian and its English version is still in the works.

You can use Chrome’s built-in translation tools if you need to view the site:


Xafari_2 

To download the latest version of XAFARI, visit http://xafari.ru/download. XAFARI currently supports DXperience v12.2.4.

Contact information for Galaktika can be found at: http://xafari.ru/contact_information

Security in On-line shop? That’s easy!

$
0
0

There are many reasons why Security is a necessity when developing even the simplest online shop backend. Instead of listing them all I will concentrate on how to empower the application prototype we created for our DXSK8 e-shop with a flexible Security System.

You may recall that in the previous post we applied a XAF layer(rich application) over an EF model located in an external lib (DSK8.Service). Now we will extend the same EF model to support XAF’s Security System.

1) Designing an Entity Framework Model for Security System objects.

XAF’s Security system uses Users,Roles and Permissions to configure both data access and UI generation for both platforms! This is done with the help of several system interfaces such as :
User: ISecurityUser, IAuthenticationStandardUser, IOperationPermissionProvider
Role:, IOperationPermissionProvider.

Our EF model from the DXSK8.Service project already contains an Employee entity, which is just perfect for taking on the role of XAF’s system user. We begin by adding all public properties of the user depended interfaces to our Employee entity. XAF interfaces are well designed and there are only three as you see below. The UserName in the black frame already existed in our Login entity, it’s not in the Employee entity with the rest of the new fields. XAF has no problems understand it as is!

image

The next step is to design the Roles and Permissions objects. While XAF supports member level and criteria based systems as well, I will utilize the Type Permission system in this case. I only need the Roles and TypePermissionObject entities listed below.

image

Be sure to follow the database migration steps detailed by EF. For the purposes of this blog I followed a standard technic described in Code First Migrations. 

Note that we must use partial classes to implement the consumed interfaces this implementation simple and can be reusable, for example let’s see how easy it is to implement the Employee interfaces. For Role, TypePermissionObject implementation please check sample at the end of the post (See also How to: Implement Custom Security Objects (Users, Roles, Operation Permissions))).

[ImageName("BO_User"), DefaultProperty("UserName")]

publicpartialclassEmployee : ISecurityUserIAuthenticationStandardUser,

                                IOperationPermissionProvider {

 

    #region IOperationPermissionProvider

    IEnumerable<IOperationPermissionProvider> IOperationPermissionProvider.GetChildren() {

        if (!Roles.IsLoaded) {

            Roles.Load();

        }

        returnnewEnumerableConverter<IOperationPermissionProvider, Role>(Roles);

    }

 

    IEnumerable<IOperationPermission> IOperationPermissionProvider.GetPermissions() {

        returnnewIOperationPermission[0];

    }

    #endregion

    #region ISecurityUser

    BooleanISecurityUser.IsActive {

        get { returnIsActive.HasValue&& IsActive.Value; }

    }

 

    StringISecurityUser.UserName {

        get { returnUserName; }

    }

    #endregion

 

    #region IAuthenticationStandardUser

    BooleanIAuthenticationStandardUser.ComparePassword(String password) {

        var passwordCryptographer = newPasswordCryptographer();

        return passwordCryptographer.AreEqual(StoredPassword, password);

    }

 

    publicvoidSetPassword(String password) {

        var passwordCryptographer = newPasswordCryptographer();

        StoredPassword = passwordCryptographer.GenerateSaltedPassword(password);

    }

 

    BooleanIAuthenticationStandardUser.ChangePasswordOnFirstLogon {

        get { returnChangePasswordOnFirstLogon.HasValue&& ChangePasswordOnFirstLogon.Value; }

        set { ChangePasswordOnFirstLogon = value; }

    }

 

    StringIAuthenticationStandardUser.UserName {

        get { returnUserName; }

    }

    #endregion

 

}

2)  Installing a XAF Security System

Although XAF has strong design time support I will go through this step using one line of code in both Program.cs and Global.asax.cs just before application.Setup() call.

application.Security = newSecurityStrategyComplex(typeof(DXSK8.Service.Employee), typeof(DXSK8.Service.Role), newAuthenticationStandard());

application.Setup();

The snippet above will assist you with applying a security strategy using the Entity Framework entities located in the external DXSk8.Service lib . For this type of security strategy XAF spares our time as usual and will automatically display a customizable credentials window for both win and web platforms as shown,

 

image

image

 

In addition XAF detects the custom Security EF Entities we designed in step 1 and automatically populates the navigation menu.

 

Win
image
Web
image
  

 

3) Supplying initial data

It is absolutely imperative that someone working on your project is assigned the security password. In addition, a user with admin privileges must also be assigned. Use the XafApplication’s CustomCheckCompatibility event inside our platform agnostic module to assign these admin priviledges.

 

publicoverridevoidSetup(XafApplication application) {

    base.Setup(application);

    application.CustomCheckCompatibility+=ApplicationOnCustomCheckCompatibility;

    application.CreateCustomObjectSpaceProvider+=ApplicationOnCreateCustomObjectSpaceProvider;

}

 

voidApplicationOnCustomCheckCompatibility(object sender, CustomCheckCompatibilityEventArgs e) {

    var objectSpace = e.ObjectSpaceProvider.CreateUpdatingObjectSpace(true);

    var updater = newUpdater(objectSpace, Version.Parse("1.0.0.0"));

    updater.UpdateDatabaseAfterUpdateSchema();

}

and the UpdateDatabaseAfterUpdateSchema where we created:
a) A Content Manager role with CRUD on Product but ReadOnly on Orders/Employees

b) A Sales Manager role wirh CRUD on Order but ReadOnly on Product/Employees

publicoverridevoidUpdateDatabaseAfterUpdateSchema() {

    base.UpdateDatabaseAfterUpdateSchema();

    if (ObjectSpace.FindObject<Employee>(CriteriaOperator.Parse("UserName=?","Admin")) == null) {

        var roleAndUser = CreateRoleAndUser("Admin");

        roleAndUser.IsAdministrative = true;

        CreateRole("Content Manager", new[]{

            CRUDPermission(typeof(Product)),

            ReadOnlyPermission(typeof(Order)),

            ReadOnlyPermission(typeof(Employee))

        });

 

        CreateRole("Sales Manager", new[]{

            CRUDPermission(typeof(Order)),

            ReadOnlyPermission(typeof(Product)),

            ReadOnlyPermission(typeof(Employee))

        });

 

        var employees = ObjectSpace.GetObjects<Employee>();

        foreach (varemployeein employees) {

            employee.IsActive = true;

            employee.ChangePasswordOnFirstLogon = true;

        }

 

        ObjectSpace.CommitChanges();

    }

}

Use this post’s sample to explore the implementation of the remaining methods, which happens to be rather simple.

 

The remainder of the project needs a business user to simply associate Employees with Roles using XAF’s well thought-out UI. For example, the next two screenshots illustrate how to assign a Content Manager Role to a list of users.

 

image

image

Conclusion

There are many difficulties and complexities when it comes to addressing business problems with technology. And that’s exactly why tools like XAF, which bridge business and technology are such a life saver. You just witness just how simple it was to integrate a complex and sensitive feature like security while working with EF as datalayer. Thanks to the flexible and well-designed XAF, your product can now be marketed more easily since it features a complete security system.

I close this time with a phrase I often hear from our customers :

XAF really works!

Download a sample from here and attach the mdf file found in the DXSK8.Service/App_Data folder to your SQL instance. Be sure to visit How to: Get Started with the Entity Framework Model First in XAF for coverage of the basics.

.

A Google Map module for XAF web applications

$
0
0

XAF it’s a great platform simply because everything is pluggable and reusable! In this post I will demonstrate one more pluggable and reusable contribution – the MapView module from Sergej Derjabkin!

Scenario: We have a business object which has an Address property and we want to display them in Google maps. However we have no time to research or develop anything by ourselves.

Step1: Install the MapView module by drag & drop from the toolbox.

image

Step2: Open Application Model editor to configure from where the module will take its data. This requires that we locate the Customer in the BOModel node and simply change the attributes as illustrated below.

image

Step3: To display the Customer Addresses, the MapView module provides the MapListEditor. Simply install the MapViewWebModule and assign the list editor to the Customer_ListView.

image

Step4: Run the XAF web app and see the results in the map!

image

Bonus scenario: Display a detail view of the mapped address.

Sergej Derjabkin also contributed webmaster detail functionality which is available with XpandSystemAspNetModule so install it as in Step1 and set the MasterDetailMode attribute to ListViewAndDetailView. Youi ‘ll need to override the SupportMasterDetailMode of your WebApplication descendant and return true.

image

Simple and fast – the XAF way!

Sergej Derjabkin released his MapView module as a preview in eXpand v13.1.7.2 and asked me to get your feedback in order to develop further, so feel free to thank him personally and ask your questions or even contribute your code or ideas in eXpand forums. To see MapView module in action use the Demos/Modules/MapView/MapViewTester.sln found in eXpandFramework sources.

Subscribe to XAF feed
Subscribe to community feed

The XAF training week in Germany

$
0
0

Last week I had the privilege to join many of our customers at Oliver’s XAF Training Class in Germany. I wanted to take the time and share with you what happened at the event – as it was an amazing week and highly recommend it to all XAF users. 

The location

The hotel is located high in the mountains and the above an amazing landscape…a simply beautiful location.

image

The agenda

Day 1:

The organizers (Oliver and John) did a great job with course content. You can see all the XAF courseware below.

image

Day 1 started with XPO and how it works independent of XAF. Oliver is an XPO legend so the introduction was amazing and even I learned some new stuff. Oliver then took the time to describe XAF Domain Components and other data layer related subjects.

The day continued with a number of hands on labs so everyone can learn by actually doing.

To help get relaxed after a busy day of learning, we spent some time on the golf course.

image

Day 2:

The day started with instruction on editing and maintaining the model as well as standard functionality available through it. Actions, controller extensions binding business logic was also on the menu.

Oliver is an experienced instructor and did great job in this topic area as well. Like day 1, hands on labs were on day 2’s agenda.

image

The day ended with time at the spa and a great dinner.

Day 3:

This day involved learning about the built-in modules in XAF and so Oliver spoke to us about Security, Validation, Printing, Reporting, Auditing, State Machines. We covered all simple modules with a few hours of hands on labs.

To blow off steam, John and Oliver organized an evening at the mini-car race track. Many of us gave it our best shot to win….

image

Unfortunately only one person can win… Smile.

image

Day 4

With spirits high, Oliver moved onto more advanced modules like XAF’s Scheduler, KPI, WorkFlow and of course a few hours of hands on labs. He also took the time to go further into more difficult topics such as extending and working outside the XAF framework.

The class insisted so I also did a presentation on eXpandFramework where I described how you can use all that extended functionality in our community project.

Day 4’s final event involved alcohol, so I’m not going to post any pictures  here Smile.

Day 5 

Unfortunately I had a early flight on the last day and couldn’t attend however I can share the daily agenda.

• Modularizing your own functionality

• Testing

• Deployment / Update / ALM / Security Considerations

• Q&A

Way to go to John, Oliver and DevExpress for this amazing XAF training week!

Until next time, Happy XAF’ing to all!

Subscribe to XAF feed
Subscribe to community feed

How to send email for any business scenario without coding

$
0
0

A few weeks ago, the eXpandFramework released registration support as discussed in How to manage users (register a new user, restore a password, etc.) from the logon form. While users could register, the implementation process was still incomplete it was missing email notification. Thus, this post will discuss the new EmailModule which was made available beginning version 13.1.8.2.

The module was designed following the workflow discussed in Declarative data auditing. In this post I will demonstrate how to install the module along with the registration functionality discussed in manage users from the logon post in order to create three mail rules.

1) When new user is registered.
2) When the password is forgotten.
3) When a new customer is created.

In addition I will discuss how to restrict the EmailModue to sending emails only when a specific user role is logged in.

1) Installation

To complete installation, drag & drop the EmailModule from the toolbox into the module designer.

image

2) Enabling Registration

To use the registration process, the XpandSecurityWinModule & XpandSecurityWebModule must be installed just as we did with the EmailModule in step 1. Drag & drop these two modules from the toolbox into the module desinger. In addition, use the XpandLogonParemeters as the LogonParametersType of our authentication as illustrated in the following image.

image

The final step is to configure the model as shown below.

image

When the application starts, the logon form will have two extra actions. See below.

image

When the end user executes the top action, the XpandSecurity module will create a new view from the non-persistent RegisterUserParameters class.

image

Let’s stop here and configure the rule that will actually send an email..

4) Sending an email when a user is registered

The EmailModule will extend the Application model with an extra node

image

The first step towards sending an email is to setup the SmtpClient. See below.

image

Next we need to create an EmailContext that will instruct the EmailModule on how to locate the email template used for this type of notification.

image

Now it’s time to create the actual EmailTemplate. The EmailModule uses the Razor engine and provides an EmailTemplate persistent object for this. Thus, the code snippet inside a ModuleUpdater bellow can do the job!

image

And of course, XAF can do its usual magic in terms of the UI, allowing the end user to fully design the template at runtime in both windows and web!

image

The next stop is to create the rule that will send an email based on the template created when a new user registers. This is illustrated below.

image

and the mail is send!

5) Sending an email for a forgotten password

As you might have guessed, the process is awfully similar here. We create a different EmailTemplate persistent object for this type of a notification and then create a new model EmailTemplateContent.

image

Then we form a rule, which instead of using the RegisterUserParameters class will use the RestorePasswordParameter and the “pass forgotten Template” context.

image

6) Sending an email to all admins when a new customer is created

The procedure is pretty similar to the steps in the previous section. The difference is that in this case we will not set the CurrentObjectEmailMember attribute, since we want to send the email to all the admins and not to the customer. This is why we will need to create an EmailRecipient context as the image below illustrates.

image

After, we must create the actual rule where we will set the EmailReceipientContext attribute..

image

7) Sending emails only when a specific user role is logged in

If you already read the Declarative data auditing post you probably know that all modules that use the Logic module can create rules using three different ways.Code Attributes decorating a class, using the Application Model or using permissions as you see bellow.

image

 

image

Note that the above layout is inherited from the Logic module using the technique discussed in the Model View inheritance version post.

An alternative approach is to use the Model Application modifications discussed in this post and using the ModelDifference module apply them to a Role Model and assign that model to the roles you want. For more information on this approach, see Changing your web Model at runtime with Model Editor and no IIS reset.

Feel free to explore what I discussed in this post in the eXpand source code under Demos/Modules/Email/EmailTester.sln

As always feel free to use the eXpand forums for your feedback and questions.

Happy XAF’ing to all!

XAF: Reporting V2 (What’s New in 13.2)

$
0
0

With the upcoming release of the eXpressApp Framework (version 13.2), we’re introducing a new way in which to create reports for your XAF powered application. Simply said, you’ll now be able to create your report using XtraReports within Visual Studio and effortlessly integrate them into your XAF applications.

This is an introductory post for the ReportsV2 module and I’ll describe it in more detail once we release. For now, please keep in mind that this will ship as a beta. We are looking forward to your feedback so we can continue to improve the module to meet your specific requirements.

To start using ReportV2, I’ll select it from the toolbox…

image

Because ReportsV2 integrates XtraReports at design time, you can use all the examples and documentation form our Reports Team. As you might imagine, when creating reports with this new module, you’ll be writing code and creating your own custom template within Visual Studio using your language of choice (C#, VB.Net). XAF will allow you to preview and print these new templates at runtime much like the existing Reports module. Since the design time report is a template, it is not editable at runtime, however, it is possible to clone it, make an editable copy and continue designing at runtime. In addition to native integration, ReportsV2 should make it easierfor you to work with Stored Procedures, SubReports and hosting of custom components (this will be the subject of a dedicated blog post)..

To integrate XtraReports at design time, our team introduced two new components: the CollectionDataSource and the ViewDataSource. In the first beta release, you will need to add them to your toolbox manually.

image

The CollectionDataSource component

Drag and drop the component from the VS toolbox to the designer template of an XtraReport class. To create the XtraReports class, use existing XtraReports documentation. After setting up the ObjectTypeName to one of your domain objects the CollectionDataSource will load all objects properties as is.

image

The ViewDataSource component

Much like CollectionDataSource, you will need to set the ObjectTypeName property. Note that the ViewDataSource component is designed to load only required plain data properties or aggregated calculations instead of the entire object hierarchy. As a result, you will get better performance and less memory consumption when you are dealing with thousands of records and complex data models. To configure the properties or expressions that will be used as a datasource, you can use the Properties collection as illustrated below.

image

Runtime integration

To load the report you created at design time with the new module, we provide a ModuleUpdater subclass -PredefinedReportsUpdater - which can be used as shown in the snippet below.

publicoverrideIEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) {

    ModuleUpdater updater = newDatabaseUpdate.Updater(objectSpace, versionFromDB);

    PredefinedReportsUpdater predefinedReportsUpdater = newPredefinedReportsUpdater(Application, objectSpace, versionFromDB);

    predefinedReportsUpdater.AddPredefinedReport<XtraReportOrdinary>("Inplace Report", typeof(Contact), isInplaceReport: true);

    predefinedReportsUpdater.AddPredefinedReport<XtraReportView>("Report with ViewDataSource", null);

    returnnewModuleUpdater[] { updater, predefinedReportsUpdater };

}

We’ve created a specific demo for the ReportsV2 module. It is located in your C:\Users\Public\Documents\DXperience 13.2 Demos\eXpressApp Framework\ReportsV2Demo folder.

Because ReportsV2 will ship as a beta, we do not recommend its use in production code. We do want to hear your thoughts on ReportsV2 and are looking forward to incorporate your feedback…so please let us know what you think…

!


XAF: Easy custom members (What’s New in 13.2)

$
0
0

With our next major release (13.2), we have simplified the manner in which you are able to add custom and computed fields to existing business models. The functionality is available to both developers and end-users.

Once beta 1 is released, you can explore this new custom member functionality by exploring the FeatureCenter solution located in the C:\Users\Public\Documents\DXperience 13.2 Demos\eXpressApp Framework\FeatureCenter\CS folder.

Design time

As you know, XAF already offered the ability to create non-calculated persistent fields at design time using the Model Editor. In 13.2, we’ve extended the Application Model with an Expression attribute as illustrated in the image below.

image

When the Expression attribute has a value, XAF will create a calculated member or it will default to the creation of a persistent member. Additionally, you can create a complex expression such as the Sum of another custom field as illustrated below.

image

By design, XAF will not display these custom fields in any view since they were created manually after the Application Model was generated.

Runtime

The great thing is that in 13.2, end-users can use the runtime version of the Model Editor to create custom members and extend the business domain as discussed in the previous section.

The image below illustrates where to locate the custom member in the Windows version of our FeatureCenter (same location for the web).

image

To invoke the runtime Model Editor, end-users can execute the Edit Model action.

image

You may also want to restrict Application Model modification to certain user groups. You can do that as illustrated below.

image

Developers can restrict end-users from creating custom members at runtime by setting the static ModelMemberRequiredCalculator.AllowPersistentCustomProperties to false.

The Web Runtime

To create a custom member for the web, you can use the Standalone Model Editor and edit the Model.xafml file located in the root of the web-site.

image

Custom members are in their first release (CTP) so we look forward to your feedback as we get it ready for the official release. Let me know what you think.

XAF: Soft Validation (What’s New in 13.2)

$
0
0

Our next major release (13.2), updates our Validation Module with more features that come with different behavior rules, such as Warnings and Information. These can be applied to your existing validation rules using code or the Model Editor.

The XAF validation module is a mature and flexible validation system, which allows you to create rules that can validate any business problem, For more information, check out the module documentation.

Suppose we have a Business Object that disallows saving a Customer if the Name property is blank. If this attempted the UI should respond with a “Everybody has a name!” message.

[DefaultClassOptions]

publicclassCustomer : BaseObject {

    publicCustomer(Session session) : base(session) { }

    [RuleRequiredField("Customer_Name_Required", DefaultContexts.Save, "Everybody has a name!")]

    publicstringName { get; set; }

    publicstringCity { get; set; }

    publicintAge { get; set; }

}

When an end user tries to save the Customer without a name, XAF will show the Validation Error listview and consequently abort.

image

Creating a warning rule

A common requirement for our Customer class is to warn the end user that, if possible, he/she should provide the Customer’s city. To do this, we need to mark the City property with a  RuleRequiredField. However, this time we have to set the ResultType to Warning as illustrated below.

[DefaultClassOptions]

publicclassCustomer : BaseObject {

    publicCustomer(Session session) : base(session) { }

    [RuleRequiredField("Customer_Name_Required", DefaultContexts.Save, "Everybody has a name!")]

    publicstringName { get; set; }

    [RuleRequiredField("Customer_City_Warning", DefaultContexts.Save, "Provide the City if possible",

        ResultType = ValidationResultType.Warning)]

    publicstringCity { get; set; }

    publicintAge { get; set; }

}

When the end user saves the Customer (in runtime) providing a Name and not a City, XAF will again show the Validation Error listview however, this time there will be an extra Ignore action.

image

If the end user executes the Close action, the object will not be saved however if he executes the Ignore action it will be saved. In both cases in the detailview there will be a warning action by the City textbox to draw the end user’s attention.

image

Creating an Information rule

XAF allows you to create validation rules even at runtime using the Model Editor. So let’s say we want to just inform the end user, if he enters a Customer Age not between 10 and 60. This means that we need to use a RuleRangeField rule as illustrated in the next two images.

image

image

When the end user saves a Customer (in runtime) with an invalid Age range, XAF will not display the Validation Error listview at all. However, it will display an Information icon to draw his/her attention to the Age property.

image

Where to see more examples?

You may explore our FeatureCenter application located in your C:\Users\Public\Documents\DXperience 13.2 Demos\eXpressApp Framework\FeatureCenter\CS folder to see a few rules in action.

What about the web?

The validation module as a platform agnostic module works similarly for the web.

image

The soft validation is in its first release (CTP), thus we look forward to your feedback as we get it ready for it’s official release. Let me know what you think.

A few more reasons to upgrade to v13.2

$
0
0

13.2 was a great release and many of you already upgraded your applications. For everyone else I am here to help you make that decision sooner and easier, by reminding you what our reviewers had to say, when they upgraded their apps to our latest major release.

These are real world feedback without any kind of interaction from us.

Gustavo Marzioni
Making Business Applications Easier

Gustavo is a veteran programmer (20 years+) with a great presence in our community (most active user in eXpandFramework). He posted a very complete review of all new XAF features and a few other interesting things we released with 13.2 as part of our DXperience subscription. In addition you can find a performance comparison for our new ReportsV2 module.

Mario Blataric
Dungeons of XAF and Magic 13.2

Mario reviews v13.2 and explains how XAF helps him to fight monsters in today’s modern dungeon of dev technologies and platforms. His XAF app has more than 1500 reports so he focuses on the ReportsV2 module.

Martynas Dauciunas
Devexpress 13.2 Review - why bother upgrading ? 

Martynas known from his very useful Excel Import Wizard module wrote an extensive review of all new features and problems encountered when he updated his 12.x ERP/CMMS application to v13.2.

Manuel Grundner

DevExpress 13.2 Review Part 1
DevExpress 13.2 Review Part 2
DevExpress 13.2 Review Part 3

Manuel has already contributed many solutions. This time he wrote a great review for all new XAF features. He also reviewed components not integrated with XAF like the new TaskBarAssistant and as a bonus in part 3 he wrote how to create a module that integrated this component with XAF. This module will soon be integrated into our community project eXpandFramework.

Robert Anderson
DevExpress 13.2 Review - Part 1
DevExpress 13.2 Review - Part 2

Robert is a casual blogger and community contributor. He wrote about all new 13.2 features along with a few more tricks and thoughts which cannot be found in our official posts.

Until next time,

Happy New Year to all!

Improved Entity Framework support in XAF 13.2

$
0
0

With the release v13.2.6, eXpressApp Framework (XAF) supports Entity Framework 6 by default. If you are upgrading from an earlier version of EF, please take special note of the following Microsoft article: Upgrading to EF6.

Due to the recent changes to Entity Framework, we have also updated and restructured our documentation to help you get started with Entity Framework in XAF. More is also coming as we simplify some of our EF-related APIs.
To learn about these changes, please be sure to visit the Business Model Design with Entity Framework section of our docs.

In addition to service refactorings and usability improvements, v13.2.7 introduces additional features requested by our Entity Framework users. Specifically, we now support composite keys and custom calculated fields in the entity data model. These changes allow your end-users to extend a business model at runtime without recompiling the app. Note that since built-in support for custom fields does not exist in Entity Framework, we had to provide our own implementation (check the docs for more information).


What's New in 13.2.8 for the eXpressApp Framework (XAF)

$
0
0

ReportsV2

With XAF v13.2.8, you are now able to use ReportsV2 and the previously available Reports modules within the same application. This is good news for those who want to maintain use of existing reports along-side of new reports generated with XAF's ReportsV2 module.

How it works?

  1. Open the Application Designer for your existing XAF application (one that is using the previously released Reports module) and drop the new ReportsV2  module from the Visual Studio Toolbox:



  2. Create and design a regular XtraReport in Visual Studio, use the new ReportsV2 data sources and then register the report to display it within XAF's application UI.

  3. Run the application and see both legacy and new reports functioning side by side:



    Note that I also renamed the navigation items so you can distinguish between Old and New.


What is next?


We have received lots of positive feedback from our customers and plan to officially release ReportsV2 in 14.1 (due late May 2014).  We will be improving the existing documentation and adding more examples to highlight popular scenarios.



EFDataView - when flexibility and performance matters


The EFDataView is our new data source that allows arbitrary combinations of calculated and aggregated values to be retrieved from an
Entity Framework data model.

As a lightweight read-only list of data records, the EFDataView retrieves records from a database without loading complete entity objects. This list can be queried much more quickly than a real objects collection. If you are familiar with XPO, think of EFDataView as an analog of the XPView component.


How it works?


To create an instance of the EFDataView, pass an EFObjectSpace
instance to the EFDataView constructor or use the IObjectSpace.CreateDataView method. The data view column names and expressions used to compute column values are specified via the Expressions list. By default, this list is empty and you should populate it manually. Both simple properties and complex expressions can be passed to the EFDataView constructor or IObjectSpace.CreateDataView method via the expressions parameter. The valid separator is a semicolon:

EFDataView dataView = new EFDataView(objectSpace, typeof(Product), "ID;Name;Sales.Sum([Count] * Price)", null, null);


The data can also be filtered and sorted via the criteria and sorting parameters:

List<DataViewExpression> dataViewExpressions = new List<DataViewExpression>();
dataViewExpressions.Add(new DataViewExpression("Count", new AggregateOperand("Sales", Aggregate.Count)));
CriteriaOperator criteria = new BinaryOperator("Sales.Count", 0, BinaryOperatorType.Greater);
SortProperty[] sorting = new SortProperty[] {new SortProperty("Name", SortingDirection.Ascending)};
EFDataView dataView = new EFDataView(objectSpace, typeof(Sale), dataViewExpressions, criteria, sorting);

Data records are not retrieved from the database when the EFDataView object is created. Instead, the database is queried when you access a specific record by its index or call one of the following methods for the first time: IBindingList.Find,IEnumerable.GetEnumerator,Contains,CopyTo,Count,IndexOf.

Later, the cached data records are used by these methods. To refresh data, use the Reload method which clears the cache.

You can limit the number of retrieved data records by using the TopReturnedObjectsCount property.


Primary usage scenarios

1. Data source for a visual data-aware control.

Since the EFDataView implements the IBindingList and ITypedList interfaces, it can serve as a data source for a visual data-aware control, e.g. the grid, chart, pivot or any other. For instance, you can now use this component “as is” on a custom form  that retrieves data from the database via Entity Framework.

2. Fast and lightweight data calculations in custom business logic.

The EFDataView retrieves only required data and not entire persistent entities as well as provides great filtering and sorting capabilities. It is perfect to perform quick data calculations as your business logic dictates.
As an example, when you access a particular data record by its index, a lightweightIDataRecord object is returned:

IDataRecord dataRecord = dataView[0];

Now to get a column value within a particular data record, use the IDataRecord.Item property as follows:

int id = dataView[0]["ID"];

Here, the "ID" string is the name of the column within the Expressions list. If you use the semicolon-separated string to specify the columns set in the EFDataView constructor, the column name coincides with the expression text:

int total = dataView[0]["Sales.Sum(Count * Price)"];

What’s next?


We want to give an XAF user the flexibility to configure the ListView’s data source mode depending on the required functionality. This will be possible without writing any code, but rather via a setting in the Model Editor. For instance, Currently the ListView operates with entire persistent objects by default, but there will also be a built-in setting to enable the “Data View” mode to achieve a greater performance in certain scenarios (e.g., for analytics and reporting involving large volumes of data).  By introducing the new ViewDataSource component for our new ReportsV2 module in v13.2 we are already on our way to offering more flexibility for an XAF user. As our upcoming release of 14.1 draws near I will be able to share more details, so stay tuned.

Viewing all 148 articles
Browse latest View live