public void outputData() { _database = new YangDb(); var users = _database.GetUsers(); foreach (var user in users) { Debug.WriteLine("user name is " + user.Name + ", pwd is " + user.Password + ", pin is " + user.Pin + ", url is " + user.Url); } }
bool isPinExist(UserEntity newUser) { List <UserEntity> users = _database.GetUsers(); foreach (UserEntity u in users) { if (newUser.Pin.Equals(u.Pin)) { return(true); } } return(false); }
// click LOGIN event async void Login_CheckAsync(string pin) { var users = _database.GetUsers(); // todo how go check usr foreach (var user in users) { if (user.Pin.Equals(pin)) { App.IsUserLoggedIn = true; // set username to application App.UserEntity = user; // grab the paths if (!App.UserEntity.Url.EndsWith("/", StringComparison.Ordinal)) { App.UserEntity.Url += "/"; } App.PathList = _database.GetPaths(user.ID); await Task.Run(async() => { await Task.Delay(0); Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage = new MainPageCS(); }); }); return; } else { Debug.WriteLine("Pin not match"); } } if (!App.IsUserLoggedIn) { await Task.Run(async() => { await Task.Delay(0); Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Failed", "Pin not match", "Ok"); }); }); } inputString = Pin1 = Pin2 = Pin3 = Pin4 = Pin5 = ""; }
// click LOGIN event async void Login_CheckAsync(object sender, EventArgs e) { if (!(string.IsNullOrEmpty(pin1.Text) || string.IsNullOrEmpty(pin2.Text) || string.IsNullOrEmpty(pin3.Text) || string.IsNullOrEmpty(pin4.Text))) { if (Utils.IsNumeric(pin1.Text) && Utils.IsNumeric(pin2.Text) && Utils.IsNumeric(pin3.Text) && Utils.IsNumeric(pin4.Text)) { String pin = pin1.Text + pin2.Text + pin3.Text + pin4.Text; var users = _database.GetUsers(); // todo how go check usr foreach (var user in users) { if (user.Pin.Equals(pin)) { App.IsUserLoggedIn = true; //isSuccess = true; // set username to application App.UserEntity = user; // grab the paths //if (!App.UserEntity.Url.EndsWith("/", StringComparison.Ordinal)) //{ // App.UserEntity.Url += "/"; //} //App.UserEntity.Url = App.UserEntity.Url; App.PathList = _database.GetPaths(user.ID); // test log foreach (var item in App.PathList) { string ret = "User ID:" + item.UserID + ",Path: " + item.Path + ", Parent: " + item.Parent; Debug.WriteLine(ret); } await Task.Run(async() => { await Task.Delay(0); Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage = new MainPageCS(); }); }); return; } else { //warning.Text = "Pin not match"; Debug.WriteLine("Pin not match"); } } } else { Debug.WriteLine("Pin only support number"); } Debug.WriteLine("contain empty"); } if (!alertLock) { alertLock = true; pin1.TextChanged -= Entry_TextChanged; pin2.TextChanged -= Entry_TextChanged; pin3.TextChanged -= Entry_TextChanged; pin4.TextChanged -= Last_LastEntry; pin1.Text = ""; pin2.Text = ""; pin3.Text = ""; pin4.Text = ""; pin1.TextChanged += Entry_TextChanged; pin2.TextChanged += Entry_TextChanged; pin3.TextChanged += Entry_TextChanged; pin4.TextChanged += Last_LastEntry; Debug.WriteLine("fail to login"); //Entry_Disanable(pin1); await DisplayAlert("Failed", "Please try again", "Ok"); } pin1.Focus(); }