/// <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; } } }
/// <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 variantDailog_OnDeleteVariant(object sender, EventArgs e) { if (Variants.Count <= 0) { return; } // Allow modifying issues in idle state only IssueInfo parentIssue = IssueInfoProvider.GetOriginalIssue(IssueID); if ((parentIssue == null) || (parentIssue.IssueStatus != IssueStatusEnum.Idle)) { return; } int currVariant = CurrentVariant; if (Variants.Count > 2) { IssueInfoProvider.DeleteIssueInfo(Variants[currVariant].IssueID); Variants.RemoveAt(currVariant); RaiseVariantDeleted(); } else { if (Variants.Count == 2) { // Remove variant IssueInfoProvider.DeleteIssueInfo(Variants[currVariant].IssueID); Variants.RemoveAt(currVariant); } // Get remaining variant IssueABVariantItem issueVariant = Variants[0]; Variants.Clear(); IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueVariant.IssueID); if (issue != null) { // Transfer all data from child to parent and delete child const string ignoredColumns = ";issueid;issueguid;issuevariantname;"; foreach (string column in parentIssue.ColumnNames) { if (!ignoredColumns.Contains(String.Format(";{0};", column.ToLowerCSafe()))) { parentIssue.SetValue(column, issue.GetValue(column)); } } parentIssue.IssueIsABTest = false; parentIssue.IssueVariantName = null; parentIssue.IssueVariantOfIssueID = 0; IssueInfoProvider.SetIssueInfo(parentIssue); // Delete files from parent issue if any MetaFileInfoProvider.DeleteFiles(parentIssue.IssueID, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); MetaFileInfoProvider.DeleteFiles(parentIssue.IssueID, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE); // Move attachments (meta files) from child to parent MetaFileInfoProvider.MoveMetaFiles(issue.IssueID, parentIssue.IssueID, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); MetaFileInfoProvider.MoveMetaFiles(issue.IssueID, parentIssue.IssueID, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); // Delete last variant IssueInfoProvider.DeleteIssueInfo(issue); OriginalIssueID = parentIssue.IssueID; // A/B variants have been deleted => deleting A/B test itself ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(OriginalIssueID); ABTestInfoProvider.DeleteABTestInfo(abi); } RaiseVariantDeleted(); } }