private async Task SenSimtomps(List <RequestValue> values, bool sintomas)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            for (int i = 0; i < responses.Length; i++)
            {
                dict[keys[i]] = responses[i].ToString();
            }
            dict["MeSientomal"] = panic.ToString();
            Analytics.TrackEvent("RenovarPasaporte", dict);
            var response = await sendSymptomsUseCase.Execute(values, panic&& sintomas);

            if (response.ErrorCode > 0)
            {
                View.HideLoading();
                if (response.ErrorCode == 401)
                {
                    View.ShowDialog(response.Message, "msg_ok", () => Locator.Current.GetService <ILogoutService>().LogoutExpired());
                }
                else
                {
                    View.ShowDialog(response.Message, "msg_ok", null);
                }
            }
            else
            {
                await getPassportUseCase.Execute(true);

                View.HideLoading();
                navigator.GoBack();
            }
        }
        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);
            }
        }
        public async Task ContinueClick()
        {
            await Task.Delay(50);

            View.ShowLoading();
            var passportResponse = await getPassportUseCase.Execute(true);

            View.HideLoading();
            if (passportResponse.ErrorCode > 0)
            {
                if (passportResponse.ErrorCode == 401)
                {
                    navigator.GoToLogin();
                }
                else
                {
                    View.ShowDialog("offline_error", "msg_ok", null);
                }
            }
            else
            {
                navigator.GoToMain();
            }
        }
Exemple #4
0
        public async Task Authorized(string token)
        {
            var appSession = Locator.Current.GetService <AppSession>();

            appSession.AccesToken = token;

            View.ShowLoading();
            var userResponse = await getUserUseCase.Execute();

            if (userResponse.ErrorCode > 0)
            {
                View.HideLoading();
                if (userResponse.ErrorCode == 401)
                {
                    View.ShowDialog("error_401_user", "msg_ok", null);
                }
                else
                {
                    View.ShowDialog(userResponse.Message, "msg_ok", null);
                }
                View.ShowRetry();
            }
            else
            {
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_SESSION, appSession.AccesToken);
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_USER, appSession.User);
                settingsService.AddOrUpdateValue <long>(DomainConstants.LAST_DATE, DateTime.Now.Ticks);
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_USER_INFO, JsonConvert.SerializeObject(appSession.UserInfo));
                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();
                if (passportResponse.ErrorCode > 0)
                {
                    View.ShowDialog(passportResponse.Message, "msg_ok", null);
                }
                else
                {
                    if (passportResponse.Data == null)
                    {
                        //navigator.GoToMedicalTest();
                        var resFactors = await getRiskFactorsUseCase.Execute();

                        if (resFactors.ErrorCode > 0)
                        {
                            View.ShowDialog(resFactors.Message, "msg_ok", null);
                            return;
                        }
                        var factors = resFactors.Data;
                        List <RequestValue> values = new List <RequestValue>();
                        for (int i = 0; i < factors.Count(); i++)
                        {
                            var value = new RequestValue()
                            {
                                Id    = factors.ElementAt(i).IdRiskFactor,
                                Value = (bool?)null
                            };
                            values.Add(value);
                        }
                        var response = await senrRiskFactorsUseCase.Execute(values);

                        if (response.ErrorCode > 0)
                        {
                            View.ShowDialog(response.Message, "msg_ok", null);
                        }
                        else
                        {
                            navigator.GoToMain();
                        }
                    }
                    else
                    {
                        navigator.GoToMain();
                    }
                }
            }
        }
Exemple #5
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();
                }
            }
        }