/// <summary> /// Exports the module. /// </summary> /// <param name="moduleID">The module unique identifier.</param> /// <returns>XML String of the module data</returns> public string ExportModule(int moduleID) { using (UnitOfWork uow = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uow); var topics = topicBo.GetAllByModuleID(moduleID); ModuleController mc = new ModuleController(); Hashtable settings = mc.GetModuleSettings(moduleID); StringWriter strXML = new StringWriter(); XmlWriter writer = new XmlTextWriter(strXML); writer.WriteStartElement("Wiki"); writer.WriteStartElement("Settings"); foreach (DictionaryEntry item in settings) { writer.WriteStartElement("Setting"); writer.WriteAttributeString("Name", Convert.ToString(item.Key)); writer.WriteAttributeString("Value", Convert.ToString(item.Value)); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("Topics"); foreach (var topic in topics) { writer.WriteStartElement("Topic"); writer.WriteAttributeString("AllowDiscussions", topic.AllowDiscussions.ToString()); writer.WriteAttributeString("AllowRatings", topic.AllowRatings.ToString()); writer.WriteAttributeString("Content", topic.Content); writer.WriteAttributeString("Description", topic.Description); writer.WriteAttributeString("Keywords", topic.Keywords); writer.WriteAttributeString("Name", topic.Name); writer.WriteAttributeString("Title", topic.Title); writer.WriteAttributeString("UpdateDate", topic.UpdateDate.ToString("g")); writer.WriteAttributeString("UpdatedBy", topic.UpdatedBy); writer.WriteAttributeString("UpdatedByUserID", topic.UpdatedByUserID.ToString("g")); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Close(); return(strXML.ToString()); } }
/// <summary> /// Exports the module. /// </summary> /// <param name="moduleID">The module unique identifier.</param> /// <returns>XML String of the module data</returns> public string ExportModule(int moduleID) { using (UnitOfWork uow = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uow); var topics = topicBo.GetAllByModuleID(moduleID); ModuleController mc = new ModuleController(); Hashtable settings = mc.GetModuleSettings(moduleID); StringWriter strXML = new StringWriter(); XmlWriter writer = new XmlTextWriter(strXML); writer.WriteStartElement("Wiki"); writer.WriteStartElement("Settings"); foreach (DictionaryEntry item in settings) { writer.WriteStartElement("Setting"); writer.WriteAttributeString("Name", Convert.ToString(item.Key)); writer.WriteAttributeString("Value", Convert.ToString(item.Value)); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("Topics"); foreach (var topic in topics) { writer.WriteStartElement("Topic"); writer.WriteAttributeString("AllowDiscussions", topic.AllowDiscussions.ToString()); writer.WriteAttributeString("AllowRatings", topic.AllowRatings.ToString()); writer.WriteAttributeString("Content", topic.Content); writer.WriteAttributeString("Description", topic.Description); writer.WriteAttributeString("Keywords", topic.Keywords); writer.WriteAttributeString("Name", topic.Name); writer.WriteAttributeString("Title", topic.Title); writer.WriteAttributeString("UpdateDate", topic.UpdateDate.ToString("g")); writer.WriteAttributeString("UpdatedBy", topic.UpdatedBy); writer.WriteAttributeString("UpdatedByUserID", topic.UpdatedByUserID.ToString("g")); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Close(); return strXML.ToString(); } }
/// <summary> /// Activates the items. /// </summary> /// <param name="currentUnitOfWork">The UnitOfWork.</param> private void ActivateItems(UnitOfWork currentUnitOfWork) { if (this.ActivateComments.Checked | this.ActivateRatings.Checked) { TopicBO topicBo = new TopicBO(currentUnitOfWork); var alltopics = topicBo.GetAllByModuleID(this.ModuleId); foreach (var topic in alltopics) { if (topic.AllowDiscussions == false & this.ActivateComments.Checked) { topic.AllowDiscussions = true; } if (topic.AllowRatings == false & this.ActivateRatings.Checked) { topic.AllowRatings = true; } topicBo.Update(topic); } } }
/// <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); } } }
/// <summary> /// Gets the search items. /// </summary> /// <param name="modInfo">The module information.</param> /// <returns>Topics that meet the search criteria.</returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { using (UnitOfWork uOw = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uOw); SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection(); var topics = topicBo.GetAllByModuleID(modInfo.ModuleID); UserController uc = new UserController(); foreach (var topic in topics) { SearchItemInfo searchItem = new SearchItemInfo(); string strContent = null; string strDescription = null; string strTitle = null; if (!string.IsNullOrWhiteSpace(topic.Title)) { strTitle = topic.Title; } else { strTitle = topic.Name; } if (topic.Cache != null) { strContent = topic.Cache; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } else { strContent = topic.Content; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } int userID = 0; userID = Null.NullInteger; if (topic.UpdatedByUserID != -9999) { userID = topic.UpdatedByUserID; } searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name)); //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription, //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _ //// "topic=" & WikiMarkup.EncodeTitle(topic.Name)) searchItemCollection.Add(searchItem); } return searchItemCollection; } }
/// <summary> /// Gets the search items. /// </summary> /// <param name="modInfo">The module information.</param> /// <returns>Topics that meet the search criteria.</returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { using (UnitOfWork uOw = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uOw); SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection(); var topics = topicBo.GetAllByModuleID(modInfo.ModuleID); UserController uc = new UserController(); foreach (var topic in topics) { SearchItemInfo searchItem = new SearchItemInfo(); string strContent = null; string strDescription = null; string strTitle = null; if (!string.IsNullOrWhiteSpace(topic.Title)) { strTitle = topic.Title; } else { strTitle = topic.Name; } if (topic.Cache != null) { strContent = topic.Cache; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } else { strContent = topic.Content; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } int userID = 0; userID = Null.NullInteger; if (topic.UpdatedByUserID != -9999) { userID = topic.UpdatedByUserID; } searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name)); //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription, //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _ //// "topic=" & WikiMarkup.EncodeTitle(topic.Name)) searchItemCollection.Add(searchItem); } return(searchItemCollection); } }