2017-04-18 42 views
0

是否有可能使用resumAfterDeleteStateForUser一個表單生成對話框後離開目前的對話框?C#BOT框架 - DeleteStateForUser在resumeafter

context.Call(searchFormDialog, this.ResumeAfterBuildSatisfactionForm); 


    private IForm<SatisfactionQuery> BuildSatisfactionForm() 
    { 
     OnCompletionAsyncDelegate<SatisfactionQuery> processSearch = async (context, state) => 
     { 
      await context.PostAsync($"Thx"); 
     }; 

     return new FormBuilder<SatisfactionQuery>() 
      //.Message("") 
      .AddRemainingFields() 
      .OnCompletion(processSearch) 
      .Build(); 
    } 

private async Task ResumeAfterBuildSatisfactionForm(IDialogContext context, IAwaitable<SatisfactionQuery> result) 
{ 
    //but i don't have Activity here :-(
activity.GetStateClient().BotState.DeleteStateForUser(activity.ChannelId,activity.From.Id); 
} 

回答

0

您可以使用的serviceUrl創建StateClient:

private async Task ResumeAfterBuildSatisfactionForm(IDialogContext context, IAwaitable<SatisfactionQuery> result) 
{ 
    var msg = context.MakeMessage(); 
    var stateClient = new StateClient(new Uri(msg.ServiceUrl)); 
    stateClient.BotState.DeleteStateForUser(msg.ChannelId, msg.From.Id); 
} 
+0

THX這麼多@EricDahlvang我解決......這項工作很好:-) – thefox

+0

對不起@EricDahlvang你知道我怎麼能發送FormBuilder查詢與博特帳戶等context.MakeMessage()從= ChannelAccount(ID:ContextConstants.BotId,名稱:ContextConstants.BotName); ? – thefox