AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.03.2017, 00:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,448 / 846 (79) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Batch Processing in Dynamics AX 2012 Using SysOperation Framework
Источник: https://stoneridgesoftware.com/batch...ion-framework/
==============

In Microsoft Dynamics AX 2012, SysOperation framework replaced RunBase framework to support the batch processing functionality. Going forward, SysOperation framework is recommended for writing custom business logic that requires batch processing functionality, over the deprecated RunBase framework.

The RunBase framework defines coding patterns that implement these requirements. The SysOperation framework provides base implementations for many of the patterns defined by the RunBase framework. Another great thing is SysOperation framework simplified the pack / unpack of variables that was additional work in the RunBase framework, taking advantage of the Attributes feature introduced with AX 2012. For a detailed comparison between SysOperation and RunBase framework, refer to Microsoft Dynamics AX 2012 White Paper: Introduction to the SysOperation Framework.

SysOperation framework allows application logic to be written in a way that supports running operations interactively or via the Microsoft Dynamics AX batch server. It implements the MVC (Model–View–Controller) design pattern, with the isolation of Parameters (Model), Dialog (View) and Service (Controller), for the code that’s executed.

The key objects of the framework are defined below:

Service: Service class extends from the SysOperationServiceBase class and contains the business logic for the batch operation. Developers often tend to add the business logic in controller classes, which violates the Single responsibility principle.

Data Contract: Data contract class is the model class defining attributes needed for batch operations. These attributes are provided by the user, in a dialog. DataContractAttribute attribute is needed for the class and the properties methods requires DataMemberAttribute attribute.

Controller: Controller class extends from the SysOperationServiceController class. It holds information about the batch operation like execution mode, show dialog or progress bar etc. and directs the batch operation.

UI Builder: UI Builder class extends from SysOperationAutomaticUIBuilder class and is used for adding custom behavior to dialog / dialog fields dynamically constructed by the SysOperation framework.

In this blogpost, I’ll cover three different scenarios (in a sequential manner) for creating batch operations using SysOperation framework classes – Service, Data Contract, Controller and UI Builder.

Scenario 1: Creating a simple batch operation

Project: SharedProject_SysOperation_SimpleBatchOperation.xpo





1. Controller Class

public class SysOperationControllerClass extends SysOperationServiceController{}public void new(){ super(); this.parmClassName(classStr(SysOperationServiceClass)); this.parmMethodName(methodStr(SysOperationServiceClass, processOperation)); this.parmDialogCaption("Batch Operation Dialog Title");}public ClassDescription caption(){ return "Batch Operation Task Description";}public static void main(Args args){ SysOperationControllerClass controller; controller = new SysOperationControllerClass(); controller.startOperation();}2. Service Class

public class SysOperationServiceClass extends SysOperationServiceBase{}public void processOperation(){ info ("Running SysOperation Batch Operation");}3. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Scenario 2: Add user defined parameters for batch operation

Project: SharedProject_SysOperation_UserDefinedParmsBatchOpr.xpo





1. Controller Class

public class SysOperationControllerClass extends SysOperationServiceController{}public void new(){ super(); this.parmClassName(classStr(SysOperationServiceClass)); this.parmMethodName(methodStr(SysOperationServiceClass, processOperation)); this.parmDialogCaption("Batch Operation Dialog Title");}public ClassDescription caption(){ return "Batch Operation Task Description";}public static void main(Args args){ SysOperationControllerClass controller; controller = new SysOperationControllerClass(); controller.startOperation();}2. Service Class

public class SysOperationServiceClass extends SysOperationServiceBase{}public void processOperation(SysOperationDataContractClass _contract){ info ("Running SysOperation Batch Operation"); info ("Date Property: " + date2Str (_contract.parmDate(), 213, DateDay::Digits2, DateSeparator::Dot, DateMonth::Long, DateSeparator::Dot, DateYear::Digits4)); info ("Text Property: " + _contract.parmText());}3. Data Contract Class

