예제 #1
0
 public async Task AddVisitors(IDialogContext context, IAwaitable <object> result)
 {
     RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(21);
     SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
     PromptDialog.Choice(context, this.MoreVisitors, new List <string>()
       {
           AddOption, RemoveOption
       }, RootDialog.BotResponse);
 }
예제 #2
0
      public async Task EnterContactName(IDialogContext context, IAwaitable <object> result)
      {
          var    activity    = await result as Activity;
          string contactname = activity.Text;

          try

          {
              using (HttpClient httpClient = new HttpClient())
              {
                  LuisResponse Data = new LuisResponse();

                  var responseInString = await httpClient.GetStringAsync(@"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/daac86e9-b94a-4897-9f5e-3dea98dc3cde?staging=true&verbose=true&timezoneOffset=-360&subscription-key=60c884e98ad84389b452b71ed84894b4&q="

                                                                         + System.Uri.EscapeDataString(contactname));

                  Data = JsonConvert.DeserializeObject <LuisResponse>(responseInString);



                  var    intent     = Data.topScoringIntent.intent;
                  string IntentName = intent;
                  var    score      = Data.topScoringIntent.score;

                  if (IntentName == "VisitorNameIntent" && score > 0.8)

                  {
                      contactname             = Data.entities[0].entity.ToString();
                      RootDialog.UserResponse = contactname;
                      VisitorData.ContactName = contactname.ToString();
                      RootDialog.BotResponse  = SQLManager.GetVisitorBadgeQuestions(8);
                      await context.PostAsync(RootDialog.BotResponse);

                      SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);


                      this.GetStartDate(context, result);
                  }


                  else

                  {
                      await context.PostAsync("please enter the  valid contact name");

                      context.Wait(EnterDepartment);
                  }
              }
          }


          catch (Exception e)
          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //throw e;
          }
      }
예제 #3
0
 public async Task StartAsync(IDialogContext context)
 {
     RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(1);
     SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
     PromptDialog.Choice(context, this.OptionSelected, new List <string>()
     {
         ConfirmOption, RejectOption
     }, $"Sure {UserData.UserName}! {RootDialog.BotResponse}\n {UserData.UserID}\n{UserData.UserName}", "Not a valid options", 3);
 }
예제 #4
0
      public async Task CompanyName(IDialogContext context, IAwaitable <object> result)
      {
          RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(19);
          context.PostAsync(RootDialog.BotResponse);
          SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
          context.Wait(EnterCompanyName);

          //this.EnterCompanyNam
      }
예제 #5
0
      public async Task StartAsync(IDialogContext context)
      {
          RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(2);
          await context.PostAsync(RootDialog.BotResponse);

          SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

          context.Wait(EnterDepartment);
      }
예제 #6
0
        public async Task IssueCategory(IDialogContext context, IAwaitable <object> result)
        {
            List <string> category = new List <string>();

            category = SQLManager.ChooseIssueCategory();
            RootDialog.BotResponse = SQLManager.GetITQuestions(1);
            SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
            //await context.PostAsync(RootDialog.BotResponse);
            PromptDialog.Choice(context, this.ChooseIssue, category, RootDialog.BotResponse);
        }
예제 #7
0
      private async Task ExtractEndDate(IDialogContext context, IAwaitable <object> result)
      {
          var    Date    = await result as Activity;
          string EndDate = Date.Value.ToString();

          RootDialog.UserResponse = EndDate;


          if (EndDate == null)
          {
              RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(12);
              await context.PostAsync(RootDialog.BotResponse);

              SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
              // await context.PostAsync("Please input the date");
              context.Wait(GetStartDate);
          }
          else
          {
              DateTime currentDate = DateTime.Now.Date;

              string[] SplitDate = EndDate.ToString().Split('"', '{', '}', ':', 'd', 'a', 't', 'e', '\n');

              foreach (string i in SplitDate)
              {
                  if (i.Trim() != "")
                  {
                      UserEndDate += i;
                  }
              }
              RootDialog.UserResponse = UserEndDate;
              VisitorData.EndDate     = UserEndDate;
              if (DateTime.Parse(UserStartDate).Date <= DateTime.Parse(UserEndDate).Date)    //condition False
              {
                  RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(14);
                  await context.PostAsync(RootDialog.BotResponse);

                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

                  this.ConfirmParkingTicket(context, result);
              }
              else
              {
                  RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(13);
                  await context.PostAsync(RootDialog.BotResponse);

                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);


                  //await context.PostAsync($"Sorry, the date you have entered is invalid. Please check and enter Valid Date again.");
                  this.GetEndDate(context, result);
              }
          }
      }
예제 #8
0
      public async Task EnterCompanyName(IDialogContext context, IAwaitable <object> result)
      {
          var    activity    = await result as Activity;
          string CompanyName = activity.Text;

          VisitorData.CompanyName.Add(CompanyName);
          RootDialog.UserResponse = CompanyName;
          VisitorData.Company     = CompanyName;
          SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
          VisitorData.Company = CompanyName;
          await context.PostAsync($" company name is {CompanyName} ");

          this.AddVisitors(context, result);
      }
예제 #9
0
      public async Task VistorName(IDialogContext context, IAwaitable <object> result)
      {
          var    activity     = await result;
          string buildingname = activity.ToString();

          RootDialog.UserResponse  = buildingname;
          VisitorData.BuildingName = buildingname;
          RootDialog.BotResponse   = SQLManager.GetVisitorBadgeQuestions(18);
          await context.PostAsync(RootDialog.BotResponse);

          SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
          context.Wait(EnterVisitorName);
          //this.EnterVisitorName(context, result);
      }
