インタラクションファセットの設定
Version:
日本語翻訳に関する免責事項
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
client.SetFacet()拡張メソッドを使用して、インタラクションファセットを設定します。インタラクションのファセットは更新できません。
デフォルトのファセット値を使用すると、その値はシャードデータベース (xDB) に保存されません。代わりに、xConnectを使用してファセットを取得するときに既定値が入力されます。デフォルト値の例としては、ブール型フィールドのfalseやint32型フィールドの0などがあります。
次の例は、新しいインタラクションにLocaleInfoファセットを設定する方法を示しています。
using Sitecore.XConnect.Collection.Model; using Sitecore.XConnect; using System; using Sitecore.XConnect.Client; namespace Documentation { public class AddInteractionFacetData { // Async Example public async void ExampleAsync() { using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient()) { { try { var existingContactTask = client.GetAsync<Sitecore.XConnect.Contact>(new IdentifiedContactReference("twitter", "myrtlesitecore"), new ContactExecutionOptions(new ContactExpandOptions())); var existingContact = await existingContactTask; if (existingContact != null) { var channelId = Guid.Parse("5746c4f3-7e16-40d9-ba1d-14c70875724c"); // Replace with real channel ID var userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1"; Interaction interaction = new Interaction(existingContact, InteractionInitiator.Brand, channelId, userAgent); LocaleInfo localeInfo = new LocaleInfo() { GeoCoordinate = new GeoCoordinate(55.676097, 12.568337) }; client.SetFacet<LocaleInfo>(interaction, LocaleInfo.DefaultFacetKey, localeInfo); client.AddInteraction(interaction); await client.SubmitAsync(); } } catch (XdbExecutionException ex) { // Handle exception } } } } // Sync example public void ExampleSync() { using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient()) { { try { var existingContact = client.Get<Contact>(new IdentifiedContactReference("twitter", "myrtlesitecore"), new ContactExecutionOptions(new ContactExpandOptions())); if (existingContact != null) { var channelId = Guid.Parse("5746c4f3-7e16-40d9-ba1d-14c70875724c"); // Replace with real channel ID var userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1"; Interaction interaction = new Interaction(existingContact, InteractionInitiator.Brand, channelId, userAgent); LocaleInfo localeInfo = new LocaleInfo() { GeoCoordinate = new GeoCoordinate(55.676097, 12.568337) }; client.SetFacet<LocaleInfo>(interaction, LocaleInfo.DefaultFacetKey, localeInfo); client.AddInteraction(interaction); client.Submit(); } } catch (XdbExecutionException ex) { // Handle exception } } } } } }