public void DoManualMarketingList() { Marketinglist marketinglist = null; reportProgress(new SimpleProgressReport("Check if manual list is already created.")); DataCollection <Entity> lists = ListHelper.RetrieveMarketinglists(service, this.Configuration.ManualListName); if (lists.Count == 0) { if (this.Configuration.IfJoinUnsuccessful == OnUnsuccessfulJoin.CreateNew) { Entity list = new Entity("list"); list.Attributes.Add("listname", this.Configuration.ManualListName); marketinglist = ListHelper.CreateMarketingList(service, list, this.Configuration.ListMemberType); } else { throw new Exception("List " + this.Configuration.ManualListName + " does not exist."); } } else if (lists.Count == 1) { marketinglist = new Marketinglist(this.Configuration.ManualListName, lists[0].Id); } else { throw new Exception("Multiple lists with the name " + this.Configuration.ManualListName + " exists."); } for (int i = 0; i < this.dataObject.Count; i++) { AddMemberToList(marketinglist.ListId, this.dataObject[i]); } }
public void DoJoinMarketingLists() { EntityMapperLight entityMapper = new EntityMapperLight(this.listEntityMetaData, this.dataObject.Metadata, this.Configuration.ListMapping); for (int i = 0; i < this.dataObject.Count; i++) { string joinKey = JoinResolver.BuildExistingCheckKey(this.dataObject[i], this.Configuration.ListMapping, this.dataObject.Metadata); if (existingLists.ContainsKey(joinKey)) { if (existingLists[joinKey].Length > 1) { throw new Exception("Multiple lists with the joinvalues " + joinKey.Replace("#", " ").TrimEnd(' ') + " exists."); } } else { if (this.Configuration.IfJoinUnsuccessful == OnUnsuccessfulJoin.CreateNew) { Entity list = new Entity("list"); entityMapper.MapAttributes(list, this.dataObject[i]); Marketinglist marketingList = ListHelper.CreateMarketingList(service, list, this.Configuration.ListMemberType); existingLists.Add(joinKey, new Guid[] { marketingList.ListId }); } else { throw new Exception("List with joinvalues " + joinKey.Replace("#", " ").TrimEnd(' ') + " does not exist."); } } AddMemberToList(existingLists[joinKey][0], this.dataObject[i]); } }