public void InstallContent(Module module, string configInfo) { if (string.IsNullOrEmpty(configInfo)) { return; } int userId = SiteUser.GetNewestUserId(module.SiteId); XmlDocument xml = new XmlDocument(); using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo))) { xml.LoadXml(stream.ReadToEnd()); } foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "forum") { Forum forum = new Forum(); forum.ModuleId = module.ModuleId; XmlAttributeCollection attributeCollection = node.Attributes; if (attributeCollection["title"] != null) { forum.Title = attributeCollection["title"].Value; } if (attributeCollection["sortOrder"] != null) { int sort = 1; if (int.TryParse(attributeCollection["sortOrder"].Value, out sort)) { forum.SortOrder = sort; } } foreach (XmlNode descriptionNode in node.ChildNodes) { if (descriptionNode.Name == "description") { forum.Description = descriptionNode.InnerText; break; } } forum.CreatedByUserId = userId; forum.Save(); foreach (XmlNode threadsNode in node.ChildNodes) { if (threadsNode.Name == "threads") { foreach (XmlNode threadNode in threadsNode.ChildNodes) { if (threadNode.Name == "thread") { XmlAttributeCollection threadAttributes = threadNode.Attributes; ForumThread thread = new ForumThread(); thread.ForumId = forum.ItemId; thread.PostUserId = userId; if (threadAttributes["subject"] != null) { thread.PostSubject = threadAttributes["subject"].Value; } foreach (XmlNode postNode in threadNode.ChildNodes) { if (postNode.Name == "post") { thread.PostMessage = postNode.InnerText; break; //TODO: this is limited to one post when creating a thread. could support more but just making it for the demo site } } thread.Post(); } } break; //there should only be one threads node } } } } }