Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int categoryPosition = 0;
        int forumPosition    = 0;

        Telerik.Forums.ForumManager oldForumManager = new Telerik.Forums.ForumManager();
        CT.Forums.ForumsManager     newForumManager = new CT.Forums.ForumsManager();

        //get all existing categories
        IList oldCategories = oldForumManager.GetCategories();

        foreach (Telerik.Forums.ICategory oldCategory in oldCategories)
        {
            categoryPosition++;

            //create new category
            CT.Forums.ICategory newCategory = newForumManager.CreateCategory();
            newCategory.ID       = oldCategory.ID;
            newCategory.Name     = oldCategory.Name;
            newCategory.Position = categoryPosition;
            newForumManager.SaveCategory(newCategory);

            forumPosition = 0;
            //get all existing forums
            IList oldForums = oldForumManager.GetForums(oldCategory.ID, false);
            foreach (Telerik.Forums.IForum oldForum in oldForums)
            {
                forumPosition++;

                CT.Forums.IForum newForum = newForumManager.CreateForum();
                newForum.Category    = newCategory;
                newForum.ID          = oldForum.ID;
                newForum.DateCreated = oldForum.DateCreated;
                newForum.Description = oldForum.Description;
                newForum.Name        = oldForum.Name;
                newForum.Position    = forumPosition;

                switch (oldForum.Status)
                {
                case Telerik.Forums.ForumStatus.Hidden:
                    newForum.Status = CT.Forums.ForumStatus.Hidden;
                    break;

                case Telerik.Forums.ForumStatus.Locked:
                    newForum.Status = CT.Forums.ForumStatus.Locked;
                    break;

                case Telerik.Forums.ForumStatus.Visible:
                    newForum.Status = CT.Forums.ForumStatus.Visible;
                    break;
                }

                newForumManager.SaveForum(newForum);

                //get all existing threads
                IList oldThreads = oldForumManager.GetForumThreads(newForum.ID, false);
                foreach (Telerik.Forums.IPost oldThread in oldThreads)
                {
                    if (String.IsNullOrEmpty(oldThread.Title))
                    {
                        continue;
                    }

                    CT.Forums.IPost newThread = newForumManager.CreatePost();
                    newThread.ID          = oldThread.ID;
                    newThread.Owner       = oldThread.Owner;
                    newThread.Title       = oldThread.Title;
                    newThread.DateCreated = oldThread.DateCreated;
                    newThread.DateUpdated = newThread.DateCreated;
                    newThread.Content     = oldThread.Content;
                    newThread.AuthorIP    = (!String.IsNullOrEmpty(oldThread.AuthorIP)) ? oldThread.AuthorIP : "";
                    newThread.Forum       = newForum;

                    switch (oldThread.Status)
                    {
                    case Telerik.Forums.PostStatus.ThreadHidden:
                        newThread.Status = CT.Forums.PostStatus.ThreadHidden;
                        break;

                    case Telerik.Forums.PostStatus.ThreadLocked:
                        newThread.Status = CT.Forums.PostStatus.ThreadLocked;
                        break;

                    case Telerik.Forums.PostStatus.ThreadVisible:
                        newThread.Status = CT.Forums.PostStatus.ThreadVisible;
                        break;
                    }

                    newForumManager.SaveThread(newThread);

                    int postNumber = 0;
                    //get all existing posts
                    IList oldPosts = oldForumManager.GetPosts(newThread.ID, false, false);
                    foreach (Telerik.Forums.IPost oldPost in oldPosts)
                    {
                        postNumber++;

                        CT.Forums.IPost newPost = newForumManager.CreatePost();
                        newPost.ID          = oldPost.ID;
                        newPost.Owner       = oldPost.Owner;
                        newPost.DateCreated = oldPost.DateCreated;
                        newPost.Content     = oldPost.Content;
                        newPost.AuthorIP    = (!String.IsNullOrEmpty(oldPost.AuthorIP)) ? oldPost.AuthorIP : "";
                        newPost.Forum       = newForum;
                        newPost.Thread      = newThread;

                        switch (oldPost.Status)
                        {
                        case Telerik.Forums.PostStatus.PostHidden:
                            newPost.Status = CT.Forums.PostStatus.PostHidden;
                            break;

                        case Telerik.Forums.PostStatus.PostVisible:
                            newPost.Status = CT.Forums.PostStatus.PostVisible;
                            break;
                        }

                        newForumManager.SaveThread(newPost);

                        if (postNumber == oldPosts.Count)
                        {
                            newThread.DateUpdated = oldPost.DateCreated;
                            newForumManager.SaveThread(newThread);
                        }
                    }
                }
            }
        }

        Response.Write("<h1>Done!</h1>");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int categoryPosition = 0;
        int forumPosition = 0;

        Telerik.Forums.ForumManager oldForumManager = new Telerik.Forums.ForumManager();
        CT.Forums.ForumsManager newForumManager = new CT.Forums.ForumsManager();

        //get all existing categories
        IList oldCategories = oldForumManager.GetCategories();
        foreach (Telerik.Forums.ICategory oldCategory in oldCategories)
        {
            categoryPosition++;

            //create new category
            CT.Forums.ICategory newCategory = newForumManager.CreateCategory();
            newCategory.ID = oldCategory.ID;
            newCategory.Name = oldCategory.Name;
            newCategory.Position = categoryPosition;
            newForumManager.SaveCategory(newCategory);

            forumPosition = 0;
            //get all existing forums
            IList oldForums = oldForumManager.GetForums(oldCategory.ID, false);
            foreach (Telerik.Forums.IForum oldForum in oldForums)
            {
                forumPosition++;

                CT.Forums.IForum newForum = newForumManager.CreateForum();
                newForum.Category = newCategory;
                newForum.ID = oldForum.ID;
                newForum.DateCreated = oldForum.DateCreated;
                newForum.Description = oldForum.Description;
                newForum.Name = oldForum.Name;
                newForum.Position = forumPosition;

                switch(oldForum.Status)
                {
                    case Telerik.Forums.ForumStatus.Hidden:
                        newForum.Status = CT.Forums.ForumStatus.Hidden;
                        break;
                    case Telerik.Forums.ForumStatus.Locked:
                        newForum.Status = CT.Forums.ForumStatus.Locked;
                        break;
                    case Telerik.Forums.ForumStatus.Visible:
                        newForum.Status = CT.Forums.ForumStatus.Visible;
                        break;
                }

                newForumManager.SaveForum(newForum);

                //get all existing threads
                IList oldThreads = oldForumManager.GetForumThreads(newForum.ID, false);
                foreach (Telerik.Forums.IPost oldThread in oldThreads)
                {
                    if (String.IsNullOrEmpty(oldThread.Title))
                    {
                        continue;
                    }

                    CT.Forums.IPost newThread = newForumManager.CreatePost();
                    newThread.ID = oldThread.ID;
                    newThread.Owner = oldThread.Owner;
                    newThread.Title = oldThread.Title;
                    newThread.DateCreated = oldThread.DateCreated;
                    newThread.DateUpdated = newThread.DateCreated;
                    newThread.Content = oldThread.Content;
                    newThread.AuthorIP = (!String.IsNullOrEmpty(oldThread.AuthorIP)) ? oldThread.AuthorIP : "";
                    newThread.Forum = newForum;

                    switch (oldThread.Status)
                    {
                        case Telerik.Forums.PostStatus.ThreadHidden:
                            newThread.Status = CT.Forums.PostStatus.ThreadHidden;
                            break;
                        case Telerik.Forums.PostStatus.ThreadLocked:
                            newThread.Status = CT.Forums.PostStatus.ThreadLocked;
                            break;
                        case Telerik.Forums.PostStatus.ThreadVisible:
                            newThread.Status = CT.Forums.PostStatus.ThreadVisible;
                            break;
                    }

                    newForumManager.SaveThread(newThread);

                    int postNumber = 0;
                    //get all existing posts
                    IList oldPosts = oldForumManager.GetPosts(newThread.ID, false, false);
                    foreach (Telerik.Forums.IPost oldPost in oldPosts)
                    {
                        postNumber++;

                        CT.Forums.IPost newPost = newForumManager.CreatePost();
                        newPost.ID = oldPost.ID;
                        newPost.Owner = oldPost.Owner;
                        newPost.DateCreated = oldPost.DateCreated;
                        newPost.Content = oldPost.Content;
                        newPost.AuthorIP = (!String.IsNullOrEmpty(oldPost.AuthorIP)) ? oldPost.AuthorIP : "";
                        newPost.Forum = newForum;
                        newPost.Thread = newThread;

                        switch (oldPost.Status)
                        {
                            case Telerik.Forums.PostStatus.PostHidden:
                                newPost.Status = CT.Forums.PostStatus.PostHidden;
                                break;
                            case Telerik.Forums.PostStatus.PostVisible:
                                newPost.Status = CT.Forums.PostStatus.PostVisible;
                                break;
                        }

                        newForumManager.SaveThread(newPost);

                        if (postNumber == oldPosts.Count)
                        {
                            newThread.DateUpdated = oldPost.DateCreated;
                            newForumManager.SaveThread(newThread);
                        }
                    }
                }
            }
        }

        Response.Write("<h1>Done!</h1>");
    }