public void SetPassportInfo(Domain.Model.Employee.Passport passport, string message)
        {
            TimeoutLabel.AttributedText = Styles.ConvertHTMLStyles(message, TimeoutLabel.Font.Name, TimeoutLabel.Font.PointSize);

            switch (passport.ColorPasaporte)
            {
            case "Gris":
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("offline_qr_timeout");
                imageView.Alpha           = 1f;
                viewState.BackgroundColor = Colors.colorStateCaducado;
                break;

            case "Verde":
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help");
                imageView.Alpha           = 1f;
                viewState.BackgroundColor = Colors.colorStateInmune;
                AccessLabel.Text          = AppDelegate.LanguageBundle.GetLocalizedString("access_allowed");
                break;

            case "Rojo":
                imageView.Alpha           = 1f;
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help");
                viewState.BackgroundColor = Colors.colorStateSintomas;
                AccessLabel.Text          = AppDelegate.LanguageBundle.GetLocalizedString("access_not_allowed");
                TimeoutLabel.Text         = "";
                break;
            }
        }
Beispiel #2
0
        public static string GenerateQRInfo(Domain.Model.Employee.Passport passport)
        {
            long date = passport.FechaExpiracion.HasValue ? passport.FechaExpiracion.Value.Ticks : -1;

            if (!passport.FechaExpiracion.HasValue)
            {
                date = -1;
            }
            String values = String.Format("{0};{1};{2}", passport.IdEmpleado,
                                          passport.ColorPasaporte, date);

            return(EncryptUtils.Encriptar(values));//JsonConvert.SerializeObject(info)));
        }
Beispiel #3
0
        public void SetPassportInfo(Domain.Model.Employee.Passport passport, string message)
        {
            textAccess.Text = "";
            ISpanned html;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
            {
                html = Html.FromHtml(message, FromHtmlOptions.ModeLegacy);
            }
            else
            {
                html = Html.FromHtml(message);
            }
            tvTimeOutLabel.SetText(html, TextView.BufferType.Spannable);

            switch (passport.ColorPasaporte)
            {
            case "Gris":
                textQRHelp.Text = Context.GetString(Resource.String.offline_qr_timeout);
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateCaducado));
                break;

            case "Verde":
                textQRHelp.Text = Context.GetString(Resource.String.qrcode_help_normal);
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateInmune));
                textAccess.Text = Context.GetString(Resource.String.access_allowed);
                break;

            case "Rojo":
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateSintomas));
                textQRHelp.Text     = Context.GetString(Resource.String.qrcode_help_normal);
                textAccess.Text     = Context.GetString(Resource.String.access_not_allowed);
                tvTimeOutLabel.Text = "";
                break;
            }
        }
        private string CalculatePassportExpiration(Domain.Model.Employee.Passport passport)
        {
            var now = DateTime.Now;

            if (passport.FechaExpiracion == null)
            {
                return("");
            }

            var dateCompare = DateTime.Compare(passport.FechaExpiracion.Value, now);


            // ReSharper disable once CommentTypo
            if (dateCompare < 0) //ha caducado, la fecha de expiración es anterior a la fecha actual
            {
                View.SetCaducado(true);
                return(View.GetString("state_caducado"));
            }

            if (dateCompare > 0) //todavia no ha caducado, vamos a calcular los dias que quedan para que caduque
            {
                var         daysLeft = Math.Truncate((passport.FechaExpiracion.Value - now).TotalDays);
                var         text     = View.GetString("state_multiple_days").Replace("dd", daysLeft.ToString());
                CultureInfo info     = new CultureInfo(Locator.Current.GetService <AppSession>().Language);
                if (daysLeft == 1)
                {
                    text = View.GetString("state_single_day").Replace("dd", passport.FechaExpiracion.Value.AddMinutes(-1).ToString("dd", info)).Replace("mm", passport.FechaExpiracion.Value.AddMinutes(-1).ToString("MMMM", info));
                }
                else if (daysLeft < 1)
                {
                    text = View.GetString("state_this_day").Replace("dd", passport.FechaExpiracion.Value.AddMinutes(-1).ToString("dd", info)).Replace("mm", passport.FechaExpiracion.Value.AddMinutes(-1).ToString("MMMM", info));

                    /*var hours = (passport.FechaExpiracion.Value - now).Hours;
                     * if (hours == 1)
                     * {
                     *  lasString = " hora</b>";
                     *  daysLeft = hours;
                     * }
                     * else if (hours > 0)
                     * {
                     *  lasString = " horas</b>";
                     *  daysLeft = hours;
                     * }
                     * else
                     * {
                     *  var minutes = (passport.FechaExpiracion.Value - now).Minutes;
                     *  if (minutes == 1)
                     *  {
                     *      lasString = " minuto</b>";
                     *      daysLeft = minutes;
                     *  }
                     *  else
                     *  {
                     *      lasString = " minutos</b>";
                     *      daysLeft = minutes;
                     *  }
                     * }*/
                }

                switch (passport.ColorPasaporte)
                {
                case "Gris":
                    View.SetCaducado(false);
                    return("");

                default:
                    View.SetCaducado(false);
                    return(text);
                }
            }
            else //la fecha es igual
            {
            }
            View.SetCaducado(false);
            return("");
        }
