示例#1
0
        private async Task <DialogTurnResult> OriginStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var bookingDetails = (BookingDetails)stepContext.Options;

            if (((BookingDetails)stepContext.Options).Incident_No == null)
            {
                bookingDetails.Incident_No = (string)stepContext.Result;
            }


            string concat = "";


            SNOWLogger nOWLoggerforinc = new SNOWLogger(Configuration);


            if ((bookingDetails.Incident_No != null))
            {
                if (!(bookingDetails.Incident_No.Equals("")))


                {
                    CoreBot.models.Incident_api_result incident_Api_Result = nOWLoggerforinc.GetIncident(bookingDetails.Incident_No);

                    CoreBot.models.apiresult apiresult = nOWLoggerforinc.GetIncidentDetails(bookingDetails.Incident_No);



                    if (incident_Api_Result != null && apiresult != null)
                    {
                        if (incident_Api_Result.Result.Count != 0 && apiresult.result.Count != 0)
                        {
                            for (int i = 0; i < incident_Api_Result.Result.Count; i++)
                            {
                                concat += " \n " + apiresult.result[i].number + ":" + apiresult.result[i].short_description + " \n Status: " + incident_Api_Result.Result[i].value + " \n Active:" + apiresult.result[i].active;
                            }


                            // Cards are sent as Attachments in the Bot Framework.
                            // So we need to create a list of attachments for the reply activity.
                            var attachments = new List <Attachment>();

                            // Reply to the activity we received with an activity.
                            var reply = MessageFactory.Attachment(attachments);

                            reply.Attachments.Add(Cards.GetHeroCardforStatus(apiresult.result[0].number, apiresult.result[0].short_description, incident_Api_Result.Result[0].value).ToAttachment());

                            await stepContext.Context.SendActivityAsync(reply, cancellationToken);



                            //await stepContext.Context.SendActivityAsync(MessageFactory.Text(concat), cancellationToken);
                            return(await stepContext.EndDialogAsync(null, cancellationToken));
                        }
                        else
                        {
                            if (incident_Api_Result.Result.Count == 0)
                            {
                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text(" Incident is not yet updated by team"), cancellationToken);

                                return(await stepContext.EndDialogAsync(null, cancellationToken));
                            }
                            else if (apiresult.result.Count == 0)
                            {
                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text("No Incident update Found:"), cancellationToken);

                                return(await stepContext.EndDialogAsync(null, cancellationToken));
                            }
                        }
                    }
                    else
                    {
                        await stepContext.Context.SendActivityAsync(
                            MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                        return(await stepContext.EndDialogAsync(null, cancellationToken));
                    }


                    //        {

                    //            //                        return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Sorry no details found for " + stepContext.Context.Activity.Text) }, cancellationToken);
                    //            if (incident_Api_Result == null)
                    //            {
                    //                await stepContext.Context.SendActivityAsync(
                    //          MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //                return await stepContext.EndDialogAsync(null, cancellationToken);
                    //            }
                    //            else

                    //            if (incident_Api_Result != null)
                    //            {

                    //                if (incident_Api_Result.Result.Count != 0)
                    //                {
                    //                    await stepContext.Context.SendActivityAsync(
                    //                    MessageFactory.Text(" Sorry no update found for: " + incident_Api_Result.Result[0].number.ToString()), cancellationToken);

                    //                    return await stepContext.EndDialogAsync(null, cancellationToken);
                    //                }
                    //                else
                    //                {
                    //                    await stepContext.Context.SendActivityAsync(
                    //                MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //                    return await stepContext.EndDialogAsync(null, cancellationToken);
                    //                }

                    //            }
                    //        }
                    //        return await stepContext.EndDialogAsync(null, cancellationToken);
                    //    }
                    //}
                    //else
                    //{

                    //    await stepContext.Context.SendActivityAsync(
                    //           MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //    return await stepContext.EndDialogAsync(null, cancellationToken);

                    //}



                    //return await stepContext.EndDialogAsync(null, cancellationToken);

                    //  return await stepContext.ContinueDialogAsync(cancellationToken);

                    // return await stepContext.ReplaceDialogAsync("MainDialog",bookingDetails,cancellationToken);
                }
            }
            return(await stepContext.EndDialogAsync(null, cancellationToken));
        }
