private async Task <DialogTurnResult> SummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { if ((bool)stepContext.Result) { await stepContext.Context.SendActivityAsync(MessageFactory.Text("Here are the details you provided."), cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text("Python programming questions - "), cancellationToken); for (int i = 0; i < QnAData.QuestionPhrase.Count; i++) { await stepContext.Context.SendActivityAsync(MessageFactory.Text(QnAData.QuestionPhrase[i]), cancellationToken); } await stepContext.Context.SendActivityAsync(MessageFactory.Text("Your programming Answer - "), cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text((string)stepContext.Values["Answer"]), cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please wait while I update my Knowledge Base."), cancellationToken); await stepContext.Context.SendActivitiesAsync( new Activity[] { new Activity { Type = ActivityTypes.Typing }, new Activity { Type = "delay", Value = 5000 }, }, cancellationToken); var authoringURL = $"https://{Configuration["ResourceName"]}.cognitiveservices.azure.com"; // <AuthorizationAuthor> var client = new QnAMakerClient(new ApiKeyServiceClientCredentials(Configuration["Key"])) { Endpoint = authoringURL }; // </AuthorizationAuthor> QnAClient.UpdateKB(client, Configuration["KnowledgeBaseId"], (string)stepContext.Values["Answer"]).Wait(); QnAClient.PublishKb(client, Configuration["KnowledgeBaseId"]).Wait(); await stepContext.Context.SendActivityAsync(MessageFactory.Text("I have update my Knowledge Base. Thank you for your contribution 😇")); return(await stepContext.EndDialogAsync(null, cancellationToken)); } else { await stepContext.Context.SendActivityAsync(MessageFactory.Text("Request Not Confirmed.")); return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken)); } }
private static void StartBridgeInternal(MainWindow t, int port, string domainName) { string authenticationTicket = null; Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "LiveConnect: Try authentication"); t.DoLogin(); authenticationTicket = t.AccessToken; if (string.IsNullOrEmpty(authenticationTicket)) { // Reset the RefreshToken, if the authentication has failed... UserSettings.Default.RefreshToken = string.Empty; Traces.Main_TraceEvent(TraceEventType.Error, 1, "Could not authenticate with LiveConnect!"); throw new ApplicationException("Could not authenticate with LiveConnect!"); } Traces.Main_TraceEvent(TraceEventType.Information, 1, "Authenticated: AccessToken: {0}", authenticationTicket); // Create the forums-ServiceProvider Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Create forums service provider: {0}", "social"); #if true var provider = new WebServiceAnswers.SwaggerAccess(); provider.UpdateAuthTicket(authenticationTicket); WebServiceAnswers.SwaggerAccess.Log = SwaggerLog; WebServiceAnswers.SwaggerAccess.LogExp = SwaggerLogExp; #else WebServiceAnswers.IForumData provider = new QnAClient("httpLiveAuth"); #endif t._Provider = provider; //if (provider.Endpoint.Behaviors.Contains(typeof(Microsoft.Support.Community.CpsAuthHeaderBehavior))) //{ // provider.Endpoint.Behaviors.Remove(typeof(Microsoft.Support.Community.CpsAuthHeaderBehavior)); //} //t._answersAuthHeader = new Microsoft.Support.Community.CpsAuthHeaderBehavior(authenticationTicket); //provider.Endpoint.Behaviors.Add(t._answersAuthHeader); //foreach (var op in provider.Endpoint.Contract.Operations) //{ // var dcsb = // op.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>(); // //if (dcsb == null) // //{ // // dcsb = new System.ServiceModel.Description.DataContractSerializerOperationBehavior(op); // //} // if (dcsb != null) // { // const int maxObj = 65536*100; // if (dcsb.MaxItemsInObjectGraph < maxObj) // dcsb.MaxItemsInObjectGraph = maxObj; // Default is 65536; increase it... // //dcsb.IgnoreExtensionDataObject = true; // } //} // Try to test the provider once: try { provider.GetSupportedLocales(); } catch (Exception exp) { Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp)); throw; } // Create our DataSource for the forums Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Creating datasource for NNTP server"); t._forumsDataSource = new Answers.ForumDataSource(provider, domainName); t._forumsDataSource.UsePlainTextConverter = UserSettings.Default.UsePlainTextConverter; t._forumsDataSource.AutoLineWrap = UserSettings.Default.AutoLineWrap; t._forumsDataSource.HeaderEncoding = UserSettings.Default.EncodingForClientEncoding; t._forumsDataSource.InMimeUseHtml = (UserSettings.Default.InMimeUse == UserSettings.MimeContentType.TextHtml); t._forumsDataSource.UserDefinedTags = UserSettings.Default.UserDefinedTags; t._forumsDataSource.ShowUserNamePostfix = UserSettings.Default.ShowUserNamePostfix; t._forumsDataSource.PostsAreAlwaysFormatFlowed = UserSettings.Default.PostsAreAlwaysFormatFlowed; t._forumsDataSource.TabAsSpace = UserSettings.Default.TabAsSpace; t._forumsDataSource.UseCodeColorizer = UserSettings.Default.UseCodeColorizer; t._forumsDataSource.AddHistoryToArticle = UserSettings.Default.AddHistoryToArticle; t._forumsDataSource.ProgressData += t._forumsDataSource_ProgressData; // Now start the NNTP-Server Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Starting NNTP server"); t._nntpServer = new NNTPServer.NntpServer(t._forumsDataSource, true); t._nntpServer.EncodingSend = UserSettings.Default.EncodingForClientEncoding; t._nntpServer.ListGroupDisabled = UserSettings.Default.DisableLISTGROUP; //t._nntpServer.DetailedErrorResponse = detailedErrorResponse; string errorMessage; t._nntpServer.Start(port, 64, UserSettings.Default.BindToWorld, out errorMessage); if (errorMessage != null) { throw new ApplicationException(errorMessage); } }