2017-12-05 19 views
1

状態をAzure Table Storeで管理するようにMBFボットを更新しています。私たちは、表ストアプロバイダを登録するためのマニュアルに従ってコードを変更:今すぐMicrosoft Bot Framework State Management

protected void Application_Start() 
{ 
     GlobalConfiguration.Configure(WebApiConfig.Register); 
     var builder = new ContainerBuilder(); 
     var store = new TableBotDataStore("..."); 

     builder.Register(c => store) 
      .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore) 
      .AsSelf() 
      .SingleInstance(); 

     builder.Register(c => new CachingBotDataStore(store, 
       CachingBotDataStoreConsistencyPolicy 
       .ETagBasedConsistency)) 
       .As<IBotDataStore<BotData>>() 
       .AsSelf() 
       .InstancePerLifetimeScope(); 

     var config = GlobalConfiguration.Configuration; 

     var container = builder.Build(); 
     config.DependencyResolver = new AutofacWebApiDependencyResolver(container); 
} 

、私たちは保存するために、次のとロードユーザデータを使用するダイアログで:

context.PrivateConversationData.SetValue<UserData>(UserDataRepositoryKey, userData); 

興味深いのは、対話状態がいるようだということです私たちはAzureテーブルは何もないと私は確信しています。ドキュメントは、正しい方法で状態を使用する方法について非常に不明です。

質問:

  1. は、当社のコンテナの登録が正しく見えるのか?それはapp_startにあるべきか、それとも毎回のリクエストに対して登録するべきですか?

  2. 会話中に状態を保存する正しい方法を使用していますか?

答えて

4

Conversationコンテナを更新していないようです。そのためにはConversation.UpdateContainerメソッドを使用する必要があります。話題の周り

Conversation.UpdateContainer(
      builder => 
      { 
       builder.Register(c => store) 
         .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore) 
         .AsSelf() 
         .SingleInstance(); 

       builder.Register(c => new CachingBotDataStore(store, 
          CachingBotDataStoreConsistencyPolicy 
          .ETagBasedConsistency)) 
          .As<IBotDataStore<BotData>>() 
          .AsSelf() 
          .InstancePerLifetimeScope(); 


      }); 

ドキュメントはhttps://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storagehttps://github.com/Microsoft/BotBuilder-Azure/tree/master/CSharp/Samples/AzureTableでのサンプルで発見することができます。

+1

ありがとうございました! – Alekos

関連する問題