コード例 #1
0
    protected void FinishABTest()
    {
        if (ABTest == null)
        {
            ShowWarning(GetString("abtesting.invalidtest"));
            return;
        }

        if (!CurrentUser.IsAuthorizedPerResource("CMS.ABTest", "Manage", ABTestSiteName))
        {
            RedirectToAccessDenied("cms.abtest", "Manage");
        }

        DateTime finish = (radNow.Checked) ? DateTime.Now : calendarControl.SelectedDateTime;

        // Validate input
        if (radLater.Checked && !ABTestValidator.IsValidFinish(ABTest.ABTestOpenFrom, finish))
        {
            ShowError(GetString("abtesting.scheduled.invaliddate"));
            return;
        }

        // Save the test with the new finish date
        ABTest.ABTestOpenTo = finish;
        ABTestInfoProvider.SetABTestInfo(ABTest);

        ScriptHelper.RegisterWOpenerScript(this);

        // Refresh the window opener with parameter indicating that the refresh was caused by this modal window
        ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshPage", ScriptHelper.GetScript("wopener.__doPostBack('', 'modalClosed'); CloseDialog();"));
    }
コード例 #2
0
        /// <summary>
        /// Checks existing test for required Conversions.
        /// If either of 2 required Conversions are not defined, created then and save.
        /// </summary>
        private void AssignPageVisitConversions()
        {
            var modified = false;

            // Page visit conversion
            if (!ABTest.ABTestConversionConfiguration.TryGetConversionByOriginalName(ABTestConversionNames.PAGE_VISIT, out ABTestConversion pageVisitConversion))
            {
                pageVisitConversion = new ABTestConversion(ABTestConversionNames.PAGE_VISIT, "/page-visit/uri");

                modified = true;
                ABTest.ABTestConversionConfiguration.AddConversion(pageVisitConversion);
            }

            PageVisitConversionName = pageVisitConversion.ConversionName;

            // Purchase conversion
            if (!ABTest.ABTestConversionConfiguration.TryGetConversion(ABTestConversionNames.PURCHASE, out _))
            {
                var purchaseConversion = new ABTestConversion(ABTestConversionNames.PURCHASE);

                modified = true;
                ABTest.ABTestConversionConfiguration.AddConversion(purchaseConversion);
            }

            // If any of the conversions were created, then save resulting test to DB
            if (modified)
            {
                ABTestInfoProvider.SetABTestInfo(ABTest);
            }
        }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        // Validate date/time
        if (dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME)
        {
            ShowError(GetString("newsletterissue_send.invaliddatetime"));
            return;
        }

        IssueInfo winner        = (IssueInfo)EditedObject;
        int       parentIssueId = winner.IssueVariantOfIssueID;

        // Get A/B test info
        ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId);

        if (abi != null)
        {
            IssueInfo issue = IssueInfoProvider.GetIssueInfo(parentIssueId);

            // Check if winner was selected and sent
            if (abi.TestWinnerIssueID != 0)
            {
                if ((issue.IssueStatus == IssueStatusEnum.Finished) || (issue.IssueStatus == IssueStatusEnum.Sending))
                {
                    // Winner was already sent
                    CloseDialogAndRefreshParent();
                    return;
                }
            }

            // Update A/B test info and winner selection task (if exist)
            abi.TestWinnerOption = ABTestWinnerSelectionEnum.Manual;
            NewsletterTasksManager.EnsureWinnerSelectionTask(abi, issue, false, DateTime.Now);

            abi.TestSelectWinnerAfter = 0;
            abi.TestWinnerSelected    = DateTime.Now;
            abi.TestWinnerIssueID     = winner.IssueID;
            ABTestInfoProvider.SetABTestInfo(abi);

            if ((issue != null) && (winner != null))
            {
                var parentIssue = IssueInfoProvider.GetIssueInfo(parentIssueId);
                NewsletterSendingStatusModifier.ResetAllEmailsInQueueForIssue(parentIssue.IssueID);

                // Copy data from winner to parent
                IssueHelper.CopyWinningVariantIssueProperties(winner, issue);
                IssueInfoProvider.SetIssueInfo(issue);

                // Remove previous scheduled task of this issue
                NewsletterTasksManager.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID);

                DateTime mailoutTime = dtpMailout.SelectedDateTime;
                Service.Resolve <IIssueScheduler>().ScheduleIssue(parentIssue, mailoutTime);
            }
        }

        // Close dialog and refresh parent page
        CloseDialogAndRefreshParent();
    }
