/// <summary> /// Получить экземпляр команды по указанному типу события. /// </summary> /// <param name="eventType"></param> /// <returns></returns> public BaseAsteriskCommand GetCommand(StasisStartEventType eventType) { switch (eventType) { case StasisStartEventType.AcceptIncomingCall: return(GetCommand <AcceptedIncomingCallCommand>()); case StasisStartEventType.Conference: return(GetCommand <ConferenceCommand>()); case StasisStartEventType.Assistant: return(GetCommand <AssistantCommand>()); case StasisStartEventType.PartialAssistant: return(GetCommand <PartialAssistantCommand>()); case StasisStartEventType.AddToSnoopBridge: case StasisStartEventType.AddToSpeakSnoopBridge: return(GetCommand <AddToSnoopBridgeCommand>()); case StasisStartEventType.RegisterIncomingCallCommand: return(GetCommand <RegisterIncomingCallCommand>()); case StasisStartEventType.DeleteChannelCommand: return(GetCommand <DeleteChannelCommand>()); case StasisStartEventType.ForceHangUpCommand: return(GetCommand <ForceHangUpCommand>()); case StasisStartEventType.SwitchRolesCommand: return(GetCommand <SwitchRolesCommand>()); case StasisStartEventType.IsolationCommand: return(GetCommand <IsolationCommand>()); case StasisStartEventType.MuteCommand: return(GetCommand <MuteCommand>()); case StasisStartEventType.CallFromUser: return(GetCommand <CallFromUserCommand>()); case StasisStartEventType.CallToDestination: return(GetCommand <AcceptedCallFromUserCommand>()); case StasisStartEventType.RejectedCallFromUser: return(GetCommand <RejectedCallFromUserCommand>()); case StasisStartEventType.RecordingStarted: return(GetCommand <RecordingStartedCommand>()); case StasisStartEventType.RecordingEnded: return(GetCommand <RecordingEndedCommand>()); default: throw new NotImplementedException("Команда с указанным типом не добавлена в AsteriskCommandServiceExtension."); } }
private async Task <Result> AddAssistantSpecificType(RouteCallDto routeDto, StasisStartEventType eventType) { _logger.WithTag("to_call_id", routeDto.ToCallId) .WithTag("from_call_id", routeDto.FromCallId) .WithTag("assistant_extension", routeDto.ToExtension) .Information($"Add {eventType}. FromCallId: {routeDto.FromCallId}. Assistant: {routeDto.ToExtension}. CallId: {routeDto.ToCallId}"); if (!routeDto.LineId.HasValue) { _logger.Warning($"Add{eventType}. LineId not found."); return(Result.Failure(ErrorCodes.ValidationError)); } if (!routeDto.FromCallId.HasValue) { _logger.Warning($"Add{eventType}. FromCallId not found."); return(Result.Failure(ErrorCodes.ValidationError)); } var setMainChannelResult = await SetMainUser(routeDto.LineId.Value, routeDto.FromCallId.Value); if (setMainChannelResult.IsFailure) { _logger.Warning($"Add{eventType}. {setMainChannelResult.ErrorMessage}"); return(Result.Failure(setMainChannelResult.ErrorCode)); } var fromCallChannel = await _channelRepository.GetChannelByCallId(routeDto.FromCallId.Value); var args = new StasisStartEventArgs { EventType = eventType, BridgeId = setMainChannelResult.Value.BridgeId, RouteData = routeDto }; var originateResult = await OriginateAsync(args, fromCallChannel.Extension, args.RouteData.ToExtension); return(originateResult); }
private StasisStartEventArgs CreateStasisArgs(string channelId, string bridgeId, StasisStartEventType eventType, RouteCallDto dto) { var args = new StasisStartEventArgs { EventType = eventType, ChannelId = channelId, RouteData = dto, BridgeId = bridgeId }; return(args); }