/// <summary> /// Saves the changes in conversions /// </summary> protected void SaveConversions() { // Check permissions if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageConversions")) { RedirectToAccessDenied("CMS.WebAnalytics", "Manage conversions"); } if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageCampaigns")) { RedirectToAccessDenied("CMS.WebAnalytics", "Manage campaigns"); } // Remove old items string newValues = ValidationHelper.GetString(usConversions.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int conversionID = ValidationHelper.GetInteger(item, 0); // remove conversion ConversionCampaignInfoProvider.RemoveConversionFromCampaign(conversionID, campaignID); } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { bool falseValues = false; // Add all new items to site foreach (string item in newItems) { int conversionID = ValidationHelper.GetInteger(item, 0); ConversionCampaignInfoProvider.AddConversionToCampaign(conversionID, campaignID); } // If some of sites could not be assigned reload selector value if (falseValues) { usConversions.Value = GetConversions(); usConversions.Reload(true); } } } ShowChangesSaved(); }
/// <summary> /// Saves the changes in conversions /// </summary> protected void SaveConversions() { // Remove old items string newValues = ValidationHelper.GetString(usConversions.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to site foreach (int conversionID in newItems.Select(item => ValidationHelper.GetInteger(item, 0))) { // remove conversion ConversionCampaignInfoProvider.RemoveConversionFromCampaign(conversionID, campaignID); } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to site foreach (int conversionID in newItems.Select(item => ValidationHelper.GetInteger(item, 0))) { ConversionCampaignInfoProvider.AddConversionToCampaign(conversionID, campaignID); } } ShowChangesSaved(); }