Exemplo n.º 1
0
        //Aqui se ejecutan los formularios para extraer la informacion que se necesite acorde a la denuncia
        #region FormDenunciation
        public async Task DenunciationFormComplete(IDialogContext context, IAwaitable <DenunciationForm> result)
        {
            try
            {
                var denunciation = await result;

                int    idtipocaso = 2; //Tipo de caso: denuncia
                int    idstatus   = 1; //Estado: No revisado
                string folio;
                int    idciudadano = 1;
                var    fecha       = DateTime.UtcNow;

                //Creación de folio
                folio = denunciation.Name.Substring(0, 2).ToUpper() + idciudadano + "_" + idtipocaso;

                //****Log to DataBase****
                ConnectionDB.Chatbot_PGBEntities DB = new ConnectionDB.Chatbot_PGBEntities();
                ConnectionDB.Casos NewCaso          = new ConnectionDB.Casos();
                NewCaso.idtipocaso         = idtipocaso;
                NewCaso.idstatus           = idstatus;
                NewCaso.folio              = folio;
                NewCaso.idciudadano        = idciudadano;
                NewCaso.nombre             = denunciation.Name;
                NewCaso.email              = denunciation.Contact;
                NewCaso.descripcion        = denunciation.Denunciation;
                NewCaso.nombre_funcionario = denunciation.Functionary;
                NewCaso.nombre_dependencia = denunciation.Dependency;
                NewCaso.fecha_registro     = DateTime.UtcNow;
                DB.Casos.Add(NewCaso);
                DB.SaveChanges();

                await context.PostAsync(ChatResponse.Thanks);

                await context.PostAsync(ChatResponse.Checkid + "Folio: " + folio);

                await context.PostAsync(ChatResponse.Status);

                await context.PostAsync(ChatResponse.Step5Else);
            }
            catch (FormCanceledException)
            {
                await context.PostAsync(ChatResponse.formCanceled);
            }
            catch (Exception)
            {
                await context.PostAsync(ChatResponse.Error);
            }

            finally
            {
                context.Wait(MessageReceived);
            }
        }
Exemplo n.º 2
0
        //private async Task ComplaintFormStatusComplete(IDialogContext context, IAwaitable<ComplaintFormStatus> result)
        //{
        //}
        #endregion

        #region FormInformationR
        public async Task InformationRFormComplete(IDialogContext context, IAwaitable <InformationRForm> result)
        {
            Activity replyToConversation = (Activity)context.MakeMessage();

            replyToConversation.Recipient = replyToConversation.Recipient;
            replyToConversation.Type      = "Message";

            IdentifyLanguage();

            try
            {
                var informationr = await result;

                int    idtipocaso = 4; //Tipo de caso: solicitud de informacion
                int    idstatus   = 1; //Estado: No revisado
                string folio;
                int    idciudadano = 1;
                var    fecha       = DateTime.UtcNow;

                //Creación de folio
                folio = informationr.Name.Substring(0, 2).ToUpper() + idciudadano + "_" + idtipocaso;

                //****Log to DataBase****
                ConnectionDB.Chatbot_PGBEntities DB = new ConnectionDB.Chatbot_PGBEntities();
                ConnectionDB.Casos NewCaso          = new ConnectionDB.Casos();
                NewCaso.idtipocaso     = idtipocaso;
                NewCaso.idstatus       = idstatus;
                NewCaso.folio          = folio;
                NewCaso.idciudadano    = idciudadano;
                NewCaso.nombre         = informationr.Name;
                NewCaso.email          = informationr.Contact;
                NewCaso.descripcion    = informationr.Information;
                NewCaso.fecha_registro = DateTime.UtcNow;
                DB.Casos.Add(NewCaso);
                DB.SaveChanges();

                ConnectionDB.Chatbot_PGBEntities1 DBot          = new ConnectionDB.Chatbot_PGBEntities1();
                ConnectionDB.UserLogin            NewUserLogBot = new ConnectionDB.UserLogin();
                NewUserLogBot.Channel  = replyToConversation.ChannelId;
                NewUserLogBot.UserID   = replyToConversation.From.Id;
                NewUserLogBot.UserName = replyToConversation.From.Name;
                NewUserLogBot.Created  = DateTime.UtcNow;
                NewUserLogBot.Message  = ChatResponse.Thanks + " " + ChatResponse.Checkid + " Folio: " + folio + " " + ChatResponse.Status + " " + ChatResponse.Step5Else;
                DBot.UserLogins.Add(NewUserLogBot);
                DBot.SaveChanges();
                DBot.Dispose();

                await context.PostAsync(ChatResponse.Thanks);

                await context.PostAsync(ChatResponse.Checkid + ": " + folio);

                await context.PostAsync(ChatResponse.Status);

                await context.PostAsync(ChatResponse.Step5Else);
            }
            catch (FormCanceledException)
            {
                await context.PostAsync(ChatResponse.formCanceled);
            }
            catch (Exception)
            {
                await context.PostAsync(ChatResponse.Error);
            }

            finally
            {
                context.Wait(MessageReceived);
            }
        }