private async Task <object> CreatePayload(UserTask task, ClientTaskType type)
        {
            var payloadCreator = _processHandlersFactory.GetPayloadHandler(task.ProcessModelId);

            if (task.HasErrorPayload())
            {
                task = await _processClient.GetPrevFinishedTaskOfSameKind(task)
                       ?? throw new Exception(
                                 $"Cannot create payload because no previous finished task found ({task.Id})");
            }

            return(type switch
            {
                Selection => payloadCreator?.CreateSelectionOptionsPayload(task),
                Scan => payloadCreator?.CreateScanPayload(task),
                Info => payloadCreator?.CreateInfoPayload(task),
                _ => null
            });
예제 #2
0
     public ClientTask(string id,
                       ClientTaskType type,
                       string key,
                       string label,
                       TaskError error,
                       object?payload,
                       Dictionary <string, object> resultTemplate)
     {
         Id    = id;
         Type  = type;
         Label = label;
         Error = error.IsEmpty() switch
         {
             true => null,
             false => error
         };
         Payload        = payload;
         ResultKey      = key;
         ResultTemplate = resultTemplate;
     }
 }