/// <summary>
        /// 通过登录名或邮箱获取登录信息
        /// </summary>
        /// <param name="mailName"></param>
        /// <param name="vt">条件类别</param>
        /// <returns></returns>
        public List<Membership> GetMemberByMailName(string checkName, ValidType vt)
        {
            MembershipDao md = new MembershipDao();
            Membership ms = new Membership();
            if (string.IsNullOrEmpty(checkName))
                return null;

            switch (vt)
            {
                case ValidType.All:
                    ms.Where = string.Format("LoweredLoginName = {0} OR LoweredEmail= {0}", checkName.ToLower());
                    break;
                case ValidType.Mail:
                    ms.Where = string.Format("LoweredEmail= {0}", checkName.ToLower());
                    break;
                case ValidType.LoginName:
                    ms.Where = string.Format("LoweredLoginName = {0}", checkName.ToLower());
                    break;
                default:
                    ms.Where = string.Format("LoweredLoginName = {0} OR LoweredEmail= {0}", checkName.ToLower());
                    break;
            }

            return md.Select(ms);
        }
        private static bool Validate(Control control, ValidType validType)
        {
            bool isValid = false;

            if (validType == ValidType.Required)
            {
                isValid = Required(control);
            }
            else
            {
                var _control = (TextBox)control;
                switch (validType)
                {
                case ValidType.Email:
                    isValid = IsValidEmail(_control.Text);
                    break;

                case ValidType.Number:
                    isValid = IsValidPositiveIntNumber(_control.Text);
                    break;

                case ValidType.Url:
                    isValid = Url(_control.Text);
                    break;

                case ValidType.Money:
                    isValid = Money(_control.Text);
                    break;
                }
            }

            return(isValid);
        }
Beispiel #3
0
        public void ValidGetQueuesTest(ValidUnderScore underscore, ValidType type, ValidScope scope)
        {
            var request = new Dictionary <string, string>
            {
                [QueueParam.Type.ToString().ToLower()] = QueueTestCaseData.ValidTypeValueMapper[type],
            };

            QueueTestCaseData.ValidUnderscoreValueMapper[underscore](request);
            QueueTestCaseData.ValidScopeValueMapper[scope](request);
            var defaultManager = new DefaultManager();
            var response       = defaultManager.Send <object>(QueueTestCaseData.QueuesEndpoint, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
        }
        public void GetFieldInfoFromType_ShouldPropertyMapCSharpType(
            ValidType expected
            )
        {
            //Act
            var actual = _inspector.GetFieldInfoFromType(
                typeof(AllValidValuesTestClass)
                );

            //Assert
            actual.Properties
            .Select(x => x.ValidType)
            .Should()
            .Contain(expected);
        }
        public void MapPropertyToSql_ShouldMapSqlType(
            ValidType type,
            string expectedSqlType
            )
        {
            //Assemble
            var property = new PropertyInfo
            {
                ValidType = type
            };

            //Act
            var actual = SqlMapper.MapPropertyToSql(property, "");

            //Assert
            actual.SqlType.Should().StartWith(expectedSqlType);
        }
        public void MapPropertyToSql_TypeHasLength_ShouldAddLengthToType(
            ValidType type,
            string length,
            string expectedSqlType
            )
        {
            //Assemble
            var property = new PropertyInfo
            {
                ValidType = type,
                Length    = length
            };

            //Act
            var actual = SqlMapper.MapPropertyToSql(property, "");

            //Assert
            actual.SqlType.Should().StartWith(expectedSqlType);
        }
        /// <summary>
        /// 生成一个随机文字图片,保存在 Session["code1"]
        /// </summary>
        /// <param name="count">图片中字的个数</param>
        /// <returns>生成的文字</returns>
        public string CreateImage(int count, ValidType type)
        {
            string ValidCode = GenCode(count, type);

            switch (type)
            {
                case ValidType.Numeric:
                    CreateCheckCodeImage(ValidCode, 13.5);
                    break;
                case ValidType.NumericAndEnglishChar:
                    CreateCheckCodeImage(ValidCode, 14);
                    break;
                case ValidType.ChineseChar:
                    CreateCheckCodeImage(ValidCode, 22.5);
                    break;
                default:
                    break;
            }
            return ValidCode;
        }
        public void MapPropertyToSql_TypeHasPrecisionAndScale_ShouldAddPrecisionAndScaleToType(
            ValidType type,
            int precision,
            int scale,
            string expectedSqlType
            )
        {
            //Assemble
            var property = new PropertyInfo
            {
                ValidType = type,
                Scale     = scale,
                Precision = precision
            };

            //Act
            var actual = SqlMapper.MapPropertyToSql(property, "");

            //Assert
            actual.SqlType.Should().StartWith(expectedSqlType);
        }
Beispiel #9
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddIf(IsRequired.HasValue, EasyuiConsts.Required, IsRequired);
            Options.AddIf(IsMultiline.HasValue, EasyuiConsts.Multiline, IsMultiline);
            Options.AddIf(IsDisable.HasValue, EasyuiConsts.Disabled, IsDisable);
            Options.AddIf(IsEdit.HasValue, EasyuiConsts.Editable, IsEdit);

            if (MaxLength > 0)
            {
                ValidTypes.Add($"{EasyuiConsts.ValidType_MaxLength}[{MaxLength}]");
            }

            if (Options.ContainsKey(EasyuiConsts.ValidType))
            {
                var valids = Options[EasyuiConsts.ValidType].ToString().Split(',').Where(x => x.IsNotNullOrWhiteSpace());
                ValidTypes.AddRange(valids);
            }

            if (ValidType.IsNotNullOrWhiteSpace())
            {
                var valids = ValidType.Split(',').Where(x => x.IsNotNullOrWhiteSpace());
                ValidTypes.AddRange(valids);
            }

            if (IsDisable == true)
            {
                Clear = false;
            }
            if (Clear.HasValue)
            {
                output.Attributes.Add(EasyuiConsts.Clear, Clear.ToString().ToCamelCase());
            }

            if (ValidTypes.Any())
            {
                Options.AddOrUpdate(EasyuiConsts.ValidType, GetJavaScriptString(ValidTypes.ToJsonString()));
            }
        }
