Ejemplo n.º 1
0
        private static async Task MainAsync(string[] args, TestData testData)
        {
            var configHelper = new ConfigureHelper();

            var cfg = await configHelper.CreateAndConfigureClient();

            // Initialize a client using the validate configuration

            using (var client = new XConnectClient(cfg))
            {
                try
                {
                    var FilterByTime = new Tutorial4();
                    await FilterByTime.ExecuteAsync(client);

                    var createHelper = new CreateHelper();

                    Contact newKnownContact = createHelper.CreateNewContact(testData.NewContact);

                    var updateHelper = new UpdateHelper();

                    updateHelper.PopulatePersonalInformationFacet(client, newKnownContact);

                    client.AddContact(newKnownContact);

                    updateHelper.RecordInteractionFacet(client, newKnownContact);

                    // Submit contact and interaction - a total of two operations (three)
                    await client.SubmitAsync();

                    var reportingHelper = new ReportingHelpers();
                    reportingHelper.DisplayResults(client);

                    var readHelper = new ReadHelper();

                    Contact existingContact = await readHelper.RetrieveExistingContactAsync(client);

                    if (existingContact != null)
                    {
                        reportingHelper.DisplayExistingContactData(existingContact);

                        var existingContactFacetData = readHelper.RetrieveExistingContactFacetData(client, existingContact);

                        reportingHelper.DisplayExistingContactFacetData(existingContactFacetData);

                        reportingHelper.ReportInteractionsForExistingContact(existingContact, client);
                    }
                    else
                    {
                        Console.WriteLine("ExistingContact is null");
                    }

                    ReportingHelpers.EnterToProceed();
                }
                catch (XdbExecutionException ex)
                {
                    // deal with exception
                }
            }
        }
Ejemplo n.º 2
0
        public void ReportInteractionsForExistingContact(Contact existingContact, XConnect.Client.XConnectClient client)
        {
            IReadOnlyCollection <IInteractionReference> interactions = existingContact.Interactions;

            var i = 0;

            Console.WriteLine("Interaction count: " + interactions.Count);
            Console.WriteLine("");

            // Cycle through all interactions
            foreach (Interaction interaction in interactions)
            {
                i++;
                var ipinfo = interaction.GetFacet <IpInfo>(IpInfo.DefaultFacetKey);
                Console.WriteLine("Interaction #" + i);

                if (ipinfo != null)
                {
                    // For each interaction, print out the business name
                    // associated with that interactions' IpInfo
                    Console.WriteLine("\tInteraction business name: " + ipinfo.BusinessName);
                    Console.WriteLine("\tInteraction Id: " + interaction.Id);

                    if (existingContact.Id != null && interaction.Id != null)
                    {
                        InteractionReference interactionReference = new InteractionReference((Guid)existingContact.Id, (Guid)interaction.Id);

                        var contactOptions = new RelatedContactExpandOptions(new string[]
                        {
                            PersonalInformation.DefaultFacetKey
                        });

                        var facets = new string[] {
                            IpInfo.DefaultFacetKey
                        };

                        var expandOptions = new InteractionExpandOptions(facets)

                        {
                            Contact = contactOptions
                        };

                        var interactionB = client.Get <Interaction>(interactionReference, expandOptions);
                        if (interactionB != null)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("All Interaction Properties");
                            foreach (var prop in interactionB.GetType().GetProperties())
                            {
                                Console.WriteLine($"\t{prop.Name} : {prop.GetValue(interactionB, null)}");
                            }
                        }
                    }
                }
            }

            ReportingHelpers.EnterToProceed();
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            var contactTestData = new TestData();

            contactTestData.NewContact = new ContactModel()
            {
                ContactIdentifier = "NewContactPrefix_" + Guid.NewGuid().ToString("N")
            };

            MainAsync(args, contactTestData).ConfigureAwait(false).GetAwaiter().GetResult();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("");
            Console.WriteLine("END OF PROGRAM");
            ReportingHelpers.EnterToProceed();
        }