public async Task StartShift(string name)
        {
            var picker = _pickerRepository.FindByName(name) ?? new Picker(Context.ConnectionId, name);

            if (picker.InstanceId == null || !await _processClient.IsProcessInstanceRunning(picker.InstanceId))
            {
                var startResponse =
                    await _processClient.CreateProcessInstanceByModelId(ProcessModelId, ProcessStartEvent, picker);

                picker.InstanceId = startResponse.ProcessInstanceId;
                if (_pickerRepository.StartShift(picker))
                {
                    await Clients.Caller.ShiftStartConfirmed();
                }
                else
                {
                    await _processClient.TerminateProcessInstanceById(startResponse.ProcessInstanceId);
                }
            }
            else
            {
                if (_pickerRepository.ResumeShift(picker, Context.ConnectionId))
                {
                    await Clients.Caller.ShiftStartConfirmed();
                }
                else
                {
                    // terminate process
                }
            }
        }
Пример #2
0
        public Task <Picker> HandleAsync(ShiftStatusPayload input, ExternalTask task)
        {
            var picker = input.Picker;

            if (input.Status)
            {
                _pickerRepository.StartShift(picker);
            }
            else
            {
                _pickerRepository.StopShift(picker, true);
            }

            return(Task.FromResult(picker));
        }