private async Task RunbookParameterFormComplete(IDialogContext context, IAwaitable <RunbookParameterFormState> result) { try { var runbookParameterFormState = await result; await this.RunbookParametersFormComplete(context, runbookParameterFormState); } catch (FormCanceledException <RunbookParameterFormState> e) { context.CleanupRunbookFormState(); string reply; if (e.InnerException == null) { reply = "You have canceled the operation. What would you like to do next?"; } else { reply = $"Oops! Something went wrong :(. Technical Details: {e.InnerException.Message}"; } await context.PostAsync(reply); context.Done <string>(null); } }
private async Task RunbookParametersFormComplete(IDialogContext context, RunbookParameterFormState runbookParameterFormState) { var runbookFormState = context.GetRunbookFormState(); if (runbookParameterFormState != null) { runbookFormState.RunbookParameters.Add(runbookParameterFormState); context.StoreRunbookFormState(runbookFormState); } var nextRunbookParameter = runbookFormState.SelectedRunbook.RunbookParameters.OrderBy(param => param.Position).FirstOrDefault( availableParam => !runbookFormState.RunbookParameters.Any(stateParam => availableParam.ParameterName == stateParam.ParameterName)); if (nextRunbookParameter == null) { context.CleanupRunbookFormState(); await this.RunbookFormComplete(context, runbookFormState); return; } var formState = new RunbookParameterFormState(nextRunbookParameter.IsMandatory, nextRunbookParameter.Position == 0, runbookFormState.SelectedRunbook.RunbookName) { ParameterName = nextRunbookParameter.ParameterName }; var form = new FormDialog <RunbookParameterFormState>( formState, AutomationForms.BuildRunbookParametersForm, FormOptions.PromptInStart); context.Call(form, this.RunbookParameterFormComplete); }