コード例 #4
0
    protected void StartABTest()
    {
        if (ABTest == null)
        {
            ShowWarning(GetString("abtesting.invalidtest"));
            return;
        }

        if (!CurrentUser.IsAuthorizedPerResource("CMS.ABTest", "Manage", ABTestSiteName))
        {
            RedirectToAccessDenied("cms.abtest", "Manage");
        }

        DateTime start = (radNow.Checked) ? DateTime.Now : calendarControl.SelectedDateTime;

        // Validate input
        if (radLater.Checked && !ABTestValidator.IsValidStart(start))
        {
            ShowError(GetString("abtesting.scheduled.invaliddate"));
            return;
        }

        // Create clone of the test to circumvent caching issues
        ABTestInfo testClone = ABTest.Clone();

        testClone.ABTestOpenFrom = start;

        // Check for collisions
        string collidingTestName = ABTestValidator.GetCollidingTestName(testClone);

        if (!String.IsNullOrEmpty(collidingTestName))
        {
            ShowError(String.Format(GetString("om.twotestsonepageerror"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(collidingTestName)), ABTest.ABTestOriginalPage));
            return;
        }

        // Save the test with the new start date
        ABTest.ABTestOpenFrom = start;
        ABTestInfoProvider.SetABTestInfo(ABTest);

        ScriptHelper.RegisterWOpenerScript(this);

        // Refresh the window opener with parameter indicating that the refresh was caused by this modal window
        ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshPage", ScriptHelper.GetScript("wopener.RefreshPage(false); CloseDialog();"));
    }
コード例 #5
0
    /// <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;

        mParentIssue = IssueInfoProvider.GetOriginalIssue(IssueID);
        if (mParentIssue != null)
        {
            parentIssueId = mParentIssue.IssueID;
        }

        // Get A/B test configuration
        mABTest = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId);
        if (mABTest == null)
        {
            // Ensure A/B test object with default settings
            mABTest = new ABTestInfo()
            {
                TestIssueID = parentIssueId, TestSizePercentage = 50, TestWinnerOption = ABTestWinnerSelectionEnum.OpenRate, TestSelectWinnerAfter = 60
            };
            ABTestInfoProvider.SetABTestInfo(mABTest);
        }

        CurrentState = GetCurrentState(mParentIssue);
        InitControls(CurrentState, forceReload);

        ucMailout.ParentIssueID = parentIssueId;
        ucMailout.ReloadData(forceReload);

        InfoMessage = GetInfoMessage(CurrentState, mParentIssue, (mABTest != null ? mABTest.TestWinnerOption : ABTestWinnerSelectionEnum.OpenRate), GetPlannedMailoutTime(ucMailout.HighestMailoutTime));

        // Init test group slider
        InitTestGroupSlider(mParentIssue, mABTest, forceReload);
        ucWO_OnChange(this, EventArgs.Empty);
    }
