protected override IList <GetChildrenReferenceResult> LoadChildrenReferencesAndTypes(ContentReference contentLink, string languageId, out bool languageSpecific)
        {
            var videoTypeId       = _contentTypeRepository.Load(typeof(Video));
            var videoFolderTypeId = _contentTypeRepository.Load(typeof(VideoFolder));

            languageSpecific = false;
            if (contentLink.CompareToIgnoreWorkID(EntryPoint))
            {
                var test =
                    _items.Where(x => x.ContentTypeID.Equals(videoFolderTypeId.ID))
                    .Select(p => new GetChildrenReferenceResult()
                {
                    ContentLink = p.ContentLink, ModelType = typeof(VideoFolder)
                }).ToList();
                return(test);
            }
            var content = LoadContent(contentLink, LanguageSelector.AutoDetect());

            return(_items
                   .Where(p => p.ContentTypeID.Equals(videoTypeId.ID) && p.ParentLink.ID.Equals(content.ContentLink.ID))
                   .Select(p => new GetChildrenReferenceResult()
            {
                ContentLink = p.ContentLink, ModelType = typeof(Video)
            }).ToList());
        }
        /// <summary>
        /// Returns all the content items of <typeparamref name="T"/> from <paramref name="contentAreaItems"/>
        /// </summary>
        /// <typeparam name="T">Type of <see cref="IContentData"/> items to extract.</typeparam>
        /// <param name="contentAreaItems">The <see cref="IEnumerable{ContentAreaItem}"/> to extract <see cref="IContent"/> instances of type <typeparamref name="T"/> from.</param>
        /// <param name="language">The <see cref="CultureInfo"/> to use. If none is specified, current culture will be used.</param>
        /// <param name="contentLoader">The <see cref="IContentLoader"/> to use</param>
        /// <returns>A <see cref="IEnumerable{T}"/> containing all <see cref="IContent"/> items found in the <paramref name="contentAreaItems"/> collection.</returns>
        public static IEnumerable <T> GetContentItems <T>(this IEnumerable <ContentAreaItem> contentAreaItems, CultureInfo language = null,
                                                          IContentLoader contentLoader = null)
            where T : IContentData
        {
            if (contentAreaItems == null)
            {
                return(Enumerable.Empty <T>());
            }

            if (contentLoader == null)
            {
                contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>();
            }

            if (language == null)
            {
                language = LanguageSelector.AutoDetect().Language;
            }


            var items = contentLoader.GetItems(contentAreaItems.Select(i => i.ContentLink), language).OfType <T>();

            var publishedFilter = new FilterPublished();
            var accessFilter    = new FilterAccess();

            var filterItems = items.OfType <IContent>().Where(x => !publishedFilter.ShouldFilter(x) && !accessFilter.ShouldFilter(x));

            return(filterItems.OfType <T>());
        }
示例#3
0
        private IEnumerable <BasicContent> CreateFoldersFromChannels(VideoFolder entryPoint)
        {
            var          type   = ContentTypeRepository.Service.Load <VideoFolder>();
            List <Album> albums = TwentyThreeVideoRepository.GetChannelList();

            foreach (var album in albums)
            {
                var folder = ContentFactory.Service.CreateContent(type, new BuildingContext(type)
                {
                    Parent            = entryPoint,
                    LanguageSelector  = LanguageSelector.AutoDetect(),
                    SetPropertyValues = true
                }) as VideoFolder;
                if (folder == null)
                {
                    continue;
                }
                if (album.AlbumId != null)
                {
                    var id = (int)album.AlbumId;
                    folder.ContentLink = new ContentReference(id, Constants.ProviderKey);
                    folder.Name        = album.Title;

                    var editorGroup = new EditorGroupChannelMappingRepository().GetEditorGroupForChannel(folder.Name);
                    if (!string.IsNullOrWhiteSpace(editorGroup))
                    {
                        folder.EditorGroup = editorGroup;
                    }

                    _log.Information("23Video: Channel {0} created.", album.Title);
                    yield return(folder);
                }
            }
        }
