Ejemplo n.º 1
0
        private void ConvertUser(BackgroundWorker sender)
        {
            BonSoChinDataContext bonSoChinContext = new BonSoChinDataContext();
            VBBDataContext context = new VBBDataContext();

            var avatarsource = (from member in bonSoChinContext.Members
                                select member.Memberimage).Distinct<string>().ToList();

            int count = 1;
            sender.ReportProgress(10, new UserProgress("avatar", count++, avatarsource.Count()));

            // ----------------------- AVATARS TABLE ------------------------------------
            foreach (string avatarImg in avatarsource)
            {
                string img;
                if (avatarImg == null)
                    img = "000.gif";
                else
                    img = avatarImg.ToString();

                string number = img.Substring(0, img.IndexOf("."));
                number = RemoveAllSpecialCharacter(number);

                Avatar avatar = new Avatar
                {

                    Avatarid = Int32.Parse(number),
                    Avatarpath = img,
                    Displayorder = 1,
                    Imagecategoryid = 3,
                    Title = "",
                    Minimumposts = 0
                };
                context.Avatars.InsertOnSubmit(avatar);

            }
            context.SubmitChanges();

            // ----------------------- USERS TABLE ------------------------------------

            var result = (from member in bonSoChinContext.Members
                         select member).ToList();

            count = 1;
            sender.ReportProgress(10, new UserProgress("user", count++, result.Count()));
            foreach (Member member in result)
            {
                string salt = FetchUserSalt(3);

                int test = ConvertToUnixTimestamp(member.Memberdateadded);
                User user = new User
                {
                    Userid = (uint)member.Memberid,
                    Username = member.Memberlogin.Trim(),
                    Password = CreatePassword(member.Memberpassword.Trim(), salt),
                    Passworddate = DateTime.Now,
                    Email = member.Memberemail,
                    Showvbcode = 1,
                    Showbirthday = 0,
                    //Usertitle = "Junior Member",
                    Usertitle = (from title in context.Usertitles
                                 where title.Minposts < member.Numberofmessages
                                 orderby title.Usertitleid ascending
                                 select title.Title).FirstOrDefault(),
                    Joindate = ConvertToUnixTimestamp(member.Memberdateadded), //1273158780,
                    //;
                    Lastvisit = 1273158780,
                    Daysprune = -1,
                    Lastactivity = 1273158780,
                    Reputation = 10,
                    Reputationlevelid = 5,
                    Timezoneoffset = "7",
                    Options = 45108311,
                    Birthday = member.Memberdateadded.Value.ToString("yyyy-MM-dd"),
                    Birthdaysearch = DateTime.Now,
                    Posts = (long)member.Numberofmessages,
                    Maxposts = -1,
                    Startofweek = 1,
                    Autosubscribe = -1,
                    Salt = salt,
                    Showblogcss = 1
                };
                string img = "000.gif";
                if (member.Memberimage != null)
                {
                    img = member.Memberimage;
                }

                user.Avatarid =
                    (short)(from avt in context.Avatars where avt.Avatarpath.Equals(img) select avt.Avatarid).FirstOrDefault();

                switch (member.Securitylevelid)
                {
                    case 1:
                        user.Usergroupid = 2;
                        break;
                    case 2:
                        user.Usergroupid = 7;
                        break;
                    case 3:
                        user.Usergroupid = 6;
                        break;
                    default:
                        user.Usergroupid = 2;
                        break;
                }

                PopulateUShort(user);
                context.Users.InsertOnSubmit(user);

                // userfield
                Userfield userfield = new Userfield();

                userfield.Userid = (uint)member.Memberid;
                context.Userfields.InsertOnSubmit(userfield);

                // usertextfield
                Usertextfield usertextfield = new Usertextfield();
                usertextfield.Userid = (uint)member.Memberid;
                context.Usertextfields.InsertOnSubmit(usertextfield);
                //}

            }

            context.SubmitChanges();
        }
Ejemplo n.º 2
0
 partial void UpdateUserfield(Userfield instance);
Ejemplo n.º 3
0
 partial void DeleteUserfield(Userfield instance);
Ejemplo n.º 4
0
 partial void InsertUserfield(Userfield instance);