// feel free to remove any interfaces that you don't wish to use // (requires that you also update the .dnn manifest file) #region Optional Interfaces /// <summary> /// Gets the modified search documents for the DNN search engine indexer. /// </summary> /// <param name="moduleInfo">The module information.</param> /// <param name="beginDate">The begin date.</param> /// <returns></returns> public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDate) { var searchDocuments = new List<SearchDocument>(); var controller = new ItemController(); var items = controller.GetItems(moduleInfo.ModuleID); foreach (var item in items) { if (item.LastModifiedOnDate.ToUniversalTime() <= beginDate.ToUniversalTime() || item.LastModifiedOnDate.ToUniversalTime() >= DateTime.UtcNow) continue; var content = string.Format("{0}<br />{1}", item.ItemName, item.ItemDescription); var searchDocumnet = new SearchDocument { UniqueKey = string.Format("Items:{0}:{1}", moduleInfo.ModuleID, item.ItemId), // any unique identifier to be able to query for your individual record PortalId = moduleInfo.PortalID, // the PortalID TabId = moduleInfo.TabID, // the TabID AuthorUserId = item.LastModifiedByUserId, // the person who created the content Title = moduleInfo.ModuleTitle, // the title of the content, but should be the module title Description = moduleInfo.DesktopModule.Description, // the description or summary of the content Body = content, // the long form of your content ModifiedTimeUtc = item.LastModifiedOnDate.ToUniversalTime(), // a time stamp for the search results page CultureCode = moduleInfo.CultureCode, // the current culture code IsActive = true // allows you to remove the item from the search index (great for soft deletes) }; searchDocuments.Add(searchDocumnet); } return searchDocuments; }
/// ----------------------------------------------------------------------------- /// <summary> /// ExportModule implements the IPortable ExportModule Interface /// </summary> /// <param name="moduleId">The Id of the module to be exported</param> /// ----------------------------------------------------------------------------- public string ExportModule(int moduleId) { var controller = new ItemController(); var items = controller.GetItems(moduleId); var sb = new StringBuilder(); var itemList = items as IList<Item> ?? items.ToList(); if (!itemList.Any()) return string.Empty; sb.Append("<Items>"); foreach (Item item in itemList) { sb.Append("<Item>"); sb.AppendFormat("<AssignedUserId>{0}</AssignedUserId>", item.AssignedUserId); sb.AppendFormat("<CreatedByUserId>{0}</CreatedByUserId>", item.CreatedByUserId); sb.AppendFormat("<CreatedOnDate>{0}</CreatedOnDate>", item.CreatedOnDate); sb.AppendFormat("<ItemId>{0}</ItemId>", item.ItemId); sb.AppendFormat("<ItemDescription>{0}</ItemDescription>", XmlUtils.XMLEncode(item.ItemDescription)); sb.AppendFormat("<ItemName>{0}</ItemName>", XmlUtils.XMLEncode(item.ItemName)); sb.AppendFormat("<LastModifiedByUserId>{0}</LastModifiedByUserId>", item.LastModifiedByUserId); sb.AppendFormat("<LastModifiedOnDate>{0}</LastModifiedOnDate>", item.LastModifiedOnDate); sb.AppendFormat("<ModuleId>{0}</ModuleId>", item.ModuleId); sb.Append("</Item>"); } sb.Append("</Items>"); // you might consider doing something similar here for any important module settings return sb.ToString(); }