public static bool CreatePortalUser(UserInfo obj, out UserCreationStatus status, UserCreationMode mode) { string sp = "[dbo].[usp_sf_CreateUser]"; try { List<KeyValuePair<string, object>> ParamCollInput = new List<KeyValuePair<string, object>>(); ParamCollInput.Add(new KeyValuePair<string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair<string, object>("@UserName", obj.UserName)); ParamCollInput.Add(new KeyValuePair<string, object>("@FirstName", obj.FirstName)); ParamCollInput.Add(new KeyValuePair<string, object>("@LastName", obj.LastName)); ParamCollInput.Add(new KeyValuePair<string, object>("@Password", obj.Password)); ParamCollInput.Add(new KeyValuePair<string, object>("@PasswordSalt", obj.PasswordSalt)); ParamCollInput.Add(new KeyValuePair<string, object>("@Email", obj.Email)); ParamCollInput.Add(new KeyValuePair<string, object>("@PasswordQuestion", obj.SecurityQuestion)); ParamCollInput.Add(new KeyValuePair<string, object>("@PasswordAnswer", obj.SecurityAnswer)); ParamCollInput.Add(new KeyValuePair<string, object>("@IsApproved", obj.IsApproved)); ParamCollInput.Add(new KeyValuePair<string, object>("@CurrentTimeUtc", obj.CurrentTimeUtc)); ParamCollInput.Add(new KeyValuePair<string, object>("@CreateDate", obj.CreatedDate)); ParamCollInput.Add(new KeyValuePair<string, object>("@UniqueEmail", obj.UniqueEmail)); ParamCollInput.Add(new KeyValuePair<string, object>("@PasswordFormat", obj.PasswordFormat)); ParamCollInput.Add(new KeyValuePair<string, object>("@PortalID", obj.PortalID)); ParamCollInput.Add(new KeyValuePair<string, object>("@AddedOn", obj.AddedOn)); ParamCollInput.Add(new KeyValuePair<string, object>("@AddedBy", obj.AddedBy)); ParamCollInput.Add(new KeyValuePair<string, object>("@RoleNames", obj.RoleNames)); ParamCollInput.Add(new KeyValuePair<string, object>("@StoreID", obj.StoreID)); List<KeyValuePair<string, object>> ParamCollOutput = new List<KeyValuePair<string, object>>(); ParamCollOutput.Add(new KeyValuePair<string, object>("@UserId", obj.UserID)); ParamCollOutput.Add(new KeyValuePair<string, object>("@ErrorCode", 0)); ParamCollOutput.Add(new KeyValuePair<string, object>("@CustomerID", obj.CustomerID)); SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List<KeyValuePair<int, string>> OutputValColl = new List<KeyValuePair<int, string>>(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int CustomerID = int.Parse(OutputValColl[2].Value); int ErrorCode = int.Parse(OutputValColl[1].Value); Guid UserID = new Guid(OutputValColl[0].Value.ToString()); switch (ErrorCode) { case 3: status = UserCreationStatus.DUPLICATE_EMAIL; break; case 6: status = UserCreationStatus.DUPLICATE_USER; break; default: status = UserCreationStatus.SUCCESS; break; } return true; } catch (Exception) { throw; } }
public void CheckEmail(string email) { try { MembershipController member = new MembershipController(); UserInfo objUser = member.GerUserByEmail(email, GetPortalID); if (objUser.IsApproved == true) { SucessFullLogin(objUser); } else { { int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = FirstName; objUser.UserName = email; objUser.LastName = LastName; string Pwd, PasswordSalt; string newPassword = GenerateRandomPassword(); PasswordHelper.EnforcePasswordSecurity(member.PasswordFormat, newPassword, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = email; objUser.SecurityQuestion = " "; objUser.SecurityAnswer = " "; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.StoreID = GetStoreID; objUser.PasswordFormat = member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER); if (status == UserCreationStatus.SUCCESS) { SucessFullLogin(objUser); } } } } catch (Exception ex) { ProcessException(ex); } }
private void RegisterUser() { try { MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString); if (string.IsNullOrEmpty(UserName.Text) || string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrEmpty(LastName.Text) || string.IsNullOrEmpty(Email.Text)) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); checkIfSucccess = 0; } else { int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = FirstName.Text; objUser.UserName = UserName.Text; objUser.LastName = LastName.Text; string Pwd, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, Password.Text, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = Email.Text; objUser.SecurityQuestion = Question.Text; objUser.SecurityAnswer = Answer.Text; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = _member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage(SageMessageTitle.Notification.ToString(), UserName.Text.Trim() + " " + GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); checkIfSucccess = 0; } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); checkIfSucccess = 0; } else if (status == UserCreationStatus.SUCCESS) { MembershipUser userInfo = Membership.GetUser(UserName.Text); if (chkIsSubscribeNewsLetter.Checked) { int? newID = 0; ManageNewsLetterSubscription(Email.Text, ref newID); } ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "UserCreatedSuccessfully"), "", SageMessageType.Success); checkIfSucccess = 1; //HandlePostRegistration(UserRegistrationType, dbMessageTemplate); } } } catch (Exception ex) { ProcessException(ex); } }
private void RegisterUser() { try { if (string.IsNullOrEmpty(UserName.Text) || string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrEmpty(LastName.Text) || string.IsNullOrEmpty(Email.Text) || string.IsNullOrEmpty(Password.Text) || string.IsNullOrEmpty(ConfirmPassword.Text) || string.IsNullOrEmpty(CaptchaValue.Text)) { ShowMessage("", GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } else if (UserName.Text.Length > 50) { ShowMessage("", "Username should not be greater than 50 characters", "", SageMessageType.Alert); } else { int UserRegistrationType = pagebase.GetSettingIntValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = Server.HtmlEncode(FirstName.Text); objUser.UserName = Server.HtmlEncode(UserName.Text); objUser.LastName = Server.HtmlEncode(LastName.Text); string Pwd, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, Password.Text, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = Email.Text; objUser.SecurityQuestion = " "; objUser.SecurityAnswer = " "; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = _member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage("", GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage("", GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.SUCCESS) { try { IsModuleInstalled(1); MembershipUser userInfo = Membership.GetUser(UserName.Text.Trim()); if (chkIsSubscribeNewsLetter.Checked) { int?newID = 0; ManageNewsLetterSubscription(Email.Text, ref newID); IsModuleInstalled(2); } HandlePostRegistration(UserRegistrationType); } catch (Exception) { ShowMessage("", GetSageMessage("UserManagement", "SecureConnection"), "", SageMessageType.Alert); } } } } catch (Exception ex) { ProcessException(ex); } }
public abstract bool UpdateUser(UserInfo user, out UserCreationStatus status);
public abstract bool CreateUser(UserInfo user, out UserCreationStatus status, UserCreationMode mode);
/// <summary> /// Connect to the database and create user. /// </summary> /// <param name="user">Object of UserInfo class.</param> /// <param name="status">User creation status.<see cref="T:SageFrame.Security.Helpers.UserCreationStatus"/></param> /// <param name="mode">User creation mode.</param> /// <returns>True for create successfully.</returns> public static bool CreatePortalUser(UserInfo obj, out UserCreationStatus status, UserCreationMode mode) { string sp = "[dbo].[usp_sf_CreateUser]"; try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", obj.UserName)); ParamCollInput.Add(new KeyValuePair <string, object>("@FirstName", obj.FirstName)); ParamCollInput.Add(new KeyValuePair <string, object>("@LastName", obj.LastName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Password", obj.Password)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordSalt", obj.PasswordSalt)); ParamCollInput.Add(new KeyValuePair <string, object>("@Email", obj.Email)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordQuestion", obj.SecurityQuestion)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordAnswer", obj.SecurityAnswer)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsApproved", obj.IsApproved)); ParamCollInput.Add(new KeyValuePair <string, object>("@CurrentTimeUtc", obj.CurrentTimeUtc)); ParamCollInput.Add(new KeyValuePair <string, object>("@CreateDate", obj.CreatedDate)); ParamCollInput.Add(new KeyValuePair <string, object>("@UniqueEmail", obj.UniqueEmail)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordFormat", obj.PasswordFormat)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", obj.PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", obj.AddedOn)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", obj.AddedBy)); ParamCollInput.Add(new KeyValuePair <string, object>("@RoleNames", obj.RoleNames)); ParamCollInput.Add(new KeyValuePair <string, object>("@StoreID", obj.StoreID)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@UserId", obj.UserID)); ParamCollOutput.Add(new KeyValuePair <string, object>("@ErrorCode", 0)); ParamCollOutput.Add(new KeyValuePair <string, object>("@CustomerID", obj.CustomerID)); SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int CustomerID = int.Parse(OutputValColl[2].Value); int ErrorCode = int.Parse(OutputValColl[1].Value); Guid UserID = new Guid(OutputValColl[0].Value.ToString()); switch (ErrorCode) { case 3: status = UserCreationStatus.DUPLICATE_EMAIL; break; case 6: status = UserCreationStatus.DUPLICATE_USER; break; default: status = UserCreationStatus.SUCCESS; break; } return(true); } catch (Exception) { throw; } }
protected void btnUserImport_Click(object sender, EventArgs e) { try { bool Flag = false; DataSet userImportDataSet = ImportUserFile(); List<string> lstColumnHeader = new List<string>(); List<string> ObjMappingList = MappingList(); if (userImportDataSet.Tables.Count > 0) { int columnLength = userImportDataSet.Tables[0].Columns.Count; for (int i = 0; i < columnLength; i++) { lstColumnHeader.Add(userImportDataSet.Tables[0].Columns[i].ColumnName); } Flag = !ObjMappingList.Except(lstColumnHeader).Any(); if (Flag) { for (int i = 0; i < columnLength; i++) { if (txtImportUserName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "UserName"; } if (txtImportFirstName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "FirstName"; } if (txtImportLastName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "LastName"; } if (txtImportEmail.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "Email"; } if (txtImportPassword.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "Password"; } if (txtImportPasswordSalt.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "PasswordSalt"; } if (txtImportPasswordFormat.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "PasswordFormat"; } if (txtImportRoleName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "RoleName"; } if (txtImportPortalID.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "PortalID"; } if (txtImportIsApproved.Text == userImportDataSet.Tables[0].Columns[i].ColumnName) { userImportDataSet.Tables[0].Columns[i].ColumnName = "IsActive"; } } } else { ShowMessage("", GetSageMessage("UserManagement", "ColumnMappingError"), "", SageMessageType.Alert); clearField(); return; } //Listing Excel Users foreach (DataRow dr in userImportDataSet.Tables[0].Rows) { ExportUserInfo userImportInfo = new ExportUserInfo(); userImportInfo.UserName = dr["UserName"].ToString(); userImportInfo.FirstName = dr["FirstName"].ToString(); userImportInfo.LastName = dr["LastName"].ToString(); userImportInfo.Email = dr["Email"].ToString(); userImportInfo.Password = dr["Password"].ToString(); userImportInfo.PasswordSalt = dr["PasswordSalt"].ToString(); userImportInfo.PasswordFormat = dr["PasswordFormat"].ToString(); userImportInfo.RoleName = dr["RoleName"].ToString(); userImportInfo.PortalID = Convert.ToInt32(dr["PortalID"]); userImportInfo.IsApproved = Convert.ToBoolean(dr["IsActive"]); lstUserImportUsers.Add(userImportInfo); } //Extracting Excel Roles List<RoleInfo> lstExcelRolesSplit = new List<RoleInfo>(); foreach (ExportUserInfo objExport in lstUserImportUsers) { string[] excelRolesArr = objExport.RoleName.Split(','); foreach (string role in excelRolesArr) { RoleInfo objRoles = new RoleInfo(); objRoles.PortalID = objExport.PortalID; objRoles.RoleName = role.Trim(); lstExcelRolesSplit.Add(objRoles); } } List<RoleInfo> lstExcelRolesIdentical = new List<RoleInfo>(); var ExcelRolesIdentical = lstExcelRolesSplit.Select(i => new { i.RoleName, i.PortalID }).Distinct(); foreach (var objRole in ExcelRolesIdentical) { RoleInfo objRoleInfo = new RoleInfo(); objRoleInfo.RoleName = objRole.RoleName; objRoleInfo.PortalID = objRole.PortalID; lstExcelRolesIdentical.Add(objRoleInfo); } //Extracting Sage Roles List<RolesManagementInfo> lstSageRoles = new List<RolesManagementInfo>(); RolesManagementController objController = new RolesManagementController(); lstSageRoles = objController.GetSageFramePortalList(); List<RoleInfo> lstSageRolesSplit = new List<RoleInfo>(); foreach (RolesManagementInfo objRoleMgntInfo in lstSageRoles) { RoleInfo objSageRoles = new RoleInfo(); objSageRoles.RoleName = objRoleMgntInfo.RoleName; objSageRoles.PortalID = objRoleMgntInfo.PortalID; lstSageRolesSplit.Add(objSageRoles); } //Retrieve Identical Roles in Sage Roles and Excel Roles List<RoleInfo> lstIdenticalRoles = lstExcelRolesIdentical.Except(lstSageRolesSplit).ToList(); //Adding Identical Roles in SageRoles for (int i = 0; i < lstIdenticalRoles.Count; i++) { RoleInfo objRole = new RoleInfo(); string rolePrefix = GetPortalSEOName + "_"; objRole.ApplicationName = Membership.ApplicationName; objRole.RoleName = lstIdenticalRoles[i].RoleName; objRole.PortalID = lstIdenticalRoles[i].PortalID; objRole.IsActive = 1; objRole.AddedOn = DateTime.Now; objRole.AddedBy = GetUsername; RoleController objRoleCon = new RoleController(); RoleCreationStatus status = new RoleCreationStatus(); objRoleCon.CreateRole(objRole, out status); } //Listing SageFrame Users UserProfileController objUserProfile = new UserProfileController(); List<ExportUserInfo> lstSageUsers = objUserProfile.GetSageFrameUserList(); //Extracting Excel Username List<string> lstExcelUserName = new List<string>(); lstExcelUserName = lstUserImportUsers.Select(x => x.UserName).ToList(); //Extracting Excel Email List<string> lstExcelEmail = new List<string>(); lstExcelEmail = lstUserImportUsers.Select(x => x.Email).ToList(); //Extracting SageFrame Username List<string> lstSageUserName = new List<string>(); lstSageUserName = lstSageUsers.Select(x => x.UserName).ToList(); //Extracting SageFrame Email List<string> lstSageEmail = new List<string>(); lstSageEmail = lstSageUsers.Select(x => x.Email).ToList(); //Check duplicacy of Self Excel Users and Email List<string> lstUserNameDuplicacyinExcel = new List<string>(); lstUserNameDuplicacyinExcel = lstExcelUserName.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList(); List<string> lstEmailDuplicacyinExcel = new List<string>(); lstEmailDuplicacyinExcel = lstExcelEmail.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList(); if (lstUserNameDuplicacyinExcel.Count > 0 || lstEmailDuplicacyinExcel.Count > 0) { ShowMessage("", GetSageMessage("UserManagement", "DuplicateUsers"), "", SageMessageType.Alert); clearField(); DeleteTempFolder(); return; } //check UserName duplicacy SageUsers And Excel Users List<string> lstUserNameDuplicacy = new List<string>(); lstUserNameDuplicacy = lstExcelUserName.Intersect(lstSageUserName).ToList(); //Removing duplicate List by UserName ExportUserInfo dupUserListByUName = null; List<ExportUserInfo> lstdubUserListByName = new List<ExportUserInfo>(); foreach (string DupUserName in lstUserNameDuplicacy) { List<ExportUserInfo> obj = lstUserImportUsers; dupUserListByUName = lstUserImportUsers.Single(x => x.UserName == DupUserName); lstUserImportUsers.Remove(dupUserListByUName); //list users in excel lstdubUserListByName.Add(dupUserListByUName); } //Extracting Email duplicacy in SageEmail and listUserImportUsers List<string> lstExcelEmailInImportUsers = new List<string>(); lstExcelEmailInImportUsers = lstUserImportUsers.Select(x => x.Email).ToList(); //check Email duplicacy SageEmail And Excel Email List<string> lstEmailDuplicacy = new List<string>(); if (!m.RequireUniqueEmail) { lstEmailDuplicacy = lstExcelEmailInImportUsers.Intersect(lstSageEmail).ToList(); } //Removing duplicate List by Email ExportUserInfo dupUserListByEmail = null; List<ExportUserInfo> lstdubUserListByEmail = new List<ExportUserInfo>(); if (lstUserImportUsers.Count != 0) { foreach (string DupEmail in lstEmailDuplicacy) { List<ExportUserInfo> obj = lstUserImportUsers; dupUserListByEmail = lstUserImportUsers.Single(x => x.Email == DupEmail); lstUserImportUsers.Remove(dupUserListByEmail); //list users in excel lstdubUserListByEmail.Add(dupUserListByEmail); } } //Retrieve Duplicate UserList in SageUsers and Excel Users lstDuplicateUserList = lstdubUserListByName.Concat(lstdubUserListByEmail).ToList(); //Retrieve Identical UserList in SageUsers and Excel Users List<ExportUserInfo> lstIdenticalUserList = lstUserImportUsers; //Adding Identical User List in SageUserList if (lstIdenticalUserList.Count > 0) { for (int i = 0; i < lstIdenticalUserList.Count; i++) { UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = lstIdenticalUserList[i].FirstName; objUser.UserName = lstIdenticalUserList[i].UserName; objUser.LastName = lstIdenticalUserList[i].LastName; objUser.Password = lstIdenticalUserList[i].Password; objUser.PasswordSalt = lstIdenticalUserList[i].PasswordSalt; objUser.Email = lstIdenticalUserList[i].Email; objUser.SecurityQuestion = ""; objUser.SecurityAnswer = ""; objUser.IsApproved = lstIdenticalUserList[i].IsApproved; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = Int32.Parse(lstIdenticalUserList[i].PasswordFormat); objUser.PortalID = lstIdenticalUserList[i].PortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = lstIdenticalUserList[i].RoleName; objUser.StoreID = GetStoreID; objUser.CustomerID = GetCustomerID; UserCreationStatus status = new UserCreationStatus(); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.CREATE); } } else { lblDuplicateUser.Visible = true; ShowMessage("", GetSageMessage("UserManagement", "UsersNotAdded"), "", SageMessageType.Error); ExportDuplicateUserList(); } if (lstDuplicateUserList.Count > 0 && lstIdenticalUserList.Count > 0) { lblDuplicateUser.Visible = true; ShowMessage("", GetSageMessage("UserManagement", "UsersAddedSuccessfullyWithDuplicateUserReport"), "", SageMessageType.Success); ExportDuplicateUserList(); } if (lstDuplicateUserList.Count == 0 && lstIdenticalUserList.Count > 0) { ShowMessage("", GetSageMessage("UserManagement", "UsersAddedSuccessfully"), "", SageMessageType.Success); } clearField(); DeleteTempFolder(); } } catch (Exception ex) { throw ex; } }
public void CreateUser() { try { if (SystemSetting.SYSTEM_DEFAULT_USERS.Contains(txtUserName.Text.Trim(), StringComparer.OrdinalIgnoreCase)) { ltrWarning.Text = "Conflict of UserName with RoleName so please enter another UserName."; } else { if (txtUserName.Text != string.Empty && txtNewPassword.Text != string.Empty) { string Uname = txtUserName.Text.Trim(); if (txtNewPassword.Text.Length >= 4) { SageFrameConfig objConfig = new SageFrameConfig(); string Role = SystemSetting.SYSTEM_SUPER_ROLES[0]; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = Uname; objUser.UserName = Uname; objUser.LastName = Uname; string Password, PasswordSalt; MembershipController m = new MembershipController(); PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtNewPassword.Text, out Password, out PasswordSalt); objUser.Password = Password; objUser.PasswordSalt = PasswordSalt; objUser.Email = Uname; objUser.SecurityQuestion = string.Empty; objUser.SecurityAnswer = string.Empty; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTimeHelper.GetUtcTime(DateTime.Now); objUser.CreatedDate = DateTimeHelper.GetUtcTime(DateTime.Now); objUser.UniqueEmail = 0; objUser.PasswordFormat = m.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTimeHelper.GetUtcTime(DateTime.Now); objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = Role; objUser.StoreID = GetStoreID; objUser.CustomerID = CustomerID; UserCreationStatus status = new UserCreationStatus(); try { MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.CREATE); } catch (Exception ex) { throw ex; } } else { ltrWarning.Text = "Password must be at least 4 characters long."; } } else { ltrWarning.Text = "Please enter all the required fields."; } } } catch (Exception ex) { ProcessException(ex); } }
public abstract bool UpdateUser(UserInfo user, out UserCreationStatus status);
public abstract bool CreateUser(UserInfo user, out UserCreationStatus status,UserCreationMode mode);
protected void imbCreateUser_Click(object sender, ImageClickEventArgs e) { try { if (txtUserName.Text != "" && txtSecurityQuestion.Text != "" && txtSecurityAnswer.Text != "" && txtFirstName.Text != "" && txtLastName.Text != "" && txtEmail.Text != "") { if (lstAvailableRoles.SelectedIndex > -1) { UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = txtFirstName.Text; objUser.UserName = txtUserName.Text; objUser.LastName = txtLastName.Text; string Password, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtPassword.Text, out Password, out PasswordSalt); objUser.Password = Password; objUser.PasswordSalt = PasswordSalt; objUser.Email = txtEmail.Text; objUser.SecurityQuestion = txtSecurityQuestion.Text; objUser.SecurityAnswer = txtSecurityAnswer.Text; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = m.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = GetSelectedRoleNameString(); objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); try { MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.CREATE); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); } else if (status == UserCreationStatus.SUCCESS) { PanelVisibility(false, true, false); BindUsers(string.Empty); ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "UserCreatedSuccessfully"), "", SageMessageType.Success); } } catch (Exception) { throw; } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "PleaseSelectRole"), "", SageMessageType.Alert); } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } } catch (Exception ex) { ProcessException(ex); } }
public void CheckEmail(string email) { try { MembershipController member = new MembershipController(); UserInfo objUser = member.GerUserByEmail(email, GetPortalID); if (objUser.IsApproved == true) { SucessFullLogin(objUser); } else { { int UserRegistrationType = pagebase.GetSettingIntValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = FirstName; objUser.UserName = email; objUser.LastName = LastName; string Pwd, PasswordSalt; string newPassword = GenerateRandomPassword(); PasswordHelper.EnforcePasswordSecurity(member.PasswordFormat, newPassword, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = email; objUser.SecurityQuestion = " "; objUser.SecurityAnswer = " "; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.StoreID = GetStoreID; objUser.PasswordFormat = member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER); if (status == UserCreationStatus.SUCCESS) { SucessFullLogin(objUser); } } } } catch (Exception ex) { ProcessException(ex); } }
public int RegisterUser(int storeID, int portalID, string firstName, string userName, string lastName, string password, string email) { SageFrameConfig pagebase = new SageFrameConfig(); MembershipController _member = new MembershipController(); int returnValue = 0; try { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(email)) { returnValue = 1;// ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } else { int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = firstName; objUser.UserName = userName; objUser.LastName = lastName; string Pwd, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, password, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = email; objUser.SecurityQuestion = ""; objUser.SecurityAnswer = ""; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = _member.PasswordFormat; objUser.PortalID = portalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = ""; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; objUser.StoreID = storeID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); //CheckRegistrationType(UserRegistrationType, ref objUser); int customerId; string sessionCode; sessionCode = GetSessionCode(); MembershipDataProvider.RegisterPortalUser(objUser, out status, out customerId, UserCreationMode.REGISTER); if (status == UserCreationStatus.DUPLICATE_USER) { returnValue = 2;// ShowMessage(SageMessageTitle.Notification.ToString(), UserName.Text.Trim() + " " + GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); //GenerateCaptchaImage(); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { returnValue = 3; //ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); //GenerateCaptchaImage(); } else if (status == UserCreationStatus.SUCCESS) { UpdateCartAnonymoususertoRegistered(storeID, portalID, customerId, sessionCode); returnValue = 4; } } } catch (Exception ex) { throw ex; // ProcessException(ex); } return returnValue; }
protected void imbCreateUser_Click(object sender, ImageClickEventArgs e) { try { if (txtUserName.Text != "" && txtSecurityQuestion.Text != "" && txtSecurityAnswer.Text != "" && txtFirstName.Text != "" && txtLastName.Text != "" && txtEmail.Text != "") { if (lstAvailableRoles.SelectedIndex > -1) { UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = txtFirstName.Text; objUser.UserName = txtUserName.Text; objUser.LastName = txtLastName.Text; string Password, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtPassword.Text, out Password, out PasswordSalt); objUser.Password = Password; objUser.PasswordSalt = PasswordSalt; objUser.Email = txtEmail.Text; objUser.SecurityQuestion = txtSecurityQuestion.Text; objUser.SecurityAnswer = txtSecurityAnswer.Text; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = m.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = GetSelectedRoleNameString(); objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); try { MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.CREATE); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); } else if (status == UserCreationStatus.SUCCESS) { PanelVisibility(false, true, false); BindUsers(string.Empty); ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "UserCreatedSuccessfully"), "", SageMessageType.Success); } } catch (Exception) { throw; } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "PleaseSelectRole"), "", SageMessageType.Alert); } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } } catch (Exception ex) { ProcessException(ex); } }
private void RegisterUser() { try { MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString); if (string.IsNullOrEmpty(UserName.Text) || string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrEmpty(LastName.Text) || string.IsNullOrEmpty(Email.Text)) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } else { int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = FirstName.Text; objUser.UserName = UserName.Text; objUser.LastName = LastName.Text; string Pwd, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, Password.Text, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = Email.Text; objUser.SecurityQuestion = Question.Text; objUser.SecurityAnswer = Answer.Text; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = _member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); int customerId; MembershipDataProvider.RegisterPortalUser(objUser, out status, out customerId, UserCreationMode.REGISTER); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage(SageMessageTitle.Notification.ToString(), UserName.Text.Trim() + " " + GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.SUCCESS) { MembershipUser userInfo = Membership.GetUser(UserName.Text); if (chkIsSubscribeNewsLetter.Checked) { int?newID = 0; ManageNewsLetterSubscription(Email.Text, ref newID); } HandlePostRegistration(UserRegistrationType, dbMessageTemplate, customerId); } } } catch (Exception ex) { ProcessException(ex); } }
private void RegisterUser() { try { if (string.IsNullOrEmpty(UserName.Text) || string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrEmpty(LastName.Text) || string.IsNullOrEmpty(Email.Text) || string.IsNullOrEmpty(Password.Text) || string.IsNullOrEmpty(ConfirmPassword.Text) || string.IsNullOrEmpty(CaptchaValue.Text)) { ShowMessage("", GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert); } else if (UserName.Text.Length > 50) { ShowMessage("", "Username should not be greater than 50 characters", "", SageMessageType.Alert); } else { int UserRegistrationType = pagebase.GetSettingIntValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration); bool isUserActive = UserRegistrationType == 2 ? true : false; UserInfo objUser = new UserInfo(); objUser.ApplicationName = Membership.ApplicationName; objUser.FirstName = Server.HtmlEncode(FirstName.Text); objUser.UserName = Server.HtmlEncode(UserName.Text); objUser.LastName = Server.HtmlEncode(LastName.Text); string Pwd, PasswordSalt; PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, Password.Text, out Pwd, out PasswordSalt); objUser.Password = Pwd; objUser.PasswordSalt = PasswordSalt; objUser.Email = Email.Text; objUser.SecurityQuestion = " "; objUser.SecurityAnswer = " "; objUser.IsApproved = true; objUser.CurrentTimeUtc = DateTime.Now; objUser.CreatedDate = DateTime.Now; objUser.UniqueEmail = 0; objUser.PasswordFormat = _member.PasswordFormat; objUser.PortalID = GetPortalID; objUser.AddedOn = DateTime.Now; objUser.AddedBy = GetUsername; objUser.UserID = Guid.NewGuid(); objUser.RoleNames = SystemSetting.REGISTER_USER_ROLENAME; objUser.StoreID = GetStoreID; objUser.CustomerID = 0; UserCreationStatus status = new UserCreationStatus(); CheckRegistrationType(UserRegistrationType, ref objUser); MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER); if (status == UserCreationStatus.DUPLICATE_USER) { ShowMessage("", GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.DUPLICATE_EMAIL) { ShowMessage("", GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert); GenerateCaptchaImage(); } else if (status == UserCreationStatus.SUCCESS) { try { IsModuleInstalled(1); MembershipUser userInfo = Membership.GetUser(UserName.Text.Trim()); if (chkIsSubscribeNewsLetter.Checked) { int? newID = 0; ManageNewsLetterSubscription(Email.Text, ref newID); IsModuleInstalled(2); } HandlePostRegistration(UserRegistrationType); } catch (Exception) { ShowMessage("", GetSageMessage("UserManagement", "SecureConnection"), "", SageMessageType.Alert); } } } } catch (Exception ex) { ProcessException(ex); } }