コード例 #6
0
        /// <summary>
        /// Starts A/B test and generates conversions and visit logs for A/B test.
        /// </summary>
        public void StartTestAndGenerateData()
        {
            DateTime from = DateTime.Now.AddMonths(-1);
            DateTime to   = DateTime.Now;

            // Starts A/B test
            ABTest.ABTestOpenFrom = from;
            ABTestInfoProvider.SetABTestInfo(ABTest);

            // Clears already logged conversions and visits
            ClearStatisticsData();

            for (DateTime startTime = from; startTime < to.AddDays(1); startTime = startTime.AddDays(1))
            {
                int daysFromStart = (startTime - from).Days;

                LogABConversionHits(daysFromStart, startTime);
                LogABVisitHits(daysFromStart, startTime);
            }
        }
コード例 #7
0
        /// <summary>
        ///     Generates statistics for AB tests on the current site.
        /// </summary>
        public void Generate()
        {
            if (AbTest == null || Conversion == null || Campaign == null)
            {
                return;
            }

            var now      = DateTime.Now;
            var dateTime = now.AddDays(-14.0);

            AbTest.ABTestOpenFrom = dateTime;
            AbTest.ABTestOpenTo   = now;
            ClearStatisticsData();
            for (var logDate = dateTime; logDate < now.AddDays(1.0); logDate = logDate.AddDays(1.0))
            {
                var days = (logDate - dateTime).Days;
                LogAbConversionHits(days, logDate);
                LogAbVisitHits(days, logDate);
            }

            AbTest.ABTestWinnerGUID = OriginalVariant.ABVariantGUID;
            ABTestInfoProvider.SetABTestInfo(AbTest);
        }
コード例 #8
0
    /// <summary>
    /// Finishes test and selects variant as winner.
    /// </summary>
    /// <param name="winnerName">Winner variant name</param>
    private void FinishTestAndSelectVariantAsWinner(string winnerName)
    {
        if (String.IsNullOrEmpty(winnerName) || (OriginalVariant == null))
        {
            ShowError(GetString("abtesting.pushwinner.error.general"));
            return;
        }

        var variant = ABVariants.FirstOrDefault(v => v.ABVariantName == winnerName);

        if (variant == null)
        {
            ShowError(GetString("abtesting.pushwinner.error.general"));
            return;
        }

        // Set winner GUID to ABTest
        ABTest.ABTestWinnerGUID = variant.ABVariantGUID;

        // If the test is running, finish it
        if (TestStatus == ABTestStatusEnum.Running)
        {
            ABTest.ABTestOpenTo = DateTime.Now;
        }

        ABTestInfoProvider.SetABTestInfo(ABTest);

        DisplayWinnerInformation(variant);
        SetWinnerTooltip();

        // Reload data because HeaderActions_ActionPerformed event is too late to change action tooltip
        gridElem.ReloadData();

        // Reload summary box based on new status
        LoadSummaryBox();
    }