Beispiel #5
0
        public void SetPassportInfo(Domain.Model.Employee.Passport passport, string message, bool offline)
        {
            if (offline)
            {
                NameLabel.Text = AppDelegate.LanguageBundle.GetLocalizedString("offline_name");
            }
            else
            {
                NameLabel.Text = passport.NombreEmpleado;
            }
            TimeoutLabel.AttributedText = Styles.ConvertHTMLStyles(message, TimeoutLabel.Font.Name, TimeoutLabel.Font.PointSize);
            if (passport.HasMessage)
            {
                ToDoLabel.Hidden = false;
            }
            else
            {
                ToDoLabel.Hidden = true;
            }

            switch (passport.ColorPasaporte)
            {
            case "Gris":
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help");
                imageView.Alpha           = 1f;
                viewState.BackgroundColor = Colors.colorStateCaducado;
                caducado = true;
                break;

            case "Verde":
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help");
                imageView.Alpha           = 1f;
                viewState.BackgroundColor = Colors.colorStateInmune;
                AccessLabel.Text          = AppDelegate.LanguageBundle.GetLocalizedString("access_allowed");
                break;

            case "Rojo":
                imageView.Alpha           = 1f;
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help");
                viewState.BackgroundColor = Colors.colorStateSintomas;
                AccessLabel.Text          = AppDelegate.LanguageBundle.GetLocalizedString("access_not_allowed");
                TimeoutLabel.Text         = "";
                if (caducado)
                {
                    caducado           = false;
                    textQRHelp.Text    = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help_timeout");
                    buttonRenew.Hidden = false;
                }
                break;
            }
            if (caducado)
            {
                textQRHelp.Text           = AppDelegate.LanguageBundle.GetLocalizedString("qrcode_help_timeout");
                buttonRenew.Hidden        = false;
                viewState.BackgroundColor = Colors.colorStateCaducado;
                imageView.Alpha           = 0.5f;
                AccessLabel.Text          = "";
                ToDoLabel.Hidden          = true;
            }
            else
            {
                if (!passport.ColorPasaporte.Equals("Rojo"))
                {
                    buttonRenew.Hidden = true;
                }
            }
        }
        public void SetPassportInfo(Domain.Model.Employee.Passport passport, string message, bool offline)
        {
            if (offline)
            {
                textUserName.Text = GetString(Resource.String.offline_name);
            }
            else
            {
                textUserName.Text = passport.NombreEmpleado;
            }
            textAccess.Text = "";
            ISpanned html;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
            {
                html = Html.FromHtml(message, FromHtmlOptions.ModeLegacy);
            }
            else
            {
                html = Html.FromHtml(message);
            }
            tvTimeOutLabel.SetText(html, TextView.BufferType.Spannable);

            if (passport.HasMessage)
            {
                textToDo.Visibility = ViewStates.Visible;
            }
            else
            {
                textToDo.Visibility = ViewStates.Gone;
            }

            switch (passport.ColorPasaporte)
            {
            case "Gris":
                textQRHelp.Text = Context.GetString(Resource.String.qrcode_help_normal);
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateCaducado));
                caducado = true;
                break;

            case "Verde":
                textQRHelp.Text = Context.GetString(Resource.String.qrcode_help_normal);
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateInmune));
                textAccess.Text = Context.GetString(Resource.String.access_allowed);
                break;

            case "Rojo":
                imageView.Alpha = 1f;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateSintomas));
                textQRHelp.Text     = Context.GetString(Resource.String.qrcode_help_normal);
                textAccess.Text     = Context.GetString(Resource.String.access_not_allowed);
                tvTimeOutLabel.Text = "";
                if (caducado)
                {
                    caducado               = false;
                    textQRHelp.Text        = Context.GetString(Resource.String.qrcode_help_caducado);
                    buttonRenew.Visibility = ViewStates.Visible;
                }
                break;
            }
            if (caducado)
            {
                textQRHelp.Text        = Context.GetString(Resource.String.qrcode_help_caducado);
                buttonRenew.Visibility = ViewStates.Visible;
                llStateView.SetBackgroundColor(Resources.GetColor(Resource.Color.colorStateCaducado));
                imageView.Alpha     = 0.5f;
                textAccess.Text     = "";
                textToDo.Visibility = ViewStates.Gone;
            }
            else
            {
                if (!passport.ColorPasaporte.Equals("Rojo"))
                {
                    buttonRenew.Visibility = ViewStates.Gone;
                }
            }
        }