To add Scaffolded items by using the AB Suite MVC Scaffolder, perform the following:
In the Solution Explorer window, right-click Views, point to Add, and then select New Scaffolded Items... from the context menu.
The Add Scaffolder dialog box appears.
In the Templates pane, select AB Suite Custom Scaffolder. This is a custom Scaffolder for AB Suite applications. It updates your MVC application with artifacts, such as Views and Controllers, based on the DataModel definitions generated from your Client Framework application.
Click Add.
The Agile Business Suite Custom MVC Scaffolder dialog box appears.
From the Select an assembly list, select the required DataModels assembly.
In Generate MVC Views from Client Framework DataModels group, select either of the following:
Select Generate all Views?, to generate MVC Razor Views for all the DataModels in the selected assembly. If you want to generate a single View, you must select the required DataModel from the Select a DataModel list.
Select Generate as Partial View?, to generate partial Views for aggregated classes. For example, in the AB Suite Sample system, you can create a partial View for the Action_Line class. The other Views would include the partial View as required.
Select Separate Sign Controls?, to generate separate sign fields for the signed numbers. If you do not select this field, the control added on the View displays the number along with the sign.
Select Overwrite existing View?, if you want to overwrite a previously generated View.
Note: You must not select the Overwrite existing Views? field, if you want to retain any design changes that you made to a previously generated View.
Select Use Layout Page?, to use a layout page that can be applied to all the Views.
Select Default, if you want to use a default layout page.
Select Custom, if you want to use a custom layout page.
From the Select a DataModel list, select a DataModel that is generated for an ispec in the DataModels assembly. This generates a View for the selected DataModel. This option is disabled if you select Generate all Views?.
In the Presentation Metadata Location box, enter the path or browse to the location of the Presentation Metadata.
The Presentation Metadata contains a set of XML files that are generated when an existing AB Suite model is converted to an AB Suite User Experience mode model. The XML files contain presentation information of the forms in an AB Suite application. This information can be used by the Scaffolder to create appropriate control types in the Scaffolded Razor Views.
If you are not using a converted AB Suite User Experience mode model, leave this field empty.
Select Add Web API Support to add Web API support. This generates the required Controllers that expose RESTful services for application transactions. You can make HTTP requests to the website from the browser application to send and receive data to and from the AB Suite system. This option would typically be used for the development of Single Page Applications (SPAs) and other HTTP clients that perform operations by using Ajax requests.
Select Use Authentication, if you have created an application that requires authentication. This option adds the "Authorize" attribute on the generated Controllers. If the request for a Controller action is not authorized based on the authentication mechanism applied to the website, the request is denied.
Click Add.
When the AB Suite Custom Scaffolder runs, it generates or updates the following files in the MVC application.
The Web.config file is updated with the Client Framework connectivity setting that are used to connect to the runtime system. The "AppSettings" section is modified to include the following keys:
<add key="System Name" value="<System Name>" /> <add key="RuntimeServer" value="localhost" /> <add key="LogLevel" value="Debug" /> <add key="LogFolder" value="C:\Temp" /> <add key="UseComputerNameForStation" value="false" /> <add key="OffLine" value="false" /> <add key="IsAnonymous" value="true" /> <add key="ForceLogin" value="true" /> <add key="RequireCallback" value="false" /> <add key="UseGateway" value="false" /> <add key="GateWayAddress" value="127.0.0.1" /> <add key="AltNameFor_Sample" value="" />
Notes:
Web.config is a configuration file for the ASP.NET applications. See Using the Web API for more information on the Access Layer connection options.
When the RequiredCallback property is set to false for an MVC Client, you do not have to add the Application User to the Administrators group. The connection to the runtime system is successful but the client application does not have access to the messaging interface that the console and report mechanisms use.
In the Web.config, when the UseGateway key is set to true then you must install Client.Framework.Direct.Remote.Connect Nuget package for the MVC project to access the AB Suite system by using the WCF Gateway Service.
The Global.asax.cs class is updated with the Session_Start() and Session_End() method to provide session management for the Web application.
The Session_Start() method establishes a host session with the AB Suite application by using the ABSuiteSession Helper class. It stores the ABSuiteSession object in Session State.
The Session_End() method closes the AB Suite session when the IIS session has timed out.
A utility class named ABSuiteSession.cs is generated under the Utility folder. This file exposes various methods that allow you to perform transactions and interact with the Access Layer API. It is used by the generated Views and Controllers to exchange data with the host system.
A Helper.cs file is generated under the Helpers folder. This class implements several HTML Helpers that need AB Suite specific implementations for model-bound controls, such as signed numbers, buttons, images, check boxes, and partial classes.
A base controller class named ABSuiteModelController.cs is generated under the Controllers folder. All other Controllers generated for the AB Suite application inherits from this base class. This class encapsulates common methods that can be used by multiple applications Controllers, especially when the application is being designed to support switching.
A System Controller class named <SystemName>Controller.cs and individual ispec Controller classes named <SystemName>.<IspecName>.cs are generated under the Controllers\<SystemName> folder. The ispec Controller classes are partial classes that extend the main Controller class.
A Razor View file named <ViewName>.cshtml is generated for each View under the Views\<SystemName> folder.
A Razor Layout page named ABSuite_Layout.cshtml is generated in the Views\Shared folder. This provides a sample layout page that includes support for displaying the status information.
A Razor View named ABSuite_Error.cshtml is generated in the Views\Shared folder. This page displays the application errors that might result in abnormal circumstances (for example, connection failures).
If you include support for Web API
The files “RouteConfig.cs” and “WebApiConfig.cs” in the App_Start folder are modified to allow for session state handling in a Web API environment.
The following Controllers are added to the Controllers\<SystemName>\WebApi folder.
IspecController – This Controller is used to implement APIs that interact with ispecs in the application.
ListController – This Controller is used to provide APIs for retrieving lists.
PMController – This Controller is used to provide APIs for making public method calls to the host application.
These Controllers be extended to include custom API methods as required.
If you are using Presentation Metadata, a file named <SystemName>.css is generated in the Content folder. This file contains a set of CSS declarations that define styles extracted from the Styles.xml file in the Presentation Metadata. These styles can be applied to add controls on the View if required.
A set of JavaScript files are generated in the Scripts\<SystemName> folder. There is a script for each ispec containing a JavaScript class that can be used by popular client-side scripting libraries, such as Knockout or AngularJS. They can also be used to serialize and deserialize data for JSON-formatted Ajax requests.
You can now run the application by performing the following:
Right-click the project and select Build from the context menu.
Right-click the project and select Set as StartUp Project.
Right-click the project, point to Debug, and then select Start New Instance.
The default ASP.NET page that is generated by the MVC application appears.
Access the Views by specifying the Controller name followed by the View name in the URL.
For example, http://localhost:8080/<ControllerName>/<ViewName>
Note: The MVC client tries to match the host context and displays the corresponding View. For example, if the fireup ispec is sent to the client, the View that is displayed initially is for the fireup ispec.
You can now interact with the application by entering data into the controls in the View and submitting the form. When a form is submitted the corresponding View appears as a response from the host application.