private static int GetNumberOfSubscribers(IssueInfo parentIssue, IReadOnlyCollection <IssueABVariantItem> variants) { if (parentIssue.IssueStatus != IssueStatusEnum.Finished && !AreAllVariantsSent(variants)) { return(NewsletterHelper.GetEmailAddressCount(parentIssue)); } if (parentIssue.IssueStatus == IssueStatusEnum.Finished) { // Issue was sent => get number of subscribers from number of sent issues return(parentIssue.IssueSentEmails); } // Only variants was sent => get current number of subscribers return(NewsletterHelper.GetEmailAddressCount(parentIssue)); }
/// <summary> /// Reloads control data. /// </summary> /// <param name="forceReload">Indicates if force reload should be used</param> public override void ReloadData(bool forceReload) { if (StopProcessing && !forceReload) { return; } if (ForceReloadNeeded) { forceReload = true; ForceReloadNeeded = false; } int parentIssueId = 0; parentIssue = IssueInfoProvider.GetOriginalIssue(IssueID); if (parentIssue != null) { parentIssueId = parentIssue.IssueID; } // Get A/B test configuration abTest = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId); if (abTest == null) { // Ensure A/B test object with default settings abTest = new ABTestInfo() { TestIssueID = parentIssueId, TestSizePercentage = 50, TestWinnerOption = ABTestWinnerSelectionEnum.OpenRate, TestSelectWinnerAfter = 60 }; ABTestInfoProvider.SetABTestInfo(abTest); } CurrentState = GetCurrentState(parentIssue); InitControls(CurrentState, forceReload); ucMailout.ParentIssueID = parentIssueId; ucMailout.ReloadData(forceReload); InfoMessage = GetInfoMessage(CurrentState, parentIssue, (abTest != null ? abTest.TestWinnerOption : ABTestWinnerSelectionEnum.OpenRate), GetPlannedMailoutTime(ucMailout.HighestMailoutTime)); // Init test group slider List <IssueABVariantItem> variants = IssueHelper.GetIssueVariants(parentIssue, null); ucGroupSlider.Variants = variants; bool allVariantsSent = true; if (variants != null) { allVariantsSent = variants.TrueForAll(delegate(IssueABVariantItem item) { return(item.IssueStatus == IssueStatusEnum.Finished); }); } if ((parentIssue.IssueStatus == IssueStatusEnum.Finished) || allVariantsSent) { // Issue was sent long time ago => get number of subscribers from issue properties instead of current number of subscribers int perVariantEmails = 1; if (abTest != null) { perVariantEmails = abTest.TestNumberPerVariantEmails; } ucGroupSlider.NumberOfTestSubscribers = ucGroupSlider.Variants.Count * perVariantEmails; if (parentIssue.IssueStatus == IssueStatusEnum.Finished) { // Issue was sent => get number of subscribers from number of sent issues ucGroupSlider.NumberOfSubscribers = parentIssue.IssueSentEmails; } else { // Only variants was sent => get current number of subscribers ucGroupSlider.NumberOfSubscribers = NewsletterHelper.GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID); } } else { ucGroupSlider.NumberOfSubscribers = NewsletterHelper.GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID); } if (forceReload || !ucGroupSlider.Enabled) { ucGroupSlider.CurrentSize = (abTest != null ? abTest.TestSizePercentage : 10); } ucGroupSlider.ReloadData(forceReload); ucWO_OnChange(this, EventArgs.Empty); }