public void GetData()
        {
            var passport = getOfflinePassportUseCase.Execute();

            View.SetQRInfo(QRUtils.GenerateQRInfo(passport));
            var message = CalculatePassportExpiration(passport);

            View.SetPassportInfo(passport, message);
        }
        public async Task GetData()
        {
            await Task.Delay(50);

            View.ShowLoading();
            var  passport         = getOfflinePassportUseCase.Execute();
            bool offline          = false;
            var  passportResponse = await getPassportUseCase.Execute(true);

            View.HideLoading();
            if (passportResponse.ErrorCode > 0)
            {
                if (passport == null)
                {
                    View.ShowDialog(passportResponse.Message, "msg_ok", null);
                    return;
                }
                offline = true;
            }
            else
            {
                passport = passportResponse.Data;
            }
            View.SetQRInfo(QRUtils.GenerateQRInfo(passport));
            var message = CalculatePassportExpiration(passport);

            View.SetPassportInfo(passport, message, offline);

            estadoPasaporte = passport.EstadoId;
            int state = settingsService.GetValueOrDefault <int>(DomainConstants.LAST_PASSPORT_STATE, -1);

            if (state != estadoPasaporte)
            {
                if (passport.HasMessage)
                {
                    View.ShowStateChange();
                }
                settingsService.AddOrUpdateValue <int>(DomainConstants.LAST_PASSPORT_STATE, estadoPasaporte);
            }
        }
Exemplo n.º 3
0
        private async Task GoLogin()
        {
            var  settingsService = Locator.Current.GetService <ISettingsService>();
            long ticks           = settingsService.GetValueOrDefault <long>(DomainConstants.LAST_DATE, 0);

            if (ticks == 0)
            {
                navigator.GoToLogin();
                return;
            }

            /*DateTime last = new DateTime(ticks);
             * if (!DateTime.Now.ToString("yyyy-MM-dd").Equals(last.ToString("yyyy-MM-dd")))
             * {
             *  navigator.GoToLogin();
             *  return;
             * }*/
            String token = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_SESSION);

            if (token == null || token.Trim().Equals(""))
            {
                navigator.GoToLogin();
                return;
            }
            var appSession = Locator.Current.GetService <AppSession>();

            appSession.AccesToken = token;
            appSession.User       = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_USER);
            string userInfo = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_USER_INFO);

            if (userInfo != null)
            {
                appSession.UserInfo = JsonConvert.DeserializeObject <User>(userInfo);
            }
            View.ShowLoading();
            var passportResponse = await getPassportUseCase.Execute(true);

            //await getPassportStatesUseCase.Execute(true);
            //await getPassportStatesColorsUseCase.Execute(true);
            await getRiskFactorsUseCase.Execute(true);

            await getSymptomTypesUseCase.Execute(true);

            //await getMedicalMonitorsUseCase.Execute(true);
            View.HideLoading();
            //navigator.GoToOffline();
            //return;
            if (passportResponse.ErrorCode > 0)
            {
                if (passportResponse.ErrorCode == 401)
                {
                    navigator.GoToLogin();
                }
                else if (passportResponse.ErrorCode == 500)
                {
                    navigator.GoToLogin();
                }
                else
                {
                    var passport = getOfflinePassportUseCase.Execute();
                    if (passport == null)
                    {
                        navigator.GoToLogin();
                    }
                    else
                    {
                        navigator.GoToOffline();
                    }
                }
            }
            else
            {
                if (passportResponse.Data == null)
                {
                    navigator.GoToLogin();// En el login tenemos botón de reintentar  navigator.GoToMedicalTest();
                }
                else
                {
                    navigator.GoToMain();
                }
            }
        }