Пример #1
0
        private async Task IntentLogin(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        //private async Task<DialogTurnResult> IntentLogin(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            AdaptiveCardList adaptiveCardLogin = new AdaptiveCardList();
            var loginCard = adaptiveCardLogin.CreateAttachment(2, "");
            await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(loginCard), cancellationToken);

            await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

            //return await stepContext.BeginDialogAsync(nameof(LoginDialog), cancellationToken: cancellationToken);
        }
Пример #2
0
        private async Task <DialogTurnResult> EndDialog(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var stepContextResult = stepContext.Result.ToString();

            JObject InfoCard = JObject.Parse(stepContextResult);
            string  id       = (string)InfoCard["id"];

            if (id == "LoginCardAceptar")
            {
                string co_documento_identidad = (string)InfoCard["cboTipoDocumento"];
                string nu_documento_identidad = (string)InfoCard["txtNumeroDocumento"];
                string no_contrasena          = Funciones.GetSHA256(InfoCard["txtContrasena"].ToString());

                ContribuyenteClient contribuyenteClient = new ContribuyenteClient();
                var result = contribuyenteClient.GetLoginAsync(Globales.id_empresa, co_documento_identidad, nu_documento_identidad, no_contrasena);

                if (result.error_number == 0)
                {
                    Globales.OnSesion         = true;
                    Globales.id_contribuyente = result.Data.id_contribuyente;
                    Globales.no_contribuyente = result.Data.no_contribuyente;

                    await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, $"Hola {Globales.no_contribuyente}, en que te puedo ayudar?"), cancellationToken);
                }
                else
                {
                    Globales.OnSesion         = false;
                    Globales.id_contribuyente = 0;
                    Globales.no_token         = string.Empty;
                    Globales.no_contribuyente = string.Empty;

                    await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, $"{result.error_message}"), cancellationToken);
                }
            }
            else
            {
                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
            }

            /*
             *          var promptOptions = new PromptOptions
             *          {
             *              Prompt = MessageFactory.Text(value)
             *          };
             *          return await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken);
             */
            //await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
            //return await stepContext.EndDialogAsync(cancellationToken: cancellationToken);

            //await stepContext.Context.SendActivityAsync($"INPUT: {stepContext.Result}");
            return(await stepContext.NextAsync());
        }
        private async Task <DialogTurnResult> SetEstablecimientoCategoria(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var choice = (FoundChoice)stepContext.Result;

            if (choice.Value == ExitOption)
            {
                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?\n\n puedes utilizar los botones de la parte inferior."), cancellationToken);

                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }

            stepContext.Values["co_establecimiento_subclase"] = CodigoList[choice.Index];
            stepContext.Values["no_establecimiento_subclase"] = choice.Value;

            EstablecimientoCategoriaDTO establecimientoCategoriaDTO = new EstablecimientoCategoriaDTO()
            {
                co_establecimiento_clase     = Convert.ToString(stepContext.Values["co_establecimiento_clase"]),
                co_establecimiento_subclase  = CodigoList[choice.Index],
                co_establecimiento_categoria = "",
                no_establecimiento_categoria = "",
                fl_inactivo = "0"
            };

            CodigoList.Clear();
            DescripcionList.Clear();

            EstablecimientoCategoriaClient establecimientoCategoriaClient = new EstablecimientoCategoriaClient();
            var result = establecimientoCategoriaClient.GetAllAsync(establecimientoCategoriaDTO);

            if (result.error_number == 0)
            {
                foreach (EstablecimientoCategoriaDTO item in result.Data)
                {
                    CodigoList.Add(item.co_establecimiento_categoria);
                    DescripcionList.Add(item.no_establecimiento_categoria);
                }
            }
            CodigoList.Add("0");
            DescripcionList.Add(ExitOption);

            var options = DescripcionList.ToList();

            var promptOptions = new PromptOptions
            {
                Prompt  = MessageFactory.Text("Por favor seleccione una **Categoria de Establecimiento**:"),
                Choices = ChoiceFactory.ToChoices(options),
                Style   = ListStyle.List
            };

            // Prompt the user for a choice.
            return(await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions, cancellationToken));
        }
        private async Task <DialogTurnResult> EndDialog(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var choice = (FoundChoice)stepContext.Result;

            if (choice.Index == 0) //Confirmar
            {
                SolicitudLicenciaDTO solicitudLicenciaDTO = new SolicitudLicenciaDTO();
                solicitudLicenciaDTO.id_contribuyente             = Globales.id_contribuyente;
                solicitudLicenciaDTO.id_empresa                   = Globales.id_empresa;
                solicitudLicenciaDTO.co_tipo_licencia             = Convert.ToString(stepContext.Values["co_tipo_licencia"]);
                solicitudLicenciaDTO.no_comercial                 = Convert.ToString(stepContext.Values["no_comercial"]);
                solicitudLicenciaDTO.co_establecimiento_clase     = Convert.ToString(stepContext.Values["co_establecimiento_clase"]);
                solicitudLicenciaDTO.co_establecimiento_subclase  = Convert.ToString(stepContext.Values["co_establecimiento_subclase"]);
                solicitudLicenciaDTO.co_establecimiento_categoria = Convert.ToString(stepContext.Values["co_establecimiento_categoria"]);
                solicitudLicenciaDTO.no_direccion_solicitud       = Convert.ToString(stepContext.Values["no_direccion_solicitud"]);
                solicitudLicenciaDTO.co_ubigeo           = Convert.ToString(stepContext.Values["co_ubigeo"]);
                solicitudLicenciaDTO.nu_area             = Convert.ToDecimal(stepContext.Values["nu_area"]);
                solicitudLicenciaDTO.id_usuario_creacion = 2;// (2=Bot)

                SolicitudLicenciaClient solicitudLicenciaClient = new SolicitudLicenciaClient();
                var result = solicitudLicenciaClient.InsertAsync(solicitudLicenciaDTO);

                if (result.error_number == 0)
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Se ha creado su solicitud exitosamente.\n\n su número de solicitud es: **{DateTime.Now.Date.Year.ToString("0000-")}{result.id_identity.ToString("000000")}**\n\n se encuentra en estado **Pendiente de Aprobación**."), cancellationToken);
                }
                else
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text($"{result.error_message}"), cancellationToken);
                }
            }
            else //Rechazar
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("La información ingresada ha sido rechazada."), cancellationToken);
            }

            await Task.Delay(500);

            await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?\n\n puedes utilizar los botones de la parte inferior."), cancellationToken);

            return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
        }
        private async Task <DialogTurnResult> SetDireccion(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var choice = (FoundChoice)stepContext.Result;

            if (choice.Value == ExitOption)
            {
                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?\n\n puedes utilizar los botones de la parte inferior."), cancellationToken);

                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }

            stepContext.Values["co_ubigeo"]   = CodigoList[choice.Index];
            stepContext.Values["no_distrito"] = choice.Value;

            var promptOptions = new PromptOptions {
                Prompt = MessageFactory.Text("por favor ingresa la **Dirección del Establecimiento**:")
            };

            return(await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken));
        }