示例#4
0
        private IDictionary <string, int> GetStatusCount(int projectId)
        {
            var statuses         = StatusList.ToDictionary(di => di.Key, di => di.Value); //clone the dictionary
            var versionableItems = _contentLoader.GetItems(_projectRepository.ListItems(projectId).Select(i => i.ContentLink),
                                                           LanguageSelector.AutoDetect()).OfType <IVersionable>();

            foreach (var versionableItem in versionableItems)
            {
                var status = HasExpired(versionableItem) ? ExtendedVersionStatus.Expired : (ExtendedVersionStatus)versionableItem.Status;
                var key    = status.ToString().ToLowerInvariant();

                var contentItem   = (IContent)versionableItem;
                var isDeleted     = contentItem.IsDeleted;
                var hasEditAccess = _contentLoaderService.HasEditAccess(contentItem, AccessLevel.Publish);

                if (isDeleted || !hasEditAccess)
                {
                    key += NoAccesKey;
                }

                statuses[key]++;
            }

            return(statuses);
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            if (_provider.Service == null)
            {
                throw new InvalidOperationException("Implementation of `IResourceListProvider` is not configured in IoC container.");
            }

            var languageSelector = LanguageSelector.AutoDetect();
            var languageName     = string.IsNullOrEmpty(context.Request.QueryString["lang"])
                                   ? languageSelector.Language.Name
                                   : context.Request.QueryString["lang"];

            var filename = ExtractFileName(context);

            var debugMode = context.Request.QueryString["debug"] != null;
            var alias     = string.IsNullOrEmpty(context.Request.QueryString["alias"]) ? "jsl10n" : context.Request.QueryString["alias"];

            var cacheKey       = CacheKeyHelper.GenerateKey(filename, languageName, debugMode);
            var responseObject = CacheManager.Get(cacheKey) as string;

            if (responseObject == null)
            {
                responseObject = _provider.Service.GetJson(filename, context, languageName, debugMode);
                responseObject = $"window.{alias} = {responseObject}";

                CacheManager.Insert(cacheKey, responseObject);
            }

            context.Response.Write(responseObject);
            context.Response.ContentType = "text/javascript";
        }
示例#6
0
        public IEnumerable <EntryContentBase> GetVariants(ProductContent content)
        {
            var variants     = content.GetVariants();
            var variantItems = _contentLoader.GetItems(variants, LanguageSelector.AutoDetect());

            return(FilterForVisitor.Filter(variantItems).OfType <EntryContentBase>());
        }
示例#7
0
        private IEnumerable <TEntryContent> GetRelatedEntries <TEntryContent>(IVariantContainer content)
            where TEntryContent : EntryContentBase
        {
            var relatedItems = content.GetVariantRelations(LinksRepository).Select(x => x.Target);

            return(ContentLoader.GetItems(relatedItems, LanguageSelector.AutoDetect()).OfType <TEntryContent>());
        }
示例#8
0
        private IEnumerable <BasicContent> ConvertToBasicContent(IEnumerable <IntermediateVideoDataModel> dataModels)
        {
            var helper          = new VideoHelper();
            var entryPoint      = ContentRepositry.Service.GetChildren <VideoFolder>(ContentReference.RootPage).FirstOrDefault();
            var videoType       = ContentTypeRepository.Service.Load <Video>();
            var videoFolderType = ContentTypeRepository.Service.Load <VideoFolder>();
            var videos          = new List <Video>();
            var folders         = new List <VideoFolder>();
            var rawcontents     = dataModels as IList <IntermediateVideoDataModel> ?? dataModels.ToList();

            foreach (IntermediateVideoDataModel dataModel in rawcontents.Where(_ => _.VideoContentType == VideoContentType.VideoFolder))
            {
                var folder = ContentFactory.Service.CreateContent(videoFolderType, new BuildingContext(videoFolderType)
                {
                    Parent            = entryPoint,
                    LanguageSelector  = LanguageSelector.AutoDetect(),
                    SetPropertyValues = true
                }) as VideoFolder;
                folder.Name        = dataModel.Name;
                folder.EditorGroup = dataModel.EditorGroup;
                folder.ContentLink = dataModel.ContentLink;
                folder.ContentGuid = dataModel.Guid;
                folders.Add(folder);
            }
            foreach (IntermediateVideoDataModel dataModel in rawcontents.Where(_ => _.VideoContentType == VideoContentType.Video))
            {
                var video = ContentFactory.Service.CreateContent(videoType, new BuildingContext(videoType)
                {
                    Parent            = folders.FirstOrDefault(x => x.ContentLink == dataModel.ParentLink),
                    LanguageSelector  = LanguageSelector.AutoDetect(),
                    SetPropertyValues = true
                }) as Video;
                video.Id               = dataModel.Id;
                video.ContentLink      = dataModel.ContentLink;
                video.Name             = dataModel.Name;
                video.oEmbedHtml       = dataModel.oEmbedHtml;
                video.oEmbedVideoName  = dataModel.oEmbedVideoName;
                video.VideoUrl         = dataModel.VideoUrl;
                video.VideoDownloadUrl = dataModel.VideoDownloadUrl;
                video.Thumbnail        = dataModel.Thumbnail;
                video.BinaryData       = dataModel.Binarydata;
                video.ContentGuid      = dataModel.Guid;
                video.OriginalHeight   = dataModel.OriginalHeight;
                video.OriginalWidth    = dataModel.OriginalWidth;
                helper.PopulateStandardVideoProperties(video);
                videos.Add(video);
            }
            foreach (VideoFolder folder in folders)
            {
                yield return(folder);
            }
            foreach (Video video in videos)
            {
                yield return(video);
            }
        }
