private async Task Handle(ExecuteSpecialLiquidationOrdersInternalCommand command, IEventPublisher publisher) { var executionInfo = await _operationExecutionInfoRepository.GetAsync <SpecialLiquidationOperationData>( operationName : SpecialLiquidationSaga.OperationName, id : command.OperationId); if (executionInfo?.Data == null) { return; } if (executionInfo.Data.SwitchState(SpecialLiquidationOperationState.InternalOrderExecutionStarted, SpecialLiquidationOperationState.InternalOrdersExecuted)) { try { var modality = executionInfo.Data.RequestedFromCorporateActions ? OrderModality.Liquidation_CorporateAction : OrderModality.Liquidation_MarginCall; //close positions with the quotes from gavel await _tradingEngine.LiquidatePositionsUsingSpecialWorkflowAsync( me : new SpecialLiquidationMatchingEngine(command.Price, command.MarketMakerId, command.ExternalOrderId, command.ExternalExecutionTime), positionIds : executionInfo.Data.PositionIds.ToArray(), executionInfo.Data.AdditionalInfo, executionInfo.Data.OriginatorType, modality); _chaosKitty.Meow(command.OperationId); publisher.PublishEvent(new SpecialLiquidationFinishedEvent { OperationId = command.OperationId, CreationTime = _dateService.Now(), }); } catch (Exception ex) { publisher.PublishEvent(new SpecialLiquidationFailedEvent { OperationId = command.OperationId, CreationTime = _dateService.Now(), Reason = ex.Message, CanRetryPriceRequest = true }); } _chaosKitty.Meow(command.OperationId); await _operationExecutionInfoRepository.Save(executionInfo); } }