This article was moved to MDriven Wiki – MDrivenServer periodic server-side actions
When you have a model driven server like MDrivenServer you can use it to execute re-occurring actions, or periodic actions.
A Periodic action is defined by a selection expression that selects what objects to act on. For each object selected for a periodic action we want to do the “action” and that probably needs a cluster of objects and it needs to do different stuff to evolve some object state. To enable efficient load for such an object cluster you must define and associate a viewmodel with each periodic action.
The periodic action logic will load the viewmodel for your object and loop through all actions that it finds in its root viewmodel class. When all actions are executed the periodic action logic will save any changed state that was the result of your actions.
Periodic actions can be used to “automatically” step your information from one state to the next – given that the circumstances are correct.
This ability might take some getting used to – but it can be used for things like assigning a unique number to an order or an article in your domain model – or for actions that need to be done serverside for some particular reason.
Define the periodic actions in the admin UI:
Consider having this state machine:
I can by use of a simple ViewModel have the periodic action on the server to assign my number that need to be unique through out the database.
Beyond the obvious – sending emails
Now – having this infrastructure we can offer a few “special” actions. The first one is Email.
If you have an action in your viewmodel named “email” then MDrivenServer will try to find the following properties in your viewmodel:
to : will be used as to email address
topresentation: the name of the owner of the email
from: the sender email
frompresentation: the name to use as sender
body: the message
subject: the subject line
The properties found will be used to send an email – you need to fill in the email settings in the admin UI for this to work.