How to Create and Customize WP

Contents:

  • Roles Management
  • Creating New Work Places
  • Existing Work Place Model Edit
  • Customizing Work Places in the Configuration File
  • Work Places Model Settings Files
  • Access Modifying in the Source Code.

Roles Management

Add a new Role to the application security system. Each Work Place requires a separate Role.

work_places_5

There is no need to assign rights to these roles for the fact they are used only to bind users to Work Places.

Assign Roles to the users. It is possible that a certain user has several roles, each one for a particular Work Place.

Creating New Work Places

To create a new Work Place, make a new Model file for the appropriate Role: Model.Workplace.<role_name>.xafml. There are three ways to do it:

  1. Manually edit the .xafml file.
  2. Use an XAF application. It can be either the target application itself or a specially developed for such purposes Xafari Application Support utility. The exact scenario depends on the developer's choice.
  3. Use a special Xafari.Workplace.ModelEditor.exe application.

1. The .xafml file

To create a new Work Place manually, create a new UTF-8 coding file in the application folder, name the file Model.Workplace.<role_name>.xafml, and add the following strings to the file:

  • xml

<?xml version="1.0" encoding="utf-8"?>
 <Application/>

2. XAF application

XafariWorkplaceCfgModule from the Xafari.Workplace.Cfg.dll assembly provides the opportunity to customize Work Places in the runtime. There are two possible use cases for this module:

  • The module is included into the end application. In such case, its functionality is available in the solution itself.
  • The end application is implemented counting on a separate administrative utility usage - Xafari Applications Support (XAS).

WorkplaceDescriptor List View displays the list of Work Places, allows to create and delete Work Places, and provides the opportunity to edit their Model.

work_places_12_en

To enable the list of Work Places in the application, use the corresponding Navigation Item or Arm Item. By default, XafariWorkplaceCfgModule creates a "Work Places" Navigation Item in the Configuration area. XAS uses Navigation Items and automatically displays all related UI controls.

Create Work Place Action loads a special Wizard that asks to specify the Role for a Work Place and the Way of creating (i.e. to create a new one or to clone an existing Work Place). If cloning, the template model source is required.

work_places_13_en

Edit Work Place Action or a double click on the record will open the Model Editor for the current Work Place.

work_places_14_zoom59

3. Xafari.Workplace.ModelEditor.exe.

  • Run the Xafari.Workplace.ModelEditor.exe app.

work_places_9

  • In the Open Workplace Model dialog window specify the .config file of the application and (if needed) the folder containing the Work Place files.
  • In the Workplace file field give a title to the Work Place file as follows: Model.Workplace.<Role_Name>.xafml.
  • Click the Create button to create the Work Place. Now you can use the Open button to run the Model Editor for further customization.

Existing Work Place Model Edit

Existing Work Place is a one that already has its own Model.Workplace.<Role_Name>.xafml file. There are two ways to modify the Work Place Model:

  • Use an XAF application. It can be either the enterprise system itself or the Xafari Application Support utility, designed specially for these purposes. This variant is described above (in the Creating New Work Places section).
  • Use a special Xafari.Workplace.ModelEditor.exe application.

The mentioned Xafari.Workplace.ModelEditor.exe utility is already included into Xafari installation pack. It allows creating new Work Places and customizing the existing ones as follows:

  • Run the editor,
  • Fill the Application configuration file and Workplace files path fields if required.
  • Specify the needed Work Place file in the Workplace file field.
  • Click the Open button to open the Model Editor for the current Work Place.

work_places_10

Customizing Work Places in the Configuration File

If the Work Places functionality is supported within an XAF application, its .config file should contain the following keys: WorkplaceFilesPath и ShowWorkplaceSelectorOnStart.

WorkplaceFilesPath defines the folder that stores the configuration files of the Work Places. If this parameter is not specified, the files are taken from the application folder by default. This is how a record in the .config file of the app looks like:

  • xml

<add key="WorkplaceFilesPath" value =" d:\Application|Workplaces \" />

The ShowWorkplaceSelectorOnStart indicator defines whether to display the Work Place selection window when the application starts. If this indicator is set to false ("no display"), the last active Work Place for the current user is loaded by default. In case such Work Place does not exist, the system uses the first one from the list. Here is an example of how it looks like in the .config file of the app:

  • xml

<add key="ShowWorkplaceSelectorOnStart" value ="true" />

Work Places Model Settings Files

The settings (modifications) of the user Model are stored in the files. These files names match to this template: Model.User.<User_Name>.xafml. When using the Work Place modules, user Model modifications are automatically divided according to Roles. The titles of the files that store user Model customizations match to this sample: Model.User.<User_Name>.<Role_Name>.xafml.

For the fact a single user can take part in several different Work Places, there is a separate file with user's configurations for each Work Place. For example, when a user runs the app choosing the "Master" Work Place, a new Model.User.Master.xafml file is created. If the same user restarts the application now choosing the "Mechanic" Work Place, the Model.User.Mechanic.xafml file is created. The example below shows the file for the whole Work Place and for a particular user of that Work Place.

work_places_11

Access in code

The developer of the application can modify the code to define the moment for switching Work Places and for opening WorkplaceModelEditor.

The WorkplaceManager class provides two possible events:

  • WorkplaceSwitching happens before switching Work Places,
  • WorkplaceSwitching happens after switching Work Places.

When using Work Places, two Actions are added into the application's main window:

  • SwitchWorkplaceAction to switch Work Places in the runtime,
  • EditWorkplaceModelAction to open WorkplaceModelEditor.

WorkplaceMainWindowController and WorkplaceWindowController contain public getters to access these Actions.