public override bool IsValid(SmsValidation smsValidation)
        {
            if (smsValidation.Sent < DateTime.UtcNow.AddMinutes(ExpirationMinutes))
            {
                return(false);
            }

            return(NextRule?.IsValid(smsValidation) ?? true);
        }
        public override bool IsValid(SmsValidation smsValidation)
        {
            if (smsValidation.UserInput != smsValidation.Code)
            {
                return(false);
            }

            return(NextRule?.IsValid(smsValidation) ?? true);
        }
        public override bool IsValid(SmsValidation smsValidation)
        {
            if (smsValidation.Attempts >= MaxAttempts)
            {
                return(false);
            }

            return(NextRule?.IsValid(smsValidation) ?? true);
        }
        internal List <TypeOfActionAgainstOrder> VerifyRuleAndProcess()
        {
            var listOFActions = new List <TypeOfActionAgainstOrder>();

            if (TypeofProduct == TypeOfRule)
            {
                listOFActions = this.Process();
            }
            else if (NextRule != null)
            {
                listOFActions = NextRule.VerifyRuleAndProcess();
            }
            return(listOFActions);
        }
Пример #5
0
        /// <summary>
        /// Method to interpret the result based on whether expected speech events occurred or not
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        private int applyTimeStampValidationRule(out NextRule rule)
        {
            DateTime uninitDate = new DateTime();       // Un-initialized date

            int result = ValidationErrors.NO_ERROR;

            /**
             * If callee did not play prompt, then entire iteration is practically meaningless. However, there
             * may be noise or echo, and should need further processing.
             * However, such situations seem rare, so I am sending back "Ignored" at this time. If the need arises,
             * this section shall be enhanced to apply further processing rules.
             * Nirav - 16th Jan 2007
             */
            if (calleeData.speakTime == uninitDate)
            {
                Console.WriteLine("OOPS: Should not get here");
                result = ValidationErrors.CALLEE_PROMPT_NOT_PLAYED;
                rule = NextRule.None;
            }
            else
            {
                // For the entire set of conditions, it is always guaranteed that callee prompt was played

                /**
                 * Callee played the prompt - but caller could not detect that.
                 * Thus, caller did not play prompt - and callee detected no speech.
                 */
                if (callerData.speechDetectionTime == uninitDate &&
                    callerData.speakTime == uninitDate && calleeData.speechDetectionTime == uninitDate)
                {
                    result = ValidationErrors.CALLEE_NOT_HEARD;
                    rule = NextRule.None;
                }
                else
                    if (callerData.speechDetectionTime == uninitDate &&
                        callerData.speakTime == uninitDate && calleeData.speechDetectionTime != uninitDate)
                    {
                        /**
                         * Callee played the prompt - but caller could not detect that.
                         * Caller did not play the prompt - however callee detected some speech.
                         * This typically happens when half-duplex channels with noise/echo are established or callee's audio
                         * underwent significant distortion in the audio channel.
                         */
                        result = ValidationErrors.CALLEE_NOT_HEARD;
                        rule = NextRule.LatencyRule;
                    }
                    else
                        if (callerData.speechDetectionTime != uninitDate && callerData.speakTime != uninitDate &&
                            calleeData.speechDetectionTime == uninitDate)
                        {
                            /**
                             * A very interesting situation.
                             * Callee played the prompt and the caller heard it.
                             * Caller started to play the prompt and callee could not hear it.
                             * This can happen due to
                             * i)  Distortion of caller's speech in the audio channel
                             * ii) Half duplex channel established - i.e. while callee is talking it can't hear anything
                             * So, we consider this failed, and yet apply latency rule to find out if there was any noise or not.
                             */
                            result = ValidationErrors.CALLER_NOT_HEARD;
                            rule = NextRule.LatencyRule;
                        }
                        else
                            if (callerData.speechDetectionTime != uninitDate && callerData.speakTime != uninitDate &&
                                calleeData.speechDetectionTime != uninitDate)
                            {
                                /**
                                 * Now all the events were present.
                                 * Callee played the prompt, caller heard the prompt, and played its own prompt and callee also heard
                                 * something. So, we consider this iteration to have no error in this rule, and continue to apply more
                                 * rules.
                                 */
                                result = ValidationErrors.NO_ERROR;
                                rule = NextRule.LatencyRule;
                            }
                            else
                            {
                                // We should not get here. This condition could only be reached if caller detected speech and could not
                                // play prompt.
                                // For now, we consider this ignored, and apply no more rules for this iteration - Nirav 16th Jan 2007.
                                result = ValidationErrors.BAD_SCENARIO_EXECUTION;
                                rule = NextRule.None;
                            }
            }
            return result;
        }