Beispiel #10
0
        /// <summary>
        /// 生成一个随机文字图片,保存在 Session["code1"]
        /// </summary>
        /// <param name="count">图片中字的个数</param>
        /// <returns>生成的文字</returns>
        public string CreateImage(int count, ValidType type)
        {
            string ValidCode = GenCode(count, type);

            switch (type)
            {
            case ValidType.Numeric:
                CreateCheckCodeImage(ValidCode, 13.5);
                break;

            case ValidType.NumericAndEnglishChar:
                CreateCheckCodeImage(ValidCode, 14);
                break;

            case ValidType.ChineseChar:
                CreateCheckCodeImage(ValidCode, 22.5);
                break;

            default:
                break;
            }
            return(ValidCode);
        }
Beispiel #11
0
        /// <summary>
        /// 产生随机字符串
        /// </summary>
        /// <param name="num">随机出几个字符</param>
        /// <returns>随机出的字符串</returns>
        private string GenCode(int num, ValidType type)
        {
            string str;

            switch (type)
            {
            case ValidType.Numeric:
                str = "0123456789";
                break;

            case ValidType.NumericAndEnglishChar:
                str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                break;

            case ValidType.ChineseChar:

                //常用498个汉字
                str = "的一是在不了有和人这中大为上个国我以要他时来用们生到作地于出就分对成会可主发年动同工也能下过子说产种面而方后多定行学法所民得经十三之进着等部度 家电力里如水化高自二理起小物现实加量都两体制机当使点从业本去把性好应开它合还因由其些然前外天政四日那社义事平形相全表间样与关各重新线内数正心反你 明看原又么利比或但质气第向道命此变条只没结解问意建月公无系军很情者最立代想已通并提直题党程展五果料象员革位入常文总次品式活设及管特件长求老头基资 边流路级少图山统接知较将组见计别她手角期根论运农指几九区强放决西被干做必战先回则任取据处队南给色光门即保治北造百规热领七海口东导器压志世金增争济 阶油思术极交受联什认六共权收证改清己美再采转更单风切打白教速花带安场身车例真务具万每目至达走积示议声报斗完类八离华名确才科张信马节话米整空元况今 集温传土许步群广石记需段研界拉林律叫且究观越织装影算低持音众书布复容儿须际商非验连断深难近矿千周委素技备半办青省列习响约支般史感劳便团往酸历市克 何除消构府称太准精值号率族维划选标写存候毛亲快效斯院查江型眼王按格养易置派层片始却专状育厂京识适属圆包火住调满县局照参红细引听该铁价严";
                break;

            default:
                str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                break;
            }

            char[] chastr = str.ToCharArray();
            string code   = "";
            Random rd     = new Random();
            int    i;

            for (i = 0; i < num; i++)
            {
                code += str.Substring(rd.Next(0, str.Length), 1);
            }
            return(code);
        }
