Ejemplo n.º 1
0
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if ((bool)stepContext.Result)
            {
                var incidentDetails = (IncidentDetails)stepContext.Options;

                SNOWLogger nOWLogger1 = new SNOWLogger(Configuration);

                string incident1 = nOWLogger1.CreateIncidentServiceNow(incidentDetails.Short_desc, incidentDetails.Descrip, incidentDetails.GetPrioritycode(incidentDetails.Priority));



                if (incident1 != null)
                {
                    string[] strList = incident1.Split(",");


                    // 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.GetHeroCard(strList[0], strList[1], incidentDetails.Short_desc, incidentDetails.Descrip, incidentDetails.Priority).ToAttachment());

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



                    //  await stepContext.Context.SendActivityAsync(
                    //MessageFactory.Text("Incident No: "+ incident1+" Created for: "+incidentDetails.Short_desc+ "\n is there anything I can help you with ?", null,null));
                    stepContext.Context.TurnState.Add("incID", incidentDetails);

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

                // return await stepContext.EndDialogAsync(null, cancellationToken);
            }
            else
            {
                await stepContext.Context.SendActivityAsync(
                    MessageFactory.Text("Incident creation aborted ! \n is there anything I can help you with ? ", null, null));

                // stepContext = null;


                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }
        static void Main(string[] args)
        {
            int    x = 1, y = 0, z;
            string incNo = string.Empty;

            try
            {
                z = x / y;
            }
            catch (Exception ex)
            {
                incNo = SNOWLogger.CreateIncidentServiceNow(ex.Message, "My App's exception : " + ex.StackTrace);

                Console.WriteLine("SNOW Incident Number : " + incNo);
            }
        }
Ejemplo n.º 3
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var    bookingDetails = stepContext.Result != null;
            string incidentno     = null;

            if (stepContext.Result != null)


            {
                string     shortds   = stepContext.Result.ToString();
                SNOWLogger nOWLogger = new SNOWLogger(Configuration);
                incidentno = nOWLogger.CreateIncidentServiceNow(shortds, "long des");
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Incident: " + incidentno + " created Successfully for : " + shortds) }, cancellationToken));
            }

            else
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Thank you."), cancellationToken);
            }
            return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));

            await stepContext.EndDialogAsync(cancellationToken : cancellationToken);

            //           ?
            //        await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
            //             :
            //        new BookingDetails();

            // In this sample we only have a single Intent we are concerned with. However, typically a scenario
            // will have multiple different Intents each corresponding to starting a different child Dialog.

            // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
            // return await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken);
            // return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(incidentno) }, cancellationToken);
        }