private void btnGo_Click(object sender, RoutedEventArgs e) { var docCategories = XDocument.Load(Constants.pathCategories); var categories = docCategories.Descendants("gdn_category").Select(ele => new Forum(ele)).ToList(); var categoriesDict = categories.ToDictionary(d => d.ForumID, d => d); var docDiscussions = XDocument.Load(Constants.pathDiscussions); var discussions = docDiscussions.Descendants("gdn_discussion").Select(ele => new Discussion(ele)).ToList(); foreach (var disc in discussions) { Forum parentForum = null; if (categoriesDict.TryGetValue(disc.CategoryID, out parentForum)) parentForum.Discussions.Add(disc); } var docComments = XDocument.Load(Constants.pathComments); var comments = docComments.Descendants("gdn_comment").Select(ele => new Comment(ele)).ToList(); var discussionDict = discussions.ToDictionary(d => d.DiscussionID, d => d); foreach (var comment in comments) { Discussion parentDiscussion = null; if (discussionDict.TryGetValue(comment.DiscussionID, out parentDiscussion)) parentDiscussion.Comments.Add(comment); } var imported = new YAFImport(); imported.AddForums(categories); }
private void btnClear_Click(object sender, RoutedEventArgs e) { var db = new YAFImport(); db.Truncate(); }