Beispiel #12
0
        /// <summary>
        /// 登录名或邮箱是否重复
        /// </summary>
        /// <param name="checkName"></param>
        /// <param name="vt">条件类别</param>
        /// <returns></returns>
        public bool RepeatMailName(string checkName, ValidType vt)
        {
            List<Membership> lms = GetMemberByMailName(checkName, vt);
            if (lms.Count > 0)
            {
                return true;
            }

            return false;
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="type">验证类型</param>
 /// <param name="paramName">要验证的参数,不传默认为验证当前方法入参的所有参数</param>
 public ValidateParamAttribute(string paramName = "", string group = "", ValidType type = ValidType.Fast)
 {
     _type       = type;
     _paramNames = paramName;
     _group      = group;
 }
        public bool IsValid(RegisterModel model, ValidType validType)
        {
            foreach (UserProfile UP in db.UserProfiles.ToList())
            {
                if (validType == ValidType.UserName)
                {
                    if (UP.UserName == model.UserName)
                    {
                        return false;
                    }
                }
                if (validType == ValidType.Email)
                {
                    if (UP.Email == model.Email)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
Beispiel #15
0
 /// <summary>
 /// 產生驗證連結
 /// </summary>
 /// <returns></returns>
 public static string GetConfirmUrl(ValidType type, string validCode, string email)
 {
     return(BaseUrl() + $"/Member/Confirm?type={type.ToString().ToLower()}&code={validCode}&key={HttpContext.Current.Server.UrlEncode(email)}");
 }
        /// <summary>
        /// 产生随机字符串
        /// </summary>
        /// <param name="num">随机出几个字符</param>
        /// <returns>随机出的字符串</returns>
        private string GenCode(int num, ValidType type)
        {
            string str;
            switch (type)
            {
                case ValidType.Numeric:
                    str = "0123456789";
                    break;
                case ValidType.NumericAndEnglishChar:
                    str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                    break;
                case ValidType.ChineseChar:

                    //常用498个汉字
                    str = "的一是在不了有和人这中大为上个国我以要他时来用们生到作地于出就分对成会可主发年动同工也能下过子说产种面而方后多定行学法所民得经十三之进着等部度 家电力里如水化高自二理起小物现实加量都两体制机当使点从业本去把性好应开它合还因由其些然前外天政四日那社义事平形相全表间样与关各重新线内数正心反你 明看原又么利比或但质气第向道命此变条只没结解问意建月公无系军很情者最立代想已通并提直题党程展五果料象员革位入常文总次品式活设及管特件长求老头基资 边流路级少图山统接知较将组见计别她手角期根论运农指几九区强放决西被干做必战先回则任取据处队南给色光门即保治北造百规热领七海口东导器压志世金增争济 阶油思术极交受联什认六共权收证改清己美再采转更单风切打白教速花带安场身车例真务具万每目至达走积示议声报斗完类八离华名确才科张信马节话米整空元况今 集温传土许步群广石记需段研界拉林律叫且究观越织装影算低持音众书布复容儿须际商非验连断深难近矿千周委素技备半办青省列习响约支般史感劳便团往酸历市克 何除消构府称太准精值号率族维划选标写存候毛亲快效斯院查江型眼王按格养易置派层片始却专状育厂京识适属圆包火住调满县局照参红细引听该铁价严";
                    break;
                default:
                    str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                    break;
            }

            char[] chastr = str.ToCharArray();
            string code = "";
            Random rd = new Random();
            int i;
            for (i = 0; i < num; i++)
            {
                code += str.Substring(rd.Next(0, str.Length), 1);
            }
            return code;
        }
 //VS Code didn't like this being inline, text coloring got messed up
 private static string Throw(ValidType x) =>
 throw new InvalidOperationException(
           $"The type {x} is missing from the test dictionary"
           );
 /// <summary>
 /// 传入api允许请求来源
 /// </summary>
 /// <param name="sources"></param>
 /// <param name="validType">验证方式</param>
 public ApiValidFilterAttribute(Source[] sources, ValidType validType = ValidType.Valid)
 {
     this.AllSource = sources;
     this.ValidType = validType;
 }
Beispiel #19
0
        private static bool Validate(Control control, ValidType validType)
        {
            bool isValid = false;

            if (validType == ValidType.Required)
            {
                isValid = Required(control);
            }
            else
            {
                var _control = (TextBox)control;
                switch (validType)
                {
                    case ValidType.Email:
                        isValid = IsValidEmail(_control.Text);
                        break;
                    case ValidType.Number:
                        isValid = IsValidPositiveIntNumber(_control.Text);
                        break;
                    case ValidType.Url:
                        isValid = Url(_control.Text);
                        break;
                    case ValidType.Money:
                        isValid = Money(_control.Text);
                        break;
                }
            }

            return isValid;
        }
Beispiel #20
0
 public static bool IsValid(string Input, ValidType Info)
 {
     return(Regex.IsMatch(Input, RegexList[(int)Info]));
 }