public async Task Actions(IDialogContext context, LuisResult result) { string response = _help.GetHelp(); string action = result.Entities.FirstOrDefault(entity => entity.Type == "ACTION").Entity; if (_actions.Any(item => item.Parse(result))) { response = _actions.FirstOrDefault(item => item.Parse(result)).GetResponse(result.Entities); await context.PostAsync(response.ToString()); context.Wait(this.MessageReceived); return; } if (action.ToLowerInvariant().Contains("introducir")) { var insert = new InsetConsumtion(); var InsetConsumtionFormDialog = new FormDialog <InsetConsumtion>(insert, this.BuildInsertForm, FormOptions.PromptInStart, result.Entities); context.Call(InsetConsumtionFormDialog, this.ResumeAfterInsert); return; } if (action.ToLowerInvariant().Contains("contratar")) { var contract = new Contract(); var ContractFormDialog = new FormDialog <Contract>(contract, this.BuildContractForm, FormOptions.PromptInStart, result.Entities); context.Call(ContractFormDialog, this.ResumeAfterContract); return; } context.Wait(this.MessageReceived); return; }
/// <summary> /// Parses input parameters and finds the correct service and command handler for executing the command. /// </summary> /// <param name="input"> /// User input from command line arguments, split into list of parameters separated by space. /// Commands are structured as follows: [command] [subCommand] [options] /// </param> /// <returns>A commandHandler that can execute the command given by user input</returns> private ISubCommandHandler ProcessArgs(string[] input) { ISubCommandHandler subCommandHandler = ServiceProvider.GetServices <ISubCommandHandler>() .FirstOrDefault(s => string.Equals(s.Name, input[1], StringComparison.OrdinalIgnoreCase) && string.Equals(s.CommandProvider, input[0], StringComparison.OrdinalIgnoreCase)); if (subCommandHandler != null) { subCommandHandler.BuildSelectableCommands(); subCommandHandler.DictOptions = ParseArguments(input); OptionBuilder.Instance(_logger).AssignValueToCliOptions(subCommandHandler); return(subCommandHandler); } // No command found, find help command to display help. IHelp helpService = ServiceProvider.GetServices <IHelp>().FirstOrDefault(); if (helpService != null) { helpService.GetHelp(); } else { _logger.LogError("Help is not found"); } return(null); }
public async Task Actions(IDialogContext context, LuisResult result) { string response = _help.GetHelp(); string action = result.Entities.FirstOrDefault(entity => entity.Type == "ACTION").Entity; if (_actions.Any(item => item.Parse(action))) { response = _actions.FirstOrDefault(item => item.Parse(action)).GetQuestion(result.Entities); } await context.PostAsync(response.ToString()); //if (result.Entities != null && result.Entities.Any(item => item.Type == "SERVICE_TYPE")) //{ await context.PostAsync($"Quieres contratar un servicio de {result.Entities.FirstOrDefault(item => item.Type == "SERVICE_TYPE").Entity}, ¿correcto?"); } //if (result.Entities != null && !result.Entities.Any(item => item.Type == "SERVICE_TYPE")) //{ await context.PostAsync($"Quieres contratar un servicio, ¿de que tipo?"); } context.Wait(this.MessageReceived); }
public void GetHelp(int helpConstant) { // the front end can only handle help request about front end if (helpConstant != INTERMEDIATE_LAYER_HELP) { // it should pass the hep request to the next object in the chain _successor.GetHelp(helpConstant); } else { Console.WriteLine("This is intermediate layer"); } }
public void GetHelp(int helpConstant) { // the front end can only handle help request about front end if (helpConstant != FROM_END_HELP) { // it should pass the hep request to the next object in the chain _successor.GetHelp(helpConstant); } else { Console.WriteLine("This the Frond end Layer"); } }