public bool CheckCampaignLimits(string triggerEvent, IDictionary <string, string> payload, SwrveQAUser qaUser)
        {
            DateTime now = SwrveHelper.GetNow();

            if (!CanTrigger(triggerEvent, payload, qaUser))
            {
                LogAndAddReason("There is no trigger in " + Id + " that matches " + triggerEvent, qaUser);
                return(false);
            }
            if (!IsActive(qaUser))
            {
                return(false);
            }
            if (!CheckImpressions(qaUser))
            {
                return(false);
            }
            if (!string.Equals(triggerEvent, "Swrve.Messages.showAtSessionStart", StringComparison.OrdinalIgnoreCase) && IsTooSoonToShowMessageAfterLaunch(now))
            {
                LogAndAddReason("{Campaign throttle limit} Too soon after launch. Wait until " + showMessagesAfterLaunch.ToString("HH\\:mm\\:ss zzz"), qaUser);
                return(false);
            }
            if (IsTooSoonToShowMessageAfterDelay(now))
            {
                LogAndAddReason("{Campaign throttle limit} Too soon after last message. Wait until " + showMessagesAfterDelay.ToString("HH\\:mm\\:ss zzz"), qaUser);
                return(false);
            }
            return(true);
        }
Example #2
0
        public bool checkCampaignLimits(string triggerEvent, IDictionary <string, string> payload, SwrveQAUser qaUser)
        {
            DateTime now = SwrveHelper.GetNow();

            if (!this.CanTrigger(triggerEvent, payload, qaUser))
            {
                this.LogAndAddReason(string.Concat(new object[]
                {
                    "There is no trigger in ",
                    this.Id,
                    " that matches ",
                    triggerEvent
                }), qaUser);
                return(false);
            }
            if (!this.IsActive(qaUser))
            {
                return(false);
            }
            if (this.Impressions >= this.maxImpressions)
            {
                this.LogAndAddReason(string.Concat(new object[]
                {
                    "{Campaign throttle limit} Campaign ",
                    this.Id,
                    " has been shown ",
                    this.maxImpressions,
                    " times already"
                }), qaUser);
                return(false);
            }
            if (!string.Equals(triggerEvent, "Swrve.Messages.showAtSessionStart", StringComparison.OrdinalIgnoreCase) && this.IsTooSoonToShowMessageAfterLaunch(now))
            {
                this.LogAndAddReason("{Campaign throttle limit} Too soon after launch. Wait until " + this.showMessagesAfterLaunch.ToString("HH\\:mm\\:ss zzz"), qaUser);
                return(false);
            }
            if (this.IsTooSoonToShowMessageAfterDelay(now))
            {
                this.LogAndAddReason("{Campaign throttle limit} Too soon after last message. Wait until " + this.showMessagesAfterDelay.ToString("HH\\:mm\\:ss zzz"), qaUser);
                return(false);
            }
            return(true);
        }
        public bool CheckCampaignLimits(string triggerEvent, IDictionary <string, string> payload, List <SwrveQaUserCampaignInfo> qaCampaignInfoList)
        {
            // Use local time to track throttle limits (want to show local time in logs)
            DateTime localNow = SwrveHelper.GetNow();

            if (!CanTrigger(triggerEvent, payload))
            {
                string reason = "There is no trigger in " + Id + " that matches " + triggerEvent;
                LogAndAddReason(reason, false, qaCampaignInfoList);
                return(false);
            }

            if (!IsActive(qaCampaignInfoList))
            {
                return(false);
            }

            if (!CheckImpressions(qaCampaignInfoList))
            {
                return(false);
            }

            if (!string.Equals(triggerEvent, SwrveSDK.DefaultAutoShowMessagesTrigger, StringComparison.OrdinalIgnoreCase) && IsTooSoonToShowMessageAfterLaunch(localNow))
            {
                string reason = "{Campaign throttle limit} Too soon after launch. Wait until " + showMessagesAfterLaunch.ToString(WaitTimeFormat);
                LogAndAddReason(reason, false, qaCampaignInfoList);
                return(false);
            }

            if (IsTooSoonToShowMessageAfterDelay(localNow))
            {
                string reason = "{Campaign throttle limit} Too soon after last message. Wait until " + showMessagesAfterDelay.ToString(WaitTimeFormat);
                LogAndAddReason(reason, false, qaCampaignInfoList);
                return(false);
            }

            return(true);
        }
Example #4
0
        public bool checkCampaignLimits(string triggerEvent, IDictionary <string, string> payload, SwrveQAUser qaUser)
        {
            // Use local time to track throttle limits (want to show local time in logs)
            DateTime localNow = SwrveHelper.GetNow();

            if (!CanTrigger(triggerEvent, payload, qaUser))
            {
                LogAndAddReason("There is no trigger in " + Id + " that matches " + triggerEvent, qaUser);
                return(false);
            }

            if (!IsActive(qaUser))
            {
                return(false);
            }

            if (Impressions >= maxImpressions)
            {
                LogAndAddReason("{Campaign throttle limit} Campaign " + Id + " has been shown " + maxImpressions + " times already", qaUser);
                return(false);
            }

            if (!string.Equals(triggerEvent, SwrveSDK.DefaultAutoShowMessagesTrigger, StringComparison.OrdinalIgnoreCase) && IsTooSoonToShowMessageAfterLaunch(localNow))
            {
                LogAndAddReason("{Campaign throttle limit} Too soon after launch. Wait until " + showMessagesAfterLaunch.ToString(WaitTimeFormat), qaUser);
                return(false);
            }

            if (IsTooSoonToShowMessageAfterDelay(localNow))
            {
                LogAndAddReason("{Campaign throttle limit} Too soon after last message. Wait until " + showMessagesAfterDelay.ToString(WaitTimeFormat), qaUser);
                return(false);
            }

            return(true);
        }
 protected void SetMessageMinDelayThrottle()
 {
     showMessagesAfterDelay = SwrveHelper.GetNow() + TimeSpan.FromSeconds(minDelayBetweenMessage);
 }
Example #6
0
 public SwrveCampaignState()
 {
     this.ShowMessagesAfterDelay = SwrveHelper.GetNow();
 }