/// <summary>
        /// Checks whether or not to deliver/defer a survey.
        /// </summary>
        /// <returns>Deliver/defer decision.</returns>
        /// <param name="script">Script.</param>
        public async Task <Tuple <bool, DateTimeOffset?> > DeliverSurveyNowAsync(IScript script)
        {
            bool deliver = new Random().NextDouble() < _deliveryProbability;

            await(_sensusServiceHelper?.FlashNotificationAsync("Delivery decision:  " + deliver) ?? Task.CompletedTask);

            // do not defer to a future time if survey is not to be delivered
            return(new Tuple <bool, DateTimeOffset?>(deliver, null));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks whether or not to deliver/defer a survey.
        /// </summary>
        /// <returns>Deliver/defer decision.</returns>
        /// <param name="script">Script.</param>
        public async Task <Tuple <bool, DateTimeOffset?> > DeliverSurveyNowAsync(IScript script)
        {
            bool deliver = new Random().NextDouble() < _deliveryProbability;

            DateTimeOffset?deferralTime = null;

            if (!deliver)
            {
                deferralTime = DateTimeOffset.UtcNow + _deferralInterval;
            }

            await(_sensusServiceHelper?.FlashNotificationAsync("Delivery decision:  " + deliver) ?? Task.CompletedTask);

            return(new Tuple <bool, DateTimeOffset?>(deliver, deferralTime));
        }