private void CreateContacts() { using (IXdbContext client = _xConnectClientFactory.GetXConnectClient()) { try { var numberOfContacts = int.Parse(tbNumberOfContacts.Text, CultureInfo.CurrentCulture); var goalIds = tbGoalIds.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(Guid.Parse); var eventIds = tbEventIds.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(Guid.Parse); var outcomeIds = tbOutcomeIds.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(Guid.Parse); var listId = !string.IsNullOrWhiteSpace(tbListId.Text) ? Guid.Parse(tbListId.Text) : Guid.Empty; var campaignId = !string.IsNullOrWhiteSpace(tbCampaignId.Text) ? Guid.Parse(tbCampaignId.Text) : Guid.Empty; for (var i = 0; i < numberOfContacts; i++) { string email = GetEmailAddress(i); var contact = new Contact(new ContactIdentifier("ListManager", email, ContactIdentifierType.Known)); client.AddContact(contact); AddPreferredEmail(i, client, contact, email); AddPhoneNumber(client, contact, tbPhoneNumber.Text); AddPersonalInfo(client, contact, tbPreferredLanguage.Text); AddListSubscription(listId, client, contact); AddConsentInformation(client, contact); AddProfileScore(client, contact); AddEngagementValue(client, contact); AddInteraction(client, contact, goalIds, outcomeIds, eventIds, campaignId); if (i % 10 != 0) { continue; } var numberOfContactsBeingSubmitted = i / 1 > 0 ? i / 1 : 1; Logger.Info($"Submitting {numberOfContactsBeingSubmitted} contacts", this); client.Submit(); } client.Submit(); } catch (Exception ex) { Logger.Error("Failed to submit contacts", ex, this); } } }
public ActivityResult Invoke(IContactProcessingContext context) { Condition.Requires(context, nameof(context)).IsNotNull(); try { _xdbContext.ExecuteRightToBeForgotten(context.Contact); _xdbContext.Submit(); return(new SuccessExitPlan()); } catch (Exception e) { _logger.LogError(0, e, "ExecuteRightToBeForgottenActivity failed"); return(new Failure("ExecuteRightToBeForgottenActivity failed", TimeSpan.FromMinutes(5))); } }