示例#9
0
        private ContentReference GetParent(ContentReference contentLink)
        {
            var content = _contentRepository.Get <IContent>(contentLink, LanguageSelector.AutoDetect(true));

            if (content == null)
            {
                return(null);
            }
            var source = _contentLanguageSettingsHandler.Get(content.ParentLink);

            return(source?.FirstOrDefault()?.DefinedOnContent);
        }
        /// <summary>
        /// Load the content for a <see cref="ContentReference"/>.
        /// </summary>
        /// <param name="contentLink">
        /// The content link.
        /// </param>
        /// <param name="languageSelector">
        /// The language selector.
        /// </param>
        /// <returns>
        /// The <see cref="IContent"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// contentLink
        /// </exception>
        /// <exception cref="System.NotSupportedException">
        /// Only cloning of pages is supported
        /// </exception>
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            if (ContentReference.IsNullOrEmpty(contentLink) || contentLink.ID == 0)
            {
                throw new ArgumentNullException("contentLink");
            }

            if (languageSelector == null)
            {
                languageSelector = LanguageSelector.AutoDetect();
            }

            if (contentLink.WorkID > 0)
            {
                return(this.ContentStore.LoadVersion(contentLink, -1));
            }

            ILanguageBranchRepository languageBranchRepository =
                ServiceLocator.Current.GetInstance <ILanguageBranchRepository>();

            LanguageSelectorContext context = new LanguageSelectorContext(
                contentLink, languageBranchRepository, this.Load);

            if (contentLink.GetPublishedOrLatest)
            {
                languageSelector.SelectPageLanguage(context);

                LanguageBranch langBr = null;

                if (context.SelectedLanguage != null)
                {
                    langBr = languageBranchRepository.Load(context.SelectedLanguage);
                }

                return(this.ContentStore.LoadVersion(contentLink, langBr != null ? langBr.ID : -1));
            }

            languageSelector.SetInitializedLanguageBranch(context);

            // Get published version of Content
            IContent originalContent = this.ContentStore.Load(
                contentLink, context.SelectedLanguageBranch != null ? context.SelectedLanguageBranch.ID : -1);

            PageData page = originalContent as PageData;

            if (page == null)
            {
                throw new NotSupportedException("Only cloning of pages is supported");
            }

            return(this.ClonePage(page));
        }
        private IEnumerable <ContentReference> GetDescendentsOfType <T>(ContentReference contentReference) where T : ContentData
        {
            foreach (var reference in ContentLoader.GetDescendents(contentReference))
            {
                var contentItem = ContentLoader.Get <ContentData>(reference, LanguageSelector.AutoDetect()) as T;
                if (contentItem == null)
                {
                    continue;
                }

                yield return(reference);
            }
        }
        /// <summary>
        /// Get the content data object using the latest version if in edit mode.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contentLink"></param>
        /// <param name="editMode"></param>
        /// <returns></returns>
        public static T GetItem <T>(ContentReference contentLink, bool editMode) where T : IContentData
        {
            if (editMode)
            {
                var versionRepo = _versionRepository.Service;
                var latest      = versionRepo.List(contentLink).OrderByDescending(v => v.Saved).FirstOrDefault(v => v.IsMasterLanguageBranch);
                contentLink = latest.ContentLink;
            }

            T content;

            _contentRepository.Service.TryGet <T>(contentLink, LanguageSelector.AutoDetect(false), out content);

            return(content);
        }
示例#13
0
        public IEnumerable <ISelectItem> GetSelections(ExtendedMetadata metadata)
        {
            var language = LanguageSelector.AutoDetect() as LanguageSelector;


            if (language != null)
            {
                var values = PaymentManager.GetPaymentMethods(language.LanguageBranch);
                foreach (var value in values.PaymentMethod)
                {
                    yield return(new SelectItem
                    {
                        Text = string.Format("{0} ({1})", value.Name, language.LanguageBranch),
                        Value = value.PaymentMethodId
                    });
                }
            }
        }
示例#14
0
        public void ProcessRequest(HttpContext context)
        {
            LanguageSelector languageSelector = LanguageSelector.AutoDetect();
            var    languageName = languageSelector.Language.Name;
            string filename     = context.Request.Path.Substring(Constants.PathBase.Length);

            bool debugMode = context.Request.QueryString["debug"] != null;

            string cacheKey       = $"{filename}_{languageName}_{(debugMode ? "debug" : "release")}}}";
            string responseObject = context.Cache.Get(cacheKey) as string;

            if (responseObject == null)
            {
                var filePath = GetFullFilePath(filename, context, languageName);
                responseObject = GetJson(filePath, debugMode);
                context.Cache.Insert(cacheKey, responseObject, new CacheDependency(filePath));
            }

            context.Response.Write(responseObject);
            context.Response.ContentType = "text/javascript";
        }
示例#15
0
        public static IContent GetLastVersion(PageReference reference, string lang)
        {
            var versionRepository = ServiceLocator.Current.GetInstance <IContentVersionRepository>();
            var contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();

            var versions    = versionRepository.List(reference);
            var lastVersion = versions
                              .OrderBy(v => v.Saved)
                              .Take(versions.Count() - 1)
                              .OrderByDescending(v => v.Saved)
                              .FirstOrDefault(version => version.LanguageBranch == lang);

            if (lastVersion == null)
            {
                //var msg = string.Format("Unable to find last version for ContentReference '{0}'.", reference.ID);
                //throw new Exception(msg);
                return(null);
            }

            return(contentRepository.Get <IContent>(lastVersion.ContentLink, LanguageSelector.AutoDetect(true)));
        }
示例#16
0
        /// <summary>
        /// Gets the content with the specified PageID.
        /// </summary>
        /// <param name="id">
        /// The PageID.
        /// </param>
        /// <param name="language">
        /// The language selector
        /// </param>
        /// <returns>
        /// The requested content
        /// </returns>
        /// <exception cref="System.Web.Http.HttpResponseException">
        /// A response exception.
        /// </exception>
        public string Get(int id, string language)
        {
            PageData requestedPageData = null;

            try
            {
                requestedPageData = this.ContentRepository.Get <PageData>(
                    new ContentReference(id),
                    language == null ? LanguageSelector.AutoDetect() : new LanguageSelector(language));
            }
            catch (ContentNotFoundException contentNotFoundException)
            {
                Logger.Info(contentNotFoundException.Message, contentNotFoundException);
            }

            if (requestedPageData == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(this.GenerateResponse(requestedPageData));
        }
        public void ProcessRequest(HttpContext context)
        {
            if (_provider.Service == null)
            {
                throw new InvalidOperationException("Implementation of `IResourceListProvider` is not configured in IoC container.");
            }

            var languageSelector = LanguageSelector.AutoDetect();
            var languageName     = string.IsNullOrEmpty(context.Request.QueryString["lang"])
                                   ? languageSelector.Language.Name
                                   : context.Request.QueryString["lang"];

            context.Response.ContentType = "text/javascript";

            var filename = ExtractFileName(context);

            if (filename == Constants.DeepMergeScriptName)
            {
                context.Response.Write("/* https://github.com/KyleAMathews/deepmerge */ var jsResourceHandler=function(){function r(r){return!(c=r,!c||'object'!=typeof c||(t=r,n=Object.prototype.toString.call(t),'[object RegExp]'===n||'[object Date]'===n||(o=t,o.$$typeof===e)));var t,n,o,c}var e='function'==typeof Symbol&&Symbol.for?Symbol.for('react.element'):60103;function t(e,t){var n;return(!t||!1!==t.clone)&&r(e)?o((n=e,Array.isArray(n)?[]:{}),e,t):e}function n(r,e,n){return r.concat(e).map(function(r){return t(r,n)})}function o(e,c,a){var u,f,y,i,b=Array.isArray(c);return b===Array.isArray(e)?b?((a||{arrayMerge:n}).arrayMerge||n)(e,c,a):(f=c,y=a,i={},r(u=e)&&Object.keys(u).forEach(function(r){i[r]=t(u[r],y)}),Object.keys(f).forEach(function(e){r(f[e])&&u[e]?i[e]=o(u[e],f[e],y):i[e]=t(f[e],y)}),i):t(c,a)}return{deepmerge:function(r,e,t){return o(r,e,t)}}}();");
                return;
            }

            var debugMode = context.Request.QueryString["debug"] != null;
            var camelCase = context.Request.QueryString["camel"] != null;
            var alias     = string.IsNullOrEmpty(context.Request.QueryString["alias"]) ? "jsl10n" : context.Request.QueryString["alias"];

            var cacheKey = CacheKeyHelper.GenerateKey(filename, languageName, debugMode);

            if (!(CacheManager.Get(cacheKey) is string responseObject))
            {
                responseObject = _provider.Service.GetJson(filename, context, languageName, debugMode, camelCase);
                responseObject = $"window.{alias} = jsResourceHandler.deepmerge(window.{alias} || {{}}, {responseObject})";

                CacheManager.Insert(cacheKey, responseObject);
            }

            context.Response.Write(responseObject);
        }
示例#18
0
        public object Convert(ContentReference target)
        {
            if (target == null)
            {
                return(null);
            }

            var content = _contentRepository.Get <IContent>(target, LanguageSelector.AutoDetect(true));
            var media   = content as MediaData;

            if (media != null)
            {
                return(new
                {
                    media.Name,
                    media.Thumbnail,
                    media.MimeType,
                    Url = _urlResolver.GetUrl(media)
                });
            }

            return(content);
        }
        /// <summary>
        /// Method for retrieving all pages passed by a page type id
        /// </summary>
        /// <returns>Returns pages for each page type given by pagetypeid</returns>
        private static IEnumerable <PageData> GetAllPagesOfPageType(int id)
        {
            var pageTypeId = id;
            var repository = ServiceLocator.Current.GetInstance <IPageCriteriaQueryService>();

            var pageTypeCriteria = new PropertyCriteria
            {
                Name      = "PageTypeID",
                Type      = PropertyDataType.PageType,
                Value     = pageTypeId.ToString(),
                Condition = CompareCondition.Equal,
                Required  = true
            };

            var criteria = new PropertyCriteriaCollection
            {
                pageTypeCriteria
            };

            var currentCulture = ContentLanguage.PreferredCulture;
            var languageBranch = currentCulture.Name;

            var pageDataCollection = repository.
                                     FindAllPagesWithCriteria(ContentReference.RootPage,
                                                              criteria,
                                                              languageBranch,
                                                              LanguageSelector.AutoDetect(true));

            if (pageDataCollection != null)
            {
                var sortedPageDataCollection = pageDataCollection.OrderByDescending(c => c.StartPublish);

                return(sortedPageDataCollection);
            }

            return(pageDataCollection);
        }
示例#20
0
        /// <summary>
        /// Gets the menu view model.
        /// </summary>
        /// <returns>MegaMenuViewModel</returns>
        private MegaMenuViewModel GetMenuViewModel()
        {
            var sectionPages = _contentLoader.Service.GetChildren <SectionPage>(ContentReference.StartPage, LanguageSelector.AutoDetect(), 0, MaxNumberOfSectionPages)
                               .Where(page => page.VisibleInMenu).ToList();
            var menuPages = CreateMenuList(sectionPages);

            return(new MegaMenuViewModel
            {
                MenuPages = menuPages
            });
        }
示例#21
0
        /// <summary>
        /// Collects the children pages of a section page and map them to a list of MenuContentViewModel objects.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <returns>A list of MenuContentViewModel objects</returns>
        private List <MenuContentViewModel> GetChildrenViewModels(SectionPage parent)
        {
            var childrenViewModels  = new List <MenuContentViewModel>();
            var maxNumberOfChildren = parent.MaxNumberOfMenuEntries >= 0 ? parent.MaxNumberOfMenuEntries : 500;
            var children            = _contentLoader.Service.GetChildren <ContentPage>(parent.ContentLink, LanguageSelector.AutoDetect(), 0, 500).
                                      Where(sp => _filterService.Service.IsVisible(sp)).ToList();

            foreach (var child in children)
            {
                childrenViewModels.Add(
                    new MenuContentViewModel
                {
                    Title            = child.MenuTitle,
                    Description      = child.MenuDescription,
                    URL              = _urlResolver.Service.GetUrl(child),
                    RenderAsLinkOnly = children.IndexOf(child) + 1 > maxNumberOfChildren
                });
            }

            return(childrenViewModels);
        }
示例#22
0
        /// <summary>
        /// Gets the latest reply in a thread.
        /// </summary>
        /// <param name="threadRef">A reference to the thread.</param>
        /// <returns>The latest reply in the thread.</returns>
        public static PageData GetLatestReply(PageReference threadRef)
        {
            PageDataCollection replies = DataFactory.Instance.GetChildren(threadRef, LanguageSelector.AutoDetect(), 0, 1);

            return(replies[0]);
        }
示例#23
0
        /// <summary>
        /// Gets the latest updated threads. Will search through all the forums beneath the supplied root.
        /// </summary>
        /// <param name="pageRef">The root page to look for threads under.</param>
        /// <param name="nrOfThreads">The number of threads to return.</param>
        /// <returns>A PageDataCollection containing threads.</returns>
        public static PageDataCollection GetLatestUpdatedThreads(PageReference pageRef, int nrOfThreads)
        {
            PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();

            criterias.Add("PageTypeName", ThreadContainerPageTypeName, CompareCondition.Equal);
            PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(pageRef, criterias);

            PageDataCollection threads         = new PageDataCollection();
            FilterPublished    publishedFilter = new FilterPublished();

            foreach (PageData threadContainer in pages)
            {
                foreach (PageData page in DataFactory.Instance.GetChildren(threadContainer.PageLink, LanguageSelector.AutoDetect(), 0, nrOfThreads))
                {
                    if (!publishedFilter.ShouldFilter(page))
                    {
                        threads.Add(page);
                    }
                }
            }

            new FilterPropertySort("PageChanged", FilterSortDirection.Descending).Filter(threads);
            new FilterCount(nrOfThreads).Filter(threads);

            return(threads);
        }
 public static MvcHtmlString GetTranslations(this HtmlHelper helper, Type containerType, string language = null, string alias = null, bool debug = false, bool camelCase = false)
 {
     return(Helper.GetTranslations(helper, containerType, language ?? LanguageSelector.AutoDetect().Language.Name, alias, debug, camelCase));
 }
示例#25
0
        public List <BasicContent> LoadFromService()
        {
            try
            {
                var entryPoint       = ContentRepositry.Service.GetChildren <VideoFolder>(ContentReference.RootPage).FirstOrDefault();
                var videoFolders     = CreateFoldersFromChannels(entryPoint).ToList();
                var videoContentList = new ConcurrentBag <BasicContent>(videoFolders);
                var videoHelper      = new VideoHelper();

                var options = new ParallelOptions
                {
                    MaxDegreeOfParallelism = SettingsRepository.Service.MaxDegreeOfParallelism
                };

                if (options.MaxDegreeOfParallelism == 0)
                {
                    throw new ArgumentOutOfRangeException("23Video: MaxDegreeOfParallelism settings must be -1 or a positive number");
                }

                Parallel.ForEach(videoFolders, options, folder =>
                {
                    if (folder is VideoFolder)
                    {
                        var videos = TwentyThreeVideoRepository.GetVideoList(folder.ContentLink.ID);

                        foreach (var videoData in videos)
                        {
                            var type  = ContentTypeRepository.Service.Load <Video>();
                            var video =
                                ContentFactory.Service.CreateContent(type, new BuildingContext(type)
                            {
                                Parent            = folder,
                                LanguageSelector  = LanguageSelector.AutoDetect(),
                                SetPropertyValues = true
                            }) as Video;
                            if (video != null)
                            {
                                _log.Debug("23Video: Added video with name {0}", video.Name);
                                if (videoHelper.PopulateVideo(video, videoData))
                                {
                                    videoContentList.Add(video);
                                }
                                else
                                {
                                    _log.Warning(
                                        "23Video: Failed validation, skipping add. Videoname from 23Video {0}",
                                        videoData.One);
                                }
                            }
                            else
                            {
                                _log.Information(
                                    "23Video: Video from 23Video can not be loaded in EPiServer as Video. Videoname from 23Video {0}",
                                    videoData.One);
                            }
                        }
                    }
                }
                                 );
                return(videoContentList.Where(_ => _ != null).ToList());
            }
            catch (Exception e)
            {
                _log.Error("23Video: LoadFromService: Could not load videos from service. Exception {0}", e.Message);

                throw new Exception("Could not load videos from service.");
            }
        }
示例#26
0
        private PageReference CreateDatePage(IContentRepository contentRepository, ContentReference parent, string name, DateTime startPublish)
        {
            BlogListPage defaultPageData = contentRepository.GetDefault <BlogListPage>(parent, typeof(BlogListPage).GetPageType().ID, LanguageSelector.AutoDetect().Language);

            defaultPageData.PageName     = name;
            defaultPageData.Heading      = name;
            defaultPageData.StartPublish = startPublish;
            defaultPageData.URLSegment   = UrlSegment.CreateUrlSegment(defaultPageData);
            return(contentRepository.Save(defaultPageData, SaveAction.Publish, AccessLevel.Publish).ToPageReference());
        }
        public Comment CreateAComment()
        {
            var comment = _contentRepository.GetDefault <Comment>(PageReference.RootPage, LanguageSelector.AutoDetect().Language);

            comment.Name       = "acomment";
            comment.User.Email = "*****@*****.**";
            comment.Body       = "This is a comment";

            var contentLink   = _contentRepository.Save(comment, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
            var loadedComment = _contentRepository.Get <Comment>(contentLink);

            System.Diagnostics.Debug.Assert(comment.User.Email == loadedComment.User.Email);
            System.Diagnostics.Debug.Assert(comment.Body == loadedComment.Body);

            return(comment);
        }
示例#28
0
 private IEnumerable <object> GetContent(IEnumerable <ContentReference> references)
 {
     return(references.Select(contentRef => _contentRepository.Get <IContent>(contentRef, LanguageSelector.AutoDetect(true))));
 }
 public static MvcHtmlString GetTranslations(this HtmlHelper helper, Expression <Func <object> > model, string language = null, string alias = null, bool debug = false, bool camelCase = false)
 {
     return(Helper.GetTranslations(helper, model, language ?? LanguageSelector.AutoDetect().Language.Name, alias, debug, camelCase));
 }
示例#30
0
        public void CreateSiteBinFolders()
        {
            foreach (var siteDefinition in this.siteDefinitionRepository.List())
            {
                var siteBin = this.contentRepository.GetBySegment(siteDefinition.StartPage, "__sitetrashbin", LanguageSelector.AutoDetect());

                if (siteBin == null)
                {
                    var trashBin = this.contentRepository.GetDefault <SiteTrashBinPage>(siteDefinition.StartPage);
                    trashBin.Name       = "Waste Basket";
                    trashBin.URLSegment = siteBinUrlSegment;
                    this.contentRepository.Save(trashBin, SaveAction.Publish, AccessLevel.NoAccess);
                }
            }
        }