コード例 #9
0
    /// <summary>
    /// Creates new variant and raises "Add" event if specified.
    /// </summary>
    /// <param name="name">Name of new variant</param>
    /// <param name="issueId">ID of source issue on which the new variant will be based</param>
    private void RaiseOnAddEvent(string name, int issueId)
    {
        // Get main issue (original)
        int       currentIssuedId = IssueID;
        IssueInfo parentIssue     = IssueInfoProvider.GetOriginalIssue(currentIssuedId);

        // Allow modifying issues in idle state only
        if ((parentIssue == null) || (parentIssue.IssueStatus != IssueStatusEnum.Idle))
        {
            return;
        }

        // Get issue content specified by ID (if not found use original)
        IssueInfo contentIssue = null;

        if (issueId > 0)
        {
            if (issueId == parentIssue.IssueID)
            {
                contentIssue = parentIssue;
            }
            else
            {
                contentIssue = IssueInfoProvider.GetIssueInfo(issueId);
            }
        }

        NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(parentIssue.IssueNewsletterID);

        // ID of the first child (if new A/B test is being created (i.e. parent and 2 children)
        int origVariantId = 0;

        // Check if current issue is variant issue
        if (!parentIssue.IssueIsABTest)
        {
            // Variant issue has not been created yet => create original and 2 child variants
            parentIssue.IssueIsABTest = true;

            // Create 1st variant based on parent issue, the 2nd variant will be created as ordinary variant below
            IssueInfo issueOrigVariant = parentIssue.Clone(true);
            issueOrigVariant.IssueVariantOfIssueID = parentIssue.IssueID;
            issueOrigVariant.IssueVariantName      = GetString("newsletter.abvariantoriginal");
            issueOrigVariant.IssueScheduledTaskID  = 0;
            IssueInfoProvider.SetIssueInfo(issueOrigVariant);
            // Create scheduled task for variant mail-out and update issue variant
            issueOrigVariant.IssueScheduledTaskID = CreateScheduledTask(issueOrigVariant);
            IssueInfoProvider.SetIssueInfo(issueOrigVariant);
            // Update parent issue
            IssueInfoProvider.SetIssueInfo(parentIssue);
            try
            {
                ObjectVersionManager.DestroyObjectHistory(parentIssue.ObjectType, parentIssue.IssueID);
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("Newsletter-AddVariant", "EXCEPTION", ex);
            }

            origVariantId = issueOrigVariant.IssueID;
        }

        // Variant issue has been created => create new variant only
        IssueInfo issueVariant = (contentIssue != null ? contentIssue.Clone(true) : parentIssue.Clone(true));

        issueVariant.IssueVariantName      = name;
        issueVariant.IssueVariantOfIssueID = parentIssue.IssueID;

        // Prepare content with empty regions if empty content will be used
        string[] regions = null;
        if ((contentIssue == null) && (newsletter != null))
        {
            EmailTemplateInfo template = EmailTemplateInfoProvider.GetEmailTemplateInfo(newsletter.NewsletterTemplateID);
            if (template != null)
            {
                bool          isValidRegionName;
                List <string> regionNames = new List <string>();
                EmailTemplateHelper.ValidateEditableRegions(template.TemplateBody, out isValidRegionName, out isValidRegionName, regionNames);
                for (int i = regionNames.Count - 1; i >= 0; i--)
                {
                    regionNames[i] = regionNames[i] + "::";
                }
                regions = regionNames.ToArray();
                // Set template ID (i.e. this template with these regions is used for current issue)
                issueVariant.IssueTemplateID = template.TemplateID;
            }
        }

        issueVariant.IssueText            = (contentIssue != null ? contentIssue.IssueText : IssueHelper.GetContentXML(regions));
        issueVariant.IssueScheduledTaskID = 0;
        IssueInfoProvider.SetIssueInfo(issueVariant);

        // Duplicate attachments and replace old guids with new guids in issue text if current variant issue is based on content of another
        if (contentIssue != null)
        {
            List <Guid> guids = new List <Guid>();
            MetaFileInfoProvider.CopyMetaFiles(contentIssue.IssueID, issueVariant.IssueID,
                                               (contentIssue.IssueIsVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE),
                                               ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, guids);
            if (guids.Count > 0)
            {
                for (int i = 0; i < guids.Count; i += 2)
                {
                    issueVariant.IssueText = LinkConverter.ReplaceInLink(issueVariant.IssueText, guids[i].ToString(), guids[i + 1].ToString());
                }
            }
        }

        // Create scheduled task for variant mail-out
        issueVariant.IssueScheduledTaskID = CreateScheduledTask(issueVariant);
        // Update issue variant
        IssueInfoProvider.SetIssueInfo(issueVariant);

        if (origVariantId > 0)
        {
            // New A/B test issue created => create new A/B test info
            ABTestInfo abi = new ABTestInfo
            {
                TestIssueID = parentIssue.IssueID, TestSizePercentage = 50, TestWinnerOption = ABTestWinnerSelectionEnum.OpenRate, TestSelectWinnerAfter = 60
            };
            ABTestInfoProvider.SetABTestInfo(abi);

            // Move attachments (meta files) from parent issue to first variant
            MetaFileInfoProvider.MoveMetaFiles(parentIssue.IssueID, origVariantId, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE);
            MetaFileInfoProvider.MoveMetaFiles(parentIssue.IssueID, origVariantId, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE);
        }

        if (OnAddVariant != null)
        {
            VariantEventArgs args = new VariantEventArgs(name, issueVariant.IssueID);
            OnAddVariant(this, args);
        }
    }
