Service — service
Updated
What it is#
A home for logic needed by more than one script (selection, calculation, document generation): dictionaries and documents of their own model do not duplicate it in every handler, but call a service. Public methods of the class form the I<Name> contract, resolved through GetService<I<Name>>() (context.GetService<T>() in events/commands). Several implementations of one contract form Chain of Command by layers.
JSON envelope#
<Name>.json (envelope) + <Name>Service.script.json (script binding, scriptType: "Service") + <Name>Service.cs (body, user partial) — three files in one folder; the envelope references the script through scriptMetaId:
{
"kind": "Service",
"object": {
"description": "Отчёт владельца стенда: кто закрыл путь, модуль и сертификат.",
"namespace": "ZuloOne.Services",
"scriptMetaId": "<GUID Script>",
"metaId": "<GUID Service>", "name": "LearningReport", "modelId": "<GUID Model>"
}
}
C# base#
public partial class <Name> — a plain class that does not inherit a platform base; the platform derives the I<Name> contract from the class's public methods automatically (you do not write a separate file by hand).
Events / Chain of Command#
This is not an event model but implementation extension: an extension of a contract from another model must call next in every override, otherwise ZOCOC002. After creating a NEW service, the I<Name> contract may be unavailable to other scripts until services/rebuild — the contract version in the DI container can remain stale.
Example#
IStoreCellService in Inventory — resolves cells and enforces store discipline; called from events and transaction scripts of several WMS documents.