/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { ReloadData(false); if (PostbackOnChange) { ucUniSelector.DropDownSingleSelect.AutoPostBack = true; ScriptManager scr = ScriptManager.GetCurrent(Page); scr.RegisterPostBackControl(ucUniSelector.DropDownSingleSelect); } if (!URLHelper.IsPostback()) { // If some test belongs to node give by NodeID - preselect it in MVTest selector if (NodeID != 0) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(NodeID, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); if (node != null) { DataSet ds = ABTestInfoProvider.GetABTests("MVTestSiteID = " + CMSContext.CurrentSiteID + " AND MVTestPage = '" + SqlHelperClass.GetSafeQueryString(node.NodeAliasPath, false) + "'", String.Empty, 1, "MVTestID", null); if (!DataHelper.DataSourceIsEmpty(ds)) { int abTestID = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["MVTestID"], 0); if (abTestID != 0) { ucUniSelector.Value = abTestID; } } } } } }
protected void Page_Load(object sender, EventArgs e) { String siteName = CMSContext.CurrentSiteName; // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } int nodeID = QueryHelper.GetInteger("nodeID", 0); int testID = QueryHelper.GetInteger("abTestId", 0); listElem.TestID = testID; // Prepare the actions string[,] actions = new string[1, 6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = ResHelper.GetString("abtesting.variant.new"); actions[0, 3] = ResolveUrl("Edit.aspx?abtestID=" + testID + "&nodeid=" + nodeID); actions[0, 5] = GetImageUrl("Objects/CMS_Variant/add.png"); // Set the actions ICMSMasterPage master = this.CurrentMaster; master.HeaderActions.Actions = actions; }
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();")); }
/// <summary> /// Handles UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of the action which should be performed</param> /// <param name="actionArgument">ID of the item the action should be performed with</param> protected void gridElem_OnAction(string actionName, object actionArgument) { int abTestId = ValidationHelper.GetInteger(actionArgument, 0); if (abTestId > 0) { switch (actionName.ToLower()) { case "edit": this.SelectedItemID = abTestId; this.RaiseOnEdit(); break; case "delete": if (CheckPermissions("CMS.ABTest", CMSAdminControl.PERMISSION_MANAGE)) { // Delete the object ABTestInfoProvider.DeleteABTestInfo(abTestId); this.RaiseOnDelete(); // Reload data gridElem.ReloadData(); } break; } } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_issue_subscribersclicks.title"); linkId = QueryHelper.GetInteger("linkid", 0); if (linkId == 0) { RequestHelper.EndResponse(); } LinkInfo link = LinkInfoProvider.GetLinkInfo(linkId); EditedObject = link; IssueInfo issue = IssueInfoProvider.GetIssueInfo(link.LinkIssueID); EditedObject = issue; // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + link.LinkIssueID); } var where = new WhereCondition().Where("LinkID", QueryOperator.Equals, linkId); // Link's issue is the main A/B test issue if (issue.IssueIsABTest && !issue.IssueIsVariant) { // Get A/B test and its winner issue ID ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get ID of the same link from winner issue var winnerLink = LinkInfoProvider.GetLinks() .WhereEquals("LinkIssueID", test.TestWinnerIssueID) .WhereEquals("LinkTarget", link.LinkTarget) .WhereEquals("LinkDescription", link.LinkDescription) .TopN(1) .Column("LinkID") .FirstOrDefault(); if (winnerLink != null) { if (winnerLink.LinkID > 0) { // Add link ID of winner issue link where.Or(new WhereCondition().Where("LinkID", QueryOperator.Equals, winnerLink.LinkID)); } } } } where.And(new WhereCondition(fltOpenedBy.WhereCondition)); UniGrid.WhereCondition = where.WhereCondition; UniGrid.QueryParameters = where.Parameters; UniGrid.Pager.DefaultPageSize = PAGESIZE; UniGrid.Pager.ShowPageSize = false; UniGrid.FilterLimit = 1; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; }
private void InitOverview() { if (mIssue.IssueIsABTest) { var abTest = ABTestInfoProvider.GetABTestInfoForIssue(mIssue.IssueID); if (abTest == null) { return; } var winnerIssueId = ValidationHelper.GetInteger(abTest.TestWinnerIssueID, 0); if (winnerIssueId == 0) { return; } var issueInForm = issueForm.EditedObject as IssueInfo; var winnerIssue = IssueInfoProvider.GetIssueInfo(winnerIssueId); if ((issueInForm != null) && (winnerIssue != null)) { issueInForm.IssueSubject = winnerIssue.IssueSubject; issueInForm.IssueSenderName = winnerIssue.IssueSenderName; issueInForm.IssueSenderEmail = winnerIssue.IssueSenderEmail; } } }
protected void Page_Load(object sender, EventArgs e) { String siteName = CMSContext.CurrentSiteName; // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } // Prepare the breadcrumbs string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("abtesting.abtest.list"); breadcrumbs[0, 1] = "~/CMSModules/OnlineMarketing/Pages/Content/ABTesting/ABTest/List.aspx?nodeid=" + NodeID; breadcrumbs[1, 0] = GetString("abtesting.abtest.new"); // Set the title PageTitle title = this.CurrentMaster.Title; title.Breadcrumbs = breadcrumbs; title.HelpTopicName = "abtest_general"; editElem.AliasPath = QueryHelper.GetString("AliasPath", String.Empty); this.editElem.OnSaved += new EventHandler(editElem_OnSaved); }
/// <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(); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Show or hide messages this.lblError.Visible = !string.IsNullOrEmpty(this.lblError.Text); this.lblInfo.Visible = !string.IsNullOrEmpty(this.lblInfo.Text); string status = string.Empty; // Set status if (AbTestObj != null) { if (!AbTestObj.ABTestEnabled) { status = "<span class=\"StatusDisabled\">" + GetString("general.disabled") + "</span>"; } else { if (ABTestInfoProvider.ABTestIsRunning(AbTestObj)) { // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(CMSContext.CurrentSiteName) || !AnalyticsHelper.TrackConversionsEnabled(CMSContext.CurrentSiteName)) { status = GetString("abtesting.statusNone"); } else { if (!ABTestInfoProvider.ContainsVariants(AbTestObj)) { // Display warning when the test does not contain any variant status = "<img src=\"" + GetImageUrl("Design/Controls/UniGrid/Actions/Warning.png") + "\" alt=\"" + GetString("abtest.novariants") + "\" title=\"" + GetString("abtest.novariants") + "\" /> " + GetString("abtesting.statusNone"); } else { status = "<span class=\"StatusEnabled\">" + GetString("abtesting.status" + ABTestInfoProvider.GetABTestStatus(AbTestObj)) + "</span>"; } } } else { status = GetString("abtesting.status" + ABTestInfoProvider.GetABTestStatus(AbTestObj)); } } } else { status = GetString("general.none"); } ltrStatusValue.Text = status; }
protected void Page_Load(object sender, EventArgs e) { CheckWebAnalyticsUI("ABTest.ConversionsValue"); CurrentMaster.PanelContent.CssClass = ""; UIHelper.AllowUpdateProgress = false; String siteName = CMSContext.CurrentSiteName; // Text for menu mSave = GetString("general.save"); mPrint = GetString("Analytics_Report.Print"); mDeleteData = GetString("Analytics_Report.ManageData"); // Images for menu buttons imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save_small.png"); imgPrint.ImageUrl = GetImageUrl("General/printSmall.png"); imgManageData.ImageUrl = GetImageUrl("CMSModules/CMS_Reporting/managedataSmall.png"); // Check 'ManageData' permission if (CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageData")) { this.lnkDeleteData.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/Reporting/WebAnalytics/Analytics_ManageData.aspx") + "?statcodename=abtest', 'AnalyticsManageData'," + AnalyticsHelper.MANAGE_WINDOW_WIDTH + ", " + AnalyticsHelper.MANAGE_WINDOW_HEIGHT + "); return false; "; this.lnkDeleteData.Visible = true; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "myModalDialog", ScriptHelper.GetScript("function myModalDialog(url, name, width, height) { " + "win = window; " + "var dHeight = height; var dWidth = width; " + "if (( document.all )&&(navigator.appName != 'Opera')) { " + "try { win = wopener.window; } catch (e) {} " + "if ( parseInt(navigator.appVersion.substr(22, 1)) < 7 ) { dWidth += 4; dHeight += 58; }; " + "dialog = win.showModalDialog(url, this, 'dialogWidth:' + dWidth + 'px;dialogHeight:' + dHeight + 'px;resizable:yes;scroll:yes'); " + "} else { " + "oWindow = win.open(url, name, 'height=' + dHeight + ',width=' + dWidth + ',toolbar=no,directories=no,menubar=no,modal=yes,dependent=yes,resizable=yes,scroll=yes,scrollbars=yes'); oWindow.opener = this; oWindow.focus(); } } ")); // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } ucConversionReportViewer.ReportsName = "abtestconversionvalue.yearreport;abtestconversionvalue.monthreport;abtestconversionvalue.weekreport;abtestconversionvalue.dayreport;abtestconversionvalue.hourreport"; ucConversionReportViewer.ShowAllConversions = true; }
protected void Page_Load(object sender, EventArgs e) { String siteName = CMSContext.CurrentSiteName; // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } if (!AnalyticsHelper.TrackConversionsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblTrackConversionsDisabled.Text = GetString("webanalytics.tackconversionsdisabled"); } listElem.ShowFilter = false; UIContext.AnalyticsTab = AnalyticsTabEnum.ABTests; listElem.NodeID = NodeID; // Get the alias path of the current node string aliasPath = String.Empty; if (this.Node != null) { aliasPath = Node.NodeAliasPath; listElem.AliasPath = aliasPath; } else { listElem.StopProcessing = true; } // Prepare the actions string[,] actions = new string[1, 6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = ResHelper.GetString("abtesting.abtest.new"); actions[0, 3] = ResolveUrl("new.aspx?nodeID=" + NodeID + "&AliasPath=" + aliasPath); actions[0, 5] = GetImageUrl("Objects/OM_AbTest/add.png"); // Set the actions ICMSMasterPage master = this.CurrentMaster; master.HeaderActions.Actions = actions; }
/// <summary> /// Creates new AB variant if AB test filled in. /// </summary> /// <param name="newDocument">Newly created document</param> /// <returns>True if new variant is successfully created or if AB test is not defined.</returns> private bool CreateABVariant(TreeNode newDocument) { // If ABTest selected - create new variant int abTestID = ValidationHelper.GetInteger(ucABTestSelector.Value, 0); if (abTestID <= 0) { return(true); } // If no test found, handle it as no test was specified ABTestInfo abTest = ABTestInfoProvider.GetABTestInfo(abTestID); if (abTest == null) { return(true); } string defaultCodeName = TextHelper.LimitLength(ValidationHelper.GetCodeName(newDocument.NodeAlias), 45, String.Empty); string codeName = defaultCodeName; ABVariantInfo info = ABVariantInfoProvider.GetABVariantInfo(codeName, abTest.ABTestName, SiteContext.CurrentSiteName); // Find non existing variant code name int index = 0; while (info != null) { index++; codeName = defaultCodeName + "-" + index; info = ABVariantInfoProvider.GetABVariantInfo(codeName, abTest.ABTestName, SiteContext.CurrentSiteName); } // Save AB Variant ABVariantInfo variantInfo = new ABVariantInfo(); variantInfo.ABVariantTestID = abTestID; variantInfo.ABVariantPath = newDocument.NodeAliasPath; variantInfo.ABVariantName = codeName; variantInfo.ABVariantDisplayName = newDocument.NodeAlias; variantInfo.ABVariantSiteID = SiteContext.CurrentSiteID; try { ABVariantInfoProvider.SetABVariantInfo(variantInfo); } catch (InfoObjectException ex) { newDocument.Delete(true, true); ShowError(ex.Message); return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (PostbackOnChange) { ucUniSelector.DropDownSingleSelect.AutoPostBack = true; ScriptManager scr = ScriptManager.GetCurrent(Page); scr.RegisterPostBackControl(ucUniSelector.DropDownSingleSelect); } if (!URLHelper.IsPostback()) { // If some test belongs to node give by NodeID - preselect it in ABTest selector if (NodeID != 0) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(NodeID, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); if (node != null) { DataSet ds = ABTestInfoProvider.GetABTests("ABTestSiteID = " + CMSContext.CurrentSiteID + " AND ABTestOriginalPage = '" + SqlHelperClass.GetSafeQueryString(node.NodeAliasPath, false) + "'", "ABTestName", -1, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { // Preselect running test bool runningTestFound = false; foreach (DataRow row in ds.Tables[0].Rows) { ABTestInfo abTestObj = new ABTestInfo(row); if (ABTestInfoProvider.ABTestIsRunning(abTestObj)) { runningTestFound = true; ucUniSelector.Value = abTestObj.ABTestID; } } // If no running test found for the page, preselect the first test (alphabetically) if (!runningTestFound) { int abTestID = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["ABTestID"], 0); if (abTestID != 0) { ucUniSelector.Value = abTestID; } } } } } } ReloadData(false); }
/// <summary> /// Handles Unigrid's OnExternalDataBound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLower()) { case "abteststatus": int testID = ValidationHelper.GetInteger(parameter, 0); ABTestInfo testInfo = ABTestInfoProvider.GetABTestInfo(testID); if (testInfo != null) { if (!testInfo.ABTestEnabled) { return("<span class=\"StatusDisabled\">" + GetString("general.disabled") + "</span>"); } else { string status = string.Empty; if (ABTestInfoProvider.ABTestIsRunning(testInfo)) { // Display disabled information if (!webAnalyticsEnabled) { return(GetString("abtesting.statusNone")); } if (!ABTestInfoProvider.ContainsVariants(testInfo)) { // Display warning when the test does not contain any variant return("<img src=\"" + GetImageUrl("Design/Controls/UniGrid/Actions/Warning.png") + "\" alt=\"" + GetString("abtest.novariants") + "\" title=\"" + GetString("abtest.novariants") + "\" /> " + GetString("abtesting.status" + ABTestStatusEnum.None)); } status += "<span class=\"StatusEnabled\">" + GetString("abtesting.status" + ABTestInfoProvider.GetABTestStatus(testInfo)) + "</span>"; } else { status += GetString("abtesting.status" + ABTestInfoProvider.GetABTestStatus(testInfo)); } return(status); } } return(string.Empty); } return(parameter); }
protected void Page_Load(object sender, EventArgs e) { String siteName = CMSContext.CurrentSiteName; // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } PageTitle title = this.CurrentMaster.Title; int testID = QueryHelper.GetInteger("abTestID", 0); editElem.TestID = testID; // Prepare the header string name = ""; title.HelpTopicName = "variant_edit"; if (editElem.VariantObj != null) { name = editElem.VariantObj.ABVariantDisplayName; title.TitleImage = GetImageUrl("Objects/CMS_Variant/object.png"); } else { name = GetString("abtesting.variant.new"); title.TitleImage = GetImageUrl("Objects/CMS_Variant/new.png"); } nodeID = QueryHelper.GetInteger("nodeID", 0); // Prepare the breadcrumbs string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("abtesting.variant.list"); breadcrumbs[0, 1] = "~/CMSModules/OnlineMarketing/Pages/Content/ABTesting/ABVariant/List.aspx?abTestID=" + testID + "&nodeid=" + nodeID; breadcrumbs[1, 0] = name; // Set the title title.Breadcrumbs = breadcrumbs; }
/// <summary> /// Handles Unigrid's OnAction event. /// </summary> protected void gridElem_OnOnAction(string actionname, object actionargument) { string argument = actionargument.ToString(); switch (actionname) { case "delete": int testId = ValidationHelper.GetInteger(argument, 0); if (testId > 0) { ABTestInfoProvider.DeleteABTestInfo(testId); LoadData(); } break; } }
protected void Page_Load(object sender, EventArgs e) { CheckWebAnalyticsUI("ABTest.Overview"); ucDisplayReport = LoadControl("~/CMSModules/Reporting/Controls/DisplayReport.ascx") as IDisplayReport; pnlOverview.Controls.Add((Control)ucDisplayReport); ucConversionRateReport = LoadControl("~/CMSModules/Reporting/Controls/DisplayReport.ascx") as IDisplayReport; pnlConversionRate.Controls.Add((Control)ucConversionRateReport); ucTestValuesReport = LoadControl("~/CMSModules/Reporting/Controls/DisplayReport.ascx") as IDisplayReport; pnlConversionValue.Controls.Add((Control)ucTestValuesReport); listElem.ShowObjectMenu = false; CurrentMaster.PanelContent.CssClass = ""; String siteName = CMSContext.CurrentSiteName; UIHelper.AllowUpdateProgress = false; // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblDisabled.Text = GetString("WebAnalytics.Disabled") + "<br/>"; } if (!ABTestInfoProvider.ABTestingEnabled(siteName)) { this.pnlDisabled.Visible = true; this.lblABTestingDisabled.Text = GetString("abtesting.disabled"); } listElem.ShowFilter = false; listElem.DelayedReload = true; listElem.Grid.GridName = "~/CMSModules/OnlineMarketing/Controls/UI/ABTest/ListWithValues.xml"; lnkTestRate.NavigateUrl = "#"; lnkTestValue.NavigateUrl = "#"; lnkTestValue.Attributes["OnClick"] = "if (parent.parent.selectTreeNode != null) parent.parent.selectTreeNode('ABTest.ConversionsValue');parent.location=\"abtest_frameset.aspx?page=conversionsvalue&displayTab=abtesting.conversionsvalue\""; lnkTestRate.Attributes["OnClick"] = "if (parent.parent.selectTreeNode != null) parent.parent.selectTreeNode('ABTest.ConversionsRate');parent.location=\"abtest_frameset.aspx?page=conversionsrate&displayTab=abtesting.conversionrate\""; ucABTests.AllowAll = true; ucABTests.AllowEmpty = false; ucABTests.IsLiveSite = false; ucABTests.ReturnColumnName = "ABTestName"; ucABTests.PostbackOnChange = true; }
protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "variantname": if (!isMainABTestIssue) { return(null); } IssueInfo issue = IssueInfoProvider.GetIssueInfo(ValidationHelper.GetInteger(parameter, 0)); string variantName = null; if (issue != null) { if (!issue.IssueIsVariant) { // Get variant name from the winner issue if (winnerIssue == null) { ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get A/B test winner variant winnerIssue = IssueInfoProvider.GetIssueInfo(test.TestWinnerIssueID); } } if (winnerIssue != null) { // Get variant name variantName = winnerIssue.IssueVariantName; } } else { // Get variant name variantName = issue.IssueVariantName; } } return(HTMLHelper.HTMLEncode(variantName)); default: return(parameter); } }
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();")); }
/// <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; } var 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.Manual }; ABTestInfo.Provider.Set(mABTest); } CurrentState = GetCurrentState(mParentIssue); if (mParentIssue.IssueForAutomation) { InitControlsForIssueUsedInAutomation(CurrentState, forceReload); } else { InitControls(CurrentState, forceReload); } ucMailout.ParentIssueID = parentIssueId; ucMailout.ReloadData(forceReload); InfoMessage = GetInfoMessage(CurrentState, mParentIssue, mABTest?.TestWinnerOption ?? ABTestWinnerSelectionEnum.Manual); // Init test group slider InitTestGroupSlider(mParentIssue, mABTest, forceReload); }
/// <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); }
/// <summary> /// Deletes an issue specified by its ID (if authorized). /// </summary> /// <param name="issueId">Issue's ID</param> private static void DeleteIssue(int issueId) { var issue = GetIssueOrRedirect(issueId); // User has to have both destroy and issue privileges to be able to delete the issue. if (!issue.CheckPermissions(PermissionsEnum.Delete, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { RedirectToAccessDenied(issue.TypeInfo.ModuleName, "AuthorIssues"); } if (issue.IssueIsABTest) { var abTest = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); NewsletterTasksManager.DeleteWinnerSelectionTask(abTest); } IssueInfo.Provider.Delete(issue); }
public override void ReloadData(bool forceReload) { if (StopProcessing && !forceReload) { return; } InitControls(forceReload); // Javascript for handling winner mailout time var scriptBlock = string.Format(@"function SelWinner(id) {{ modalDialog('{0}?objectid=' + id, 'NewsletterWinnerMailout', '700px', '425px'); return false; }}", ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_WinnerMailout.aspx")); ScriptHelper.RegisterDialogScript(Page); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); ScriptHelper.RegisterTooltip(Page); // Register handlers grdElem.OnExternalDataBound -= grdElem_OnExternalDataBound; grdElem.OnExternalDataBound += grdElem_OnExternalDataBound; grdElem.GridView.RowDataBound -= GridView_RowDataBound; grdElem.GridView.RowDataBound += GridView_RowDataBound; // Get winner ID if any var abTestInfo = ABTestInfoProvider.GetABTestInfoForIssue(ParentIssueID); if (abTestInfo != null) { WinnerIssueID = abTestInfo.TestWinnerIssueID; } mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(SiteContext.CurrentSiteName); grdElem.OrderBy = "IssueVariantName, IssueID"; grdElem.WhereCondition = GetWhereCondition(ParentIssueID, false); grdElem.ShowActionsMenu = false; grdElem.ShowObjectMenu = false; if (!ShowSelectWinnerAction) { grdElem.GridActions = null; } grdElem.ReloadData(); }
public override void ReloadData(bool forceReload) { if (StopProcessing && !forceReload) { return; } InitControls(forceReload); // Javascript for handling winner mailout time string scriptBlock = string.Format(@"function SelWinner(id) {{ modalDialog('{0}?issueid=' + id, 'NewsletterWinnerMailout', '400px', '300px'); return false; }} function ShowOpenedBy(id) {{ modalDialog('{1}?issueid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px'); return false; }} function ViewClickedLinks(id) {{ modalDialog('{2}?issueid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}", ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_WinnerMailout.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx")); ScriptHelper.RegisterDialogScript(Page); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); // Register handlers grdElem.OnExternalDataBound -= new OnExternalDataBoundEventHandler(grdElem_OnExternalDataBound); grdElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(grdElem_OnExternalDataBound); grdElem.GridView.RowDataBound -= new GridViewRowEventHandler(GridView_RowDataBound); grdElem.GridView.RowDataBound += new GridViewRowEventHandler(GridView_RowDataBound); // Get winner ID if any ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(ParentIssueID); if (abi != null) { WinnerIssueID = abi.TestWinnerIssueID; } grdElem.WhereCondition = GetWhereCondition(ParentIssueID, false); grdElem.ShowActionsMenu = false; grdElem.ShowObjectMenu = false; if (!ShowSelectWinnerAction) { grdElem.GridActions = null; } grdElem.ReloadData(); }
protected void Page_Load(object sender, EventArgs e) { int abTestId = QueryHelper.GetInteger("abTestId", 0); int nodeID = QueryHelper.GetInteger("nodeid", 0); ABTestInfo abTest = ABTestInfoProvider.GetABTestInfo(abTestId); if (abTest != null) { // Prepare the tabs string[,] tabs = new string[3, 4]; tabs[0, 0] = GetString("general.general"); tabs[0, 1] = "SetHelpTopic('helpTopic', 'abtest_general');"; tabs[0, 2] = "Tab_General.aspx?abTestId=" + abTestId + "&nodeid=" + nodeID; tabs[1, 0] = GetString("abtesting.variant.list"); tabs[1, 1] = "SetHelpTopic('helpTopic', 'abtest_variants');"; tabs[1, 2] = ResolveUrl("~/CMSModules/OnlineMarketing/Pages/Content/ABTesting/ABVariant/List.aspx?abTestId=" + abTestId + "&nodeid=" + nodeID); tabs[2, 0] = GetString("general.reports"); tabs[2, 1] = "SetHelpTopic('helpTopic', 'abtest_reports');"; tabs[2, 2] = "abtestreports.aspx?abtestid=" + abTestId; // Prepare the breadcrumbs string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("abtesting.abtest.list"); breadcrumbs[0, 1] = "~/CMSModules/OnlineMarketing/Pages/Content/ABTesting/ABTest/List.aspx?nodeid=" + nodeID; breadcrumbs[0, 2] = "_parent"; breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(abTest.ABTestDisplayName.ToString()); // Set the tabs ICMSMasterPage master = CurrentMaster; master.Tabs.Tabs = tabs; master.Tabs.UrlTarget = "content"; // Set the title PageTitle title = CurrentMaster.Title; title.Breadcrumbs = breadcrumbs; title.HelpTopicName = "abtest_general"; title.HelpName = "helpTopic"; } }
/// <summary> /// Loads data into Unigrid. /// </summary> private void LoadData() { var whereCondition = new WhereCondition(); if (!String.IsNullOrEmpty(AliasPath)) { whereCondition.WhereEquals("ABTestOriginalPage", AliasPath); } DataSet abTests = ABTestInfoProvider.GetABTests().OnSite(SiteContext.CurrentSiteID).Where(whereCondition); abTests.Tables[0].Columns.Add("ABTestStatus", typeof(int)); foreach (DataRow abTestDataRow in abTests.Tables[0].Rows) { abTestDataRow["ABTestStatus"] = (int)ABTestStatusEvaluator.GetStatus(new ABTestInfo(abTestDataRow)); } gridElem.DataSource = abTests; }
/// <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); } }
/// <summary> /// Handles Unigrid's OnExternalDataBound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { string param = parameter.ToString(); switch (sourceName.ToLowerCSafe()) { case "status": { ABTestStatusEnum status; if (Enum.TryParse(param, out status)) { return(ABTestStatusEvaluator.GetFormattedStatus(status)); } break; } case "page": return(new HyperLink { NavigateUrl = DocumentURLProvider.GetUrl(param), Text = HTMLHelper.HTMLEncode(param), Target = "_blank" }); case "visitors": case "conversions": { string statisticsCodeName = (sourceName.ToLowerCSafe() == "visitors" ? "abvisitfirst" : "absessionconversionfirst"); ABTestInfo abTestInfo = ABTestInfoProvider.GetABTestInfo(param, SiteContext.CurrentSiteName); if (abTestInfo != null) { return(ValidationHelper.GetInteger(HitsInfoProvider.GetAllHitsInfo(SiteContext.CurrentSiteID, HitsIntervalEnum.Year, statisticsCodeName + ";" + abTestInfo.ABTestName + ";%", "SUM(HitsCount)", abTestInfo.ABTestCulture).Tables[0].Rows[0][0], 0)); } return(0); } } return(null); }
/// <summary> /// Validates the form. If validation succeeds returns true, otherwise returns false. /// </summary> private bool Validate() { // Validate required fields string errorMessage = new Validator() .NotEmpty(txtABVariantDisplayName.Text.Trim(), rfvABVariantDisplayName.ErrorMessage) .NotEmpty(txtABVariantName.Text.Trim(), rfvABVariantName.ErrorMessage) .IsCodeName(txtABVariantName.Text.Trim(), GetString("general.invalidcodename")).Result; string abTestName = string.Empty; string siteName = CMSContext.CurrentSiteName; // Get AB test info object ABTestInfo abti = ABTestInfoProvider.GetABTestInfo(TestID); if (abti != null) { abTestName = abti.ABTestName; } // Test unique codename ABVariantInfo info = ABVariantInfoProvider.GetABVariantInfo(txtABVariantName.Text.Trim(), abTestName, siteName); if ((info != null) && ((VariantObj == null) || (info.ABVariantID != VariantObj.ABVariantID))) { errorMessage = GetString("general.codenameexists"); } if (String.IsNullOrEmpty(ucPath.Value.ToString())) { errorMessage = GetString("abtesting.entertestpage"); } // Set the error message if (!String.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return(false); } return(true); }