Ejemplo n.º 1
0
        private List <ImportUser> getUserNameList(string userNamePath)
        {
            String[] lines = file.ReadAllLines(PathHelper.Map(userNamePath));

            List <ImportUser> list = new List <ImportUser>();

            foreach (String rUser in lines)
            {
                if (strUtil.IsNullOrEmpty(rUser))
                {
                    continue;
                }

                ImportUser user = new ImportUser();

                if (rUser.IndexOf(',') <= 0 && rUser.IndexOf(',') <= 0)
                {
                    user.Name = rUser.Trim();
                }
                else
                {
                    String[] arr = rUser.Split(new char[] { ',', ',' });
                    if (arr.Length != 2)
                    {
                        continue;
                    }

                    user.Name        = arr[0].Trim();
                    user.FriendlyUrl = arr[1].Trim();
                }

                if (user.Name.Length > config.Instance.Site.UserNameLengthMax)
                {
                    continue;
                }
                if (strUtil.IsAbcNumberAndChineseLetter(user.Name) == false)
                {
                    continue;
                }

                if (strUtil.HasText(user.FriendlyUrl))
                {
                    if (user.FriendlyUrl.Length > config.Instance.Site.UserNameLengthMax)
                    {
                        continue;
                    }
                    if (strUtil.IsUrlItem(user.FriendlyUrl) == false)
                    {
                        continue;
                    }
                }

                list.Add(user);
            }

            return(list);
        }
Ejemplo n.º 2
0
        private void importUserSingle(ImportUser u, List <string> picList)
        {
            OpenService os = new OpenService();

            //
            String pwd   = getRandomPwd();
            String email = pwd + "@xxx.com";
            String apps  = " home,blog,photo,microblog,friend,visitor,forumpost,about";

            // 注册
            Result result;

            if (strUtil.HasText(u.FriendlyUrl))
            {
                result = os.UserRegister(u.Name, pwd, email, u.FriendlyUrl, apps);
            }
            else
            {
                String uFriendlyUrl = getFriendlyUrl();
                result = os.UserRegister(u.Name, pwd, email, uFriendlyUrl, apps);
            }

            if (result.HasErrors)
            {
                return;
            }
            User user = result.Info as User;

            if (picList.Count > 0)
            {
                String randomPic = picList[0];

                // 上传头像
                Result saved = AvatarUploader.Save(randomPic, user.Id);

                // 更新头像信息
                user.Pic = saved.Info.ToString();
                user.update();

                picList.RemoveAt(0);
            }
        }
Ejemplo n.º 3
0
        private List<ImportUser> getUserNameList( string userNamePath )
        {
            String[] lines = file.ReadAllLines( PathHelper.Map( userNamePath ) );

            List<ImportUser> list = new List<ImportUser>();
            foreach (String rUser in lines) {

                if (strUtil.IsNullOrEmpty( rUser )) continue;

                ImportUser user = new ImportUser();

                if (rUser.IndexOf( ',' ) <= 0 && rUser.IndexOf( ',' ) <= 0) {
                    user.Name = rUser.Trim();

                }
                else {
                    String[] arr = rUser.Split( new char[] { ',', ',' } );
                    if (arr.Length != 2) continue;

                    user.Name = arr[0].Trim();
                    user.FriendlyUrl = arr[1].Trim();
                }

                if (user.Name.Length > config.Instance.Site.UserNameLengthMax) continue;
                if (strUtil.IsAbcNumberAndChineseLetter( user.Name ) == false) continue;

                if (strUtil.HasText( user.FriendlyUrl )) {

                    if (user.FriendlyUrl.Length > config.Instance.Site.UserNameLengthMax) continue;
                    if (strUtil.IsUrlItem( user.FriendlyUrl ) == false) continue;
                }

                list.Add( user );

            }

            return list;
        }
Ejemplo n.º 4
0
        private void importUserSingle( ImportUser u, List<string> picList ) {

            OpenService os = new OpenService();

            // 
            String pwd = getRandomPwd();
            String email = pwd + "@xxx.com";
            String apps = " home,blog,photo,microblog,friend,visitor,forumpost,about";

            // 注册
            Result result;
            if (strUtil.HasText( u.FriendlyUrl )) {
                result = os.UserRegister( u.Name, pwd, email, u.FriendlyUrl, apps );
            }
            else {
                String uFriendlyUrl = getFriendlyUrl();
                result = os.UserRegister( u.Name, pwd, email, uFriendlyUrl, apps );
            }

            if (result.HasErrors) return;
            User user = result.Info as User;

            if (picList.Count > 0) {

                String randomPic = picList[0];

                // 上传头像
                Result saved = AvatarUploader.Save( randomPic, user.Id );

                // 更新头像信息
                user.Pic = saved.Info.ToString();
                user.update();

                picList.RemoveAt( 0 );

            }
        }