/// <summary>
 /// 设置控件状态
 /// </summary>
 public override void SetControlState()
 {
     if (BaseSystemInfo.UserIsLogOn)
     {
         this.Text = AppMessage.MSGReLogOn;
     }
     // 是否允许申请密码
     this.btnRequestAnAccount.Visible = BaseSystemInfo.AllowUserRegister;
     // 密码强度检查
     this.labPasswordReq.Visible = BaseSystemInfo.CheckPasswordStrength;
     // 已登录了?还是未登录状态
     if (BaseSystemInfo.UserIsLogOn)
     {
         this.CancelButton = this.btnCancel;
         this.btnCancel.Show();
         this.btnExit.Hide();
     }
     else
     {
         this.CancelButton = this.btnExit;
         this.btnExit.Show();
         this.btnCancel.Hide();
     }
     this.btnConfig.Visible = UserConfigHelper.Exists();
 }
Exemple #2
0
        /// <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);
             * }
             */
        }
Exemple #3
0
        public override void SetControlState()
        {
            if (UserConfigHelper.Exists())
            {
                this.btnConfirm.Enabled        = true;
                this.btnEncrypt.Enabled        = true;
                this.btnSystemSecurity.Enabled = true;
            }
            // 已经登录了系统,并且是系统管理员才可以做这个服务器端的配置,第一次用时无法配置系统了

            /*
             * if (!BaseSystemInfo.LogOned || !this.UserInfo.IsAdministrator)
             * {
             *  this.tcConfirm.TabPages.Remove(tpServer);
             * }
             */
            this.btnSystemSecurity.Visible = BaseSystemInfo.UserIsLogOn && BaseSystemInfo.UserInfo.IsAdministrator;
            // 只有系统管理员才可以初始化系统,并却是sqlserver数据库下才运行
            this.btnInitialize.Visible = BaseSystemInfo.UserIsLogOn && BaseSystemInfo.UserInfo.IsAdministrator;
            if (this.btnInitialize.Visible)
            {
                if (BaseSystemInfo.UserCenterDbType == DbTypes.SqlServer)
                {
                    string parameter = DotNetService.Instance.ParameterService.GetParameter(UserInfo, "System", "System", "Initialize");
                    if (!string.IsNullOrEmpty(parameter) && parameter.Equals("None"))
                    {
                        this.btnInitialize.Enabled = true;
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取配置信息
        /// </summary>
        public static void GetConfig()
        {
            // 读取客户端配置文件
            BaseSystemInfo.ConfigurationFrom = ConfigurationCategory.UserConfig;
            UserConfigHelper.GetConfig();

            // 这里应该读取服务上的配置信息,不只是读取本地的配置信息

            /*
             * DotNetService dotNetService = new DotNetService();
             * string allowUserRegister = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "AllowUserRegister");
             * BaseSystemInfo.AllowUserRegister = allowUserRegister.Equals(false.ToString()) ? false : true;
             * // 密码强度检查
             * string checkPasswordStrength = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "CheckPasswordStrength");
             * BaseSystemInfo.CheckPasswordStrength = checkPasswordStrength.Equals(false.ToString()) ? false : true;
             * string useColumnPermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseColumnPermission");
             * BaseSystemInfo.UseColumnPermission = useColumnPermission.Equals(true.ToString()) ? true : false;
             * string useModulePermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseModulePermission");
             * BaseSystemInfo.UseModulePermission = useModulePermission.Equals(true.ToString()) ? true : false;
             * string usePermissionScope = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UsePermissionScope");
             * BaseSystemInfo.UsePermissionScope = usePermissionScope.Equals(true.ToString()) ? true : false;
             * string useTablePermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseTablePermission");
             * BaseSystemInfo.UseTablePermission = useTablePermission.Equals(true.ToString()) ? true : false;
             * if (dotNetService.ParameterService is ICommunicationObject)
             * {
             *  ((ICommunicationObject)dotNetService.ParameterService).Close();
             * }
             */
        }
Exemple #5
0
        protected override void OnStart(string[] args)
        {
            // 是否检查在线状态
            SystemInfo.CheckOnLine = false;
            SystemInfo.EnableCheckPasswordStrength = true;
            // 是否记录日志
            SystemInfo.EnableRecordLog = true;
            // 是否需要注册
            SystemInfo.NeedRegister = false;
            // 读取配置文件
            UserConfigHelper.GetConfig(SystemInfo.StartupPath + "\\" + UserConfigHelper.FileName);

            // 读取配置文件
            var configuration            = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var serviceModelSectionGroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
            // 开启每个服务
            var idxService = 0;

            serviceHosts = new ServiceHost[serviceModelSectionGroup.Services.Services.Count];
            foreach (ServiceElement serviceElement in serviceModelSectionGroup.Services.Services)
            {
                var assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'));
                var serviceHost    = new ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name), serviceElement.Endpoints[0].Address);
                //var serviceHost = new ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name));
                serviceHost.Opened += delegate { Console.WriteLine("第{0}个服务:{1}", idxService + 1, serviceHost.BaseAddresses[0]); };
                serviceHost.Open();
                serviceHosts[idxService] = serviceHost;
                idxService++;
            }
            base.OnStart(args);
        }
Exemple #6
0
        /// <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();
        }
Exemple #8
0
        private void AutoLogin_OnClick(object sender, RoutedEventArgs e)
        {
            var config     = UserConfigHelper.GetInstence();
            var userConfig = config.LoadLastUserConfig();

            userConfig.AutoLogin = 0;
            config.SaveConfig(userConfig);
        }
        /// <summary>
        /// 获取配置信息
        /// </summary>
        private void GetSystemInfo()
        {
            this.lblCurrentVersion.Text = BaseSystemInfo.Version;
            string fileName   = "http://files.cnblogs.com/jirigala/Config.xml";
            string selectPath = "//appSettings/add";
            string key        = "Version";

            this.lblNewVersion.Text = UserConfigHelper.GetValue(fileName, selectPath, key);
        }
Exemple #10
0
        //调试修改添加
        private void GetAllDbLinks()
        {
            UserConfigHelper.GetConfig();
            //RDIFramework.Utilities.UserInfo user = new RDIFramework.Utilities.UserInfo();
            this.UserInfo.OpenId          = "7d46323d-0091-4bf5-8a13-67fef63a4cd4";
            this.UserInfo.Id              = "26F43BC9-AE6D-42D2-BAC9-F4237A949484";
            this.UserInfo.Code            = "Administrator";
            this.UserInfo.RealName        = "Administrator";
            this.UserInfo.IsAdministrator = true;
            DataTable dtDbLinks = RDIFrameworkService.Instance.DbLinkDefineService.GetDT(this.UserInfo);

            if (dtDbLinks != null && dtDbLinks.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dtDbLinks.Rows)
                {
                    ConnectString connStr = new ConnectString
                    {
                        LinkName = dataRow[CiDbLinkDefineTable.FieldLinkName].ToString()
                    };
                    string dbType = dataRow[CiDbLinkDefineTable.FieldLinkType].ToString();
                    switch (dbType.ToUpper())
                    {
                    case "ACCESS":
                        connStr.DbType = CurrentDbType.Access;
                        break;

                    case "ORACLE":
                        connStr.DbType = CurrentDbType.Oracle;
                        break;

                    case "MYSQL":
                        connStr.DbType = CurrentDbType.MySql;
                        break;

                    case "SQLLITE":
                        connStr.DbType = CurrentDbType.SQLite;
                        break;

                    case "DB2":
                        connStr.DbType = CurrentDbType.DB2;
                        break;

                    default:
                        connStr.DbType = CurrentDbType.SqlServer;
                        break;
                    }
                    connStr.DbLink = dataRow[CiDbLinkDefineTable.FieldLinkData].ToString();
                    DbLinks.Add(connStr);
                }
            }
        }
 /// <summary>
 /// 设置控件状态
 /// </summary>
 public override void SetControlState()
 {
     if (UserConfigHelper.Exists())
     {
         DefaultPassword = UserConfigHelper.GetValue("DefaultPassword");
     }
     this.btnSetDefaultPassword.Visible = !string.IsNullOrEmpty(DefaultPassword);
     // 密码强度检查
     this.lblConfirmPasswordReq.Visible = BaseSystemInfo.CheckPasswordStrength;
     this.lblNewPasswordReq.Visible     = BaseSystemInfo.CheckPasswordStrength;
     // this.btnDeletePassword.Visible = !BaseSystemInfo.CheckPasswordStrength;
     this.btnSetAsUserCode.Visible = this.UserInfo.IsAdministrator;
     this.btnSetAsUserName.Visible = this.UserInfo.IsAdministrator;
 }
