private void validateUnlock() { try { DataSet user = new BL_User().checkLogin(new ML_User { LoginId = UniversalVariables.Username, Password = txt_password.Text }); if (user.Tables[0].Rows.Count == 1 && user.Tables[1].Rows.Count > 0) { this.Hide(); Home.InactivityTimer.Enabled = true; Home.idleFlag = true; } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The password you entered is wrong. Please retry!", "Wrong Password"); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
public static String getLoggedInUserOrganization() { try { DataTable dt = new BL_User().select(SessionHandler.getLoggedInUsername()); return(dt.Rows.Count >= 1 ? dt.Rows[0]["organization_name"].ToString() : string.Empty); } catch (Exception ex) { return(string.Empty); } }
private int BindUser() { using (DataTable dt = new BL_User().selectAll(new ML_User { Key = null })) { lst_users.UnSelectAll(); lst_users.DataSource = dt; lst_users.DisplayMember = "Name"; lst_users.ValueMember = "Key"; return(dt.Rows.Count); } }
public void GetGreenhouseDeviceDataForGraphs(string user_id, string token, string greenhouse_id, string device_id, string start_time, string end_time) { token = token.Trim(); string role = new BL_User().getUserRoleID(user_id); if ((new BL_User().validateTokenByUserID(user_id, token) == 1) && (new BL_Greenhouse().doesGreenhouseIDExist(greenhouse_id, user_id, role)) && (new BL_GreenhouseDevice().doesGreenhouseDeviceExist(greenhouse_id, device_id))) { DataResponse response = new DataResponse(); try { DataTable Data = new BL_GreenhouseDeviceData().selectDataSet(device_id, start_time, end_time); List <GraphDataPointResponse> dataPointList = new List <GraphDataPointResponse>(); foreach (DataRow item in Data.Rows) { dataPointList.Add(new GraphDataPointResponse() { time = item["collected_time"].ToString(), value = item["data"].ToString() }); } HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new GraphDataResponse() { success = true, errorMessage = null, listOfDataPoints = dataPointList })); return; } catch { HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = false, errorCode = UniversalProperties.EC_UnhandledError, errorMessage = UniversalProperties.unknownError })); } HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(response)); } else { HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = false, errorMessage = UniversalProperties.invalidRequest, errorCode = UniversalProperties.EC_InvalidRequest, })); } }
void btn_Login_Click(object sender, EventArgs e) { try { if (LoginForm.txt_loginid.IsNotEmpty() && LoginForm.txt_pwd.IsNotEmpty()) { DataSet user = new BL_User().checkLogin(new ML_User { LoginId = LoginForm.txt_loginid.Text, Password = LoginForm.txt_pwd.Text }); if (user.Tables[0].Rows.Count == 1 && user.Tables[1].Rows.Count > 0) { UniversalVariables.UserKey = user.Tables[0].Rows[0]["Key"].ToString().ToInt(); UniversalVariables.Name = user.Tables[0].Rows[0]["Name"].ToString(); UniversalVariables.UserAccessTypeKey = user.Tables[0].Rows[0]["UserAccessTypeKey"].ToString().ToInt(); UniversalVariables.AccessTypeName = user.Tables[0].Rows[0]["AccessTypeName"].ToString(); UniversalVariables.Username = user.Tables[0].Rows[0]["LoginId"].ToString(); UniversalVariables.IsLoggedIn = true; Privileges.UserPrivileges = user.Tables[1]; Configurations.ConfigurationTable = user.Tables[2]; lbUserName.Text = "Logged in as : " + UniversalVariables.Name; lbUserName.Visible = true; MenuStrip1.Enabled = true; SetDefaults(false); SetMainFormPrivileges(); LoginForm.Hide(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "Wrong username and / or password! Please enter correct details to continue.", "Login Error!"); LoginForm.txt_loginid.Focus(); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The username and / or password field/s cannot be blank. Please re-check!", "Login Error!"); LoginForm.txt_loginid.Focus(); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
public void getCustomerData() { using (DataTable dt = new BL_User().selectByUserID(new ML_User() { id_user = SessionHandler.getLoggedInUserID().ToInt() })) { if (dt.Rows.Count == 1) { this.Address = dt.Rows[0]["address"].ToString(); this.Country = dt.Rows[0]["country"].ToString(); this.Email = dt.Rows[0]["email"].ToString(); this.Telephone = dt.Rows[0]["telephone"].ToString(); this.Mobile = dt.Rows[0]["mobile"].ToString(); this.FirstName = dt.Rows[0]["first_name"].ToString(); this.LastName = dt.Rows[0]["last_name"].ToString(); this.Gender = dt.Rows[0]["gender"].ToString(); this.OrganizationName = dt.Rows[0]["organization_name"].ToString(); this.Title = dt.Rows[0]["title"].ToString(); this.Username = dt.Rows[0]["username"].ToString(); } } }
private void btn_update_password_Click(object sender, EventArgs e) { try { DataSet user = new BL_User().checkLogin(new ML_User { LoginId = UniversalVariables.Username, Password = txt_current_pwd.Text }); if (user.Tables[0].Rows.Count == 1 && user.Tables[1].Rows.Count > 0) { if (vp_password.Validate() && txt_retype_pwd.Text == txt_password.Text) { new BL_User().resetPassword(new ML_User() { Key = UniversalVariables.UserKey, Password = txt_password.Text, LoginId = UniversalVariables.Username, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); FormDirty = false; ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Information, "Password changed successfully! The new password will be available from next login.", "Success"); this.Close(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The passwords you have entered do not match or there are errors in the password constraints. Please re-check!", "Error"); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The current password you have entered does not match what is stored in the database. Please re-check. If the problem persists contact the System Administrator.", "Error"); txt_current_pwd.Focus(); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
public UserController() { BLUser = new BL_User(); }
public void GetLatestGreenhouseDeviceDataByGreenhouseID(string user_id, string greenhouse_id, string token) { token = token.Trim(); string role = new BL_User().getUserRoleID(user_id); if (new BL_User().validateTokenByUserID(user_id, token) == 1 && new BL_Greenhouse().doesGreenhouseIDExist(greenhouse_id, user_id, role)) { DataResponse response = new DataResponse(); try { if (new BL_User().checkForAdmin(user_id) == "1") { DataTable latestData = new Business.BL_GreenhouseDeviceData().getLatestDataForAdmin(greenhouse_id); List <DataResponse> dataList = new List <DataResponse>(); foreach (DataRow item in latestData.Rows) { dataList.Add(new DataResponse() { collected_time = item["collected_time"].ToString(), data = item["data"].ToString(), data_unit = item["data_unit"].ToString(), device_unique_id = item["device_unique_id"].ToString(), device_type = item["device_type"].ToString(), device_type_id = item["device_type_id"].ToString() }); } HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = true, errorMessage = null, listOfData = dataList })); return; } else { DataTable latestData = new Business.BL_GreenhouseDeviceData().getLatestData(greenhouse_id); List <DataResponse> dataList = new List <DataResponse>(); foreach (DataRow item in latestData.Rows) { dataList.Add(new DataResponse() { collected_time = item["collected_time"].ToString(), data = item["data"].ToString(), data_unit = item["data_unit"].ToString(), device_unique_id = item["device_unique_id"].ToString(), device_type = item["device_type"].ToString() }); } HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = true, errorMessage = null, listOfData = dataList })); return; } } catch { HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = false, errorCode = UniversalProperties.EC_UnhandledError, errorMessage = UniversalProperties.unknownError })); } HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(response)); } else { HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(new DataListResponse() { success = false, errorMessage = UniversalProperties.invalidRequest, errorCode = UniversalProperties.EC_InvalidRequest, })); } }
public AuthenticationController() { BLUser = new BL_User(); }
public ActionResult ContactMessage(ContactVM ContactVM) { TransactionResult <object> result = new BL_User().BL_SaveContactInfo(ContactVM); return(Json(result)); }
protected void signinClick(object sender, EventArgs e) { if (Page.IsValid) { try { string user_name = userName.Text.Trim(); string pass_word = password.Text.Trim(); LoginResponse login = MyUser.validateUserIS(user_name, pass_word); if (login.credentials == Constants.VALID && login.success == true) { using (DataTable dt = new BL_User().selectByUserName(new Model.ML_User() { username = user_name })) { string type = dt.Rows[0]["role_name"].ToString(); string userID = dt.Rows[0]["id_user"].ToString(); string loginID = login.loginID; SessionHandler.initiateLoginSession(user_name, type, login.token, userID, loginID); switch (type.Trim()) { case Constants.AIGROW_ADMIN: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_ADMIN + "Index.aspx", false); break; case Constants.CHG_NETWORK: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_NETWORK_OWNER + "Index.aspx", false); break; case Constants.AIGROW_CUSTOMER: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_CUSTOMER + "Index.aspx", false); break; case Constants.CHG_OWNER: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_CHARGE_POINT_OWNER + "Index.aspx", false); break; case Constants.CHG_STAFF: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_STAFF + "Index.aspx", false); break; case Constants.CHG_ACCOUNTANT: Response.Redirect(Constants.HOME_PATH_DASHBOARDS_ACCOUNTANT + "Index.aspx", false); break; default: Response.Redirect(string.Format("{0}?error={1}&token={2}", Constants.LOGIN_URL, Messages.undefinedError, Encryption.createSHA1(Messages.undefinedError)), false); break; } } } else { if (login.errorCode == Constants.EC_UserNotActive) { string message = login.errorMessage + " " + Messages.activateYourAccount + " " + Messages.resendActivationEmail.Replace("<here>", "<a href=\"../ResendActivationEmail.aspx?username="******"\">here</a>"); string message_enc = WebUtility.UrlEncode(Encryption.Base64Encode(message)); Response.Redirect(string.Format("{0}?message_enc={1}&token={2}", Constants.LOGIN_URL, message_enc, Encryption.createSHA1(message_enc)), false); } else { Response.Redirect(string.Format("{0}?error={1}&token={2}", Constants.LOGIN_URL, Messages.invalidUsernameOrPassword, Encryption.createSHA1(Messages.invalidUsernameOrPassword)), false); } } } catch (Exception error) { ApplicationUtilities.writeMsg(error.StackTrace); ApplicationUtilities.writeMsg(error.Message); Response.Redirect(string.Format("{0}?error={1}&token={2}", Constants.LOGIN_URL, Messages.undefinedError, Encryption.createSHA1(Messages.undefinedError)), false); } } else { userName.Focus(); } }
private void btn_save_Click(object sender, EventArgs e) { try { if (!IsNewRecord && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } using (DataTable Table = new BL_User().selectUsage(new ML_User { Key = (SelectedID == 0 ? null : (int?)SelectedID), LoginId = txt_login_name.Text })) { if (IsNewRecord) { //New record - insert if (UserWithPasswordValidation.Validate() && UserValidation.Validate()) { if (Table.Rows.Count < 1) { new BL_User().insert(new ML_User() { LoginId = txt_login_name.Text.Trim(), Name = txt_name.Text.Trim(), NIC = txt_nic.Text.Trim(), Password = (txt_password.IsEmpty() ? null : txt_password.Text), UserAccessTypeKey = (int)cbo_user_access_type.EditValue, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); LastUser = txt_name.Text; BindUser(); ResetForm(false, true, true, hasAccessInsert, hasAccessDelete, true); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered user login name is already in the database. Please re-check!", "Error"); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "None of the values can be null / invalid. Please re-check!", "Error!"); } } else { //Update if (UserValidation.Validate() && SelectedID > 0) { if (Table.Rows.Count <= 1) { bool IsPasswordReset; if (txt_password.IsNotEmpty()) { IsPasswordReset = UserWithPasswordValidation.Validate(); if (!IsPasswordReset) { return; } } else { IsPasswordReset = false; } new BL_User().update(new ML_User { LoginId = txt_login_name.Text.Trim(), Name = txt_name.Text.Trim(), NIC = txt_nic.Text.Trim(), UserAccessTypeKey = Convert.ToInt32(cbo_user_access_type.EditValue), UserKey = UniversalVariables.UserKey, Key = SelectedID, Password = IsPasswordReset ? (txt_password.IsEmpty() ? null : txt_password.Text) : null, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); LastUser = txt_name.Text.Trim(); BindUser(); ResetForm(false, true, true, hasAccessInsert, hasAccessDelete, true); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered user login name is already in the database. Please re-check!", "Error"); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "None of the values can be null / invalid. Please re-check!", "Error"); } } } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
public static string getProfileImageURL() { string profile_pic_url = new BL_User().select(SessionHandler.getLoggedInUsername()).Rows[0]["profile_picture_url"].ToString(); return((profile_pic_url == string.Empty || profile_pic_url == null) ? AppFunction.ReadSetting("DefaultProPicURL") : profile_pic_url); }