1. xConnectデータ エクスポート ツール

カスタムストレージプロバイダーとプロファイルの例

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

カスタムプロバイダーとプロファイルを導入するには、次の手順を実行します。

  1. カスタムプロバイダーを紹介します。IStorageProviderから継承されたデータを格納するロジックを実装する必要があります。

    using Sitecore.XConnect.DataTools.CortexWorkers.DataExport.StorageProviders;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;
    
    namespace CortexWorkers.DataExport.StorageProviders.Examples
    {
        internal class CustomProvider : IStorageProvider
        {
            public CustomProvider(IEnumerable<CustomProfile> profiles)
            {
                Profiles = profiles == null
                    ? new Dictionary<string, CustomProfile>()
                    : profiles.ToDictionary(x => x.ProfileName, x => x);
            }
            public IReadOnlyCollection<string> ProfileNames => Profiles.Keys;
            protected Dictionary<string, CustomProfile> Profiles { get; }
            protected CustomProfile GetProfile(string profileName)
            {
                if (!Profiles.TryGetValue(profileName, out CustomProfile profile))
                {
                    throw new InvalidOperationException();
                }
                return profile;
            }
            public Task UploadAsync(string fileName, string fileContent, string profileName, CancellationToken cancellationToken)
            {
                /*Implement the logic of the custom provider*/
            }
        }
    }
  2. 特定のストレージパラメータのセットを定義するカスタムストレージプロファイルを導入します。適切なプロファイルを識別するには、ProfileNameパラメーターを追加する必要があります。

    using System;
    using System.Globalization;
    using Microsoft.Extensions.Configuration;
    
    namespace CortexWorkers.DataExport.StorageProviders.Examples
    {
        internal class CustomProfile
        {
            public CustomProfile(IConfiguration options)
            : this((options ?? throw new ArgumentNullException(nameof(options))).GetValue<string>(nameof(ProfileName)),
            options.GetValue<string>(nameof(Param1)), options.GetValue<string>(nameof(Param2)), options.GetValue<string>(nameof(Param3)))
            {    
            }
            public CustomProfile(string profileName, string param1, string param2, string param3)
            {
                if (string.IsNullOrWhiteSpace(profileName))
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Looks up a localized string similar to The {0} is not valid..", nameof(profileName)));
                }
                if (string.IsNullOrWhiteSpace(param1))
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Looks up a localized string similar to The {0} is not valid..", nameof(param1)));
                }
                if (string.IsNullOrWhiteSpace(param2))
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Looks up a localized string similar to The {0} is not valid..", nameof(param2)));
                }
                if (string.IsNullOrWhiteSpace(param3))
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Looks up a localized string similar to The {0} is not valid..", nameof(param3)));
                }
                ProfileName = profileName;
                Param1 = param1;
                Param2 = param2;
                Param3 = param3;
            }
            public string ProfileName { get; }
            public string Param1 { get; }
            public string Param2 { get; }
            public string Param3 { get; }
        }
    }
  3. Cortex ProcessingロールとProcessing Engineサービス設定Sitecore\Processing\Servicesセクションに、新しいカスタム プロバイダとプロファイルを適用します。

    <?xml version="1.0" encoding="utf-8" ?>
    <Settings>
        <Sitecore>
            <Processing>
                <Services>
                    <StorageProviders.CustomProfile>
                        <Type>CortexWorkers.DataExport.StorageProviders.Examples.CustomProfile, CortexWorkers.DataExport.StorageProviders.Examples</Type>
                        <As>CortexWorkers.DataExport.StorageProviders.Examples.CustomProfile, CortexWorkers.DataExport.StorageProviders.Examples</As>
                        <LifeTime>Singleton</LifeTime>
                        <Options>
                            <ProfileName>CustomProfile</ProfileName>
                            <Param1>Value1</Param1>
                            <Param2>Value2</Param2>
                            <Param3>Value3</Param3>
                        </Options>
                    </StorageProviders.CustomProfile>
                    <StorageProviders.CustomProvider>
                        <Type>CortexWorkers.DataExport.StorageProviders.Examples.CustomProvider, CortexWorkers.DataExport.StorageProviders.Examples</Type>
                        <As>Sitecore.XConnect.DataTools.CortexWorkers.DataExport.StorageProviders.IStorageProvider, Sitecore.XConnect.DataTools.CortexWorkers</As>
                        <LifeTime>Singleton</LifeTime>
                    </StorageProviders.CustomProvider>
                </Services>
            </Processing>
        </Sitecore>
    </Settings>
  4. ソリューションを構築します。DLLファイルをCortex ProcessingロールとProcessing Engineサービスに追加します。

  5. 変更を適用するには、処理エンジン・サービスを再起動します。

これで、CustomProfileをDataExportツールに渡し、新しいカスタム プロバイダーにアップロードを実行させることができます。

この記事を改善するための提案がある場合は、 お知らせください!