Exemple #12
0
        /// <summary>
        /// /保存登录成功用户配置
        /// </summary>
        private void SaveUserInfoToConfig()
        {
            _config.UserId        = _userInfo.UserId;
            _config.UserName      = _userInfo.UserName;
            _config.UserPwd       = AecDesCrypto.Encrypt(UserPwd, _key); //加密
            _config.RememberPwd   = Convert.ToInt32(IsRememberPwd);
            _config.AutoLogin     = Convert.ToInt32(_isAutoLogin);
            _config.LastLoginTime = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            _config.OnLine        = 1; //在线

            var configHepler = UserConfigHelper.GetInstence();

            configHepler.SaveConfig(_config);
        }
        /// <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>
        /// 获取配置文件选项
        /// </summary>
        private void GetLogOnTo()
        {
            Dictionary <String, String> logOnTo = UserConfigHelper.GetLogOnTo();

            foreach (KeyValuePair <String, String> keyValue in logOnTo)
            {
                ListItem item = new ListItem(keyValue.Key, keyValue.Value);
                this.cmbLogOnTo.Items.Add(item);
            }
            this.cmbLogOnTo.ValueMember   = "Id";
            this.cmbLogOnTo.DisplayMember = "Name";
            if (this.cmbLogOnTo.Items.Count > 0)
            {
                this.cmbLogOnTo.SelectedIndex = 0;
            }
        }
        /// <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;
            }
        }
 /// <summary>
 /// 读取配置信息
 /// </summary>
 public static void GetSetting()
 {
     // 读取注册表
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.RegistryKey)
     {
         RegistryHelper.GetConfig();
     }
     // 读取配置文件
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.Configuration)
     {
         ConfigurationHelper.GetConfig();
     }
     // 读取个性化配置文件
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.UserConfig)
     {
         UserConfigHelper.GetConfig();
     }
 }