예제 #10
0
        public async Task IssueDescription(IDialogContext context, IAwaitable <object> result)
        {
            var    activity    = await result as Activity;
            string description = activity.Text;

            RootDialog.UserResponse = description;
            RootDialog.BotResponse  = SQLManager.GetITQuestions(4);
            SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
            PromptDialog.Choice(context, this.RaiseIssue, new List <string>()
            {
                "Yes", "No"
            }, RootDialog.BotResponse);

            //await context.PostAsync("end flow");
        }
예제 #11
0
      public async Task EnterAnyComments(IDialogContext context, IAwaitable <object> result)
      {
          var    activity = await result as Activity;
          string Comments = activity.Text;

          RootDialog.UserResponse = Comments;
          VisitorData.Comment     = Comments;
          VisitorID = SQLManager.InsertVisitorData(UserData.UserID, VisitorData.ContactName, VisitorData.VisitorName, VisitorData.CompanyName, VisitorData.NeedParking, VisitorData.NoOfParkingTicket, VisitorData.BuildingName, VisitorData.StartDate, VisitorData.EndDate, VisitorData.Comment);
          RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(23);
          RootDialog.BotResponse = RootDialog.BotResponse.Replace("<ref. number>", VisitorID);
          await context.PostAsync(RootDialog.BotResponse);

          SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

          this.SendMail(context, result);
      }
예제 #12
0
        public async Task HardwareIssue(IDialogContext context, IAwaitable <string> result)
        {
            try

            {
                string optionSelected = await result;
                RootDialog.UserResponse = optionSelected;
                RootDialog.BotResponse  = SQLManager.GetITQuestions(3);
                await context.PostAsync(RootDialog.BotResponse);

                SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

                context.Wait(IssueDescription);
            }

            catch (Exception e)

            {
                await context.PostAsync("enter a valid option");
            }
        }
예제 #13
0
      public async Task NoOfParkingTickets(IDialogContext context, IAwaitable <object> result)
      {
          try
          {
              var activity = await result as Activity;
              int tickets  = Convert.ToInt16(activity.Text);
              VisitorData.NoOfParkingTicket = tickets;
              RootDialog.UserResponse       = activity.Text;
              RootDialog.BotResponse        = SQLManager.GetVisitorBadgeQuestions(16);
              await context.PostAsync(RootDialog.BotResponse);

              SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

              this.SelectBuilding(context, result);
          }
          catch (Exception e)
          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //throw e;
          }
      }
예제 #14
0
      public async Task MoreVisitors(IDialogContext context, IAwaitable <string> result)
      {
          try

          {
              string optionSelected = await result;
              RootDialog.UserResponse = optionSelected;
              //RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(21);


              switch (optionSelected)

              {
              case AddOption:
                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                  context.Wait(VistorName);

                  break;

              case RemoveOption:
                  RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(22);
                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                  await context.PostAsync(RootDialog.BotResponse);

                  context.Wait(EnterAnyComments);


                  //context.Call(new RejectDialog(), this.ResumeAfterOptionDialog);

                  break;
              }
          }

          catch (Exception e)

          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              // await context.PostAsync("enter a valid option");
          }
      }
예제 #15
0
      public async Task OptionSelected(IDialogContext context, IAwaitable <string> result)
      {
          try

          {
              string optionSelected = await result;
              //RootDialog.UserResponse = optionSelected;
              //VisitorData.NeedParking = Convert.ToBoolean(optionSelected);
              switch (optionSelected)

              {
              case YesOption:
                  VisitorData.NeedParking = true;
                  RootDialog.UserResponse = VisitorData.NeedParking.ToString();
                  RootDialog.BotResponse  = SQLManager.GetVisitorBadgeQuestions(15);
                  await context.PostAsync(RootDialog.BotResponse);

                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);

                  context.Wait(NoOfParkingTickets);

                  break;

              case NoOption:
                  VisitorData.NeedParking = false;
                  RootDialog.UserResponse = VisitorData.NeedParking.ToString();
                  this.SelectBuilding(context, result);
                  //context.Call(new RejectDialog(), this.ResumeAfterOptionDialog);

                  break;
              }
          }

          catch (Exception e)

          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //await context.PostAsync("enter a valid option");
          }
      }
예제 #16
0
        public async Task ChooseIssue(IDialogContext context, IAwaitable <string> result)
        {
            try

            {
                string optionSelected = await result;
                RootDialog.UserResponse = optionSelected;

                List <string> Issues = new List <string>();
                Issues = SQLManager.GetIssueName(optionSelected.ToString());

                switch (optionSelected)

                {
                case "Software":
                    RootDialog.BotResponse = SQLManager.GetITQuestions(2);
                    SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                    PromptDialog.Choice(context, this.SoftwareIssue, Issues, RootDialog.BotResponse);



                    break;

                case "Hardware":
                    RootDialog.BotResponse = SQLManager.GetITQuestions(3);
                    SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                    PromptDialog.Choice(context, this.HardwareIssue, Issues, RootDialog.BotResponse);


                    break;
                }
            }

            catch (Exception e)

            {
                await context.PostAsync("enter a valid option");
            }
        }
예제 #17
0
        public async Task RaiseIssue(IDialogContext context, IAwaitable <string> result)
        {
            RootDialog root = new RootDialog();

            try

            {
                string optionSelected = await result;
                RootDialog.UserResponse = optionSelected;
                switch (optionSelected)

                {
                case "Yes":
                    RootDialog.BotResponse = SQLManager.GetITQuestions(5);
                    await context.PostAsync(RootDialog.BotResponse);

                    SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                    root.StartAsync(context);


                    break;

                case "No":
                    root.StartAsync(context);

                    break;
                }
            }

            catch (Exception e)

            {
                SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
                // await context.PostAsync("enter a valid option");
            }
        }