With the Accelerator, it is possible to define multiple modules in the Accelerator Maintenance that point to the same WPF and BOS code. This ensures a high level of reuse for easy maintenance. An example of why you would do this can be demonstrated with 2 Accelerator Modules. In the Accelerator, we have a file FWUG that has a type field to designate whether the Group is a User Group (Type = "SYSTEM") or a Command Group (Type = "COMMAND"). I want to create 2 separate modules, with 2 separate module names and iconography as well as only show the FWUG records for the Type selected. The best way to do this is to have both modules share the same code base and then condition where appropriate. You can condition on Module number since User Group and Command Group will have different module numbers, but I would recommend that you condition (In this case) based on the Accelerator View in the Business Process layer.
Let me take you through the steps:
Step 1 - Make sure the module is generated. This will give you a module definition for 1 of the types. Change the module information according to match the type.
Step 2 - Create a Search Explorer Bar that will be used by the new module. In the Accelerator, views are tied to the explorer bar and not the module number. We need to create another Explorer Bar that will be used to define the new view(s). Open the module code in Visual Studio. You can create the explorer bar 2 ways. (1) If you want to have different search fields per module, then you need to copy the existing Explorer Bar xaml and code behind and then rename. (2) If you will have the same search fields and just want different views, then you can just create a C# class that inherits the initial explorer bar code behind.
The new C# class will look like this: (In this example, UserGroupsExpBarSearch_RFWUGEBS1 (Type = "SYSTEM") is the original and UserGroupsExpBarSearch_RFWUGEBS2 (Type = "COMMAND") is the new class that inherits from the original.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WPF.UserGroups { /// <summary> /// Class UserGroupsExpBarSearch_RFWUGEBS2. This class used by the Command Groups Module. The Group Type will be "Command". /// </summary> public class UserGroupsExpBarSearch_RFWUGEBS2 : UserGroupsExpBarSearch_RFWUGEBS1 { } }
Step 3 - Create New Module and View Reference and View in Accelerator. In order to make sure the assembly names are correct. It is important to first copy the existing module and save it. Then you can change the Module Name, Description, Image, and most importantly the Explorer Bar Item Name which must match your newly created Search Explorer Bar. Save your module again. Then click on the View References and create a new View Reference and View. In this example, I created a new View named "FWUGV01_COMMAND".
Step 4 - Code your query conditions based on view name in the Module Business Process am_Select method.
public override AB_SelectReturnArgs am_Select(AB_SelectInputArgs inputArgs) { switch (inputArgs.ap_View) { case "FWUGV01_COMMAND": if (inputArgs.ap_Query == null) { inputArgs.ap_Query = new AB_Query(); } // Remove Group Type "SYSTEM" and add Group Type "COMMAND" inputArgs.ap_Query.am_RemoveWhereClause(UserGroupsEntity.GroupTypeProperty.ap_PropertyName); inputArgs.ap_Query.am_AddWhereClause(UserGroupsEntity.GroupTypeProperty.ap_PropertyName, "=", "COMMAND"); break; default: if (inputArgs.ap_Query == null) { inputArgs.ap_Query = new AB_Query(); } // Make sure Group Type "SYSTEM" Exists inputArgs.ap_Query.am_RemoveWhereClause(UserGroupsEntity.GroupTypeProperty.ap_PropertyName); inputArgs.ap_Query.am_AddWhereClause(UserGroupsEntity.GroupTypeProperty.ap_PropertyName, "=", "SYSTEM"); break; } return base.am_Select(inputArgs); }