Пример #6
0
        private async Task IntentNone(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var resultQnA = await _qnaMakerAIService._qnaMakerResult.GetAnswersAsync(stepContext.Context);

            var    score    = resultQnA.FirstOrDefault()?.Score;  // Capturo el puntaje
            string response = resultQnA.FirstOrDefault()?.Answer; // Capturo la respuesta que devuelve Qna Maker

            if (score >= 0.5)
            {
                await stepContext.Context.SendActivityAsync(response, cancellationToken : cancellationToken);

                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?"), cancellationToken);
            }
            else
            {
                await Task.Delay(500);

                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "No entiendo lo que me dices, puedes utilizar los botones de la parte inferior."), cancellationToken);
            }
        }
Пример #7
0
        protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            foreach (var member in membersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    Globales.OnSesion         = false;
                    Globales.id_contribuyente = 0;
                    Globales.no_token         = string.Empty;
                    Globales.no_contribuyente = string.Empty;

                    AdaptiveCardList adaptiveCard = new AdaptiveCardList();
                    var nameCard = adaptiveCard.CreateAttachment(0, "");
                    await turnContext.SendActivityAsync(MessageFactory.Attachment(nameCard), cancellationToken);

                    await Task.Delay(500);

                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?\n\n puedes utilizar los botones de la parte inferior."), cancellationToken);
                }
            }
        }
