public async Task StateIntent(IDialogContext context, LuisResult result) { string state = BillDialogUtil.GetEntityState(result); if (state != null && state != "" && state != "nothing") { Continuity.SetSavedState(context, state); } else { state = Continuity.GetSavedState(context); } await context.PostAsync("All hail the great state of " + state + "."); context.Wait(MessageReceived); }
public async Task FindIntent(IDialogContext context, LuisResult result) { try { string CurState; CurState = Continuity.GetSavedState(context); string SearchTerm = BillDialogUtil.GetSearchTerm(result); string CurVoter; CurVoter = Continuity.GetSavedLegislator(context); DateTime MinTime; DateTime MaxTime; bool Ok = BillDialogUtil.GetEntityDateRange(result, out MinTime, out MaxTime); // if (Ok) { // await context.PostAsync($"SearchTerm = {SearchTerm} MinTime = {MinTime}, MaxTime = {MaxTime}"); // // context.Wait(MessageReceived); OpenStateClientLib.OpenStateClient cli = new OpenStateClientLib.OpenStateClient(); Newtonsoft.Json.Linq.JArray arr = await cli.GetBillsFilteredAsync(CurState, MinTime, MaxTime, SearchTerm, null, ExtraGuiActionBill); int CurrentBill = 0; bool WillBeMore; int MaxToShow = Continuity.NumBillsToShowInGroup; if (MaxToShow >= arr.Count) { MaxToShow = arr.Count; WillBeMore = false; } else { WillBeMore = true; } bool MoreToDisplay = false; for (int ii = 0; ii < MaxToShow; ii++) { CurrentBill = ii; MoreToDisplay = (ii >= (arr.Count - 1)); await BillDialogUtil.DisplayOneBill(context, arr[ii], CurState, CurVoter); } if (MoreToDisplay) { await context.PostAsync("Type 'More' to see more bills.\n"); } // context.ConversationData.SetValue(KeyBillNumber, CurrentBill + 1); Continuity.SetSavedBillNumber(context, CurrentBill + 1); if (WillBeMore) { // context.ConversationData.SetValue(KeyBillResults, arr); Continuity.SetSavedBills(context, arr); if (SearchTerm != null && SearchTerm != "") { await context.PostAsync($"Type 'More' to see more '{SearchTerm}' bills.\n"); } else { await context.PostAsync("Type 'More' to see more bills.\n"); } } else { Continuity.RemoveSavedBills(context); } } context.Wait(MessageReceived); } catch (System.Exception) { } }
public async Task LegislatorIntent(IDialogContext context, LuisResult result) { // await context.PostAsync("result.Query = " + result.Query); // context.Wait(MessageReceived); string State = Continuity.GetSavedState(context); if (State == null || State == "") { await context.PostAsync("No State selected" + "."); context.Wait(MessageReceived); return; } string SearchTerm = BillDialogUtil.GetSearchTerm(result); OpenStateClientLib.OpenStateClient cli = new OpenStateClientLib.OpenStateClient(); OpenStateClientLib.LegeSet lset = await cli.GetStatePeopleAsync(State); if (lset == null) { await context.PostAsync("Cannot get legislator list" + "."); context.Wait(MessageReceived); return; } string Summary = lset.SummarizeLeges(); if (SearchTerm == null || SearchTerm == "") { string OldLegislator = Continuity.GetSavedLegislator(context); if (OldLegislator != null && OldLegislator != "") { Summary += "Selected Legislator is " + OldLegislator + "!\n"; } // await context.PostAsync(Summary); await PostIt(context, Summary); context.Wait(MessageReceived); return; } if (SearchTerm != null || SearchTerm != "") { Continuity.SetSavedLegislator(context, SearchTerm); string Msg; if (SearchTerm.ToLower() == "all") { string Msg2 = $"We will show the votes made by all legislators\nwhen you search for bills."; Msg = Msg2; await context.PostAsync(Msg); context.Wait(MessageReceived); return; } else if (SearchTerm.ToLower() == "none") { string Msg2 = $"We will show no votes made by legislators\nwhen you search for bills."; Msg = Msg2; await context.PostAsync(Msg); context.Wait(MessageReceived); return; } else { int NumFound = lset.FindLegislator(SearchTerm, out Msg); if (NumFound == 1) { string Msg2 = $"We will show the votes made by this legislator\nwhen you search for bills."; Msg += ("\n" + Msg2); await context.PostAsync(Msg); context.Wait(MessageReceived); return; } if (NumFound >= 0) { string Msg2 = $"We will show the votes made by these legislators\nwhen you search for bills."; Msg += ("\n" + Msg2); await context.PostAsync(Msg); context.Wait(MessageReceived); return; } else { await context.PostAsync(Msg); context.Wait(MessageReceived); return; } } } }
public async Task MoreIntent(IDialogContext context, LuisResult result) { int BillNumber = Continuity.GetSavedBillNumber(context); if (BillNumber < 0) { // none left await context.PostAsync("Not anymore bills to show."); context.Wait(MessageReceived); return; } string CurVoter = Continuity.GetSavedLegislator(context); Newtonsoft.Json.Linq.JArray arr = Continuity.GetSavedBills(context); string State = Continuity.GetSavedState(context); if (arr == null) { await context.PostAsync("No bills saved to show."); context.Wait(MessageReceived); return; } int NumLeft = arr.Count; if (BillNumber >= NumLeft) { // none left await context.PostAsync("No more bills to show."); context.Wait(MessageReceived); return; } int NumToShow = NumLeft; if (NumToShow > Continuity.NumBillsToShowInGroup) { NumToShow = Continuity.NumBillsToShowInGroup; } for (int i = BillNumber; i < BillNumber + NumToShow; i++) { if (arr != null && i < arr.Count) { await BillDialogUtil.DisplayOneBill(context, arr[i], State, CurVoter); } } BillNumber += NumToShow; if (BillNumber < arr.Count) { Continuity.SetSavedBillNumber(context, BillNumber); await context.PostAsync("Type 'More' to see more bills.\n"); } else { Continuity.SetSavedBills(context, null); Continuity.SetSavedBillNumber(context, -1); } }