/// <summary> /// 将登录信息保存到XML文件中。 /// 若不保存用户名密码,那就应该删除掉。 /// </summary> /// <param name="userInfo">登录用户</param> private void SaveLogOnInfo(BaseUserInfo userInfo) { BaseSystemInfo.RememberPassword = this.chkRememberPassword.Checked; if (this.chkRememberPassword.Checked) { BaseSystemInfo.CurrentUserName = userInfo.UserName; // BaseSystemInfo.CurrentUserName = SecretUtil.Encrypt(userInfo.UserName); BaseSystemInfo.CurrentPassword = SecretUtil.Encrypt(this.txtPassword.Text); } else { BaseSystemInfo.CurrentUserName = string.Empty; BaseSystemInfo.CurrentPassword = string.Empty; } // 保存用户的信息 UserConfigHelper.SaveConfig(); /* * // 写入注册表,有时候会没有权限,发生异常信息等,可以考虑写入XML文件 * RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(@"Software\" + BaseConfiguration.COMPANY_NAME + "\\" + BaseSystemInfo.SoftName); * if (this.chkRememberPassword.Checked) * { * // 默认的信息写入注册表,呵呵需要改进一下 * registryKey.SetValue(BaseConfiguration.CURRENT_USERNAME, SecretUtil.Encrypt(userInfo.UserName)); * registryKey.SetValue(BaseConfiguration.CURRENT_PASSWORD, SecretUtil.Encrypt(this.txtPassword.Text)); * } * else * { * registryKey.SetValue(BaseConfiguration.CURRENT_USERNAME, string.Empty); * registryKey.SetValue(BaseConfiguration.CURRENT_PASSWORD, string.Empty); * } */ }
/// <summary> /// 保存系统设置 /// </summary> private void SaveConfigInfo() { // 是否加密先保存好 BaseSystemInfo.ClientEncryptPassword = this.chkClientEncryptPassword.Checked; BaseSystemInfo.CurrentUserName = this.txtUser.Text; BaseSystemInfo.CurrentPassword = this.txtClientPassword.Text; if (BaseSystemInfo.ClientEncryptPassword) { BaseSystemInfo.CurrentPassword = SecretUtil.Encrypt(this.txtClientPassword.Text); } if (!string.IsNullOrEmpty(this.cmbCurrentLanguage.Text)) { BaseSystemInfo.CurrentLanguage = this.cmbCurrentLanguage.SelectedItem.ToString(); } BaseSystemInfo.RememberPassword = this.chkRememberPassword.Checked; BaseSystemInfo.AutoLogOn = this.chbAutoLogOn.Checked; BaseSystemInfo.UseMessage = this.chkUseMessage.Checked; BaseSystemInfo.Service = this.cmbService.SelectedItem.ToString(); BaseSystemInfo.MainForm = txtMainForm.Text; BaseSystemInfo.LogOnForm = this.txtLogOnForm.Text; BaseSystemInfo.RecordLog = this.chkRecordLog.Checked; BaseSystemInfo.AllowUserRegister = this.chkAllowUserRegister.Checked; BaseSystemInfo.UseUserPermission = this.chkUseUserPermission.Checked; BaseSystemInfo.UseOrganizePermission = this.chkUseOrganizePermission.Checked; BaseSystemInfo.UseModulePermission = this.chkUseModulePermission.Checked; BaseSystemInfo.UsePermissionScope = this.chkUsePermissionScope.Checked; BaseSystemInfo.UseAuthorizationScope = this.chkUseAuthorizationScope.Checked; BaseSystemInfo.UseTableColumnPermission = this.chkUseTableColumnPermission.Checked; BaseSystemInfo.UseTableScopePermission = this.chkUseTableScopePermission.Checked; BaseSystemInfo.UseWorkFlow = this.chkWorkFlow.Checked; BaseSystemInfo.OnLineLimit = (int)this.nupOnLineLimit.Value; BaseSystemInfo.CustomerCompanyName = this.txtCustomerCompanyName.Text; if (this.cmbUserCenterDbDbType.Text.Length != 0) { BaseSystemInfo.UserCenterDbType = BaseConfiguration.GetDbType(this.cmbUserCenterDbDbType.SelectedItem.ToString()); } if (this.cmbBusinessDbDbType.Text.Length != 0) { BaseSystemInfo.BusinessDbType = BaseConfiguration.GetDbType(this.cmbBusinessDbDbType.SelectedItem.ToString()); } if (this.cmbWorkFlowDbDbType.Text.Length != 0) { BaseSystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(this.cmbWorkFlowDbDbType.SelectedItem.ToString()); } BaseSystemInfo.EncryptDbConnection = this.chkEncryptDbConnection.Checked; BaseSystemInfo.UserCenterDbConnectionString = this.txtUserCenterDbConnection.Text; BaseSystemInfo.BusinessDbConnectionString = this.txtBusinessDbConnection.Text; BaseSystemInfo.WorkFlowDbConnectionString = this.txtWorkFlowDbConnection.Text; // 保存用户的信息 UserConfigHelper.SaveConfig(); }
private void buttonStyleCustom_SelectedColorChanged(object sender, EventArgs e) { m_ColorSelected = true; // Indicate that color was selected for buttonStyleCustom_ExpandChange method buttonStyleCustom.CommandParameter = buttonStyleCustom.SelectedColor; SystemInfo.CurrentThemeColor = System.Drawing.ColorTranslator.ToHtml(buttonStyleCustom.SelectedColor); UserConfigHelper.SaveConfig(); }
/// <summary> /// 修改密码 /// </summary> private bool ChangePassword() { // 设置鼠标繁忙状态,并保留原先的状态 Cursor holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; bool returnValue = false; string statusCode = string.Empty; string statusMessage = string.Empty; DotNetService.Instance.LogOnService.ChangePassword(UserInfo, this.txtOldPassword.Text, this.txtNewPassword.Text, out statusCode, out statusMessage); // 设置为平常状态 this.Cursor = holdCursor; if (statusCode == StatusCode.ChangePasswordOK.ToString()) { if (BaseSystemInfo.ShowInformation) { // 提示修改成功 MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } // 保存用户的密码信息,方便下次登录时直接记住了新密码,否则登录时,还是会出错的。 #if (!DEBUG) if (BaseSystemInfo.ClientEncryptPassword) { BaseSystemInfo.CurrentPassword = SecretUtil.Encrypt(this.txtNewPassword.Text); } UserConfigHelper.SaveConfig(); #endif this.DialogResult = DialogResult.OK; returnValue = true; } else { if (statusCode == StatusCode.PasswordCanNotBeNull.ToString()) { this.ClearOldPassword(); } if (statusCode == StatusCode.OldPasswordError.ToString()) { this.ClearOldPassword(); } MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); returnValue = false; } return(returnValue); }
/// <summary> /// 将配置文件保存到XML文件里 /// </summary> private void SaveConfig() { BaseSystemInfo.ServerEncryptPassword = this.chkServerEncryptPassword.Checked; BaseSystemInfo.PasswordMiniLength = (int)this.nudPasswordMiniLength.Value; BaseSystemInfo.NumericCharacters = this.chkNumericCharacters.Checked; BaseSystemInfo.PasswordChangeCycle = (int)this.nudPasswordChangeCycle.Value; BaseSystemInfo.CheckOnLine = this.chkCheckOnLine.Checked; BaseSystemInfo.AccountMinimumLength = (int)this.nudAccountMinimumLength.Value; BaseSystemInfo.PasswordErrowLockLimit = (int)this.nudPasswordErrowLockLimit.Value; BaseSystemInfo.PasswordErrowLockCycle = (int)this.nudPasswordErrowLockCycle.Value; // 保存用户的信息 #if (!DEBUG) UserConfigHelper.SaveConfig(); #endif }
private void AppCommandTheme_Executed(object sender, EventArgs e) { var source = sender as ICommandSource; if (source.CommandParameter is string) { SystemInfo.CurrentStyle = source.CommandParameter.ToString(); var style = (eStyle)Enum.Parse(typeof(eStyle), SystemInfo.CurrentStyle); StyleManager.ChangeStyle(style, Color.Empty); UserConfigHelper.SaveConfig(); } else if (source.CommandParameter is Color) { StyleManager.ColorTint = (Color)source.CommandParameter; } }
private void AppCommandTheme_Executed(object sender, EventArgs e) { ICommandSource source = sender as ICommandSource; if (source.CommandParameter is string) { SystemInfo.CurrentStyle = source.CommandParameter.ToString(); eStyle style = (eStyle)Enum.Parse(typeof(eStyle), SystemInfo.CurrentStyle); // Using StyleManager change the style and color tinting StyleManager.ChangeStyle(style, Color.Empty); //if (style == eStyle.Office2007Black || style == eStyle.Office2007Blue || style == eStyle.Office2007Silver || style == eStyle.Office2007VistaGlass) // buttonFile.BackstageTabEnabled = false; //else // buttonFile.BackstageTabEnabled = true; UserConfigHelper.SaveConfig(); } else if (source.CommandParameter is Color) { StyleManager.ColorTint = (Color)source.CommandParameter; } }
/// <summary> /// 将登录信息保存到XML文件中。 /// 若不保存用户名密码,那就应该删除掉。 /// </summary> /// <param name="userInfo">登录用户</param> private void SaveLogOnInfo(UserInfo userInfo) { SystemInfo.RememberPassword = this.chkRememberPassword.Checked; if (this.chkRememberPassword.Checked) { SystemInfo.CurrentUserName = userInfo.UserName; // SystemInfo.CurrentUserName = SecretHelper.AESEncrypt(userInfo.UserName); SystemInfo.CurrentPassword = SystemInfo.EncryptClientPassword ? SecretHelper.AESEncrypt(this.txtPassword.Text) : this.txtPassword.Text; } else { SystemInfo.CurrentUserName = string.Empty; SystemInfo.CurrentPassword = string.Empty; } //SystemInfo.AutoLogOn = this.chbAutoLogOn.Checked; // 保存用户的信息 UserConfigHelper.SaveConfig(); /* * // 写入注册表,有时候会没有权限,发生异常信息等,可以考虑写入XML文件 * RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(@"Software\" + SystemInfo.CompanyName + "\\" + SystemInfo.SoftName); * if (this.chkRememberPassword.Checked) * { * // 默认的信息写入注册表,呵呵需要改进一下 * registryKey.SetValue(SystemInfo.CurrentUserName, SecretUtil.Encrypt(userInfo.UserName)); * registryKey.SetValue(SystemInfo.CurrentPassword, SecretUtil.Encrypt(this.txtPassword.Text)); * } * else * { * registryKey.SetValue(SystemInfo.CurrentUserName, string.Empty); * registryKey.SetValue(SystemInfo.CurrentPassword, string.Empty); * } */ }
/// <summary> /// 将登录信息保存到XML文件中。 /// 若不保存用户名密码,那就应该删除掉。 /// </summary> /// <param name="userInfo">登录用户</param> private void SaveLogOnInfo(BaseUserInfo userInfo) { BaseSystemInfo.RememberPassword = this.chkRememberPassword.Checked; if (this.chkRememberPassword.Checked) { BaseSystemInfo.CurrentUserName = userInfo.UserName; // BaseSystemInfo.CurrentUserName = SecretUtil.Encrypt(userInfo.UserName); if (BaseSystemInfo.ClientEncryptPassword) { BaseSystemInfo.CurrentPassword = SecretUtil.Encrypt(this.txtPassword.Text); } else { BaseSystemInfo.CurrentPassword = this.txtPassword.Text; } } else { BaseSystemInfo.CurrentUserName = string.Empty; BaseSystemInfo.CurrentPassword = string.Empty; } // 保存用户的信息 UserConfigHelper.SaveConfig(); }
private void SaveConfigInfo() { //********************************************************** //一、客户端配置 //********************************************************** SystemInfo.EncryptClientPassword = EncryptClientPassword.Checked; SystemInfo.AutoLogOn = AutoLogOn.Checked; SystemInfo.RememberPassword = RememberPassword.Checked; SystemInfo.LoadAllUser = LoadAllUser.Checked; SystemInfo.EncryptDbConnection = EncryptDbConnection.Checked; SystemInfo.ServiceUserName = ServiceUserName.Text.Trim(); SystemInfo.ServicePassword = ServicePassword.Text.Trim(); switch (RDIFrameworkDbType.Text.Trim()) { case "SqlServer": SystemInfo.RDIFrameworkDbType = CurrentDbType.SqlServer; break; case "Oracle": SystemInfo.RDIFrameworkDbType = CurrentDbType.Oracle; break; case "MySql": SystemInfo.RDIFrameworkDbType = CurrentDbType.MySql; break; case "DB2": SystemInfo.RDIFrameworkDbType = CurrentDbType.DB2; break; case "Access": SystemInfo.RDIFrameworkDbType = CurrentDbType.Access; break; case "SQLite": SystemInfo.RDIFrameworkDbType = CurrentDbType.SQLite; break; default: SystemInfo.RDIFrameworkDbType = CurrentDbType.SqlServer; break; } SystemInfo.CurrentLanguage = CurrentLanguage.SelectedItem == null ? "zh-CN" : CurrentLanguage.SelectedItem.ToString(); SystemInfo.RDIFrameworkDbConectionString = RDIFrameworkDbConection.Text.Trim(); if (SystemInfo.EncryptDbConnection) { SystemInfo.RDIFrameworkDbConectionString = SecretHelper.AESEncrypt(SystemInfo.RDIFrameworkDbConectionString); SystemInfo.BusinessDbConnectionString = SecretHelper.AESEncrypt(SystemInfo.BusinessDbConnectionString); SystemInfo.WorkFlowDbConnectionString = SecretHelper.AESEncrypt(SystemInfo.WorkFlowDbConnectionString); } //********************************************************** //二、服务端配置 //********************************************************** SystemInfo.AllowUserToRegister = AllowUserToRegister.Checked; SystemInfo.EnableRecordLog = EnableRecordLog.Checked; SystemInfo.EnableCheckIPAddress = EnableCheckIPAddress.Checked; SystemInfo.EnableUserAuthorization = EnableUserAuthorization.Checked; SystemInfo.EnableModulePermission = EnableModulePermission.Checked; SystemInfo.EnablePermissionItem = EnablePermissionItem.Checked; SystemInfo.EnableTableFieldPermission = EnableTableFieldPermission.Checked; SystemInfo.EnableTableConstraintPermission = EnableTableConstraintPermission.Checked; SystemInfo.EnableEncryptServerPassword = EnableEncryptServerPassword.Checked; SystemInfo.EnableCheckPasswordStrength = EnableCheckPasswordStrength.Checked; SystemInfo.NumericCharacters = NumericCharacters.Checked; SystemInfo.CheckOnLine = CheckOnLine.Checked; SystemInfo.EnableOrganizePermission = EnableOrganizePermission.Checked; if (OnLineLimit.Text.Trim().Length > 0) { SystemInfo.OnLineLimit = OnLineLimit.Value; } if (OnLineTime0ut.Text.Trim().Length > 0) { SystemInfo.OnLineTime0ut = OnLineTime0ut.Value; } if (AccountMinimumLength.Text.Trim().Length > 0) { SystemInfo.AccountMinimumLength = AccountMinimumLength.Value; } if (PasswordChangeCycle.Text.Trim().Length > 0) { SystemInfo.PasswordChangeCycle = PasswordChangeCycle.Value; } if (PasswordErrorLockLimit.Text.Trim().Length > 0) { SystemInfo.PasswordErrorLockLimit = PasswordErrorLockLimit.Value; } if (PasswordErrorLockCycle.Text.Trim().Length > 0) { SystemInfo.PasswordErrorLockCycle = PasswordErrorLockCycle.Value; } SystemInfo.DefaultPassword = DefaultPassword.Text.Trim(); if (PasswordMiniLength.Text.Trim().Length > 0) { SystemInfo.PasswordMiniLength = PasswordMiniLength.Value; } //********************************************************** //三、系统参数配置 //********************************************************** SystemInfo.MainForm = BusinessLogic.ConvertToString(MainForm.SelectedItem); SystemInfo.LogOnForm = LogOnForm.Text.Trim(); SystemInfo.LogOnAssembly = LogOnAssembly.Text.Trim(); SystemInfo.CustomerCompanyName = CustomerCompanyName.Text.Trim(); //SystemInfo.ConfigurationFrom = ConfigurationFrom.Text.Trim(); SystemInfo.SoftName = SoftName.Text.Trim(); SystemInfo.SoftFullName = SoftFullName.Text.Trim(); SystemInfo.Version = Version.Text.Trim(); SystemInfo.Service = Service.Text.Trim(); //SystemInfo.RegisterKey = RegisterKey.Text; /********************************************************** * 四、错误报告反馈配置 **********************************************************/ SystemInfo.ErrorReportFrom = ErrorReportFrom.Text.Trim(); SystemInfo.ErrorReportMailServer = ErrorReportMailServer.Text.Trim(); SystemInfo.ErrorReportMailUserName = ErrorReportMailUserName.Text.Trim(); SystemInfo.ErrorReportMailPassword = ErrorReportMailPassword.Text.Trim(); UserConfigHelper.SaveConfig(); //再次得到配置文件。这儿主要是对加密的数据在软件运行过程中是解密的。 UserConfigHelper.GetConfig(); }
private void btSelectLang_Click(object sender, EventArgs e) { BaseSystemInfo.CurrentLanguage = (sender as ButtonItem).Tag.ToString(); UserConfigHelper.SaveConfig(); this.LoadLanguages(); }