コード例 #10
0
    /// <summary>
    /// Saves current newsletter settings.
    /// </summary>
    public bool SaveIssue()
    {
        try
        {
            switch (CurrentState)
            {
            case STATE_WAITING_TO_SEND_PAGE:
            case STATE_WAITING_TO_SEND_WIZARD:
            case STATE_TEST_READY_FOR_SENDING:
            case STATE_TEST_WAITING_TO_SEL_WINNER:
                if (abTest == null)
                {
                    abTest = ABTestInfoProvider.GetABTestInfoForIssue(parentIssue.IssueID);
                }

                // Get A/B test settings from controls
                bool abTestChanged = SaveABTestInfo(abTest);

                if (abTest == null)
                {
                    return(false);
                }

                if (abTest.TestWinnerOption != ABTestWinnerSelectionEnum.Manual)
                {
                    // Check minimal time interval
                    if (abTest.TestSelectWinnerAfter < 5)
                    {
                        ErrorMessage = GetString("newsletterissue_send.saveissuewrongwinnerselectioninterval");
                        return(false);
                    }
                }

                // Check if test options has changed
                if (abTestChanged)
                {
                    if (abTest.TestWinnerIssueID > 0)
                    {
                        // Options has been changed => reset previously selected winner
                        IssueInfoProvider.DeleteMailoutTask(parentIssue.IssueGUID, parentIssue.IssueSiteID);
                        abTest.TestWinnerIssueID  = 0;
                        abTest.TestWinnerSelected = DateTimeHelper.ZERO_TIME;
                        // Hide/reload winner selection in issue mail-out grid
                        ucMailout.ReloadData(false);
                    }
                    IssueInfoProvider.SetIssueInfo(parentIssue);
                }

                ABTestInfoProvider.SetABTestInfo(abTest);
                IssueHelper.EnsureWinnerSelectionTask(abTest, parentIssue, (CurrentState == STATE_TEST_WAITING_TO_SEL_WINNER), ucMailout.HighestMailoutTime);

                // Update info message for parent control
                int currentState = GetCurrentState(parentIssue);
                InfoMessage = GetInfoMessage(currentState, parentIssue, abTest.TestWinnerOption, GetPlannedMailoutTime(ucMailout.HighestMailoutTime));
                return(true);

            case STATE_TEST_FINISHED:
                ErrorMessage = GetString("newsletterissue_send.saveissuehasbeensent");
                break;
            }
        }
        catch (Exception e)
        {
            ErrorMessage = e.Message;
            return(false);
        }
        return(true);
    }
コード例 #11
0
    /// <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 = GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID);
            }
        }
        else
        {
            ucGroupSlider.NumberOfSubscribers = GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID);
        }

        if (forceReload || !ucGroupSlider.Enabled)
        {
            ucGroupSlider.CurrentSize = (abTest != null ? abTest.TestSizePercentage : 10);
        }
        ucGroupSlider.ReloadData(forceReload);
        ucWO_OnChange(this, EventArgs.Empty);
    }