示例#2
0
        private async Task <DialogTurnResult> OriginStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var incidentDetails = (IncidentDetails)stepContext.Options;

            if (((IncidentDetails)stepContext.Options).Incident_No == null)
            {
                incidentDetails.Incident_No = (string)stepContext.Result.ToString().ToUpper();
            }


            string concat = "";


            SNOWLogger nOWLoggerforinc = new SNOWLogger(Configuration);


            if ((incidentDetails.Incident_No != null))
            {
                if (!(incidentDetails.Incident_No.Equals("")))


                {
                    incident_Api_Result = nOWLoggerforinc.GetIncident(incidentDetails.Incident_No.ToUpper());

                    apiresult = nOWLoggerforinc.GetIncidentDetails(incidentDetails.Incident_No.ToUpper());



                    if (incident_Api_Result != null && apiresult != null)
                    {
                        if (incident_Api_Result.Result.Count != 0 && apiresult.result.Count != 0)
                        {
                            for (int i = 0; i < incident_Api_Result.Result.Count; i++)
                            {
                                concat += " \n " + apiresult.result[i].number + ":" + apiresult.result[i].short_description + " \n Status: " + incident_Api_Result.Result[i].value + " \n Active:" + apiresult.result[i].active;
                            }


                            // Cards are sent as Attachments in the Bot Framework.
                            // So we need to create a list of attachments for the reply activity.
                            var attachments = new List <Attachment>();

                            // Reply to the activity we received with an activity.
                            var reply = MessageFactory.Attachment(attachments);

                            reply.Attachments.Add(Cards.GetHeroCardforStatus(apiresult.result[0].number, apiresult.result[0].short_description, incident_Api_Result.Result[0].value).ToAttachment());

                            await stepContext.Context.SendActivityAsync(reply, cancellationToken);



                            return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                                 new PromptOptions
                            {
                                Prompt = MessageFactory.Text("Are you satisfied ? if not please select."),
                                Choices = ChoiceFactory.ToChoices(new List <string> {
                                    "comment", "Escalate", "Satisfied"
                                }),
                            }, cancellationToken));

                            //await stepContext.Context.SendActivityAsync(MessageFactory.Text(concat), cancellationToken);
                            //  return await stepContext.EndDialogAsync(null, cancellationToken);
                            //  return await stepContext.NextAsync(stepContext, cancellationToken);
                        }
                        else
                        {
                            if (incident_Api_Result.Result.Count == 0)
                            {
                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text(" Incident is not yet updated by team"), cancellationToken);

                                //  return await stepContext.EndDialogAsync(null, cancellationToken);
                                //return await stepContext.NextAsync(stepContext, cancellationToken);

                                return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                                     new PromptOptions
                                {
                                    Prompt = MessageFactory.Text("Are you satisfied ? if Not please select."),
                                    Choices = ChoiceFactory.ToChoices(new List <string> {
                                        "Comment", "Escalate", "Satisfied"
                                    }),
                                    // Choices = ChoiceFactory.ToChoices(new List<string> { "Add my comment for SNOW team", "Escalate this issue", "I am Satisfied" }),
                                }, cancellationToken));
                            }
                            else if (apiresult.result.Count == 0)
                            {
                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text("No Incident update Found:"), cancellationToken);

                                //   return await stepContext.EndDialogAsync(null, cancellationToken);
                                //  return await stepContext.NextAsync(stepContext, cancellationToken);
                            }
                        }
                    }
                    else
                    {
                        await stepContext.Context.SendActivityAsync(
                            MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                        //  return await stepContext.EndDialogAsync(null, cancellationToken);
                        return(await stepContext.NextAsync(stepContext, cancellationToken));
                    }


                    //        {

                    //            //                        return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Sorry no details found for " + stepContext.Context.Activity.Text) }, cancellationToken);
                    //            if (incident_Api_Result == null)
                    //            {
                    //                await stepContext.Context.SendActivityAsync(
                    //          MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //                return await stepContext.EndDialogAsync(null, cancellationToken);
                    //            }
                    //            else

                    //            if (incident_Api_Result != null)
                    //            {

                    //                if (incident_Api_Result.Result.Count != 0)
                    //                {
                    //                    await stepContext.Context.SendActivityAsync(
                    //                    MessageFactory.Text(" Sorry no update found for: " + incident_Api_Result.Result[0].number.ToString()), cancellationToken);

                    //                    return await stepContext.EndDialogAsync(null, cancellationToken);
                    //                }
                    //                else
                    //                {
                    //                    await stepContext.Context.SendActivityAsync(
                    //                MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //                    return await stepContext.EndDialogAsync(null, cancellationToken);
                    //                }

                    //            }
                    //        }
                    //        return await stepContext.EndDialogAsync(null, cancellationToken);
                    //    }
                    //}
                    //else
                    //{

                    //    await stepContext.Context.SendActivityAsync(
                    //           MessageFactory.Text(" Sorry no incident update found"), cancellationToken);

                    //    return await stepContext.EndDialogAsync(null, cancellationToken);

                    //}



                    //return await stepContext.EndDialogAsync(null, cancellationToken);

                    //  return await stepContext.ContinueDialogAsync(cancellationToken);

                    // return await stepContext.ReplaceDialogAsync("MainDialog",incidentDetails,cancellationToken);
                }
            }


            //return await stepContext.EndDialogAsync(null, cancellationToken);
            return(await stepContext.NextAsync(stepContext, cancellationToken));
        }