//***********Helper Methods***********// //************************************// //************************************// #region SetBlendedListItems private List <BlendedListItem> SetBlendedListItems(IEnumerable <IDocument> results) { log.Info("Begin SetBlendedListItems"); var resultSet = new List <BlendedListItem>(); var taxonomyManager = TaxonomyManager.GetManager(); if (results != null) { foreach (var result in results) { //log.Trace("Getting a new instance of BlendedListItem."); var featured = result.Fields.Any(c => c.Name == "FeaturedRank") && (result.GetValue("FeaturedRank")?.ToString() == "1" ? true : false); var newsResult = new BlendedListItem() { Title = result.GetValue("Title")?.ToString() ?? string.Empty, LocationStreet = result.Fields.Any(c => c.Name == "LocationStreet") ? (result.GetValue("LocationStreet")?.ToString() ?? string.Empty):String.Empty, LocationState = result.Fields.Any(c => c.Name == "LocationState") ? result.GetValue("LocationState")?.ToString() ?? string.Empty: string.Empty, LocationCity = result.Fields.Any(c => c.Name == "LocationCity") ? result.GetValue("LocationCity")?.ToString() ?? string.Empty: string.Empty, Summary = result.GetValue("Summary")?.ToString() ?? string.Empty, Content = result.GetValue("Content")?.ToString() ?? String.Empty, Featured = featured, Link = result.Fields.Any(c => c.Name == "Link") ? result.GetValue("Link")?.ToString() ?? string.Empty: string.Empty, DefaultLinkBase = result.Fields.Any(c => c.Name == "DefaultLinkBase") ? result.GetValue("DefaultLinkBase")?.ToString() ?? string.Empty: string.Empty, DisplayDate = result.Fields.Any(c => c.Name == "DisplayDate") ? result.GetValue("DisplayDate")?.ToString() ?? string.Empty: string.Empty, ContentType = result.Fields.Any(c => c.Name == "ContentTypeDescription") ? result.GetValue("ContentTypeDescription")?.ToString() ?? String.Empty: string.Empty, Image = result.Fields.Any(c => c.Name == "ImageUrl") ? result.GetValue("ImageUrl")?.ToString() ?? string.Empty: string.Empty }; if (result.Fields.Any(x => x.Name == "Selfpaced")) { var selfPaced = result.GetValue("Selfpaced")?.ToString() ?? String.Empty; if (!selfPaced.IsNullOrWhitespace()) { newsResult.SelfPaced = bool.Parse(result.GetValue("Selfpaced").ToString()); } } if (result.Fields.Any(x => x.Name == "DateField")) { if (result.Fields.Any(x => x.Name == "EventStart")) { DateTime dt; if (!String.IsNullOrEmpty(result.GetValue("DateField")?.ToString())) { //newsResult.DateField = DateTime.ParseExact(result.GetValue("DateField").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime.TryParseExact(result.GetValue("DateField").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out dt); newsResult.DateField = dt; } } } if (result.Fields.Any(x => x.Name == "Protected")) { string IsProtected = result.GetValue("Protected")?.ToString() ?? "0"; newsResult.Protected = !string.IsNullOrEmpty(IsProtected) && (IsProtected == "1" ? true : false); } DateTime eDateTime; if (result.Fields.Any(x => x.Name == "EventStart")) { if (!String.IsNullOrEmpty(result.GetValue("EventStart")?.ToString())) { //ParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime.TryParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out eDateTime); newsResult.EventStartDate = eDateTime; } } if (result.Fields.Any(x => x.Name == "EventEnd")) { //newsResult.EventEndDate = DateTime.ParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (!String.IsNullOrEmpty(result.GetValue("EventEnd")?.ToString())) { DateTime.TryParseExact(result.GetValue("EventEnd").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out eDateTime); newsResult.EventEndDate = eDateTime; } } if (result.Fields.Any(x => x.Name == "PublishDate")) { //newsResult.PublicationDate = DateTime.ParseExact(result.GetValue("PublishDate").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (!String.IsNullOrEmpty(result.GetValue("PublishDate")?.ToString())) { DateTime.TryParseExact(result.GetValue("PublishDate").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out eDateTime); newsResult.PublicationDate = eDateTime; } } if (result.Fields.Any(x => x.Name == "CategoryIds")) { newsResult.Categories = new List <CategoryPair>(); var categoryIds = result.GetValue("CategoryIds")?.ToString()?.Split(',')?.ToList(); if (categoryIds != null && categoryIds.Any()) { foreach (var categoryItem in categoryIds) { try { var categoryPair = new CategoryPair(); if (!String.IsNullOrEmpty(categoryItem) && categoryItem.IsGuid()) { categoryPair.Guid = categoryItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(categoryItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("RelatedContentDyn-GetCategoryIds: {0}", ex.Message); } } } //newsResult.Categories = result.GetValue("CategoryList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("CategoryList Set."); } if (result.Fields.Any(x => x.Name == "ResourceTypesIds")) { newsResult.ResourceTypes = new List <CategoryPair>(); var resourceTypesIds = result.GetValue("ResourceTypesIds")?.ToString()?.Split(',')?.ToList(); if (resourceTypesIds != null && resourceTypesIds.Any()) { foreach (var resourceTypeItem in resourceTypesIds) { try { var categoryPair = new CategoryPair(); if (!String.IsNullOrEmpty(resourceTypeItem) && resourceTypeItem.IsGuid()) { categoryPair.Guid = resourceTypeItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(resourceTypeItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("RelatedContentDyn-GetResourceTypesIds: {0}", ex.Message); } } } //newsResult.ResourceTypes = result.GetValue("ResourceTypesList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("ResourceTypesList Set."); } if (result.Fields.Any(x => x.Name == "OrganizationalAuthorsIds")) { newsResult.OrganizationalAuthors = new List <CategoryPair>(); var organizationalAuthorIds = result.GetValue("OrganizationalAuthorsIds")?.ToString()?.Split(',')?.ToList(); if (organizationalAuthorIds != null && organizationalAuthorIds.Any()) { foreach (var organizationalAuthorItem in organizationalAuthorIds) { try { var categoryPair = new CategoryPair(); if (!String.IsNullOrEmpty(organizationalAuthorItem) && organizationalAuthorItem.IsGuid()) { categoryPair.Guid = organizationalAuthorItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(organizationalAuthorItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("RelatedContentDyn-GetOrganizationalAuthorsIds: {0}", ex.Message); } } } //newsResult.OrganizationalAuthors = result.GetValue("OrganizationalAuthorsList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("OrganizationalAuthorsList Set."); } if (string.IsNullOrWhiteSpace(newsResult.Summary) && !string.IsNullOrWhiteSpace(newsResult.Content)) { newsResult.Summary = SummaryParser.GetSummary(newsResult.Content, new SummarySettings(SummaryMode.Words, 40, true)); } resultSet.Add(newsResult); } } return(resultSet); }
//***********Helper Methods***********// //************************************// //************************************// #region SetBlendedListItems private List <BlendedListItem> SetBlendedListItems(IResultSet results) { log.Info("Begin SetBlendedListItems."); var resultSet = new List <BlendedListItem>(); var taxonomyManager = TaxonomyManager.GetManager(); log.Debug("Iterating through the results."); foreach (IDocument result in results) { log.Trace("Getting a new instance of BlendedListItem."); var newsResult = new BlendedListItem(); log.Trace(() => String.Join("\n", result.Fields.Select(f => f.Name + ": " + f.Value))); if (result.Fields.Any(x => x.Name == "Title")) { newsResult.Title = result.GetValue("Title").ToString(); log.Trace("Title Set."); } if (result.Fields.Any(x => x.Name == "LocationStreet")) { newsResult.LocationStreet = result.GetValue("LocationStreet").ToString(); log.Trace("LocationStreet Set."); } if (result.Fields.Any(x => x.Name == "LocationState")) { newsResult.LocationState = result.GetValue("LocationState").ToString(); log.Trace("LocationState Set."); } if (result.Fields.Any(x => x.Name == "LocationCity")) { newsResult.LocationCity = result.GetValue("LocationCity").ToString(); log.Trace("LocationCity Set."); } if (result.Fields.Any(x => x.Name == "Summary")) { newsResult.Summary = result.GetValue("Summary").ToString(); log.Trace("Summary Set."); } if (result.Fields.Any(x => x.Name == "Content")) { newsResult.Content = result.GetValue("Content").ToString(); log.Trace("Content Set."); } var featured = result.GetValue("FeaturedRank").ToString() == "1" ? true : false; newsResult.Featured = featured; if (result.Fields.Any(x => x.Name == "Link")) { newsResult.Link = result.GetValue("Link").ToString(); log.Trace("Link Set."); } if (result.Fields.Any(x => x.Name == "EventStart")) { try { DateTime dp = DateTime.MinValue; //newsResult.EventStartDate = DateTime.ParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime.TryParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out dp); newsResult.EventStartDate = dp; //log.Trace("EventStart Set."); } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } if (result.Fields.Any(x => x.Name == "EventEnd")) { try { /*newsResult.EventEndDate = DateTime.ParseExact(result.GetValue("EventStart").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); * log.Trace("EventStart Set.");*/ DateTime dp = DateTime.MinValue; DateTime.TryParseExact(result.GetValue("EventEnd").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out dp); newsResult.EventEndDate = dp; } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } if (result.Fields.Any(x => x.Name == "PublishDate")) { try { /*newsResult.PublicationDate = DateTime.ParseExact(result.GetValue("PublishDate").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); * log.Trace("PublishDate Set.");*/ DateTime dp = DateTime.MinValue; DateTime.TryParseExact(result.GetValue("PublishDate").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out dp); newsResult.PublicationDate = dp; } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } if (result.Fields.Any(x => x.Name == "CategoryIds")) { newsResult.Categories = new List <CategoryPair>(); var categoryIds = result.GetValue("CategoryIds").ToString().Split(',').ToList(); foreach (var categoryItem in categoryIds) { try { if (!categoryItem.IsNullOrWhitespace()) { var categoryPair = new CategoryPair(); if (categoryItem.IsGuid()) { categoryPair.Guid = categoryItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(categoryItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } //newsResult.Categories = result.GetValue("CategoryList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("CategoryList Set."); } if (result.Fields.Any(x => x.Name == "ResourceTypesIds")) { newsResult.ResourceTypes = new List <CategoryPair>(); var resourceTypesIds = result.GetValue("ResourceTypesIds").ToString().Split(',').ToList(); foreach (var resourceTypeItem in resourceTypesIds) { try { if (!resourceTypeItem.IsNullOrWhitespace()) { var categoryPair = new CategoryPair(); if (resourceTypeItem.IsGuid()) { categoryPair.Guid = resourceTypeItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(resourceTypeItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } //newsResult.ResourceTypes = result.GetValue("ResourceTypesList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("ResourceTypesList Set."); } if (result.Fields.Any(x => x.Name == "OrganizationalAuthorsIds")) { newsResult.OrganizationalAuthors = new List <CategoryPair>(); var organizationalAuthorIds = result.GetValue("OrganizationalAuthorsIds").ToString().Split(',').ToList(); foreach (var organizationalAuthorItem in organizationalAuthorIds) { try { if (!organizationalAuthorItem.IsNullOrWhitespace()) { var categoryPair = new CategoryPair(); if (organizationalAuthorItem.IsGuid()) { categoryPair.Guid = organizationalAuthorItem; var taxon = taxonomyManager.GetTaxon(Guid.Parse(organizationalAuthorItem)); categoryPair.Name = taxon.Title.Value; newsResult.Categories.Add(categoryPair); } } } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } //newsResult.OrganizationalAuthors = result.GetValue("OrganizationalAuthorsList").ToString().Split(',').Select(x => x.Trim()).ToList(); //log.Trace("OrganizationalAuthorsList Set."); } if (result.Fields.Any(x => x.Name == "DefaultLinkBase")) { newsResult.DefaultLinkBase = result.GetValue("DefaultLinkBase").ToString(); log.Trace("DefaultLinkBase Set."); } if (result.Fields.Any(x => x.Name == "Selfpaced")) { var selfPaced = result.GetValue("Selfpaced").ToString(); if (!selfPaced.IsNullOrWhitespace()) { newsResult.SelfPaced = bool.Parse(result.GetValue("Selfpaced").ToString()); log.Trace("SelfPaced Set."); } } if (result.Fields.Any(x => x.Name == "DisplayDate")) { newsResult.DisplayDate = result.GetValue("DisplayDate").ToString(); log.Trace("DisplayDate Set."); } if (result.Fields.Any(x => x.Name == "DateField")) { try { /*newsResult.DateField = DateTime.ParseExact(result.GetValue("DateField").ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); * log.Trace("DateField Set.");*/ DateTime dp = DateTime.MinValue; DateTime.TryParseExact(result.GetValue("DateField").ToString(), "MM/dd/yyyy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None, out dp); newsResult.DateField = dp; } catch (Exception ex) { log.Error("Source: {0}", ex.Source); log.Error("Stack Trace: {0}", ex.StackTrace); log.Error("Message: {0}", ex.Message); } } if (result.Fields.Any(x => x.Name == "ContentTypeDescription")) { newsResult.ContentType = result.GetValue("ContentTypeDescription").ToString(); log.Trace("ContentTypeDescription Set."); } if (result.Fields.Any(x => x.Name == "ImageUrl")) { newsResult.Image = result.GetValue("ImageUrl").ToString(); log.Trace("Image Set."); } if (result.Fields.Any(x => x.Name == "Protected")) { newsResult.Protected = result.GetValue("Protected") == "1"; log.Trace("Protected Set."); } if (string.IsNullOrWhiteSpace(newsResult.Summary) && !string.IsNullOrWhiteSpace(newsResult.Content)) { log.Trace("The summary field is empty and the content has a value, so we will make a summary."); newsResult.Summary = SummaryParser.GetSummary(newsResult.Content, new SummarySettings(SummaryMode.Words, 40, true)); log.Trace("Summary made and set."); } resultSet.Add(newsResult); log.Trace("result added to the resturn set."); } log.Info("Finishing SetBlendedListItems."); return(resultSet); }
public static IEnumerable <SearchResult> GetSearchResults_stv(string catalog, SearchCriteria criteria, int skip, int take, int summaryWordCount, out int hitCount) { var searchService = ServiceBus.ResolveService <ISearchService>(); var searchQuery = ObjectFactory.Resolve <ISearchQuery>(); var queryBuilder = ObjectFactory.Resolve <IQueryBuilder>(); StringBuilder sb = new StringBuilder(); searchQuery.Skip = skip; searchQuery.Take = take; searchQuery.OrderBy = criteria.OrderBy == null ? new string[] { "PublicationDate DESC" } : new string[] { criteria.OrderBy }; searchQuery.HighlightedFields = null; searchQuery.IndexName = catalog; searchQuery.SearchGroup = BuildSearchQuery(criteria, new[] { "Title", "Content", "DocumentText" }); var resultSet = searchService.Search(searchQuery); hitCount = resultSet.HitCount; var results = new List <SearchResult>(); var taxonomyManager = TaxonomyManager.GetManager(); log.InfoFormat("ResourceLib:{0};", criteria.ToQueryString()); foreach (var result in resultSet.SetContentLinks()) { var searchResult = new SearchResult(); try { if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("CategoryIds").ToString())) { var categoryIds = result.GetValue("CategoryIds").ToString().Split(' ').ToList(); searchResult.CategoryPair = new List <CategoryPair>(); var parentGuidId = AppSettingsUtility.GetValue <Guid>("ResourceLibraryTaxonomyId"); foreach (var categoryId in categoryIds) { log.InfoFormat("ResourceLibraryTaxonomyId-cateids:{0}, parentGuidId:{1}", categoryIds, parentGuidId); var category = taxonomyManager.GetTaxon(Guid.Parse(categoryId)) as HierarchicalTaxon; do { if (category.Parent != null && category.Parent.Id == parentGuidId) { category = taxonomyManager.GetTaxon(Guid.Parse(categoryId)) as HierarchicalTaxon; var categoryPair = new CategoryPair(); categoryPair.Name = category.Title.Value; categoryPair.Guid = categoryId.ToString().Replace("-", ""); log.InfoFormat("CateInParent, Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid); sb.Append(String.Format("CateInParent, Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid)); searchResult.CategoryPair.Add(categoryPair); break; } category = taxonomyManager.GetTaxon(category.Parent.Id) as HierarchicalTaxon; } while (category.Parent != null); } } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("OrganizationalAuthorsIds").ToString())) { var categoryIds = result.GetValue("OrganizationalAuthorsIds").ToString().Split(' ').ToList(); searchResult.Author = new List <CategoryPair>(); var taxonomyGuidId = AppSettingsUtility.GetValue <Guid>("ResourceLibraryTaxonomyAuthorId"); foreach (var categoryId in categoryIds) { var category = taxonomyManager.GetTaxon(Guid.Parse(categoryId)) as HierarchicalTaxon; if (category.Taxonomy.Id == taxonomyGuidId) { var categoryPair = new CategoryPair(); categoryPair.Name = category.Title.Value; categoryPair.Guid = categoryId.ToString().Replace("-", ""); searchResult.Author.Add(categoryPair); log.InfoFormat("ResourceLibraryTaxonomyAuthorId-Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid); sb.AppendFormat("ResourceLibraryTaxonomyAuthorId-Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid); } } } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("ResourceTypesIds").ToString())) { var categoryIds = result.GetValue("ResourceTypesIds").ToString().Split(' ').ToList(); searchResult.ResourceTypes = new List <CategoryPair>(); var taxonomyGuidId = AppSettingsUtility.GetValue <Guid>("ResourceLibraryTaxonomyTypeId"); foreach (var categoryId in categoryIds) { var category = taxonomyManager.GetTaxon(Guid.Parse(categoryId)) as HierarchicalTaxon; if (category.Taxonomy.Id == taxonomyGuidId) { var categoryPair = new CategoryPair(); categoryPair.Name = category.Title.Value; categoryPair.Guid = categoryId.ToString().Replace("-", ""); searchResult.ResourceTypes.Add(categoryPair); log.InfoFormat("ResourceLibraryTaxonomyTypeId-Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid); sb.AppendFormat("ResourceLibraryTaxonomyTypeId-Title:{0}, guid:{1}", categoryPair.Name, categoryPair.Guid); } } } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("Title").ToString())) { searchResult.Title = result.GetValue("Title").ToString(); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("Link").ToString())) { searchResult.Link = result.GetValue("Link").ToString(); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("PublishDate").ToString())) { searchResult.PublicationDate = DateTime.Parse(result.GetValue("PublishDate").ToString()); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("DocumentLibrary").ToString())) { searchResult.DocumentFolder = result.GetValue("DocumentLibrary").ToString(); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("Summary").ToString())) { searchResult.Summary = result.GetValue("Summary").ToString(); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("ContentType").ToString())) { searchResult.Type = result.GetValue("ContentType").ToString(); } if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("ThumbnailUrl").ToString())) { searchResult.ImageUrl = result.GetValue("ThumbnailUrl").ToString(); } else if (!SitefinityExtensions.IsNullOrEmpty(result.GetValue("ImageUrl").ToString())) { searchResult.ImageUrl = result.GetValue("ImageUrl").ToString(); } var contentType = TypeResolutionService.ResolveType(searchResult.Type); searchResult.Type = contentType.Name; if (result.Fields.Any(f => f.Name == "EventStart") && !string.IsNullOrWhiteSpace(result.GetValue("EventStart").ToString())) { searchResult.EventStart = DateTime.Parse(result.GetValue("EventStart").ToString()); } if (result.Fields.Any(f => f.Name == "EventEnd") && !string.IsNullOrWhiteSpace(result.GetValue("EventEnd").ToString())) { searchResult.EventEnd = DateTime.Parse(result.GetValue("EventEnd").ToString()); } var content = result.GetValue("Content").ToString().StripHtmlTags(); var docLink = result.GetValue("DocumentLink"); var documentText = result.GetValue("DocumentText"); if (string.IsNullOrWhiteSpace(content) && !string.IsNullOrWhiteSpace(docLink.ToString())) { searchResult.Link = docLink.ToString(); content = documentText.ToString(); } if (string.IsNullOrWhiteSpace(searchResult.Summary)) { searchResult.Summary = SummaryParser.GetSummary(content, new SummarySettings(SummaryMode.Words, summaryWordCount, true, true)); } } catch (Exception ex) { //ex.ToString(); log.InfoFormat("Resources-Exception:{0}, details:{1}", ex.Message, sb.ToString()); } results.Add(searchResult); } return(results); }