예제 #1
0
        private bool CheckLoginValid(out string errorMessage)
        {
            errorMessage = string.Empty;

            if (string.IsNullOrEmpty(TbAdminName.Text))
            {
                errorMessage = "管理员用户名不能为空!";
                return(false);
            }

            if (string.IsNullOrEmpty(TbAdminPassword.Text))
            {
                errorMessage = "管理员密码不能为空!";
                return(false);
            }

            if (TbAdminPassword.Text.Length < 6)
            {
                errorMessage = "管理员密码必须大于6位!";
                return(false);
            }

            if (TbAdminPassword.Text != TbComfirmAdminPassword.Text)
            {
                errorMessage = "两次输入的管理员密码不一致!";
                return(false);
            }
            if (!EUserPasswordRestrictionUtils.IsValid(TbAdminPassword.Text, EUserPasswordRestrictionUtils.GetValue(EUserPasswordRestriction.LetterAndDigit)))
            {
                errorMessage =
                    $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestriction.LetterAndDigit)}";
                return(false);
            }
            return(true);
        }
예제 #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }
            if (IsPostBack)
            {
                return;
            }

            BreadCrumbAdmin(AppManager.Admin.LeftMenu.AdminConfiguration, "管理员设置", AppManager.Admin.Permission.AdminConfiguration);

            TbLoginUserNameMinLength.Text = ConfigManager.SystemConfigInfo.LoginUserNameMinLength.ToString();
            TbLoginPasswordMinLength.Text = ConfigManager.SystemConfigInfo.LoginPasswordMinLength.ToString();
            EUserPasswordRestrictionUtils.AddListItems(DdlLoginPasswordRestriction);
            ControlUtils.SelectListItemsIgnoreCase(DdlLoginPasswordRestriction, EUserPasswordRestrictionUtils.GetValue(ConfigManager.SystemConfigInfo.LoginPasswordRestriction));

            EBooleanUtils.AddListItems(RblIsLoginFailToLock, "是", "否");
            ControlUtils.SelectListItemsIgnoreCase(RblIsLoginFailToLock, ConfigManager.SystemConfigInfo.IsLoginFailToLock.ToString());

            PhFailToLock.Visible = ConfigManager.SystemConfigInfo.IsLoginFailToLock;

            TbLoginFailToLockCount.Text = ConfigManager.SystemConfigInfo.LoginFailToLockCount.ToString();

            DdlLoginLockingType.Items.Add(new ListItem("按小时锁定", EUserLockTypeUtils.GetValue(EUserLockType.Hours)));
            DdlLoginLockingType.Items.Add(new ListItem("永久锁定", EUserLockTypeUtils.GetValue(EUserLockType.Forever)));
            ControlUtils.SelectListItemsIgnoreCase(DdlLoginLockingType, ConfigManager.SystemConfigInfo.LoginLockingType);

            PhLoginLockingHours.Visible = false;
            if (!EUserLockTypeUtils.Equals(ConfigManager.SystemConfigInfo.LoginLockingType, EUserLockType.Forever))
            {
                PhLoginLockingHours.Visible = true;
                TbLoginLockingHours.Text    = ConfigManager.SystemConfigInfo.LoginLockingHours.ToString();
            }

            EBooleanUtils.AddListItems(RblIsFindPassword, "启用", "禁用");
            ControlUtils.SelectListItemsIgnoreCase(RblIsFindPassword, ConfigManager.SystemConfigInfo.IsFindPassword.ToString());
            PhFindPassword.Visible      = ConfigManager.SystemConfigInfo.IsFindPassword;
            TbFindPasswordSmsTplId.Text = ConfigManager.SystemConfigInfo.FindPasswordSmsTplId;

            EBooleanUtils.AddListItems(RblIsViewContentOnlySelf, "不可以", "可以");
            ControlUtils.SelectListItemsIgnoreCase(RblIsViewContentOnlySelf, ConfigManager.SystemConfigInfo.IsViewContentOnlySelf.ToString());
        }