[DataContractAttribute]public class SysOperationDataContractClass{ TransDate dateValue; Description255 textValue;}[DataMemberAttribute, SysOperationLabelAttribute('Date Property'), SysOperationHelpTextAttribute('Enter a date in past'), SysOperationDisplayOrderAttribute('1')]public TransDate parmDate(TransDate _dateValue = dateValue){ dateValue = _dateValue; return dateValue;}[DataMemberAttribute, SysOperationLabelAttribute('Text Property'), SysOperationHelpTextAttribute('Type some text'), SysOperationDisplayOrderAttribute('2')]public Description255 parmText(Description255 _textValue = textValue){ textValue = _textValue; return textValue;}4. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Scenario 3: Add custom validation to dialog fields

Project: SharedProject_SysOperation_UserParmsValidationBatchOpr.xpo

Scenario 3.1 – Validation failed:





Scenario 3.2 – Validation passed:





1. Controller Class

public class SysOperationControllerClass extends SysOperationServiceController{}public void new(){ super(); this.parmClassName(classStr(SysOperationServiceClass)); this.parmMethodName(methodStr(SysOperationServiceClass, processOperation)); this.parmDialogCaption("Batch Operation Dialog Title");}public ClassDescription caption(){ return "Batch Operation Task Description";}public static void main(Args args){ SysOperationControllerClass controller; controller = new SysOperationControllerClass(); controller.startOperation();}2. Service Class

public class SysOperationServiceClass extends SysOperationServiceBase{}public void processOperation(SysOperationDataContractClass _contract){ info ("Running SysOperation Batch Operation"); info ("Date Property: " + date2Str (_contract.parmDate(), 213, DateDay::Digits2, DateSeparator::Dot, DateMonth::Long, DateSeparator::Dot, DateYear::Digits4)); info ("Text Property: " + _contract.parmText());}3. Data Contract Class

[DataContractAttribute, SysOperationContractProcessingAttribute(classStr(SysOperationUIBuilderClass))]public class SysOperationDataContractClass{ TransDate dateValue; Description255 textValue;}[DataMemberAttribute, SysOperationLabelAttribute('Date Property'), SysOperationHelpTextAttribute('Enter a date in past'), SysOperationDisplayOrderAttribute('1')]public TransDate parmDate(TransDate _dateValue = dateValue){ dateValue = _dateValue; return dateValue;}[DataMemberAttribute, SysOperationLabelAttribute('Text Property'), SysOperationHelpTextAttribute('Type some text'), SysOperationDisplayOrderAttribute('2')]public Description255 parmText(Description255 _textValue = textValue){ textValue = _textValue; return textValue;}4. UI Builder Class

public class SysOperationUIBuilderClass extends SysOperationAutomaticUIBuilder { DialogField dateField;}public void postBuild(){ super(); // get references to dialog controls after creation dateField = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(SysOperationDataContractClass, parmDate));}public void postRun(){ super(); // register overrides for form control events dateField.registerOverrideMethod(methodstr(FormDateControl, validate), methodstr(SysOperationUIBuilderClass, validateDate), this);}public boolean validateDate(FormDateControl _dateControl){ if (_dateControl.dateValue() > today()) { error("Please select a past date"); return false; } return true;}5. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Import all three Shared Project SysOperation object files here:

SharedProject_SysOperation.zip (1 download)

Источник: https://stoneridgesoftware.com/batch...ion-framework/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
За это сообщение автора поблагодарили: Logger (1).
Теги
sysoperation framework

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: AX Performance - Analyzing key SQL Server configuration and database settings Blog bot DAX Blogs 0 28.09.2015 14:11
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 13 Blog bot Dynamics CRM: Blogs 0 27.03.2013 22:12
DAX: Official Dynamics AX 2012 R2 Content (update) - Where is it, and how can you find out about updates? Blog bot DAX Blogs 0 03.12.2012 11:11
Platform updates overview - 3.70.B - NAV2009 R2 Blog bot Dynamics CRM: Blogs 0 07.02.2011 22:06
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:57.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.