コード例 #12
0
    /// <summary>
    /// Saves current newsletter settings.
    /// </summary>
    public bool SaveIssue()
    {
        try
        {
            switch (CurrentState)
            {
                case VariantStatusEnum.WaitingToSend:
                case VariantStatusEnum.ReadyForSending:
                case VariantStatusEnum.ReadyForTesting:
                case VariantStatusEnum.WaitingToSelectWinner:
                    if (mABTest == null)
                    {
                        mABTest = ABTestInfoProvider.GetABTestInfoForIssue(mParentIssue.IssueID);
                    }

                    // Get A/B test settings from controls
                    var abTestChanged = SaveABTestInfo(mABTest);

                    if (mABTest == null)
                    {
                        return false;
                    }

                    if (mABTest.TestWinnerOption != ABTestWinnerSelectionEnum.Manual)
                    {
                        // Check minimal time interval
                        if (mABTest.TestSelectWinnerAfter < 5)
                        {
                            ErrorMessage = GetString("newsletterissue_send.saveissuewrongwinnerselectioninterval");
                            return false;
                        }
                    }

                    // Check if test options has changed
                    if (abTestChanged)
                    {
                        if (mABTest.TestWinnerIssueID > 0)
                        {
                            // Options has been changed => reset previously selected winner
                            NewsletterTasksManager.DeleteMailoutTask(mParentIssue.IssueGUID, mParentIssue.IssueSiteID);
                            mABTest.TestWinnerIssueID = 0;
                            mABTest.TestWinnerSelected = DateTimeHelper.ZERO_TIME;
                            // Hide/reload winner selection in issue mail-out grid
                            ucMailout.ReloadData(false);
                        }
                        IssueInfoProvider.SetIssueInfo(mParentIssue);
                    }

                    ABTestInfoProvider.SetABTestInfo(mABTest);

                    if (CurrentState == VariantStatusEnum.WaitingToSelectWinner)
                    {
                        NewsletterTasksManager.EnsureWinnerSelectionTask(mABTest, mParentIssue, true, ucMailout.HighestMailoutTime);
                    }

                    // Update info message for parent control
                    var currentState = GetCurrentState(mParentIssue);
                    InfoMessage = GetInfoMessage(currentState, mParentIssue, mABTest.TestWinnerOption);
                    return true;
                case VariantStatusEnum.Finished:
                    ErrorMessage = GetString("newsletterissue_send.saveissuehasbeensent");
                    break;
            }
        }
        catch (Exception e)
        {
            ErrorMessage = e.Message;
            return false;
        }
        return true;
    }
コード例 #13
0
    /// <summary>
    // Processes the form - saves the data.
    /// </summary>
    private void Process()
    {
        // Check manage permissions
        if (!CheckPermissions("CMS.ABTest", CMSAdminControl.PERMISSION_MANAGE))
        {
            return;
        }

        // Validate the form
        if (Validate())
        {
            bool isNew = false;

            // Ensure the info object
            if (this.AbTestObj == null)
            {
                this.AbTestObj = new ABTestInfo();
                if (AliasPath != String.Empty)
                {
                    this.AbTestObj.ABTestOriginalPage = AliasPath;
                }

                isNew = true;
            }

            // Initialize object
            String newName = this.txtABTestName.Text.Trim();
            this.AbTestObj.ABTestDisplayName    = this.txtABTestDisplayName.Text.Trim();
            this.AbTestObj.ABTestDescription    = this.txtABTestDescription.Text.Trim();
            this.AbTestObj.ABTestMaxConversions = ValidationHelper.GetInteger(this.txtABTestMaxConversions.Text.Trim(), 0);
            this.AbTestObj.ABTestOpenFrom       = this.dtpABTestOpenFrom.SelectedDateTime;
            this.AbTestObj.ABTestOpenTo         = this.dtpABTestOpenTo.SelectedDateTime;
            this.AbTestObj.ABTestCulture        = this.ucCultureSelector.Value.ToString();
            this.AbTestObj.ABTestEnabled        = this.chkABTestEnabled.Checked;
            this.AbTestObj.ABTestSiteID         = CMSContext.CurrentSiteID;

            // Name has changed. Change analytics statistics data for existing object
            if ((this.AbTestObj.ABTestID != 0) && (this.AbTestObj.ABTestName != newName))
            {
                ABTestInfoProvider.RenameABTestStatistics(this.AbTestObj.ABTestName, newName, CMSContext.CurrentSiteID);
            }
            this.AbTestObj.ABTestName = newName;

            // Store conversion type
            TargetConversionType conversionType = TargetConversionType.Total;
            if (radAnyVariant.Checked)
            {
                conversionType = TargetConversionType.AnyVariant;
            }
            this.AbTestObj.ABTestTargetConversionType = conversionType;

            if (ShowAliasPath)
            {
                this.AbTestObj.ABTestOriginalPage = this.ucPath.Value.ToString().Trim();
            }

            // Save object data to database
            ABTestInfoProvider.SetABTestInfo(this.AbTestObj);

            this.ItemID = this.AbTestObj.ABTestID;

            // For new A/B test create default variant
            if (isNew)
            {
                // Create instance of ab variant
                ABVariantInfo variant = new ABVariantInfo();

                // Set properties
                variant.ABVariantPath        = this.AbTestObj.ABTestOriginalPage;
                variant.ABVariantTestID      = this.AbTestObj.ABTestID;
                variant.ABVariantDisplayName = this.AbTestObj.ABTestDisplayName + " " + GetString("om.variant");
                variant.ABVariantName        = this.AbTestObj.ABTestName;
                variant.ABVariantSiteID      = this.AbTestObj.ABTestSiteID;

                // Save to the storage
                ABVariantInfoProvider.SetABVariantInfo(variant);
            }

            this.RaiseOnSaved();

            // Set the info message
            this.lblInfo.Text = GetString("general.changessaved");
        }
    }