예제 #3
0
        public static async Task Execute(IJobContext context)
        {
            if (!CliUtils.ParseArgs(Options, context.Args))
            {
                return;
            }

            if (_isHelp)
            {
                PrintUsage();
                return;
            }

            try
            {
                if (string.IsNullOrEmpty(_userName))
                {
                    await CliUtils.PrintErrorAsync("未设置参数管理员用户名:{userName} !");

                    return;
                }

                if (string.IsNullOrEmpty(_password))
                {
                    await CliUtils.PrintErrorAsync("未设置参数管理员密码:{password} !");

                    return;
                }

                if (_password.Length < 6)
                {
                    await CliUtils.PrintErrorAsync("管理员密码必须大于6位 !");

                    return;
                }

                if (!EUserPasswordRestrictionUtils.IsValid(_password, EUserPasswordRestrictionUtils.GetValue(EUserPasswordRestriction.LetterAndDigit)))
                {
                    await CliUtils.PrintErrorAsync($"管理员密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestriction.LetterAndDigit)}");

                    return;
                }

                var webConfigPath = PathUtils.Combine(CliUtils.PhysicalApplicationPath, "web.config");
                if (!FileUtils.IsFileExists(webConfigPath))
                {
                    await CliUtils.PrintErrorAsync($"系统配置文件不存在:{webConfigPath}!");

                    return;
                }

                if (string.IsNullOrEmpty(WebConfigUtils.ConnectionString))
                {
                    await CliUtils.PrintErrorAsync("web.config 中数据库连接字符串 connectionString 未设置");

                    return;
                }

                WebConfigUtils.Load(CliUtils.PhysicalApplicationPath, "web.config");

                await Console.Out.WriteLineAsync($"数据库类型: {WebConfigUtils.DatabaseType.Value}");

                await Console.Out.WriteLineAsync($"连接字符串: {WebConfigUtils.ConnectionString}");

                await Console.Out.WriteLineAsync($"系统文件夹: {CliUtils.PhysicalApplicationPath}");

                if (!DataProvider.DatabaseDao.IsConnectionStringWork(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString))
                {
                    await CliUtils.PrintErrorAsync("系统无法连接到 web.config 中设置的数据库");

                    return;
                }

                if (!SystemManager.IsNeedInstall())
                {
                    await CliUtils.PrintErrorAsync("系统已安装在 web.config 指定的数据库中,命令执行失败");

                    return;
                }

                WebConfigUtils.UpdateWebConfig(WebConfigUtils.IsProtectData, WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, WebConfigUtils.AdminDirectory, StringUtils.GetShortGuid(), false);

                DataProvider.Reset();

                SystemManager.InstallDatabase(_userName, _password);
            }
            catch (Exception e)
            {
                await CliUtils.PrintErrorAsync(e.Message);

                return;
            }

            await Console.Out.WriteLineAsync("恭喜,系统安装成功!");
        }
예제 #4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (!IsPostBack)
            {
                BreadCrumbUser(AppManager.User.LeftMenu.UserConfiguration, "用户注册配置", AppManager.User.Permission.UserConfiguration);

                EBooleanUtils.AddListItems(RblIsRegisterAllowed);

                TbRegisterPasswordMinLength.Text = ConfigManager.UserConfigInfo.RegisterPasswordMinLength.ToString();

                EUserPasswordRestrictionUtils.AddListItems(DdlRegisterPasswordRestriction);
                ControlUtils.SelectListItemsIgnoreCase(DdlRegisterPasswordRestriction, EUserPasswordRestrictionUtils.GetValue(ConfigManager.UserConfigInfo.RegisterPasswordRestriction));

                EUserVerifyTypeUtils.AddListItems(DdlRegisterVerifyType);

                ControlUtils.SelectListItemsIgnoreCase(RblIsRegisterAllowed, ConfigManager.UserConfigInfo.IsRegisterAllowed.ToString());
                ControlUtils.SelectListItemsIgnoreCase(DdlRegisterVerifyType, EUserVerifyTypeUtils.GetValue(ConfigManager.UserConfigInfo.RegisterVerifyType));

                TbRegisterMinMinutesOfIpAddress.Text = ConfigManager.UserConfigInfo.RegisterMinMinutesOfIpAddress.ToString();
            }
        }