public UserInfoEntity GetUserInfo() { UserInfoEntity userInfoEntity = new UserInfoEntity( this.txt_username.Text, this.txt_firstname.Text, this.txt_initials.Text, this.txt_lastname.Text, this.txt_display.Text, this.txt_alias.Text, this.cb_gender.Value.ToString(), this.cb_title.Value.ToString(), this.dt_dateofbirth.DateTime, this.txt_email.Text, this.txt_telephoneno.Text, this.txt_faxno.Text, this.txt_mobileno.Text, this.txt_pagerno.Text, this.txt_remarks.Text, this.StatusTextEditor.Text, DateTime.Now, String.Empty, _changedDefaultOfficeKey, "", this.Txt_JobTitle.Text, cb_branch.Value == null || cb_branch.Value.ToString() == "0" || string.IsNullOrEmpty(cb_branch.Value.ToString()) ? null : cb_branch.Value.ToString(), cb_unit.Value == null || cb_unit.Value.ToString() == "0" || string.IsNullOrEmpty(cb_unit.Value.ToString()) ? null : cb_unit.Value.ToString(), cb_subunit.Value == null || cb_subunit.Value.ToString() == "0" || string.IsNullOrEmpty(cb_subunit.Value.ToString()) ? null : cb_subunit.Value.ToString(), cb_grade.Value == null || cb_grade.Value.ToString() == "0" || string.IsNullOrEmpty(cb_grade.Value.ToString()) ? null : cb_grade.Value.ToString(), // Extend "job title" property ReportsTo // Extend "Reports To" property, TO-DO: set "Reports To" value here. ); //userInfoEntity.ConfigurationInfo = UserHelper.CreateUserBasicConfigurationSection(); int epRIN ; userInfoEntity.IsInternal = !this.chb_ExternalUser.Checked; if (!userInfoEntity.IsInternal && int.TryParse(txt_EPRIN.Text.Split('-')[0], out epRIN)) { //It should be validated ok in validation userInfoEntity.EPRIN = epRIN; } else { userInfoEntity.EPRIN = null; } return userInfoEntity; }
public UserInfoEntity GetUpdatedUserInfo(UserInfoEntity userInfo) { if (userInfo == null) return GetUserInfo(); userInfo.FirstName = this.txt_firstname.Text; userInfo.Initials = this.txt_initials.Text; userInfo.LastName = this.txt_lastname.Text; userInfo.Display = this.txt_display.Text; userInfo.Alias = this.txt_alias.Text; userInfo.Gender = this.cb_gender.Value.ToString(); userInfo.Title = this.cb_title.Value.ToString(); userInfo.DateOfBirth = this.dt_dateofbirth.DateTime; userInfo.Email = this.txt_email.Text; userInfo.TelephoneNo = this.txt_telephoneno.Text; userInfo.FaxNo = this.txt_faxno.Text; userInfo.MobileNo = this.txt_mobileno.Text; userInfo.PageNo = this.txt_pagerno.Text; //userInfo.Organisation = String.Empty; userInfo.Remarks = this.txt_remarks.Text; //User office userInfo.Office = this._changedDefaultOfficeKey; // Extend "job title" property userInfo.JobTitle = this.Txt_JobTitle.Text; //Delegations userInfo.Branch = cb_branch.Value == null || cb_branch.Value.ToString() == "0" || string.IsNullOrEmpty(cb_branch.Value.ToString()) ? null : cb_branch.Value.ToString(); userInfo.Unit = cb_unit.Value == null || cb_unit.Value.ToString() == "0" || string.IsNullOrEmpty(cb_unit.Value.ToString()) ? null : cb_unit.Value.ToString(); userInfo.SubUnit = cb_subunit.Value == null || cb_subunit.Value.ToString() == "0" || string.IsNullOrEmpty(cb_subunit.Value.ToString()) ? null : cb_subunit.Value.ToString(); userInfo.Grade = cb_grade.Value == null || cb_grade.Value.ToString() == "0" || string.IsNullOrEmpty(cb_grade.Value.ToString()) ? null : cb_grade.Value.ToString(); // Extend "Reports To" property, TO-DO: set "Reports To" value here. userInfo.ReportsTo = ReportsTo == null ? string.Empty : ReportsTo; // int epRIN ; userInfo.IsInternal = !this.chb_ExternalUser.Checked; if (!userInfo.IsInternal && int.TryParse(txt_EPRIN.Text.Split('-')[0], out epRIN)) { //It should be validated ok in validation userInfo.EPRIN = epRIN; } else { userInfo.EPRIN = null; } return userInfo; }
public UserInfoEntity GetUser(string userName) { if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } ProfileBase userProfile = ProfileBase.Create(userName); UserInfoEntity userInfoEntity = new UserInfoEntity(); userInfoEntity.UserName = userName; userInfoEntity.FirstName = userProfile["FirstName"].ToString(); userInfoEntity.Initials = userProfile["Initials"] == null ? String.Empty : userProfile["Initials"].ToString(); userInfoEntity.LastName = userProfile["LastName"].ToString(); userInfoEntity.Display = userProfile["Display"].ToString(); userInfoEntity.Alias = userProfile["Alias"] == null ? String.Empty : userProfile["Alias"].ToString(); userInfoEntity.Gender = userProfile["Gender"].ToString(); userInfoEntity.Title = userProfile["Title"].ToString(); userInfoEntity.DateOfBirth = userProfile["DateOfBirth"] == null ? MinMaxValues.MinDate : Convert.ToDateTime(userProfile["DateOfBirth"]); userInfoEntity.Email = userProfile["Email"].ToString(); userInfoEntity.TelephoneNo = userProfile["TelephoneNo"].ToString(); userInfoEntity.FaxNo = userProfile["FaxNo"] == null ? String.Empty : userProfile["FaxNo"].ToString(); userInfoEntity.MobileNo = userProfile["MobileNo"] == null ? String.Empty : userProfile["MobileNo"].ToString(); userInfoEntity.PageNo = userProfile["PageNo"] == null ? String.Empty : userProfile["PageNo"].ToString(); //userInfoEntity.Organisation = userProfile["Organisation"].ToString(); userInfoEntity.Remarks = userProfile["Remarks"] == null ? String.Empty : userProfile["Remarks"].ToString(); userInfoEntity.UserStatus = (this.IsActiveUser(userInfoEntity.UserName)) ? UserStatus.Active : UserStatus.Inactive; //XElement userConfigurationInfo = new XElement(HiiP.Framework.Common.Constants.UserConfigInfoSectionNames.RootSectionName); //if (userProfile["ConfigurationInfo"] != null && userProfile["ConfigurationInfo"].ToString() != String.Empty) //{ // userConfigurationInfo = XElement.Parse(userProfile["ConfigurationInfo"].ToString()); //} //userInfoEntity.ConfigurationInfo = userConfigurationInfo; userInfoEntity.VersionNo = Convert.ToInt32(userProfile["VersionNo"]); if (userProfile["Office"] != null) { userInfoEntity.Office = userProfile["Office"].ToString(); } // Extend "job title" property userInfoEntity.JobTitle = userProfile["JobTitle"] == null ? String.Empty : userProfile["JobTitle"].ToString(); // Extend "ReportsTo" property userInfoEntity.ReportsTo = userProfile["ReportsTo"] == null ? String.Empty : userProfile["ReportsTo"].ToString(); userInfoEntity.EPRIN = Convert.ToInt32(userProfile["EPRIN"]); if (userInfoEntity.EPRIN == -999) { userInfoEntity.EPRIN = null; } if (userProfile["IsInternal"] != null) { userInfoEntity.IsInternal = Convert.ToBoolean(userProfile["IsInternal"]); } else { userInfoEntity.IsInternal = true; } //Delegations userInfoEntity.Branch = userProfile["Branch"].ToString(); userInfoEntity.Unit = userProfile["Unit"].ToString(); userInfoEntity.SubUnit = userProfile["SubUnit"].ToString(); userInfoEntity.Grade = userProfile["Grade"].ToString(); return userInfoEntity; }
public UserInfoEntity[] GetUserInRoleByRoleName(string roleName) { if (string.IsNullOrEmpty(roleName)) return new UserInfoEntity[] { }; DataTable dt = new DataTable(); DbHelper helper = new DbHelper(); DbCommand command = helper.BuildDbCommand("P_IC_USER_IN_ROLE_SEARCH"); helper.AssignParameterValues( command, roleName ); Helper.Fill(dt, command); Dictionary<string, UserInfoEntity> arrayList = new Dictionary<string, UserInfoEntity>(); UserInfoEntity userInfo ; foreach (DataRow row in dt.Rows) { userInfo = new UserInfoEntity(); string userId = row["USER_ID"].ToString(); userInfo.UserName = row["USER_NAME"].ToString(); userInfo.FirstName = row["FIRST_NAME"].ToString(); userInfo.Initials = row["INITIALS"].GetType() == typeof(System.DBNull) ? String.Empty : row["INITIALS"].ToString(); userInfo.LastName = row["LAST_NAME"].ToString(); userInfo.Display = row["DISPLAY"].ToString(); userInfo.Alias = row["ALIAS"].GetType() == typeof(System.DBNull) ? String.Empty : row["ALIAS"].ToString(); userInfo.Gender = row["GENDER"].ToString(); userInfo.Title = row["TITLE"].ToString(); userInfo.DateOfBirth = row["DATE_OF_BIRTH"].GetType() == typeof(System.DBNull) ? MinMaxValues.MinDate : Convert.ToDateTime(row["DATE_OF_BIRTH"]); userInfo.Email = row["EMAIL"].ToString(); userInfo.TelephoneNo = row["TELEPHONE_NO"].ToString(); userInfo.FaxNo = row["FAX_NO"].GetType() == typeof(System.DBNull) ? String.Empty : row["FAX_NO"].ToString(); userInfo.MobileNo = row["MOBILE_NO"].GetType() == typeof(System.DBNull) ? String.Empty : row["MOBILE_NO"].ToString(); userInfo.PageNo = row["PAGER_NO"].GetType() == typeof(System.DBNull) ? String.Empty : row["PAGER_NO"].ToString(); //UIE.Organisation = row["ORGANISATION"].ToString(); userInfo.Remarks = row["REMARKS"].GetType() == typeof(System.DBNull) ? String.Empty : row["REMARKS"].ToString(); userInfo.UserStatus = row["STATUS"].ToString(); userInfo.CreatedOn = (DateTime)row["CREATED_TIME"]; userInfo.Office = row["OFFICE"].GetType() == typeof(DBNull) ? String.Empty : row["OFFICE"].ToString(); arrayList.Add(userId, userInfo); } dt.Dispose(); return arrayList.Values.ToArray<UserInfoEntity>(); }
public void CreateUserInfo(UserInfoEntity userInfoEntity, List<DataFilterEntity> dataFilterEntities, string[] roles) { // ceate a new user account Membership.CreateUser(userInfoEntity.UserName, "Password0"); // create user basic information by created username ProfileBase profileInfo = ProfileBase.Create(userInfoEntity.UserName); profileInfo["FirstName"] = userInfoEntity.FirstName; profileInfo["Initials"] = userInfoEntity.Initials; profileInfo["LastName"] = userInfoEntity.LastName; profileInfo["Display"] = userInfoEntity.Display; profileInfo["Alias"] = userInfoEntity.Alias; profileInfo["Gender"] = userInfoEntity.Gender; profileInfo["Title"] = userInfoEntity.Title; profileInfo["DateOfBirth"] = userInfoEntity.DateOfBirth; profileInfo["Email"] = userInfoEntity.Email; profileInfo["TelephoneNo"] = userInfoEntity.TelephoneNo; profileInfo["FaxNo"] = userInfoEntity.FaxNo; profileInfo["MobileNo"] = userInfoEntity.MobileNo; profileInfo["PageNo"] = userInfoEntity.PageNo; //profileInfo["Organisation"] = userInfoEntity.Organisation; profileInfo["Remarks"] = userInfoEntity.Remarks; profileInfo["ConfigurationInfo"] = new XElement(HiiP.Framework.Common.Constants.UserConfigInfoSectionNames.RootSectionName).ToString(); profileInfo["Office"] = userInfoEntity.Office; // Extend "job title" property profileInfo["JobTitle"] = userInfoEntity.JobTitle; //profileInfo // Extend "Reports to" property profileInfo["ReportsTo"] = userInfoEntity.ReportsTo; profileInfo["EPRIN"] = userInfoEntity.EPRIN; profileInfo["IsInternal"] = userInfoEntity.IsInternal; //Delegations profileInfo["Branch"] = userInfoEntity.Branch; profileInfo["Unit"] = userInfoEntity.Unit; profileInfo["SubUnit"] = userInfoEntity.SubUnit; profileInfo["Grade"] = userInfoEntity.Grade; profileInfo["VersionNo"] = userInfoEntity.VersionNo + 1; profileInfo.Save(); //// Mapping office to user //if (officeEntities != null && officeEntities.Count > 0) //{ // foreach (OfficeEntity officeEntity in officeEntities) // { // officeEntity.UserName = userInfoEntity.UserName; // } // MappingUserOffices(officeEntities); //} // Mapping data filters to user if (dataFilterEntities != null && dataFilterEntities.Count > 0) { foreach (DataFilterEntity dataFilterEntity in dataFilterEntities) { dataFilterEntity.UserName = userInfoEntity.UserName; } MappingUserDataFilterValues(dataFilterEntities); } // Add roles to the user if (roles.Length > 0) { AddUserToRoles(userInfoEntity.UserName, roles); } }
public void UpdateUserInfo(UserInfoEntity userInfoEntity, List<DataFilterEntity> dataFilterEntities, string[] roles) { // update user basic information by username ProfileBase profileInfo = ProfileBase.Create(userInfoEntity.UserName); profileInfo["FirstName"] = userInfoEntity.FirstName; profileInfo["Initials"] = userInfoEntity.Initials; profileInfo["LastName"] = userInfoEntity.LastName; profileInfo["Display"] = userInfoEntity.Display; profileInfo["Alias"] = userInfoEntity.Alias; profileInfo["Gender"] = userInfoEntity.Gender; profileInfo["Title"] = userInfoEntity.Title; profileInfo["DateOfBirth"] = userInfoEntity.DateOfBirth; profileInfo["Email"] = userInfoEntity.Email; profileInfo["TelephoneNo"] = userInfoEntity.TelephoneNo; profileInfo["FaxNo"] = userInfoEntity.FaxNo; profileInfo["MobileNo"] = userInfoEntity.MobileNo; profileInfo["PageNo"] = userInfoEntity.PageNo; //profileInfo["Organisation"] = userInfoEntity.Organisation; profileInfo["Remarks"] = userInfoEntity.Remarks; //profileInfo["ConfigurationInfo"] = userInfoEntity.ConfigurationInfo.ToString(); profileInfo["VersionNo"] = userInfoEntity.VersionNo + 1; profileInfo["Office"] = userInfoEntity.Office; // Extend "job title" property profileInfo["JobTitle"] = userInfoEntity.JobTitle; // Extend "Reports to" property profileInfo["ReportsTo"] = userInfoEntity.ReportsTo; profileInfo["EPRIN"] = userInfoEntity.EPRIN; profileInfo["IsInternal"] = userInfoEntity.IsInternal; //Delegations profileInfo["Branch"] = string.IsNullOrEmpty(userInfoEntity.Branch ) ? null : userInfoEntity.Branch; profileInfo["Unit"] = string.IsNullOrEmpty(userInfoEntity.Unit ) ? null : userInfoEntity.Unit; profileInfo["SubUnit"] = string.IsNullOrEmpty(userInfoEntity.SubUnit ) ? null : userInfoEntity.SubUnit; profileInfo["Grade"] = string.IsNullOrEmpty(userInfoEntity.Grade ) ? null : userInfoEntity.Grade; profileInfo.Save(); //// Mapping office to user //if (officeEntities != null && officeEntities.Count > 0) //{ // foreach (OfficeEntity officeEntity in officeEntities) // { // officeEntity.UserName = userInfoEntity.UserName; // } // MappingUserOffices(officeEntities); //} // Mapping data filters to user if (dataFilterEntities != null && dataFilterEntities.Count > 0) { foreach (DataFilterEntity dataFilterEntity in dataFilterEntities) { dataFilterEntity.UserName = userInfoEntity.UserName; } MappingUserDataFilterValues(dataFilterEntities); } // Update roles for the user if (roles != null) { UpdateRolesForUser(userInfoEntity.UserName, roles); } }