Processing Template pattern

I want to offer to the community for discussion Processing Template Pattern.
We use processing template pattern to setup document workflow for Nav and external applications.
Basic concepts:
1. Document Status. Every document should have status.
2. Statuses list must be configured for document type.
3. Processing template defines document workflow, every line of the template contains:
3.1. Current Status
3.2 Handling Template (a Function or a Set of Functions). For example - checking template, reservation template, posting template and so-on. Every handling template should return true on success or false and error description otherwise.
3.3. Status on Success.
3.4. Status on Failure.
3.5. Manual-Switching Status Filter.
3.6. On run-time error Status.
4. It's possible to define diffent Processing Templates for one document type based on rules.
4. Switching between statuses is Event. New status is Event Type. All event logs in Event Table.
5. Application server and external application can subscribe on Event Type. For example - send e-mail notification or document data via EDI.
Main idea of the subscription - run parallel processes and allow external applications handle Nav documents


A main function SwitchStatus:
1. Find processing template line and Write new status in document.
2. Generate Event.
3. Commit.
4. If Handling Template is empty and onSuccessStatus<>'' then SwitchStatus(onSuccessStatus) else exit.
4. Set Handling Template for handling codeunit.
5. If not(handlingCU.run) then begin HandleLastError(); SwitchStatus(onRunTimeErrorStatus); end;
6. if handlingCU.GetResult then SwitchStatus(onSuccessStatus) else SwitchStatus(onFailereStatus);



Benefits:
1. An application server do all work wherever possible based on templates.
2. The commit between status switching makes transactions short as possible.
3. User have only one shortcut key (F11) to run handling function and analize errors or manual switch status.
4. Document workflow is equal to visio diagram and can be configured after diagram approval.
5. External applications can subscribe on Nav events.
6. I found many reasons for the occurrence of deadlocks using LastError field of event table :).
Looking for part-time work.
Nav, T-SQL.
Sign In or Register to comment.