/// <summary> /// Imports the module. /// </summary> /// <param name="moduleID">The module unique identifier.</param> /// <param name="content">The content.</param> /// <param name="version">The version.</param> /// <param name="userID">The user unique identifier.</param> public void ImportModule(int moduleID, string content, string version, int userID) { using (UnitOfWork uow = new UnitOfWork()) { XmlNode node = null; XmlNode nodes = Globals.GetContent(content, "Wiki"); ModuleController objModules = new ModuleController(); foreach (XmlNode node_loopVariable in nodes.SelectSingleNode("Settings")) { node = node_loopVariable; objModules.UpdateModuleSetting(moduleID, node.Attributes["Name"].Value, node.Attributes["Value"].Value); } TopicBO topicBo = new TopicBO(uow); // clean up var topics = topicBo.GetAllByModuleID(moduleID); foreach (var topic in topics) { // TODO - On the old version topics where deleted via the SPROC // [Wiki_TopicDelete], it should be dropped in this new version topicBo.Delete(new Topic { TopicID = topic.TopicID }); } try { foreach (XmlNode node_loopVariable in nodes.SelectNodes("Topics/Topic")) { node = node_loopVariable; var topic = new Topic(); topic.PortalSettings = PortalController.GetCurrentPortalSettings(); topic.AllowDiscussions = bool.Parse(node.Attributes["AllowDiscussions"].Value); topic.AllowRatings = bool.Parse(node.Attributes["AllowRatings"].Value); topic.Content = node.Attributes["Content"].Value; topic.Description = node.Attributes["Description"].Value; topic.Keywords = node.Attributes["Keywords"].Value; topic.ModuleId = moduleID; //// Here we need to define the TabID otherwise the import won't work until //// the content is saved again. ModuleController mc = new ModuleController(); ModuleInfo mi = mc.GetModule(moduleID, -1); topic.TabID = mi.TabID; topic.Name = node.Attributes["Name"].Value; topic.RatingOneCount = 0; topic.RatingTwoCount = 0; topic.RatingThreeCount = 0; topic.RatingFourCount = 0; topic.RatingFiveCount = 0; topic.RatingSixCount = 0; topic.RatingSevenCount = 0; topic.RatingEightCount = 0; topic.RatingNineCount = 0; topic.RatingTenCount = 0; topic.Title = node.Attributes["Title"].Value; topic.UpdateDate = DateTime.Parse(node.Attributes["UpdateDate"].Value); topic.UpdatedBy = node.Attributes["UpdatedBy"].Value; topic.UpdatedByUserID = int.Parse(node.Attributes["UpdatedByUserID"].Value); topicBo.Add(topic); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } }