Esempio n. 1
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 = string.Empty;

            context.UserData.TryGetValue <string>("Name", out 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 AfterConfirm_SetNamedItem(IDialogContext context, IAwaitable <bool> result)
 {
     if (await result)
     {
         await NamedItemsWorker.DoSetNamedItemValue(context, Value);
     }
     context.Wait(MessageReceived);
 }
        public async Task SetNamedItemValue(IDialogContext context, LuisResult result)
        {
            // Telemetry
            TelemetryHelper.TrackDialog(context, result, "NamedItems", "SetNamedItemValue");

            ObjectType type;

            if (!(context.UserData.TryGetValue <ObjectType>("Type", out type)))
            {
                type = ObjectType.NamedItem;
                context.UserData.SetValue <ObjectType>("Type", type);
            }

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

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

            Value = LuisHelper.GetValue(result);

            string workbookId = String.Empty;

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

            if (!(String.IsNullOrEmpty(name)))
            {
                string worksheetId = String.Empty;
                context.UserData.TryGetValue <string>("WorksheetId", out worksheetId);

                if (name != null)
                {
                    await NamedItemsWorker.DoSetNamedItemValue(context, Value);
                }
                else
                {
                    await context.PostAsync($"You need to provide a name to set the value");
                }
                context.Wait(MessageReceived);
            }
            else
            {
                context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SetNamedItem);
            }
        }