Exemple #18
0
        /// <summary>
        /// 加载所有用户配置
        /// </summary>
        /// <returns></returns>
        private void InitUserConfig()
        {
            UserConfigHelper.AppFolderName = AssemblyInfoHelper.Product + "\\";
            var configHepler = UserConfigHelper.GetInstence();

            _config = configHepler.LoadLastUserConfig();

            if (_config != null)
            {
                UserName      = _config.UserName;
                IsRememberPwd = Convert.ToBoolean(_config.RememberPwd);
                if (IsRememberPwd)
                {
                    //生成密钥
                    _key = AecDesCrypto.GenerateKey();
                    //解密
                    UserPwd = AecDesCrypto.Decrypt(_config.UserPwd, _key);
                }
                IsAutoLogin = Convert.ToBoolean(_config.AutoLogin);
            }
        }
        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();
 }
Exemple #22
0
 private void btnOuter_Click(object sender, EventArgs e)
 {
     this.SelectNetwork = "Outer";
     UserConfigHelper.GetConfig();
     this.Close();
 }
Exemple #23
0
 private void btSelectLang_Click(object sender, EventArgs e)
 {
     BaseSystemInfo.CurrentLanguage = (sender as ButtonItem).Tag.ToString();
     UserConfigHelper.SaveConfig();
     this.LoadLanguages();
 }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns>是否成功</returns>
        private bool LogOn()
        {
            if (!BaseSystemInfo.UserIsLogOn && this.cmbLogOnTo.Enabled)
            {
                UserConfigHelper.LogOnTo = ((ListItem)this.cmbLogOnTo.SelectedItem).Id;
                // 读取配置文件
                UserConfigHelper.GetConfig();
            }

            string        statusCode    = string.Empty;
            string        statusMessage = string.Empty;
            DotNetService dotNetService = new DotNetService();
            BaseUserInfo  userInfo      = dotNetService.LogOnService.UserLogOn(UserInfo, this.txtUserName.Text, this.txtPassword.Text, true, out statusCode, out statusMessage);

            if (dotNetService.LogOnService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.LogOnService).Close();
            }
            if (statusCode == StatusCode.OK.ToString())
            {
                // 检查身份
                if ((userInfo != null) && (userInfo.Id.Length > 0))
                {
                    BaseSystemInfo.UserInfo = userInfo;
                    if (BaseSystemInfo.RememberPassword)
                    {
                        this.SaveLogOnInfo();
                    }

                    // 这里是登录功能部分
                    if (this.Parent == null)
                    {
                        this.Hide();
                        if (!BaseSystemInfo.UserIsLogOn)
                        {
                            Form mainForm = CacheManager.Instance.GetForm(BaseSystemInfo.MainAssembly, BaseSystemInfo.MainForm);
                            ((IBaseMainForm)mainForm).InitService();
                            ((IBaseMainForm)mainForm).InitForm();
                            mainForm.Show();
                        }
                    }
                    // 这里表示已经登录系统了
                    BaseSystemInfo.UserIsLogOn = true;
                    // 登录次数归零,允许重新登录
                    this.LogOnCount = 0;

                    // 打开这个窗体的主窗口
                    if (this.Owner != null)
                    {
                        ((IBaseMainForm)this.Owner).InitService();
                        ((IBaseMainForm)this.Owner).InitForm();
                        ((IBaseMainForm)this.Owner).CheckMenu();
                        return(true);
                    }
                    if (this.Parent != null)
                    {
                        // 重新获取登录状态信息
                        ((IBaseMainForm)this.Parent.Parent).InitService();
                        ((IBaseMainForm)this.Parent.Parent).InitForm();
                        ((IBaseMainForm)this.Parent.Parent).CheckMenu();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtPassword.Focus();
                this.txtPassword.SelectAll();
                return(false);
            }
            return(true);
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SystemInfo.EnableRecordLog = true;
            SystemInfo.StartupPath     = Application.StartupPath;
            UserConfigHelper.GetConfig();
            System.Console.ForegroundColor = ConsoleColor.Red;
            System.Console.WriteLine(@"服务器端正在启动...");
            System.Console.ForegroundColor = ConsoleColor.White;
            // 读取配置文件
            var configuration            = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var serviceModelSectionGroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
            // 开启每个服务
            var idxService = 1;

            if (serviceModelSectionGroup != null)
            {
                foreach (var serviceHost in from ServiceElement serviceElement in serviceModelSectionGroup.Services.Services
                         let assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'))
                                              select new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name), serviceElement.Endpoints[0].Address))
                {
                    serviceHost.Opened += delegate
                    {
                        Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                    };
                    serviceHost.Open();
                    idxService++;
                }


                /* V2.7版本时的方法
                 * foreach (ServiceElement serviceElement in serviceModelSectionGroup.Services.Services)
                 * {
                 *  var assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'));
                 *  var serviceHost =
                 *      new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name),
                 *          serviceElement.Endpoints[0].Address);
                 *
                 *  serviceHost.Opened += delegate
                 *  {
                 *      Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                 *  };
                 *  serviceHost.Open();
                 *  idxService++;
                 * }*/
            }
            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine(@"服务器端已正常启动...");
            System.Console.ForegroundColor = ConsoleColor.White;

            System.Console.WriteLine();
            System.Console.WriteLine();


            System.Console.WriteLine(@"服务器 当前时间:" + DateTime.Now.ToString(SystemInfo.DateTimeFormat));
            var dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConection);

            System.Console.WriteLine(@"数据库服务器 当前时间:" + dbProvider.GetDBDateTime());
            System.Console.WriteLine();

            // 写入调试信息
            #if (DEBUG)
            var rdiDBProviderService = new RDIFrameworkDBProviderService();
            System.Console.WriteLine(@"RDIFramework.NET ━ .NET快速信息化系统开发框架 数据库服务器数据库连接:");
            System.Console.WriteLine(rdiDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(rdiDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.WriteLine();

            var bizDBProviderService = new BusinessDBProviderService();
            System.Console.WriteLine(@"业务数据库服务器 数据库连接:");
            System.Console.WriteLine(bizDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(bizDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.ReadLine();
            #endif
            Application.Run(new FrmServiceHost());
        }
Exemple #26
0
        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();
        }
Exemple #27
0
 /// <summary>
 /// 获取配置信息
 /// </summary>
 public static void GetConfig()
 {
     // 读取客户端配置文件
     SystemInfo.ConfigurationFrom = ConfigurationCategory.UserConfig;
     UserConfigHelper.GetConfig();
 }
Exemple #28
0
        /// <summary>
        /// 获取系统配置信息
        /// </summary>
        private void GetConfigInfo()
        {
            // 若没有配置文件
            if (!UserConfigHelper.Exists())
            {
                return;
            }
            this.chkClientEncryptPassword.Checked = BaseSystemInfo.ClientEncryptPassword;
            this.chkClientEncryptPassword.Visible = UserConfigHelper.Exists("ClientEncryptPassword");

            this.txtUser.Text = BaseSystemInfo.CurrentUserName;
            // 对密码进行解密操作
            this.txtClientPassword.Text = BaseSystemInfo.CurrentPassword;
            if (BaseSystemInfo.ClientEncryptPassword)
            {
                this.txtClientPassword.Text = SecretUtil.Decrypt(BaseSystemInfo.CurrentPassword);
            }

            // 初始化语言选项菜单
            // this.cmbCurrentLanguage.Items.Clear();
            // this.cmbCurrentLanguage.Items.Add("zh-CN");
            // this.cmbCurrentLanguage.Items.Add("zh-TW");
            // this.cmbCurrentLanguage.Items.Add("en-US");
            string[] currentLanguageItems = UserConfigHelper.GetOptions("CurrentLanguage");
            for (int i = 0; i < currentLanguageItems.Length; i++)
            {
                this.cmbCurrentLanguage.Items.Add(currentLanguageItems[i]);
            }
            this.cmbCurrentLanguage.SelectedIndex = this.cmbCurrentLanguage.Items.IndexOf(BaseSystemInfo.CurrentLanguage);
            this.lblCurrentLanguage.Visible       = UserConfigHelper.Exists("CurrentLanguage");
            this.cmbCurrentLanguage.Visible       = UserConfigHelper.Exists("CurrentLanguage");

            // this.cmbService.Items.Clear();
            // this.cmbService.Items.Add("DotNet.Service");
            // this.cmbService.Items.Add("DotNet.WCFClient");
            // this.cmbService.Items.Add("DotNet.RemotingClient");
            string[] servicePathItems = UserConfigHelper.GetOptions("Service");
            for (int i = 0; i < servicePathItems.Length; i++)
            {
                this.cmbService.Items.Add(servicePathItems[i]);
            }
            this.cmbService.SelectedIndex = this.cmbService.Items.IndexOf(BaseSystemInfo.Service);

            this.chkRememberPassword.Checked = BaseSystemInfo.RememberPassword;
            this.chbAutoLogOn.Checked        = BaseSystemInfo.AutoLogOn;
            this.chkRecordLog.Checked        = BaseSystemInfo.RecordLog;

            // 客户端若没这个配置,那就不读取这个配置了。
            this.chkUseMessage.Visible = UserConfigHelper.Exists("UseMessage");
            this.chkUseMessage.Checked = BaseSystemInfo.UseMessage;

            this.chkAllowUserRegister.Checked = BaseSystemInfo.AllowUserRegister;
            this.txtCustomerCompanyName.Text  = BaseSystemInfo.CustomerCompanyName;

            this.txtMainForm.Text  = BaseSystemInfo.MainForm;
            this.txtLogOnForm.Text = BaseSystemInfo.LogOnForm;

            this.nupOnLineLimit.Value = BaseSystemInfo.OnLineLimit;

            this.chkUseUserPermission.Checked     = BaseSystemInfo.UseUserPermission;
            this.chkUseOrganizePermission.Checked = BaseSystemInfo.UseOrganizePermission;
            this.chkUseModulePermission.Checked   = BaseSystemInfo.UseModulePermission;
            this.chkWorkFlow.Visible = UserConfigHelper.Exists("UseWorkFlow");
            this.chkWorkFlow.Checked = BaseSystemInfo.UseWorkFlow;

            // 是否隐藏这个配置选项
            this.chkUseOrganizePermission.Visible = UserConfigHelper.Exists("UseOrganizePermission");
            this.chkUsePermissionScope.Visible    = UserConfigHelper.Exists("UsePermissionScope");
            this.chkUsePermissionScope.Checked    = BaseSystemInfo.UsePermissionScope;
            this.chkUseAuthorizationScope.Visible = UserConfigHelper.Exists("UseAuthorizationScope");
            this.chkUseAuthorizationScope.Checked = BaseSystemInfo.UseAuthorizationScope;

            // 是否隐藏这个配置选项
            this.chkUseTableColumnPermission.Visible = UserConfigHelper.Exists("UseTableColumnPermission");
            this.chkUseTableColumnPermission.Checked = BaseSystemInfo.UseTableColumnPermission;

            // 是否隐藏这个配置选项
            this.chkUseTableScopePermission.Visible = UserConfigHelper.Exists("UseTableScopePermission");
            this.chkUseTableScopePermission.Checked = BaseSystemInfo.UseTableScopePermission;

            // 初始化数据库
            // this.cmbDbType.Items.Clear();
            // this.cmbDbType.Items.Add("SqlServer");
            // this.cmbDbType.Items.Add("Oracle");
            // this.cmbDbType.Items.Add("Access");
            // this.cmbDbType.Items.Add("DB2");
            // this.cmbDbType.Items.Add("MySql");
            // this.cmbDbType.Items.Add("SQLite");
            string[] dataBaseTypeItems = UserConfigHelper.GetOptions("UserCenterDbType");
            for (int i = 0; i < dataBaseTypeItems.Length; i++)
            {
                this.cmbUserCenterDbDbType.Items.Add(dataBaseTypeItems[i]);
            }
            this.cmbUserCenterDbDbType.SelectedIndex = this.cmbUserCenterDbDbType.Items.IndexOf(BaseSystemInfo.UserCenterDbType.ToString());

            dataBaseTypeItems = UserConfigHelper.GetOptions("BusinessDbType");
            for (int i = 0; i < dataBaseTypeItems.Length; i++)
            {
                this.cmbBusinessDbDbType.Items.Add(dataBaseTypeItems[i]);
            }
            this.cmbBusinessDbDbType.SelectedIndex = this.cmbBusinessDbDbType.Items.IndexOf(BaseSystemInfo.BusinessDbType.ToString());

            dataBaseTypeItems = UserConfigHelper.GetOptions("WorkFlowDbType");
            for (int i = 0; i < dataBaseTypeItems.Length; i++)
            {
                this.cmbWorkFlowDbDbType.Items.Add(dataBaseTypeItems[i]);
            }
            this.cmbWorkFlowDbDbType.SelectedIndex = this.cmbWorkFlowDbDbType.Items.IndexOf(BaseSystemInfo.WorkFlowDbType.ToString());

            this.chkEncryptDbConnection.Checked = BaseSystemInfo.EncryptDbConnection;
            this.btnEncrypt.Visible             = !BaseSystemInfo.EncryptDbConnection;
            this.txtUserCenterDbConnection.Text = BaseSystemInfo.UserCenterDbConnectionString;
            this.txtBusinessDbConnection.Text   = BaseSystemInfo.BusinessDbConnectionString;

            this.txtWorkFlowDbConnection.Text    = BaseSystemInfo.WorkFlowDbConnectionString;
            this.lblWorkFlowDbConnection.Visible = UserConfigHelper.Exists() && UserConfigHelper.Exists("WorkFlowDbConnection");
            this.cmbWorkFlowDbDbType.Visible     = UserConfigHelper.Exists() && UserConfigHelper.Exists("WorkFlowDbConnection");
            this.txtWorkFlowDbConnection.Visible = UserConfigHelper.Exists() && UserConfigHelper.Exists("WorkFlowDbConnection");
        }
Exemple #29
0
 /// <summary>
 /// 获取服务器上的配置信息
 /// </summary>
 /// <param name="userInfo">用户</param>
 /// <param name="key">配置项主键</param>
 /// <returns>配置内容</returns>
 public string GetServiceConfig(BaseUserInfo userInfo, string key)
 {
     return(UserConfigHelper.GetValue(key));
 }