public void SaveUserLogin(string accesstoken, User objLoginUser) { try { DALUserLogin objdalLogin = new DALUserLogin(); objLoginUser.LoginTime = DateTime.Now; string resultmsg = objdalLogin.SaveUserDailyLogin(accesstoken, objLoginUser); } catch (Exception ex) { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "LoginPage.xaml.cs", "", "SaveUserLogin"); } }
private async void BtnUpdatePassword_Clicked(object sender, EventArgs e) { try { if (DeviceInternet.InternetConnected()) { ShowLoading(true); dal_Userlogin = new DALUserLogin(); objloginuser.Password = entryNewPassword.Text; string currentPassword = await SecureStorage.GetAsync("Password"); if (currentPassword != null && currentPassword != "") { if ((entryCurrentPassword.Text != null && entryCurrentPassword.Text != "" && entryCurrentPassword.Text.Length >= 8 && entryCurrentPassword.Text == currentPassword)) { if ((entryNewPassword.Text != null && entryNewPassword.Text != "" && entryNewPassword.Text.Length >= 8)) { if ((entryConfirmPassword.Text != null && entryConfirmPassword.Text != "" && entryConfirmPassword.Text.Length >= 8)) { if (entryNewPassword.Text == entryConfirmPassword.Text) { string msg = dal_Userlogin.UpdateUserPassword(Convert.ToString(App.Current.Properties["apitoken"]), objloginuser); if (msg == "Success") { await SecureStorage.SetAsync("Password", entryNewPassword.Text.Trim()); await DisplayAlert("Alert", "Your password updated successfully", "Ok"); var masterPage = new MasterHomePage(); await Navigation.PushAsync(masterPage); } else { await DisplayAlert("Alert", "Unable to update Password,Please contact Admin", "Ok"); var masterPage = new MasterHomePage(); await Navigation.PushAsync(masterPage); } } else { await DisplayAlert("Alert", "Password and Confirm Password do not match", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please enter valid Confirm Password", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please enter valid New Password", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please enter valid Current Password", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Unable to get Password details", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please check your Internet connection", "Ok"); ShowLoading(false); } } catch (Exception ex) { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "ChangePasswordPage.xaml.cs", "", "BtnUpdatePassword_Clicked"); } }
public async void UserLoginVerification() { User resultObj = null; string appversionmsg = string.Empty; ShowLoading(true); IsOnline = VerifyInternet(); try { await Task.Run(() => { appversionmsg = AppVersionServices.GetAndroidStoreAppVersion(); }); if (appversionmsg == string.Empty || appversionmsg == "") { if ((entryUserID.Text != null && entryUserID.Text.Length >= 4) && (entryPassword.Text != null && entryPassword.Text.Length >= 8)) { if (DeviceInternet.InternetConnected()) { await GetAPIToken(); await GetCurrentLocation(); if (App.Current.Properties.ContainsKey("apitoken")) { DALUserLogin objdalLogin = new DALUserLogin(); UserLogin objinputuser = new UserLogin(); objinputuser.UserName = entryUserID.Text.Trim(); objinputuser.Password = entryPassword.Text.Trim(); objinputuser.Latitude = Latitude; objinputuser.Longitude = Longitude; objinputuser.LoginDeviceID = GetDeviceUniqueID(); APIResponse objAPIResponse; objAPIResponse = objdalLogin.LoginVerification(Convert.ToString(App.Current.Properties["apitoken"]), objinputuser); if (objAPIResponse != null) { if (objAPIResponse.Result) { resultObj = JsonConvert.DeserializeObject <User>(Convert.ToString(objAPIResponse.Object)); App.Current.Properties["LoginUser"] = resultObj; resultObj.LoginDeviceID = LoginDeviceID; MasterHomePage masterPage = null; DateTime toDay = DateTime.Parse(resultObj.LocationParkingLotID.LotCloseTime); // Load VehicleTypes in SQLLite await App.SQLiteDb.SaveAllVehicleTypesInSQLLite(Convert.ToString(App.Current.Properties["apitoken"]), resultObj.LocationParkingLotID.LocationID.LocationID); await App.SQLiteDb.SaveVehiclesParkingFeesDetailOnLogin(Convert.ToString(App.Current.Properties["apitoken"]), resultObj.LocationParkingLotID.LocationParkingLotID); await DisplayAlert("Alert", "Your Location and Lot details are:" + resultObj.LocationParkingLotID.LocationID.LocationName + "-" + resultObj.LocationParkingLotID.LocationParkingLotName, "Ok"); if ((resultObj.UserTypeID.UserTypeName.ToUpper()) == ("Operator".ToUpper())) { if (DateTime.Now < toDay) { await Task.Run(() => { if (string.IsNullOrEmpty(cookieUserName) && string.IsNullOrEmpty(cookiePassword)) { SaveUserLogin(Convert.ToString(App.Current.Properties["apitoken"]), resultObj); } SecureStorage.SetAsync("apitoken", Convert.ToString(App.Current.Properties["apitoken"])); SecureStorage.SetAsync("UserName", entryUserID.Text.Trim()); SecureStorage.SetAsync("Password", entryPassword.Text.Trim()); masterPage = new MasterHomePage(); }); await Navigation.PushAsync(masterPage); } else { await DisplayAlert("Alert", "Please contact Admin,lot time (" + toDay + ") closed", "Cancel"); ShowLoading(false); } } else { await Task.Run(() => { if (string.IsNullOrEmpty(cookieUserName) && string.IsNullOrEmpty(cookiePassword)) { SaveUserLogin(Convert.ToString(App.Current.Properties["apitoken"]), resultObj); } SecureStorage.SetAsync("apitoken", Convert.ToString(App.Current.Properties["apitoken"])); SecureStorage.SetAsync("UserName", entryUserID.Text.Trim()); SecureStorage.SetAsync("Password", entryPassword.Text.Trim()); masterPage = new MasterHomePage(); }); await Navigation.PushAsync(masterPage); } } else { await DisplayAlert("Alert", objAPIResponse.Message, "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Invalid Credentials", "Cancel"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Unable to connect API.Please contact Admin", "Ok"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please check your Internet connection", "Ok"); ShowLoading(false); } } else { await DisplayAlert("Alert", "Please enter Valid UserID and Password.", "Ok"); ShowLoading(false); } ShowLoading(false); } else { await DisplayAlert("Alert", appversionmsg, "Ok"); ShowLoading(false); Device.OpenUri(new Uri("https://play.google.com/store/apps/details?id=com.sprvtec.InstaOperator")); DependencyService.Get <ILaunchActivity>().LaunchActivityInAndroid("com.sprvtec.InstaOperator"); } } catch (Exception ex) { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "LoginPage.xaml.cs", "", "BtnSignIn_Clicked"); ShowLoading(false); await DisplayAlert("Alert", "Unable to connect API" + ex.Message, "Ok"); } }