Beispiel #1
0
        public void ProcessDigitsReceived()
        {
            if (_call.GetCurrentState() != State.CapturingInput ||
                DigitsReceived.Length < NumberOfDigitsToWaitForNextStep)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0 &&
                !DigitsReceived.EndsWith(TerminationDigit))
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (TerminationDigit != "")
            {
                if (DigitsReceived.EndsWith(TerminationDigit))
                {
                    if (_settings.SetValueAsDestination)
                    {
                        _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    }

                    _call.CallState.AddStepToIncomingQueue(_settings.NextStep);
                    _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    ResetInputRetryCount();
                    _call.FireStateChange(Trigger.InputReceived);
                    return;
                }
            }
            else if (_settings.SetValueAsDestination)
            {
                _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length);
                _call.CallState.AddStepToIncomingQueue(_settings.NextStep);
                _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length);
                ResetInputRetryCount();
                _call.FireStateChange(Trigger.InputReceived);
                return;
            }
            if (NumberOfDigitsToWaitForNextStep == 0)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            var validStep = false;

            foreach (var option in _settings.Options.Where(option => option.Input == DigitsReceived))
            {
                ResetInputRetryCount();
                _call.CallState.AddStepToIncomingQueue(option.NextStep);
                validStep = true;
            }

            if (!validStep)
            {
                if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0)
                {
                    ResetInputRetryCount();
                    _call.AddStepToProcessQueue(_settings.MaxAttemptsReachedStep);
                }
                else
                {
                    _call.CallState.AddStepToIncomingQueue(_settings.Invalid);
                }
            }
            _call.FireStateChange(Trigger.InputReceived);
        }
Beispiel #2
0
        public async Task ProcessDigitsReceived()
        {
            if (DigitsReceived.Length < NumberOfDigitsToWaitForNextStep)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0 &&
                !DigitsReceived.EndsWith(TerminationDigit))
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (TerminationDigit != "")
            {
                if (DigitsReceived.EndsWith(TerminationDigit))
                {
                    if (_settings.SetValueAsDestination)
                    {
                        _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    }
                    else if (!string.IsNullOrEmpty(_settings.SetValueAs))
                    {
                        DynamicState.SetProperty(_call.CallState, _settings.SetValueAs, DigitsReceived);
                    }

                    AddStepToProperQueue(_settings.NextStep);
                    _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    ResetInputRetryCount();
                    await _call.FireStateChange(Trigger.InputReceived);

                    return;
                }
            }
            else if (_settings.SetValueAsDestination)
            {
                _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length);
                AddStepToProperQueue(_settings.NextStep);
                _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length);
                ResetInputRetryCount();
                await _call.FireStateChange(Trigger.InputReceived);

                return;
            }
            else if (!string.IsNullOrEmpty(_settings.SetValueAs))
            {
                DynamicState.SetProperty(_call.CallState, _settings.SetValueAs, DigitsReceived);
                _call.CallState.InputData = DigitsReceived;
                ResetInputRetryCount();
                AddStepToProperQueue(_settings.NextStep);
                await _call.FireStateChange(Trigger.InputReceived);

                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            var validStep = false;

            foreach (var option in _settings.Options.Where(option => option.Key == DigitsReceived.Substring(0, NumberOfDigitsToWaitForNextStep)))
            {
                ResetInputRetryCount();

                AddStepToProperQueue(option.Value);

                validStep = true;
            }

            if (!validStep)
            {
                if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0)
                {
                    ResetInputRetryCount();

                    AddStepToProperQueue(_settings.MaxAttemptsReachedStep);
                }
                else
                {
                    AddStepToProperQueue(_settings.Invalid);
                }
            }
            await _call.FireStateChange(Trigger.InputReceived);
        }