コード例 #1
0
        // Simulates background work that happens behind the splash screen
        async void SimulateStartup()
        {
            ISharedPreferences sharedPreferences = Application.Context.GetSharedPreferences("loginfile", FileCreationMode.Private);
            string             email             = sharedPreferences.GetString("email", string.Empty);
            string             password          = sharedPreferences.GetString("password", string.Empty);

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
                await Task.Delay(1000); // Simulate a bit of startup work.

                Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
                StartActivity(new Intent(Application.Context, typeof(Login)));
            }
            else
            {
                Login login = new Login();
                if (login.CheckWifiStatus())
                {
                    var user = await Account.UserLogin(email, Convert.ToInt32(password));

                    if (user == null)
                    {
                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            Toast.MakeText(this, "Invalid login credintials provided!", ToastLength.Long).Show();
                            StartActivity(new Intent(Application.Context, typeof(Login)));
                        });
                    }

                    else
                    {
                        var iss = new Intent(this, typeof(FragmentHomeActivity));
                        ISharedPreferences       sharedPrefrences = Application.Context.GetSharedPreferences("loginfile", FileCreationMode.Private);
                        ISharedPreferencesEditor spEdit           = sharedPrefrences.Edit();
                        spEdit.PutString("email", user.email_address);
                        spEdit.PutString("password", user.password_hash.ToString());
                        spEdit.Apply();
                        UserInfoHolder.FetchUserInfo(user);
                        FetchandSendTokenWithEmail();
                        MainThread.BeginInvokeOnMainThread(() => {
                            this.StartActivity(iss);
                            // circle5.Visibility = Android.Views.ViewStates.Visible;
                            this.Finish();
                        });
                    }
                }
                else
                {
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        Toast.MakeText(this, "Please connect to Wifi", ToastLength.Long).Show();
                        StartActivity(new Intent(Application.Context, typeof(Login)));
                    });
                }
            }
        }
コード例 #2
0
ファイル: AdminLogic.cs プロジェクト: emc255/BugTracker
        public static List <UserInfoHolder> GetAllUsersInfo()
        {
            var users = db.Users.Include("Roles").ToList();

            var userInfo = new List <UserInfoHolder>();

            foreach (var u in users)
            {
                var ui = new UserInfoHolder();
                ui.Id   = u.Id;
                ui.Name = u.UserName;

                foreach (var r in u.Roles)
                {
                    var role = db.Roles.Find(r.RoleId);
                    ui.RolesInfo.Add(role);
                }
                userInfo.Add(ui);
            }
            return(userInfo.Where(u => u.RolesInfo.All(r => r.Name != "Admin")).ToList());
        }
コード例 #3
0
        private async void Worker_DoWork1(object sender, DoWorkEventArgs e)
        {
            var duration = TimeSpan.FromMilliseconds(100);

            Vibration.Vibrate(duration);

            if (Android.Util.Patterns.EmailAddress.Matcher(email.Text).Matches() == true)
            {
                if (InputValidation.ValidatePassword(pass.Text, pass.Text, this))
                {
                    MainThread.BeginInvokeOnMainThread(() => {
                        //loadingIndicator.Visibility = Android.Views.ViewStates.Visible;
                        loginbuttonindicator.Visibility = Android.Views.ViewStates.Visible;
                    });

                    try
                    {
                        if (CheckWifiStatus())
                        {
                            var user = await Account.UserLogin(email.Text, pass.Text.GetHashCode());

                            if (user == null)
                            {
                                MainThread.BeginInvokeOnMainThread(() =>
                                {
                                    Toast.MakeText(this, "Invalid login credintials provided!", ToastLength.Long).Show();
                                    int hash = pass.Text.GetHashCode();
                                    loadingIndicator.Visibility     = Android.Views.ViewStates.Gone;
                                    loginbuttonindicator.Visibility = Android.Views.ViewStates.Gone;
                                });
                            }

                            else
                            {
                                var iss = new Intent(this, typeof(FragmentHomeActivity));
                                ISharedPreferences       sharedPrefrences = Application.Context.GetSharedPreferences("loginfile", FileCreationMode.Private);
                                ISharedPreferencesEditor spEdit           = sharedPrefrences.Edit();
                                spEdit.PutString("email", user.email_address);
                                spEdit.PutString("password", user.password_hash.ToString());
                                spEdit.Apply();
                                UserInfoHolder.FetchUserInfo(user);
                                FetchandSendTokenWithEmail();
                                MainThread.BeginInvokeOnMainThread(() => {
                                    this.StartActivity(iss);
                                    // circle5.Visibility = Android.Views.ViewStates.Visible;
                                    this.Finish();
                                });
                            }
                        }
                        else
                        {
                            MainThread.BeginInvokeOnMainThread(() =>
                            {
                                Toast.MakeText(this, "Please connect to Wifi", ToastLength.Long).Show();
                                loadingIndicator.Visibility = Android.Views.ViewStates.Gone;
                                email.Enabled = true;
                                pass.Enabled  = true;
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            Toast.MakeText(this, "Please Connect to the Internet| No Internet Connection", ToastLength.Long).Show();
                            loadingIndicator.Visibility = Android.Views.ViewStates.Gone;
                            email.Enabled = true;
                            pass.Enabled  = true;
                        });
                    }
                }


                else
                {
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        Toast.MakeText(this, "PLEASE ENTER CORRECT PASSWORD", ToastLength.Long).Show();
                        loadingIndicator.Visibility = Android.Views.ViewStates.Gone;
                        email.Enabled = true;
                        pass.Enabled  = true;
                    });
                }
            }
            else
            {
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    Toast.MakeText(this, "PLEASE ENTER CORRECT EMAIL ADDRESS", ToastLength.Long).Show();
                    loadingIndicator.Visibility = Android.Views.ViewStates.Gone;
                    email.Enabled = true;
                    pass.Enabled  = true;
                });
            }
        }