C# Microsoft Bot框架状态管理
我们正在更新MBF bot,以便在Azure表存储中管理其状态。我们根据文档更改了代码以注册我们的表存储提供商:C# Microsoft Bot框架状态管理,c#,azure,botframework,C#,Azure,Botframework,我们正在更新MBF bot,以便在Azure表存储中管理其状态。我们根据文档更改了代码以注册我们的表存储提供商: protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); var builder = new ContainerBuilder(); var store = new TableBotDataStore("...")
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);
}
受保护的无效应用程序\u Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
var builder=new ContainerBuilder();
var store=新的TableBotDataStore(“…”);
builder.Register(c=>store)
.Keyed(AzureModule.Key_数据存储)
.AsSelf()
.SingleInstance();
builder.Register(c=>新的CachingBotDataStore(store,
cachingbotdatastoreconsistency策略
.ETAGBASED(一致性)
.As()
.AsSelf()
.InstancePerLifetimeScope();
var config=GlobalConfiguration.Configuration;
var container=builder.Build();
config.DependencyResolver=新的AutoFacWebApidencyResolver(容器);
}
现在,在对话框中,我们使用以下命令存储和加载用户数据:
context.PrivateConversationData.SetValue<UserData>(UserDataRepositoryKey, userData);
context.PrivateConversationData.SetValue(UserDataRepositoryKey,userData);
有趣的是,对话框状态似乎保持不变,但我们看不到任何东西是我们的Azure表,我真的怀疑是否有任何调用能够访问该存储。关于如何正确使用state,文档非常不清楚
问题:
您似乎没有更新
对话
容器。为此,您需要使用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();
});
Conversation.UpdateContainer(
生成器=>
{
builder.Register(c=>store)
.Keyed(AzureModule.Key_数据存储)
.AsSelf()
.SingleInstance();
builder.Register(c=>新的CachingBotDataStore(store,
cachingbotdatastoreconsistency策略
.ETAGBASED(一致性)
.As()
.AsSelf()
.InstancePerLifetimeScope();
});
有关该主题的文档可在中找到,样本可在中找到