/// <summary> /// Validates the form. If validation succeeds returns true, otherwise returns false. /// </summary> private bool Validate() { string codename = this.txtABTestName.Text.Trim(); // Validate required fields string errorMessage = new Validator() .NotEmpty(txtABTestDisplayName.Text.Trim(), this.rfvABTestDisplayName.ErrorMessage) .NotEmpty(codename, this.rfvABTestName.ErrorMessage) .IsCodeName(codename, GetString("general.invalidcodename")).Result; if (!dtpABTestOpenFrom.IsValidRange() || !dtpABTestOpenTo.IsValidRange()) { errorMessage = GetString("general.errorinvaliddatetimerange"); } if ((dtpABTestOpenFrom.SelectedDateTime != DateTimeHelper.ZERO_TIME) && (dtpABTestOpenTo.SelectedDateTime != DateTimeHelper.ZERO_TIME) && (dtpABTestOpenFrom.SelectedDateTime > dtpABTestOpenTo.SelectedDateTime)) { errorMessage = GetString("om.wrongtimeinterval"); } string maxConversions = txtABTestMaxConversions.Text.Trim(); if (!String.IsNullOrEmpty(maxConversions) && (String.IsNullOrEmpty(errorMessage))) { errorMessage = new Validator().IsInteger(maxConversions, GetString("om.targetconversionrequiresinteger")).IsPositiveNumber(maxConversions, GetString("om.targetconversionrequiresinteger")).Result; } // Check the uniqueness of the codename ABTestInfo info = ABTestInfoProvider.GetABTestInfo(txtABTestName.Text.Trim(), CMSContext.CurrentSiteName); if ((info != null) && ((this.AbTestObj == null) || (info.ABTestID != this.AbTestObj.ABTestID))) { errorMessage = GetString("general.codenameexists"); } if (String.IsNullOrEmpty(ucPath.Value.ToString()) && (AliasPath == String.Empty)) { errorMessage = GetString("abtesting.enteroriginalpage"); } // Test if there is no enabled test for same page if (chkABTestEnabled.Checked && TestToValidate()) { QueryDataParameters parameters = null; string testPage = ((AliasPath != String.Empty) && !ShowAliasPath) ? AliasPath : ucPath.Value.ToString(); string where = ABTestInfoProvider.GetRunningCondition(ABTestID, testPage, CMSContext.CurrentSiteID, ucCultureSelector.Value.ToString(), dtpABTestOpenFrom.SelectedDateTime, dtpABTestOpenTo.SelectedDateTime, out parameters); DataSet ds = ABTestInfoProvider.GetABTests(where, null, -1, null, parameters); if (!DataHelper.DataSourceIsEmpty(ds)) { errorMessage = GetString("om.twotestsonepageerror"); } } // Set the error message if (!String.IsNullOrEmpty(errorMessage)) { this.lblError.Text = errorMessage; return(false); } return(true); }