
Last year we participated in
TechEd Russia and, of course, we talked a lot with visitors. Then it turned out that Russian developers are well aware of our company as a manufacturer of .NET controls, but few have heard that DevExpress has a framework - eXpressApp Framework (
XAF ) - which unites most of our WinForms and ASP.NET products. Then the idea was born to tell the Russian-speaking community about XAF, which is being implemented now.
So, what is XAF and why are you asked to memorize another three-letter abbreviation? Simply put, XAF is a framework for quickly developing other three-letter things, such as
CRM ,
ERP ,
EAM ,
WMS , etc. (any business applications).
XAF can be useful not only for experienced .NET developers. The “threshold of entry” is low - you can safely say that you can start developing HAF applications without having any experience in .NET. So, XAF sysadmin masters can help to create a serious corporate application and get rid of a heap of shared Excel tables or Access databases into which users enter and try to analyze.
')
At the same time, advanced developers can create arbitrarily complex solutions (for example, the
Galaxy EAM ).
And how can XAF help?
A programmer who has XAF in his arsenal does not have to worry about how to create a beautiful and functional user interface from our controls and organize work with the database. To begin with, it is enough to write on C # or VB.NET a set of classes or interfaces representing objects with which the application will operate (for example, “employee”, “client”, “order”, etc.). Everything else XAF takes over, providing at the output of WinForms and ASP.NET applications that already have the necessary set of forms for entering and presenting data.
The default functionality is easily expanded. On our site you can see
screenshots of applications written in XAF .
Where to download, how to install?
To try XAF, you will need Visual Studio 2008/2010 and one of the supported DBMS, for example MS SQL Server, MySQL, PostgreSQL (
full list ). A trial installation is available for download
here (choose the eXpressApp Framework in the right column). Trial can be used for 30 days, with full technical support available.
Where to begin?
So, after a successful installation, you can see what project templates have become available in Visual Studio. Now we are interested in
eXpressApp Framework /
Applications Solution v11.2 .
Specify the name of the solution, for example
DemoForHabr , and see what happened. And that's what happened.
Before us are five projects. Two of them are Windows Forms and ASP.NET applications. The remaining three projects are so-called modules.
Now we will describe the business model, so we go into the platform-independent module (
DemoForHabr.Module ). In XAF, two ways of describing a business model are the creation of "business classes" and "domain components." Both methods have their advantages and disadvantages, the discussion of which is beyond the scope of this article. Here, in order to save space, we use the second method, which requires less code.
The
DemoForHabr.Module project contains the
Business Objects folder, and we will add the code to it. Suppose we need an application to store a list of tasks assigned to employees. To describe the “task” and “employee” entities, we add a pair of domain components
Task and
Employee (these are normal interfaces with the
DomainComponent attribute).
using System; using System.Collections.Generic; using DevExpress.ExpressApp.DC; using DevExpress.Persistent.Base; namespace DemoForHabr.Module.BusinessObjects { [DomainComponent, DefaultClassOptions, ImageName("BO_Person")] public interface IEmployee { string Name { get; set; } string Position { get; set; } IList<ITask> Tasks { get; } } [DomainComponent, DefaultClassOptions, ImageName("BO_Task")] public interface ITask { string Subject { get; set; } IEmployee AssignedTo { get; set; } DateTime Deadline { get; set; } bool IsCompleted { get; set; } [FieldSize(int.MaxValue)] string Description { get; set; } } }
It remains to register these entities. To do this, open the
Module.cs code and
override the
Setup method of the
Module class:
public override void Setup(XafApplication application) { if (!XafTypesInfo.IsInitialized) { XafTypesInfo.Instance.RegisterEntity("Employee", typeof(IEmployee)); XafTypesInfo.Instance.RegisterEntity("Task", typeof(ITask)); } base.Setup(application); }
Configuring the connection to the database
If you have a locally installed Microsoft SQL Server, you can skip this paragraph, everything will start automatically. Otherwise, open the
App.config file from the WinForms application project (
DemoForHabr.Win ) and specify the
ConnectionString option (there are several commented out options).
And what happened?
Now you can run the WinForms application. XAF automatically creates forms for editing Task and Employee entities.
What's up with the base?
All necessary tables and links are generated automatically.
And in Russian?
To date, we have an application in English. Fortunately, locating it is a snap. The Russian language is already in the installation, you just need to translate the names of our entities and their properties.
To do this, in the module in which the code was written, open the
Model.DesignedDiffs.xafml file (the designer will start). Through the toolbar, open Languages ​​Manager and add the Russian language.
There is also a
Localization button on the panel that opens a list of texts for translation.
Now the value of the
PreferredLanguage property can be changed to “ru”.
Run the application, now everything is in Russian.
How about a web interface?
To start a web application, it is enough to change the starting project. The same functionality is available in the web interface.
What else to read?
We have just created a very simple application for entering and viewing data. The real possibilities of XAF are much broader - you can configure access rights, add an application server, create reports, use the capabilities of the
Workflow Foundation , analyze data using pivot tables and charts, print and export data, display events in the scheduler, decorate the application with skins and much more.
If you liked XAF and want to study it more seriously, go through the
Basic Tutorial . Then you can go to a more in-depth
Comprehensive Tutorial .