示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mediaItem"></param>
        /// <returns></returns>
        public ContentCrawlProxy BuildSearchableAsset(MediaData mediaItem)
        {
            var searchableAsset = mediaItem as ISearchableAsset;

            if (searchableAsset == null)
            {
                return(null);
            }

            var url = UrlResolver.Current.GetUrl(mediaItem.ContentLink);

            if (url == null)
            {
                return(null);
            }

            searchableAsset._ContentID = string.Format("{0}", mediaItem.ContentGuid);

            try
            {
                searchableAsset.AssetBlob = EpiHelper.ReadEpiBlob(mediaItem.BinaryData);
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Error(string.Format("Asset Crawler: Error Retrieving Asset {0} {1}", ex.Message, ex.StackTrace));
                }
            }

            var pageCrawlParameters = new ContentCrawlProxy();


            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "title",
                Value = mediaItem.Name,
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "url",
                Value = url.Replace("?epslanguage=en", string.Format("?epslanguage={0}", mediaItem.Language.Name)),
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "pagetype",
                Value = "Media",
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "mimetype",
                Value = mediaItem.MimeType,
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "contenttype",
                Value = MimeType.GetDisplayName(mediaItem.MimeType),
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "language",
                Value = Languages,
            });

            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "folder",
                Value = EpiHelper.GetParentFolderName(mediaItem.ParentLink.ToPageReference()),
            });


            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "paths",
                Value = EpiHelper.GetPageTreePaths(mediaItem.ParentLink.ToPageReference()),
            });


            pageCrawlParameters.Content.Add(new CrawlerContent()
            {
                Name  = "path",
                Value = EpiHelper.GetFolderPath(mediaItem.ParentLink.ToPageReference()),
            });

            //searchableAsset.CrawlProperties = pageCrawlMetadata;
            pageCrawlParameters.ContentItem = searchableAsset;
            return(pageCrawlParameters);
        }