public ChatPageModel()
 {
     _chatsServices  = new ChatsServices();
     _lockeable      = FreshIOC.Container.Resolve <ILockeable>();
     _audioManager   = FreshIOC.Container.Resolve <IAudioManager>();
     _dateTimeHelper = FreshIOC.Container.Resolve <IDateTimeHelper>();
 }
Exemple #2
0
        public static async Task ConnectPersonToChatHub()
        {
            if (Persona != null)
            {
                ChatsServices chatService = new ChatsServices();

                for (int i = 0; i < 3; i++)
                {
                    if (CrossConnectivity.Current.IsConnected && await CrossConnectivity.Current.IsRemoteReachable(URL.Host, msTimeout: 1000))
                    {
                        try
                        {
                            await chatService.ConectarChatHub(Persona.Consecutivo);

                            if (!string.IsNullOrWhiteSpace(ConnectionIDChatHub))
                            {
                                DisposeChatEvents();
                                ChatsServices.ErrorConexion   += ChatsServices_ErrorConexion;
                                ChatsServices.ConexionPerdida += ChatsServices_ConexionPerdida;
                                break;
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
        public async Task <JsonResult> GetMyContacts(ContactosDTO contact)
        {
            Result <ContactosDTO> result = new Result <ContactosDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                if (GetPersonToSearch() != null && GetPersonToSearch().Consecutivo != 0)
                {
                    contact.CodigoPersonaOwner = GetPersonToSearch().Consecutivo;
                }
                else
                {
                    contact.CodigoPersonaOwner = UserLoggedIn().PersonaDelUsuario.Consecutivo;
                }

                contact.CodigoIdiomaUsuarioBase = UserLoggedIn().PersonaDelUsuario.CodigoIdioma;
                result.list = await chatService.ListarContactos(contact);

                if (result.list == null)
                {
                    return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
 public PerfilPageModel()
 {
     _archivoServices    = new ArchivosServices();
     _personaServices    = new PersonasServices();
     _candidatosServices = new CandidatosServices();
     _gruposServices     = new GruposServices();
     _chatServices       = new ChatsServices();
     _dateTimeHelper     = FreshIOC.Container.Resolve <IDateTimeHelper>();
 }
Exemple #5
0
        public static async Task ReconectarChatHub()
        {
            if (string.IsNullOrWhiteSpace(ConnectionIDChatHub) && Persona != null && _appInicializada && !_reconectando)
            {
                try
                {
                    CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
                    using (await _lockeable.LockAsync(cancellationTokenSource.Token))
                    {
                        await Task.Run(async() =>
                        {
                            _reconectando = true;

                            ChatsServices chatService = new ChatsServices();
                            while (string.IsNullOrWhiteSpace(ConnectionIDChatHub))
                            {
                                if (await CrossConnectivity.Current.IsRemoteReachable(URL.Host, msTimeout: 1000))
                                {
                                    try
                                    {
                                        await chatService.ConectarChatHub(Persona.Consecutivo);

                                        if (!string.IsNullOrWhiteSpace(ConnectionIDChatHub))
                                        {
                                            _reconectando = false;
                                            break;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }

                                await Task.Delay(3000);
                            }
                        });
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #6
0
        public async Task <JsonResult> DeleteConversation(ChatsDTO chat)
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                result.obj = await chatService.EliminarChat(chat);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorDelete(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(Helper.returnDeleteSuccess(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorDelete(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #7
0
        public async Task <JsonResult> GetChatMessages(ChatsMensajesDTO chat)
        {
            Result <ChatsMensajesDTO> result = new Result <ChatsMensajesDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                result.list = await chatService.ListarChatsMensajes(chat);

                if (result.list == null)
                {
                    return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #8
0
        public async Task <JsonResult> SaveMessage(ChatsMensajesDTO chatMessage)
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                result.obj = await chatService.CrearChatMensaje(chatMessage);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #9
0
        public async Task <JsonResult> SaveChat(ChatsDTO chat)
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                chat.CodigoPersonaOwner = UserLoggedIn().PersonaDelUsuario.Consecutivo;
                result.obj = await chatService.CrearChat(chat);

                if (result.list == null)
                {
                    return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #10
0
        public async Task <JsonResult> GetChatFromContact(ChatsDTO chat)
        {
            Result <ChatsDTO> result = new Result <ChatsDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                chat.CodigoPersonaOwner = UserLoggedIn().PersonaDelUsuario.Consecutivo;
                result.obj = await chatService.BuscarChatEntreDosPersonas(chat);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <JsonResult> CreateContact()
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                ChatsServices chatService = new ChatsServices();
                ContactosDTO  contact     = new ContactosDTO();
                contact.CodigoPersonaContacto = GetPersonToSearchTemp().Consecutivo;
                contact.CodigoPersonaOwner    = UserLoggedIn().PersonaDelUsuario.Consecutivo;
                result.obj = await chatService.CrearContacto(contact);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #12
0
 public ContactosChatPageModel()
 {
     _chatsServices = new ChatsServices();
 }