Exemplo n.º 1
0
        private void TransitionViewController(object state)
        {
            var    appPreferences = new AppPreferences(this.ApplicationContext);
            string Username       = appPreferences.GetUsername();

            if (Username == "")
            {
                // No User Remembered
                appPreferences.SaveLoginSkipped(false);
                TransitionToSignIn();
            }
            else
            {
                // User exists.
                appPreferences.SaveLoginSkipped(true);

                bool MasterDBDownloaded = appPreferences.GetMasterDBDownloaded();
                if (MasterDBDownloaded)
                {
                    // Master DB Downloaded
                    TransitionToMain();
                }
                else
                {
                    // Master DB Not Found
                    TransitionToDownload();
                }
            }
        }
Exemplo n.º 2
0
        private async Task Login(string username, string password, string macAddr)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            bool loginResult = await serviceManager.VerifyLogin(username, password, macAddr).ConfigureAwait(false);

            sw.Stop();

            AndHUD.Shared.Dismiss(this);

            int elapsed = sw.Elapsed.Seconds;

            if (elapsed <= timeLimit)
            {
                loginCheckCallObserver.Dispose();
                loginCheckCallObserver = null;
            }

            if (loginResult)
            {
                if (Core.Globals.LoginStatus == BL.Enums.LoginStatusType.Success)
                {
                    // Login Success
                    var appPreferences = new AppPreferences(this.ApplicationContext);
                    appPreferences.SaveUsername(username);
                    appPreferences.SavePassword(password);
                    appPreferences.SaveLoginSkipped(false);

                    TransitionToDownload();
                }
                else if (Core.Globals.LoginStatus == BL.Enums.LoginStatusType.LoginError)
                {
                    // Login Failure/Error
                    ShowError();
                }
            }
            else
            {
                RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                    builder.SetTitle("Error");
                    builder.SetMessage("Something went wrong. Please try it later.");
                    builder.SetPositiveButton("OK", (sender, e) =>
                    {
                    });
                    builder.Show();
                });
            }
        }