コード例 #14
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        // Validate date/time (blank date/time textbox is allowed)
        if ((dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME) && !String.IsNullOrEmpty(dtpMailout.DateTimeTextBox.Text.Trim()))
        {
            ShowError(GetString("newsletterissue_send.invaliddatetime"));
            return;
        }

        IssueInfo winner        = (IssueInfo)EditedObject;
        int       parentIssueId = winner.IssueVariantOfIssueID;

        // Get A/B test info
        ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId);

        if (abi != null)
        {
            IssueInfo issue = IssueInfoProvider.GetIssueInfo(parentIssueId);

            // Check if winner was selected and sent
            if (abi.TestWinnerIssueID != 0)
            {
                if ((issue.IssueStatus == IssueStatusEnum.Finished) || (issue.IssueStatus == IssueStatusEnum.Sending))
                {
                    // Winner was already sent
                    CloseDialogAndRefreshParent();
                    return;
                }
            }

            // Update A/B test info and winner selection task (if exist)
            abi.TestWinnerOption = ABTestWinnerSelectionEnum.Manual;
            IssueHelper.EnsureWinnerSelectionTask(abi, issue, false);

            abi.TestSelectWinnerAfter = 0;
            abi.TestWinnerSelected    = DateTime.Now;
            abi.TestWinnerIssueID     = winner.IssueID;
            ABTestInfoProvider.SetABTestInfo(abi);

            if ((issue != null) && (winner != null))
            {
                // Copy data from winner to parent
                IssueHelper.CopyIssueProperties(winner, issue, "issuesubject;issuetext;issuetemplateid;issueshowinnewsletterarchive;issuesendername;issuesenderemail");
                IssueInfoProvider.SetIssueInfo(issue);

                // Remove previous scheduled task of this issue
                IssueInfoProvider.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID);

                DateTime mailoutTime = dtpMailout.SelectedDateTime;
                if (mailoutTime < DateTime.Now)
                {
                    // Send parent issue now
                    IssueInfoProvider.SendIssue(parentIssueId, DateTime.Now);
                }
                else
                {
                    // Send winner at specified time
                    IssueInfoProvider.SendIssue(parentIssueId, mailoutTime);
                }
            }
        }

        // Close dialog and refresh parent page
        CloseDialogAndRefreshParent();
    }