160 likes | 178 Views
MVC in AX2012. Rama Sridhar Ramasridhar_rr@hotmail.com http:// ramasridhar.wordpress.com. Agenda. What is MVC? Overview on BOF BOF in Services BOF in Reports Q&A. What is MVC?. Is MVC an architecture or design pattern?. Pros and cons of MVC. Pros: Loosely coupled
E N D
MVC in AX2012 Rama Sridhar Ramasridhar_rr@hotmail.com http://ramasridhar.wordpress.com
Agenda • What is MVC? • Overview on BOF • BOF in Services • BOF in Reports • Q&A
What is MVC? Is MVC an architecture or design pattern?
Pros and cons of MVC Pros: • Loosely coupled • Clear separation of UI, Data and Business logic • Test Driven • Code Reuse • Hide Data Access • Adaptable to change cons: • Duplicated code between common views • Not a true n-tier architecture (triangulation) • Not a true publisher – subscriber model
Business Operation Framework The Business Operation Framework service is one of the system services exposed by Microsoft Dynamics AX and that adheres to the Windows Communication Foundation (WCF) protocols and standards. Following are the features of BOF: • Allows menu-driven execution or batch execution of services. • Call services in synchronous or asynchronous mode. • Automatically creates a customizable UI based on the data contract. • Encapsulates code to operate on the appropriate tier (prompting on the client tier, and business logic on the server tier).
Components • DataContract • Controller • Service class • UIBuilder
BOF in Services Methods Diaglog() GetFromDialog() PutToDialog() Prompt() Run() Main() Member variables pack/unpack methods
BOF Service Demo
How to create a BOF service? To create a Business Operation Framework service, the following steps must be performed: • Create a data contract class • Identify the parameters passed to the service • Register the class as a Business Operation Framework service • Optionally customize the automatically generated UI for the class
What are the ways to customize UI? • Attribute based customizations. Attributes are SysOperationGroupAttribute, SysOperationGroupMemberAttribute, SysOperationDisplayOrderAttribute, SysOperationLabelAttribute, SysOperationHelpTextAttribute etc. • Code based customizations. Using UIBuilder class. For example check CustRecurrenceInvoiceUIBuilder Class.
DataContract • Validate DataContract at design time • To perform validation on contract class, you need to implement SysOperationValidatable Interface and override the validate method. For example of this, check CustRecurrenceInvoiceDataContract class. • Modify DataContract at run time • To modify the contract at runtime, we need to create a controller class extend from SysOperationServiceController class. • Get the contract object by calling the method getDataContractObject from controller class instance and then call the corresponding parm methods of contract class, passing the desired values.
Calling a BOF service A Business Operation Framework service can be called in four ways: • As a menu item • Create an Action Menu Item • Set the ObjectType to Class • Set the Object to SysOperationServiceController • Set the Parameters to <ServiceClassName>.<MethodName> • As a batch process • Create a job and create the service method in that job • Synchronously • To run the service synchronously, edit the menu item, set EnumTypeParameter=SysOperationExecutionMode; EnumParameter=Synchronous • Asynchronously • To run the service synchronously, edit the menu item, set EnumTypeParameter=SysOperationExecutionMode; EnumParameter=ASynchronous
BOF in Reports • AX 2012 report programming model is build on SysOperation Framework • In AX2012, we have 2 options to develop reports • Modeled solution aka query based • Code based solution aka Report data provider based
View:SrsReportDataContractUIBuilderModel:SrsReportDataContract/SrsReportDataProviderBaseView:SrsReportDataContractUIBuilderModel:SrsReportDataContract/SrsReportDataProviderBase Controller:SrsReportRunController