Exemple #1
0
        protected virtual IEvent Select(Predicate <Entity> match)
        {
            var serviceContext = Dependencies.GetServiceContext();
            var website        = Dependencies.GetWebsite();

            var publishingStateAccessProvider = new PublishingStateAccessProvider(Dependencies.GetRequestContext().HttpContext);

            // Bulk-load all ad entities into cache.
            var allEntities = serviceContext.CreateQuery("adx_event")
                              .Where(e => e.GetAttributeValue <EntityReference>("adx_websiteid") == website)
                              .ToArray();

            var entity = allEntities.FirstOrDefault(e =>
                                                    match(e) &&
                                                    IsActive(e) &&
                                                    publishingStateAccessProvider.TryAssert(serviceContext, e));

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

            var securityProvider = Dependencies.GetSecurityProvider();

            if (!securityProvider.TryAssert(serviceContext, entity, CrmEntityRight.Read))
            {
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Forum={0}: Not Found", entity.Id));

                return(null);
            }

            var myevent = new Event(entity);

            return(myevent);
        }
        protected virtual IForum Select(Predicate <Entity> match)
        {
            var serviceContext = Dependencies.GetServiceContext();
            var website        = Dependencies.GetWebsite();

            var publishingStateAccessProvider = new PublishingStateAccessProvider(Dependencies.GetRequestContext().HttpContext);

            // Bulk-load all ad entities into cache.
            var fetch = new Fetch
            {
                Entity = new FetchEntity("adx_communityforum")
                {
                    Filters = new[]
                    {
                        new Filter
                        {
                            Conditions = new[] { new Condition("adx_websiteid", ConditionOperator.Equal, website.Id) }
                        }
                    }
                }
            };

            var allEntities = serviceContext.RetrieveMultiple(fetch).Entities;

            var entity = allEntities.FirstOrDefault(e =>
                                                    match(e) &&
                                                    IsActive(e) &&
                                                    publishingStateAccessProvider.TryAssert(serviceContext, e));

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

            var securityProvider = Dependencies.GetSecurityProvider();

            if (!securityProvider.TryAssert(serviceContext, entity, CrmEntityRight.Read))
            {
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Forum={0}: Not Found", entity.Id));

                return(null);
            }

            var viewEntity      = new PortalViewEntity(serviceContext, entity, securityProvider, Dependencies.GetUrlProvider());
            var forumInfo       = serviceContext.FetchForumInfo(entity.Id);
            var counterStrategy = Dependencies.GetCounterStrategy();

            var forum = new Forum(
                entity,
                viewEntity,
                forumInfo,
                // Only lazily get counts, because it's unlikely to be used in the common case.
                // SelectThreadCount and SelectPostCount will generally be used instead.
                () => counterStrategy.GetForumCounts(serviceContext, entity));

            return(forum);
        }
Exemple #3
0
            protected UncachedProvider(
                WebPageAccessControlSecurityProvider webPageAccessControlProvider,
                PublishedDatesAccessProvider publishedDatesAccessProvider,
                PublishingStateAccessProvider publishingStateAccessProvider, string portalName = null)
            {
                _webPageAccessControlProvider  = webPageAccessControlProvider;
                _publishedDatesAccessProvider  = publishedDatesAccessProvider;
                _publishingStateAccessProvider = publishingStateAccessProvider;
                _eventAccessPermissionProvider = new EventAccessPermissionProvider();
                _forumAccessPermissionProvider = new ForumAccessPermissionProvider(this.current);
                _blogSecurityProvider          = new BlogSecurityProvider(_webPageAccessControlProvider, this.current, portalName);
                _ideaSecurityProvider          = new IdeaSecurityProvider(this.current, portalName);
                _issueSecurityProvider         = new IssueSecurityProvider(portalName);

                PortalName = portalName;
            }