Exemplo n.º 1
0
        /// <summary>
        /// Lokale Variablen prüfen und ggf. automatisch Anmelden
        /// </summary>
        private void AutoLogin()
        {
            string user = null, passwort = null;

            try
            {
                var current = Connectivity.NetworkAccess;
                if (current == NetworkAccess.Internet)
                {
                    if (Current.Properties.ContainsKey("userid"))
                    {
                        if (Current.Properties["userid"] != null)
                        {
                            user = Current.Properties["userid"].ToString();
                        }
                    }

                    if (Current.Properties.ContainsKey("userpw"))
                    {
                        if (Current.Properties["userpw"] != null)
                        {
                            passwort = Current.Properties["userpw"].ToString();
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(passwort))
                    {
                        bool?exists = AllVM.Datenbank.User.Exists(user);
                        if (exists == true)
                        {
                            string pw = AllVM.Datenbank.User.GetPasswort(user);

                            if (user != null && (passwort == pw))
                            {
                                AllVM.Initial(user);
                                MainPage = new AppShell();
                            }
                            else
                            {
                                DependencyService.Get <IMessage>().ShortAlert("Passwort stimmt nicht");
                                MainPage = new NavigationPage(new Login());
                            }
                        }
                        else if (exists == false)
                        {
                            DependencyService.Get <IMessage>().ShortAlert("Nutzer existiert nicht");
                            MainPage = new NavigationPage(new Login());
                        }
                        else
                        {
                            DependencyService.Get <IMessage>().ShortAlert("Fehler beim Prüfen");
                            MainPage = new NavigationPage(new Login());
                        }
                    }
                    else
                    {
                        MainPage = new NavigationPage(new Login());
                    }
                }
            }
            catch (Exception ex)
            {
                _        = ex.Message;
                MainPage = new NavigationPage(new Login());
            }
        }
Exemplo n.º 2
0
        public App()
        {
            InitializeComponent();

            MainPage = new AppShell();
        }