The order editing screen allows changes to be made at the plugin's initiative
Starting from V7Preview5, the plugin can edit the current order via the API without receiving EntityAlreadyInUseException :-)
Previously, in V7Preview4, the ability to edit the current order while processing a card or barcode was added (details). Now a similar capability is available at any time when no other operations are being performed.
To make changes to the order opened on the editing screen, the plugin needs to call the method TryEditCurrentOrder and pass a reference to a callback that SyrveFront will invoke as soon as it becomes possible.
If idle, this will happen immediately, but if other operations are being performed at that moment, the callback will be invoked right after they are completed.
In any case, the method TryEditCurrentOrder will return control after the callback is invoked.
If the callback throws an exception, it will propagate out of TryEditCurrentOrder.
If another operation was being performed at the time of calling TryEditCurrentOrder, which ultimately led to exiting the order editing screen, the callback will not be invoked either immediately or deferred, and the method TryEditCurrentOrder will generate an OperationCanceledException.
Currently, the method TryEditCurrentOrder is only supported on the order editing screen in fast food or restaurant mode (IOrderEditScreen).
Support for delivery editing screens, banquet screens, payment screens, etc., will be added later.
During the execution of the callback, a progress bar is displayed.
The callback will receive the current order, a local version of IOperationService for editing the current order, as well as IViewManager with the ability to show dialog windows and change text on the progress bar.
In the SamplePlugin window EditorTester, which contains examples of order editing, a checkbox “Apply changes to order that is opened in SyrveFront” has been added; when enabled, changes are applied to the currently opened order on the screen.