internal async Task AddKnownContactAsync(CandidateMockContactInfo candidate) { if (IsInit) { using (var client = new XConnectClient(cfg)) { await CreateOneContactAsync(client, candidate); } } else { Console.WriteLine("Broker not init"); } }
private static void Main(string[] args) { bool keepGoing = true; var candidateInfoGenerator = new MockContactGenerator(); var contactCreator = new ContactCreator(); while (keepGoing) { CandidateMockContactInfo CandidateContactInfo = candidateInfoGenerator.GetRandomContactInfo(); Task.Run(async() => { await contactCreator.CreateKnownContact(CandidateContactInfo); }).Wait(); Console.WriteLine("Press 'Y' to generate another contact"); var result = Console.ReadKey().Key; keepGoing = result == ConsoleKey.Y; } }
internal async Task ReportOnKnownContactAsync(CandidateMockContactInfo candidate) { if (IsInit) { using (var client = new XConnectClient(cfg)) { var retrievedContact = await RetrieveContactAsync(client, candidate.MarketingIdentifierId); if (retrievedContact != null) { var feedbackHelper = new FeedbackHelper(retrievedContact); feedbackHelper.ReportContactData(client); } } } else { Console.WriteLine("Broker not init"); } }
public async System.Threading.Tasks.Task CreateKnownContact(CandidateMockContactInfo candidateContactInfo) { var cfgGenerator = new CFGGenerator(); var cfg = cfgGenerator.GetCFG(CinemaVisitorCollectionModel.Model); try { await cfg.InitializeAsync(); using (var client = new XConnectClient(cfg)) { await CreateOneContactAsync(client, candidateContactInfo); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task CreateOneContactAsync(XConnectClient client, CandidateMockContactInfo candidate) { try { var operationsHelper = new OperationsDataHelper(candidate); var contact = operationsHelper.CreateContact(); client.AddContact(contact); client.SetFacet(contact, PersonalInformation.DefaultFacetKey, operationsHelper.MakeFacetPersonalInformation()); client.SetFacet(contact, EmailAddressList.DefaultFacetKey, operationsHelper.MakeFacetEmailAddressList()); client.SetFacet(contact, AddressList.DefaultFacetKey, operationsHelper.MakeFacetAddress()); client.SetFacet(contact, CinemaBusinessMarketing.DefaultFacetKey, operationsHelper.MakeFacetMarketing()); client.AddInteraction(operationsHelper.SetRegistrationGoalInteraction(contact)); DrawCandidateDataToConsole(candidate); await client.SubmitAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void DrawCandidateDataToConsole(CandidateMockContactInfo candidate) { Console.WriteLine("Attempting to create known contact: " + candidate.FirstName + " " + candidate.LastName); Console.WriteLine("Marketing Identifier: " + candidate.MarketingIdentifierId); }
private async System.Threading.Tasks.Task CreateOneContactAsync(XConnectClient client, CandidateMockContactInfo candidateContactInfo) { try { var identifierId = "MockContact." + Guid.NewGuid(); ContactIdentifier identifier = new ContactIdentifier(CollectionConst.XConnect.ContactIdentifiers.Sources.SitecoreCinema, identifierId, ContactIdentifierType.Known); Contact contact = new Contact(new ContactIdentifier[] { identifier }); client.AddContact(contact); PersonalInformation personalInfo = new PersonalInformation() { FirstName = candidateContactInfo.FirstName, LastName = candidateContactInfo.LastName, Birthdate = DateTime.Now, Gender = candidateContactInfo.Gender, }; client.SetFacet(contact, PersonalInformation.DefaultFacetKey, personalInfo); var emailAddress = new EmailAddress(candidateContactInfo.EmailAddress, true); var address = new EmailAddressList(emailAddress, CollectionConst.XConnect.EmailPreferredKey); client.SetFacet(contact, EmailAddressList.DefaultFacetKey, address); Interaction interaction = new Interaction(contact, InteractionInitiator.Brand, CollectionConst.XConnect.Channels.RegisterInteractionCode, string.Empty); interaction.Events.Add(new Goal(CollectionConst.XConnect.Goals.RegistrationGoal, DateTime.UtcNow)); client.AddInteraction(interaction); await client.SubmitAsync(); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } }