예제 #1
0
        internal static IEnumerable <IPublishedContent> ConvertSearchResultToPublishedContent(
            this IEnumerable <SearchResult> results,
            IPublishedStore store)
        {
            //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent,
            // however thsi is currently not the case:
            // http://examine.codeplex.com/workitem/10350

            var list = new List <IPublishedContent>();

            foreach (var result in results.OrderByDescending(x => x.Score))
            {
                var doc = store.GetDocumentById(
                    UmbracoContext.Current,
                    result.Id);
                if (doc == null)
                {
                    continue;                              //skip if this doesn't exist in the cache
                }
                doc.Properties.Add(
                    new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty));
                list.Add(doc);
            }
            return(list);
        }
예제 #2
0
        private dynamic DocumentById(string id, IPublishedStore store, object ifNotFound)
        {
            int docId;

            return(int.TryParse(id, out docId)
                                ? DocumentById(docId, store, ifNotFound)
                                : ifNotFound);
        }
예제 #3
0
        private dynamic DocumentById(int id, IPublishedStore store, object ifNotFound)
        {
            var doc = store.GetDocumentById(UmbracoContext.Current, id);

            return(doc == null
                                        ? ifNotFound
                                        : new DynamicPublishedContent(doc).AsDynamic());
        }
예제 #4
0
        private IPublishedContent TypedDocumentById(string id, IPublishedStore store)
        {
            int docId;

            return(int.TryParse(id, out docId)
                                       ? DocumentById(docId, store, null)
                                       : null);
        }
 public PublisherService(IPublishedStore publishedStore, IBackgroundTaskQueue backgroundTaskQueue, IOptions <EventLogOptions> options,
                         ILogger <PublisherService> logger)
 {
     _publishedStore      = publishedStore;
     _backgroundTaskQueue = backgroundTaskQueue;
     _logger  = logger;
     _options = options.Value;
 }
예제 #6
0
        private dynamic DocumentByIds(IPublishedStore store, params string[] ids)
        {
            var nodes = ids.Select(eachId => DocumentById(eachId, store))
                        .Where(x => !TypeHelper.IsTypeAssignableFrom <DynamicNull>(x))
                        .Cast <DynamicPublishedContent>();

            return(new DynamicPublishedContentList(nodes));
        }
예제 #7
0
        private dynamic DocumentById(string id, IPublishedStore store)
        {
            int docId;

            return(int.TryParse(id, out docId)
                                ? DocumentById(docId, store)
                                : new DynamicNull());
        }
예제 #8
0
        private dynamic DocumentById(int id, IPublishedStore store)
        {
            var doc = store.GetDocumentById(UmbracoContext.Current, id);

            return(doc == null
                                        ? new DynamicNull()
                                        : new DynamicPublishedContent(doc).AsDynamic());
        }
예제 #9
0
 /// <summary>
 /// Overloaded method accepting an 'object' type
 /// </summary>
 /// <param name="id"></param>
 /// <param name="store"> </param>
 /// <param name="ifNotFound"> </param>
 /// <returns></returns>
 /// <remarks>
 /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass
 /// this result in to this method.
 /// This method will throw an exception if the value is not of type int or string.
 /// </remarks>
 private dynamic DocumentById(object id, IPublishedStore store, object ifNotFound)
 {
     if (id is string)
     {
         return(DocumentById((string)id, store, ifNotFound));
     }
     if (id is int)
     {
         return(DocumentById((int)id, store, ifNotFound));
     }
     throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer");
 }
예제 #10
0
 /// <summary>
 /// Overloaded method accepting an 'object' type
 /// </summary>
 /// <param name="id"></param>
 /// <param name="store"> </param>
 /// <returns></returns>
 /// <remarks>
 /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass
 /// this result in to this method.
 /// This method will throw an exception if the value is not of type int or string.
 /// </remarks>
 private IPublishedContent TypedDocumentById(object id, IPublishedStore store)
 {
     if (id is string)
     {
         return(TypedDocumentById((string)id, store));
     }
     if (id is int)
     {
         return(TypedDocumentById((int)id, store));
     }
     throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer");
 }
예제 #11
0
		internal static IEnumerable<IPublishedContent> ConvertSearchResultToPublishedContent(
			this IEnumerable<SearchResult> results,
			IPublishedStore store)
		{
			//TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, 
			// however thsi is currently not the case: 
			// http://examine.codeplex.com/workitem/10350

			var list = new List<IPublishedContent>();
			
			foreach (var result in results.OrderByDescending(x => x.Score))
			{
				var doc = store.GetDocumentById(
					UmbracoContext.Current,
					result.Id);
				if (doc == null) continue; //skip if this doesn't exist in the cache				
				doc.Properties.Add(
					new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty));				
				list.Add(doc);
			}
			return list;
		}
예제 #12
0
 private IEnumerable <IPublishedContent> TypedDocumentsbyIds(IPublishedStore store, params string[] ids)
 {
     return(ids.Select(eachId => TypedDocumentById(eachId, store)));
 }
예제 #13
0
        private IPublishedContent TypedDocumentById(int id, IPublishedStore store)
        {
            var doc = store.GetDocumentById(UmbracoContext.Current, id);

            return(doc);
        }