private async Task ResumeAfterFilterPickerDialogWithDadMeasure(IDialogContext context, IAwaitable <FilterResult> result) { try { try { var isQuit = await HandleQuitAsync(context); if (!isQuit) { FilterResult currentFilterChoice = await result; if (!filterValues.ContainsKey(currentFilterChoice.filterName) && !currentFilterChoice.filterValue.Equals("clear", StringComparison.OrdinalIgnoreCase)) { filterValues.Add(currentFilterChoice.filterName, currentFilterChoice.filterValue); } else if (currentFilterChoice.filterValue.Equals("clear", StringComparison.OrdinalIgnoreCase)) { filterValues.Remove(currentFilterChoice.filterName); await context.PostAsync($"Removing filter {currentFilterChoice.filterName}"); } else { filterValues[currentFilterChoice.filterName] = currentFilterChoice.filterValue; } await context.PostAsync("Please wait while we apply the filters."); DeviceType dt = string.Equals(context.UserData.GetValue <string>(deviceTypeKey), "oasis", StringComparison.OrdinalIgnoreCase) ? DeviceType.Oasis : DeviceType.Hololens; isCurrentContextOasis = (dt == DeviceType.Oasis); string dadString = "DAD"; string measureName = string.Join(",", filterValues.Values); SSASTabularModel.CreateNewDadMeasure($"{dadString} - " + measureName, measureName, filterValues, dt); var resultMessage = context.MakeMessage(); resultMessage.Text = $"New measure is created and the name of the measure is \"{dadString} - {measureName}\"."; await context.PostAsync(resultMessage); } } catch (TooManyAttemptsException) { await context.PostAsync("I'm sorry, I'm having issues understanding you. Let's try again."); } } finally { await LoopFilterAsyncWithDadMeasure(context); } }
public async Task ShowMad(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result) { var message = await activity; message.Text = $"Let me get the MAD for you..."; await context.PostAsync(message.Text); //var text = "<table><tr><th>heading 1</th><th>heading 2</th></tr><tr><td>row 1 column 1</td><td>row 1 column 2</td></tr><tr><td>row 2 column 1</td><td>row 2 column 2</td></tr></table>"; //await context.PostAsync(text); if (result.TryFindEntity(DeviceTypeEntity, out deviceType)) { deviceType.Type = "DeviceType"; } if (string.Equals(deviceType.Entity, "vr", StringComparison.OrdinalIgnoreCase) || string.Equals(deviceType.Entity, "oasis", StringComparison.OrdinalIgnoreCase)) { isCurrentContextOasis = true; var mad = SSASTabularModel.GetMadNumber(new Dictionary <string, object>(), DeviceType.Oasis); var resultMessage = context.MakeMessage(); resultMessage.Text = $"Mad for Oasis is **{mad}**"; context.UserData.Clear(); context.UserData.SetValue(deviceTypeKey, "Oasis"); context.UserData.SetValue(metricTypeKey, "mad"); await context.PostAsync(resultMessage); context.Call(new RefinementPickerDialog(filterValues, slicerValues, firstRun: true, showFilterDialog: true, isOasis: isCurrentContextOasis), this.ResumeAfterFilterDialog); } else { isCurrentContextOasis = false; var mad = SSASTabularModel.GetMadNumber(new Dictionary <string, object>(), DeviceType.Hololens); var resultMessage = context.MakeMessage(); resultMessage.Text = $"Mad for Hololens is **{mad}**"; context.UserData.Clear(); context.UserData.SetValue(deviceTypeKey, "Hololens"); context.UserData.SetValue(metricTypeKey, "mad"); await context.PostAsync(resultMessage); context.Call(new RefinementPickerDialog(filterValues, slicerValues, firstRun: true, showFilterDialog: true, isOasis: isCurrentContextOasis), this.ResumeAfterFilterDialog); } }
private async Task ResumeAfterSlicerDialog(IDialogContext context, IAwaitable <FilterResult> result) { try { FilterResult currentFilterChoice = await result; if (currentFilterChoice.filterName.Equals(SlicerPickerDialog.filterSwitchText, StringComparison.OrdinalIgnoreCase)) { context.Call(new RefinementPickerDialog(filterValues, slicerValues, firstRun: false, showFilterDialog: true, isOasis: isCurrentContextOasis), this.ResumeAfterFilterDialog); } else { if (!slicerValues.Contains(currentFilterChoice.filterName)) { slicerValues.Add(currentFilterChoice.filterName); } else { slicerValues.Remove(currentFilterChoice.filterName); await context.PostAsync($"Removing slicer {currentFilterChoice.filterName}"); } string filterString = "Your current filters are: "; foreach (var filter in filterValues.Keys) { filterString += $" filter = {filter}, value = {filterValues[filter]}" + Environment.NewLine; } await context.PostAsync(filterString); string slicerString = "Your current slicers are: "; foreach (var slicer in slicerValues) { slicerString += $" slicer = {slicer}" + Environment.NewLine; } await context.PostAsync(slicerString); await context.PostAsync("Please wait while we apply the slicers."); DeviceType dt = string.Equals(context.UserData.GetValue <string>(deviceTypeKey), "oasis", StringComparison.OrdinalIgnoreCase) ? DeviceType.Oasis : DeviceType.Hololens; string madDadValue = context.UserData.GetValue <string>(metricTypeKey).ToUpper(); IMessageActivity resultMessage; if (slicerValues.Count > 0) { await context.PostAsync("One or more slicers selected, displaying results as a table..."); var groupByData = string.Equals(madDadValue, "mad", StringComparison.OrdinalIgnoreCase) ? SSASTabularModel.ExecuteGroupByMad(slicerValues, filterValues, dt) : SSASTabularModel.ExecuteGroupByDad(slicerValues, filterValues, dt); var tableResponse = BuildGroupByTable(slicerValues, groupByData); resultMessage = context.MakeMessage(); resultMessage.Text = $"The {madDadValue} data with the requested grouping is: {Environment.NewLine}{tableResponse}"; } else { await context.PostAsync("No slicers selected, returning a single value..."); var newValue = string.Equals(madDadValue, "mad", StringComparison.OrdinalIgnoreCase) ? SSASTabularModel.GetMadNumber(filterValues, dt) : SSASTabularModel.GetDadNumber(filterValues, dt); resultMessage = context.MakeMessage(); resultMessage.Text = $"The new {madDadValue} value is **{newValue}**"; } await context.PostAsync(resultMessage); // loop back and show filters/slicers again await LoopFilterSlicerAsync(context, false); } } catch (TooManyAttemptsException) { await context.PostAsync("I'm sorry, I'm having issues understanding you. Let's try again."); } }