/// <summary> /// Gets search items filled with all necessary properties from <see cref="SearchContext.CurrentSearchResults"/> and <see cref="mRawResults"/> collection. /// </summary> /// <returns>Search items collection</returns> private IEnumerable <SearchResultItem> GetSearchItems() { var searchItems = new List <SearchResultItem>(); if (DataHelper.DataSourceIsEmpty(SearchContext.CurrentSearchResults) || (mRawResults == null) || (SearchContext.CurrentSearchResults == null)) { return(null); } var attachmentIdentifiers = new List <Guid>(); foreach (DataRow row in mRawResults.Tables[0].Rows) { string date, pageTypeDisplayName, pageTypeCodeName; int nodeId; int documentNodeId = GetDocumentNodeId(row["type"], row["id"]); Guid imageGuid = ((row["image"] as string) == null) ? Guid.Empty : new Guid(row["image"].ToString()); attachmentIdentifiers.Add(imageGuid); GetAdditionalData(row["type"], documentNodeId, out date, out nodeId, out pageTypeDisplayName, out pageTypeCodeName); var searchItem = new SearchResultItem { NodeId = nodeId, Title = row["title"].ToString(), Content = row["content"].ToString(), Date = date, PageTypeDispayName = pageTypeDisplayName, PageTypeCodeName = pageTypeCodeName }; searchItems.Add(searchItem); } var attachments = AttachmentInfoProvider.GetAttachments().OnSite(mSiteName).BinaryData(false).WhereIn("AttachmentGUID", attachmentIdentifiers).ToDictionary(x => x.AttachmentGUID); for (int i = 0; i < searchItems.Count; i++) { AttachmentInfo attachment; if (attachments.TryGetValue(attachmentIdentifiers[i], out attachment)) { searchItems[i].ImageAttachment = new Attachment(attachment); } } return(searchItems); }
private SearchResultItem <BaseInfo> CreateSearchResultItem(DataRow row) { DateTime date; DateTime.TryParse(row["created"].ToString(), out date); var objectType = row["type"].ToString(); var id = row["id"].ToString(); var searchItem = new SearchResultItem <BaseInfo> { Fields = new SearchFields { Title = row["title"].ToString(), Content = row["content"].ToString(), ImagePath = GetImagePath(objectType, id, row["image"].ToString()), Date = date, ObjectType = objectType }, Data = GetDataObject(id, objectType) }; return(searchItem); }
/// <summary> /// Gets search items filled with all necessary properties from <see cref="SearchContext.CurrentSearchResults"/> and <see cref="mRawResults"/> collection. /// </summary> /// <returns>Search items collection</returns> private IEnumerable<SearchResultItem> GetSearchItems() { var searchItems = new List<SearchResultItem>(); if (DataHelper.DataSourceIsEmpty(SearchContext.CurrentSearchResults) || (mRawResults == null) || (SearchContext.CurrentSearchResults == null)) { return null; } var attachmentIdentifiers = new List<Guid>(); foreach (DataRow row in mRawResults.Tables[0].Rows) { string date, pageTypeDisplayName, pageTypeCodeName; int nodeId; int documentNodeId = GetDocumentNodeId(row["type"], row["id"]); Guid imageGuid = ((row["image"] as string) == null) ? Guid.Empty : new Guid(row["image"].ToString()); attachmentIdentifiers.Add(imageGuid); GetAdditionalData(row["type"], documentNodeId, out date, out nodeId, out pageTypeDisplayName, out pageTypeCodeName); var searchItem = new SearchResultItem { NodeId = nodeId, Title = row["title"].ToString(), Content = row["content"].ToString(), Date = date, PageTypeDispayName = pageTypeDisplayName, PageTypeCodeName = pageTypeCodeName }; searchItems.Add(searchItem); } var attachments = AttachmentInfoProvider.GetAttachments().OnSite(mSiteName).BinaryData(false).WhereIn("AttachmentGUID", attachmentIdentifiers).ToDictionary(x => x.AttachmentGUID); for (int i = 0; i < searchItems.Count; i++) { AttachmentInfo attachment; if (attachments.TryGetValue(attachmentIdentifiers[i], out attachment)) { searchItems[i].ImageAttachment = new Attachment(attachment); } } return searchItems; }
/// <summary> /// Gets search items collection filled with all necessary properties from <see cref="SearchContext.CurrentSearchResults"/> and <see cref="mRawResults"/> collection. /// </summary> /// <returns>Search items collection</returns> private IEnumerable <SearchResultItem> GetSearchItems() { var searchItems = new List <SearchResultItem>(); if (DataHelper.DataSourceIsEmpty(SearchContext.CurrentSearchResults) || (mRawResults == null) || (SearchContext.CurrentSearchResults == null)) { return(null); } var pageAttachmentGUIDs = new List <Guid>(); foreach (DataRow row in mRawResults.Tables[0].Rows) { string pageTypeDisplayName = String.Empty; string pageTypeCodeName = String.Empty; int nodeId = 0; string date = row["created"].ToString(); Guid imageGuid = ((row["image"] as string) == null) ? Guid.Empty : new Guid(row["image"].ToString()); string objectType = row["type"].ToString(); if (objectType == PredefinedObjectType.DOCUMENT) { // Get additional info specific for page objects int documentNodeId = GetDocumentNodeId(objectType, row["id"].ToString()); GetAdditionalData(objectType, documentNodeId, out nodeId, out pageTypeDisplayName, out pageTypeCodeName); if (imageGuid != Guid.Empty) { pageAttachmentGUIDs.Add(imageGuid); } } var searchItem = new SearchResultItem { // General object info Title = row["title"].ToString(), Content = row["content"].ToString(), ImageGuid = imageGuid, Date = date, ObjectType = objectType, // Page related info NodeId = nodeId, PageTypeDispayName = pageTypeDisplayName, PageTypeCodeName = pageTypeCodeName }; searchItems.Add(searchItem); } // Add page attachments to the searchItems collection if (pageAttachmentGUIDs.Count > 0) { var attachments = GetPageAttachments(pageAttachmentGUIDs); foreach (var item in searchItems) { if (item.ImageGuid != Guid.Empty) { AttachmentInfo attachmentInfo; if (attachments.TryGetValue(item.ImageGuid, out attachmentInfo)) { item.ImageAttachment = new Attachment(attachmentInfo); } } } } return(searchItems); }