private void AddOptOutRoles(List <string> roles) { foreach (ListviewItem item in this.OptOutOf.Items) { TargetAudience targetAudience = Factory.GetTargetAudience(item.Value); if (targetAudience != null) { TargetAudienceSource targetAudienceSource = CoreFactory.Instance.GetTargetAudienceSource(targetAudience); string domain = this.DomainCombobox.Value; string str2 = targetAudienceSource.CreateRoleToExtraOptOut(domain); if (!string.IsNullOrEmpty(str2)) { roles.Add(str2); } } } }
private bool SelectRolesCompleted() { //here goes actual import List <string> roles = new List <string>(); try { this.AddAdvancedRoles(roles); } catch (Exception exception) { SheerResponse.Alert(exception.Message, new string[0]); return(false); } TargetAudience ta = null; Item listsContainerRoot = Root.GetRecipientListContainerItem(); if (roles.Count > 0) { using (new SecurityDisabler()) { string rolename = roles[0]; if (listsContainerRoot != null) { try { ta = TargetAudienceSource.Create(this.RecipientListName.Value, listsContainerRoot, rolename, null); roles.RemoveAt(0); } catch (Exception e) { SheerResponse.Alert(EcmTexts.Localize("Error appeared during creating a new Recipient List.", new object[0]), new string[0]); Log.Error("Error appeared during creating a new Recipient List.", e, this); } } } } else { using (new SecurityDisabler()) { if (listsContainerRoot != null) { try { ta = TargetAudienceSource.Create(this.RecipientListName.Value, listsContainerRoot, null, null); } catch (Exception e) { SheerResponse.Alert(EcmTexts.Localize("Error appeared during creating a new Recipient List.", new object[0]), new string[0]); Log.Error("Error appeared during creating a new Recipient List.", e, this); } } } } if (ta == null) { SheerResponse.Alert(EcmTexts.Localize("Recipient List could not be created.", new object[0]), new string[0]); return(false); } if ((ta != null) && (ta.InnerItem != null)) { try { foreach (string str in roles) { ta.Source.AddRoleToExtraOptIn(str); } } catch (Exception e) { SheerResponse.Alert(EcmTexts.Localize("Error appeared during adding extra roles to a new Recipient List.", new object[0]), new string[0]); Log.Error("Error appeared during adding extra roles to a new Recipient List.", e, this); } } return(true); }