Пример #8
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            //Logger.LogInformation("Running dialog with Message Activity.");

            var GoMainDialog = true;

            if (turnContext.Activity.Type == ActivityTypes.Message)
            {
                var activity = turnContext.Activity;

                if (activity.Text != null && activity.Value == null)
                {
                    switch (activity.Text)
                    {
                    case "Inicio":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Iniciar Sesion":
                        GoMainDialog = false;

                        AdaptiveCardList adaptiveCardLogin = new AdaptiveCardList();
                        var loginCard = adaptiveCardLogin.CreateAttachment(2, "");
                        await turnContext.SendActivityAsync(MessageFactory.Attachment(loginCard), cancellationToken);

                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Cerrar Sesion":
                        GoMainDialog = false;

                        string mensaje = Globales.no_contribuyente;
                        Globales.OnSesion         = false;
                        Globales.id_contribuyente = 0;
                        Globales.no_token         = string.Empty;
                        Globales.no_contribuyente = string.Empty;

                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Has cerrado tu sesión {mensaje}, hasta pronto."), cancellationToken);

                        break;

                    case "Foto":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para mostrar la {activity.Text}"), cancellationToken);
                        }
                        else
                        {
                            var result = contribuyenteClient.GetAsync(Globales.id_contribuyente, Globales.no_token);
                            if (result.error_number == 0)
                            {
                                var DataJson = JsonConvert.SerializeObject(result.Data);

                                AdaptiveCardList adaptiveCardLicencia = new AdaptiveCardList();
                                var ContribuyenteCard = adaptiveCardLicencia.CreateAttachment(8, DataJson);
                                await turnContext.SendActivityAsync(MessageFactory.Attachment(ContribuyenteCard), cancellationToken);

                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
                            }
                            else
                            {
                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
                            }
                        }
                        break;

                    case "Crear una cuenta":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(5, "Seleccione Tipo de Persona:"), cancellationToken);

                        break;

                    case "Crear Cuenta Persona Natural":
                        GoMainDialog = false;
                        AdaptiveCardList adaptiveCardNatural = new AdaptiveCardList();
                        var PersonaNaturalCard = adaptiveCardNatural.CreateAttachment(1, "");
                        await turnContext.SendActivityAsync(MessageFactory.Attachment(PersonaNaturalCard), cancellationToken);

                        await Task.Delay(500);

                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Crear Cuenta Persona Juridica":
                        GoMainDialog = false;
                        AdaptiveCardList adaptiveCardJuridica = new AdaptiveCardList();
                        var PersonaJuridicaCard = adaptiveCardJuridica.CreateAttachment(4, "");
                        await turnContext.SendActivityAsync(MessageFactory.Attachment(PersonaJuridicaCard), cancellationToken);

                        await Task.Delay(500);

                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Seleccionar Trámite":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(1, ""), cancellationToken);

                        break;

                    case "Trámite Licencia de Funcionamiento":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(2, ""), cancellationToken);

                        break;

                    case "Nuevo Trámite Licencia de Funcionamiento":
                        if (Globales.OnSesion == false)
                        {
                            GoMainDialog = false;
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar {activity.Text}"), cancellationToken);
                        }
                        break;

                    case "Consultar Licencias de Funcionamiento":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar {activity.Text}"), cancellationToken);
                        }
                        else
                        {
                            // Obtiene la información del contribuyente
                            var resultado = contribuyenteClient.GetJsonAsync(Globales.id_contribuyente, Globales.no_token);

                            if (resultado.error_number == 0)
                            {
                                AdaptiveCardList adaptiveCardLicencia = new AdaptiveCardList();
                                var LicenciaCard = adaptiveCardLicencia.CreateAttachment(5, resultado.Data.no_data_json);
                                await turnContext.SendActivityAsync(MessageFactory.Attachment(LicenciaCard), cancellationToken);

                                await Task.Delay(500);

                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
                            }
                            else
                            {
                                await Task.Delay(500);

                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, resultado.error_message), cancellationToken);
                            }
                        }
                        break;

                    case "Requisitos Licencia de Funcionamiento":
                        GoMainDialog = true;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Trámite Impuesto de Alcabala":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(3, ""), cancellationToken);

                        break;

                    case "Nuevo Trámite Impuesto de Alcabala":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar un {activity.Text}"), cancellationToken);
                        }
                        break;

                    case "Consultar Trámites Impuesto de Alcabala":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar {activity.Text}"), cancellationToken);
                        }
                        break;

                    case "Requisitos Impuesto de Alcabala":
                        GoMainDialog = true;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;

                    case "Trámite Impuesto Vehicular":
                        GoMainDialog = false;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(4, ""), cancellationToken);

                        break;

                    case "Nuevo Trámite Impuesto Vehicular":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar {activity.Text}"), cancellationToken);
                        }
                        break;

                    case "Consultar Trámites Impuesto Vehicular":
                        GoMainDialog = false;

                        if (Globales.OnSesion == false)
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Debe **Iniciar Sesión** para realizar {activity.Text}"), cancellationToken);
                        }
                        break;

                    case "Requisitos Impuesto Vehicular":
                        GoMainDialog = true;
                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);

                        break;
                    }
                }

                if (string.IsNullOrWhiteSpace(activity.Text) && activity.Value != null)
                {
                    //activity.Text = JsonConvert.SerializeObject(activity.Value);

                    JObject InfoCard = JObject.Parse(activity.Value.ToString());
                    string  idCard   = (string)InfoCard["id"];

                    switch (idCard)
                    {
                    case "LoginCard":
                        GoMainDialog = false;

                        if (
                            string.IsNullOrEmpty(InfoCard.GetValue("cboTipoDocumento").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtNumeroDocumento").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtContrasena").ToString()))
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Ingrese documento de identidad/contraseña"), cancellationToken);
                        }
                        else
                        {
                            var co_documento_identidad = InfoCard.GetValue("cboTipoDocumento").ToString();
                            var nu_documento_identidad = InfoCard.GetValue("txtNumeroDocumento").ToString();
                            var no_contrasena          = Funciones.GetSHA256(InfoCard.GetValue("txtContrasena").ToString());

                            var result = contribuyenteClient.GetLoginAsync(Globales.id_empresa, co_documento_identidad, nu_documento_identidad, no_contrasena);

                            if (result.error_number == 0)
                            {
                                Globales.OnSesion         = true;
                                Globales.no_token         = result.Data.no_token;
                                Globales.id_contribuyente = result.Data.id_contribuyente;
                                if (result.Data.co_tipo_persona == "0002")     // 0002=Persona Juridica
                                {
                                    Globales.no_contribuyente = result.Data.no_razon_social;
                                }
                                else
                                {
                                    Globales.no_contribuyente = result.Data.no_nombres + ' ' + result.Data.no_apellido_paterno + ' ' + result.Data.no_apellido_materno;
                                }

                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"Hola {Globales.no_contribuyente}, en que te puedo ayudar?"), cancellationToken);
                            }
                            else
                            {
                                Globales.OnSesion         = false;
                                Globales.id_contribuyente = 0;
                                Globales.no_token         = string.Empty;
                                Globales.no_contribuyente = string.Empty;
                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"{result.error_message}"), cancellationToken);
                            }
                        }
                        break;

                    case "PersonaNaturalNewCard":
                        GoMainDialog = false;
                        if
                        (
                            string.IsNullOrEmpty(InfoCard.GetValue("txtNombres").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtApellidoPaterno").ToString()) ||
                            // string.IsNullOrEmpty(InfoCard.GetValue("txtApellidoMaterno").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtFechaNacimiento").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("cboSexo").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("cboTipoDocumento").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtDocumentoIdentidad").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtCorreoElectronico").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtTelefono").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtDireccion").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtContrasena").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtVerificarContrasena").ToString())
                        )
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Todos los campos son obligatorios."), cancellationToken);
                        }
                        else
                        {
                            if (InfoCard.GetValue("txtContrasena").ToString() != InfoCard.GetValue("txtVerificarContrasena").ToString())
                            {
                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Contraseña y Verificar Contraseña deben ser iguales."), cancellationToken);
                            }
                            else
                            {
                                ContribuyenteDTO contribuyenteDTO = new ContribuyenteDTO();
                                contribuyenteDTO.id_empresa             = 1;
                                contribuyenteDTO.no_nombres             = InfoCard.GetValue("txtNombres").ToString();
                                contribuyenteDTO.no_apellido_paterno    = InfoCard.GetValue("txtApellidoPaterno").ToString();
                                contribuyenteDTO.no_apellido_materno    = InfoCard.GetValue("txtApellidoMaterno").ToString();
                                contribuyenteDTO.fe_nacimiento          = InfoCard.GetValue("txtFechaNacimiento").ToString();
                                contribuyenteDTO.co_sexo                = InfoCard.GetValue("cboSexo").ToString();
                                contribuyenteDTO.co_documento_identidad = InfoCard.GetValue("cboTipoDocumento").ToString();
                                contribuyenteDTO.nu_documento_identidad = InfoCard.GetValue("txtDocumentoIdentidad").ToString();
                                contribuyenteDTO.no_correo_electronico  = InfoCard.GetValue("txtCorreoElectronico").ToString();
                                contribuyenteDTO.nu_telefono            = InfoCard.GetValue("txtTelefono").ToString();
                                contribuyenteDTO.no_direccion           = InfoCard.GetValue("txtDireccion").ToString();
                                contribuyenteDTO.no_contrasena          = InfoCard.GetValue("txtContrasena").ToString();
                                contribuyenteDTO.no_contrasena_sha256   = Funciones.GetSHA256(InfoCard.GetValue("txtContrasena").ToString());
                                contribuyenteDTO.id_usuario_creacion    = 2;  // (2=Bot)

                                // Verificar Informacion en RENIEC
                                var numero = _reniecPIDE.VerificarDNI(contribuyenteDTO);

                                switch (numero)
                                {
                                case 0:
                                    var result = contribuyenteClient.InsertAsync(contribuyenteDTO);

                                    if (result.error_number == 0)
                                    {
                                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Se ha creado su cuenta exitosamente."), cancellationToken);
                                    }
                                    else
                                    {
                                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"{result.error_message}"), cancellationToken);
                                    }
                                    break;

                                case -1:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Los datos ingresados no coinciden con la información de RENIEC."), cancellationToken);

                                    break;

                                case 999:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "No se ha encontrado información para el número de DNI."), cancellationToken);

                                    break;

                                case 1000:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Uno o más datos de la petición no son válidos."), cancellationToken);

                                    break;

                                case 1001:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "El DNI, RUC y contraseña no corresponden a un usuario válido."), cancellationToken);

                                    break;

                                case 1002:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "La contraseña para el DNI y RUC está caducada."), cancellationToken);

                                    break;

                                case 1003:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Se ha alcanzado el límite de consultas permitidas por día."), cancellationToken);

                                    break;

                                case 1999:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Error desconocido / inesperado."), cancellationToken);

                                    break;

                                default:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Sucedió un problema, intente otra vez."), cancellationToken);

                                    break;
                                }
                            }
                        }
                        break;

                    case "PersonaJuridicaNewCard":
                        GoMainDialog = false;
                        if
                        (
                            string.IsNullOrEmpty(InfoCard.GetValue("txtRazonSocial").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtRepresentanteLegal").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("cboTipoDocumento").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtDocumentoIdentidad").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtCorreoElectronico").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtTelefono").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtDireccion").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtContrasena").ToString()) ||
                            string.IsNullOrEmpty(InfoCard.GetValue("txtVerificarContrasena").ToString())
                        )
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Todos los campos son obligatorios."), cancellationToken);
                        }
                        else
                        {
                            if (InfoCard.GetValue("txtContrasena").ToString() != InfoCard.GetValue("txtVerificarContrasena").ToString())
                            {
                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Contraseña y Verificar Contraseña deben ser iguales."), cancellationToken);
                            }
                            else
                            {
                                ContribuyenteDTO contribuyenteDTO = new ContribuyenteDTO();
                                contribuyenteDTO.id_empresa             = 1;
                                contribuyenteDTO.no_razon_social        = InfoCard.GetValue("txtRazonSocial").ToString();
                                contribuyenteDTO.no_representante_legal = InfoCard.GetValue("txtRepresentanteLegal").ToString();
                                contribuyenteDTO.co_documento_identidad = InfoCard.GetValue("cboTipoDocumento").ToString();
                                contribuyenteDTO.nu_documento_identidad = InfoCard.GetValue("txtDocumentoIdentidad").ToString();
                                contribuyenteDTO.no_correo_electronico  = InfoCard.GetValue("txtCorreoElectronico").ToString();
                                contribuyenteDTO.nu_telefono            = InfoCard.GetValue("txtTelefono").ToString();
                                contribuyenteDTO.no_direccion           = InfoCard.GetValue("txtDireccion").ToString();
                                contribuyenteDTO.no_contrasena          = InfoCard.GetValue("txtContrasena").ToString();
                                contribuyenteDTO.no_contrasena_sha256   = Funciones.GetSHA256(InfoCard.GetValue("txtContrasena").ToString());
                                contribuyenteDTO.id_usuario_creacion    = 2;  // (2=Bot)

                                // Verificar Informacion en SUNAT
                                var numero = _sunatPIDE.VerificarRUC(contribuyenteDTO);
                                switch (numero)
                                {
                                case 0:
                                    var result = contribuyenteClient.InsertAsync(contribuyenteDTO);

                                    if (result.error_number == 0)
                                    {
                                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Se ha creado su cuenta exitosamente."), cancellationToken);
                                    }
                                    else
                                    {
                                        await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"{result.error_message}"), cancellationToken);
                                    }
                                    break;

                                case -1:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Número de RUC errado, no está registrado en SUNAT."), cancellationToken);

                                    break;

                                case -2:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Los datos no coinciden con la información de SUNAT."), cancellationToken);

                                    break;

                                case 999:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "No se ha encontrado información para el número RUC ingresado."), cancellationToken);

                                    break;

                                default:
                                    await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Sucedió un problema, intente otra vez."), cancellationToken);

                                    break;
                                }
                            }
                        }
                        break;

                    case "ConsultarIdSolicitudLicencia":
                        GoMainDialog = false;

                        if (string.IsNullOrEmpty(InfoCard.GetValue("txtNumeroSolicitud").ToString()))
                        {
                            await turnContext.SendActivityAsync(MenuBot.Buttons(0, "Debe ingresar un número de Solicitud."), cancellationToken);
                        }
                        else
                        {
                            SolicitudLicenciaDTO solicitudLicenciaDTO = new SolicitudLicenciaDTO();
                            solicitudLicenciaDTO.id_solicitud_licencia = 0;
                            solicitudLicenciaDTO.id_contribuyente      = Globales.id_contribuyente;
                            solicitudLicenciaDTO.nu_solicitud_licencia = InfoCard.GetValue("txtNumeroSolicitud").ToString();

                            SolicitudLicenciaClient solicitudLicenciaClient = new SolicitudLicenciaClient();
                            var result = solicitudLicenciaClient.GetAsync(solicitudLicenciaDTO);

                            if (result.error_number == 0)
                            {
                                var dataJson = JsonConvert.SerializeObject(result.Data);
                                AdaptiveCardList adaptiveCardLicencia = new AdaptiveCardList();
                                var LicenciaCard = adaptiveCardLicencia.CreateAttachment(6, dataJson);
                                await turnContext.SendActivityAsync(MessageFactory.Attachment(LicenciaCard), cancellationToken);

                                await Task.Delay(500);

                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, ""), cancellationToken);
                            }
                            else
                            {
                                await turnContext.SendActivityAsync(MenuBot.Buttons(0, $"{result.error_message}"), cancellationToken);
                            }
                        }
                        break;
                    }
                }
            }

            // Run the Dialog with the new message Activity.
            if (GoMainDialog)
            {
                await Dialog.RunAsync(turnContext, ConversationState.CreateProperty <DialogState>(nameof(DialogState)), cancellationToken);
            }
        }
Пример #9
0
 private async Task IntentDespedir(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, $"Espero verte pronto {Globales.no_contribuyente}."), cancellationToken);
 }
Пример #10
0
 private async Task IntentAgradecer(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "gracias a ti, en que te puedo ayudar?"), cancellationToken);
 }
Пример #11
0
 private async Task IntentSaludar(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "Hola, que gusto verte, en que te puedo ayudar?"), cancellationToken);
 }
Пример #12
0
 private async Task IntentRealizarTramiteVehicular(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(4, "Selecciona una opción"), cancellationToken);
 }
Пример #13
0
 private async Task IntentRealizarTramite(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(1, "Que trámite deseas realizar?"), cancellationToken);
 }
Пример #14
0
 private async Task IntentCrearCuenta(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     await stepContext.Context.SendActivityAsync(MenuBot.Buttons(5, "Selecciona un tipo de persona"), cancellationToken);
 }