public async Task LookupTableRow(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "Tables", "LookupTableRow");

            string workbookId = String.Empty;

            context.UserData.TryGetValue <string>("WorkbookId", out workbookId);

            var name = LuisHelper.GetNameEntity(result.Entities);

            if (name != null)
            {
                context.UserData.SetValue <string>("TableName", name);

                context.UserData.SetValue <ObjectType>("Type", ObjectType.Table);
                context.UserData.SetValue <string>("Name", name);
            }

            Value = (LuisHelper.GetValue(result))?.ToString();

            if (!(String.IsNullOrEmpty(workbookId)))
            {
                await TablesWorker.DoLookupTableRow(context, (string)Value);

                context.Wait(MessageReceived);
            }
            else
            {
                context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_LookupTableRow);
            }
        }
        public async Task SelectWorksheet(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "Worksheets", "SelectWorksheet");

            string workbookId = String.Empty;

            context.UserData.TryGetValue <string>("WorkbookId", out workbookId);

            WorksheetName = LuisHelper.GetNameEntity(result.Entities);

            if (!(String.IsNullOrEmpty(workbookId)))
            {
                if (!(String.IsNullOrEmpty(WorksheetName)))
                {
                    await WorksheetWorker.DoSelectWorksheetAsync(context, WorksheetName);

                    context.Wait(MessageReceived);
                }
                else
                {
                    // Call the SelectWorksheet Form
                    SelectWorksheetForm.Worksheets = await WorksheetWorker.GetWorksheetNamesAsync(context, workbookId);

                    context.Call <SelectWorksheetForm>(
                        new FormDialog <SelectWorksheetForm>(new SelectWorksheetForm(), SelectWorksheetForm.BuildForm, FormOptions.PromptInStart),
                        SelectWorksheet_FormComplete);
                }
            }
            else
            {
                context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SelectWorksheet);
            }
        }
        public async Task GetNamedItemValue(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "NamedItems", "GetNamedItemValue");

            var name = LuisHelper.GetNameEntity(result.Entities);

            if (!(String.IsNullOrEmpty(name)))
            {
                context.UserData.SetValue <string>("Name", name);
                context.UserData.SetValue <ObjectType>("Type", ObjectType.NamedItem);

                string workbookId = String.Empty;
                context.UserData.TryGetValue <string>("WorkbookId", out workbookId);

                if (!(String.IsNullOrEmpty(workbookId)))
                {
                    await NamedItemsWorker.DoGetNamedItemValue(context);

                    context.Wait(MessageReceived);
                }
                else
                {
                    context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_GetNamedItemValue);
                }
            }
            else
            {
                await context.PostAsync($"You need to provide a name to get the value");

                context.Wait(MessageReceived);
            }
        }
예제 #4
0
        public async Task SetActiveCellValue(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "Cells", "SetActiveCellValue");

            ObjectType?type = null;

            context.UserData.TryGetValue <ObjectType?>("Type", out type);

            var name = LuisHelper.GetNameEntity(result.Entities);

            if (!string.IsNullOrEmpty(name))
            {
                context.UserData.SetValue <string>("Name", name);
            }

            Value = LuisHelper.GetValue(result);

            string workbookId = String.Empty;

            context.UserData.TryGetValue <string>("WorkbookId", out workbookId);

            if (!(String.IsNullOrEmpty(workbookId)))
            {
                await NamedItemsWorker.DoSetNamedItemValue(context, Value);

                context.Wait(MessageReceived);
            }
            else
            {
                context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SetActiveCellValue);
            }
        }
        public async Task AddTableRow(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "Tables", "AddTableRow");

            // Extract the name of the table from the query and save it
            var name = LuisHelper.GetNameEntity(result.Entities);

            if (name != null)
            {
                context.UserData.SetValue <string>("TableName", name);

                context.UserData.SetValue <ObjectType>("Type", ObjectType.Table);
                context.UserData.SetValue <string>("Name", name);
            }

            // Get the new table row from the query and persist it in the dialog
            Rows = new object[]
            {
                LuisHelper.GetTableRow(result.Entities, result.Query)
            };

            // Check if there is an open workbook and add the row to the table
            string workbookId = String.Empty;

            context.UserData.TryGetValue <string>("WorkbookId", out workbookId);

            if (!(String.IsNullOrEmpty(workbookId)))
            {
                await TablesWorker.DoAddTableRow(context, Rows);

                context.Wait(MessageReceived);
            }
            else
            {
                context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_AddTableRow);
            }
        }