Beispiel #1
0
        public static MessageCode CheckUserName(string userName, string logo)
        {
            ////检查是否有屏蔽字
            //if (FilterHelper.Instance.ScanContent(userName))
            //{
            //    return MessageCode.RegisterNameContainBadWord;
            //}
            if (string.IsNullOrEmpty(userName))
            {
                return(MessageCode.RegisterNameIsEmpty);
            }
            if (string.IsNullOrEmpty(logo))
            {
                logo = "1";
            }
            logo = logo.ToLower();
            if (!logo.Contains("http"))
            {
                string chinese = @"[\u4E00-\u9FA5]";
                string letter  = @"[a-zA-Z]";
                string number  = @"^\d+$";
                //bool result = false;
                int    count = 0;
                char[] ch    = userName.ToCharArray();
                foreach (char c in ch)
                {
                    if (Regex.IsMatch(c.ToString(), chinese))
                    {
                        count = count + 2;
                    }
                    else if (Regex.IsMatch(c.ToString(), letter) || Regex.IsMatch(c.ToString(), number))
                    {
                        count++;
                    }
                    else
                    {
                        return(MessageCode.RegisterNameHasValidWord);
                    }
                }
                if (count < 4 || count > 12)
                {
                    return(MessageCode.RegisterNameLengthRange);
                }
            }
            int exists = -1;

            NbManagerMgr.NameExists(userName, ref exists);
            if (exists == 0)
            {
                return(MessageCode.Success);
            }
            else
            {
                return(MessageCode.RegisterNameRepeat);
            }
        }