Пример #1
0
        private string GetLayouts(Entity entityList)
        {
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Getting Entity List For: {0}, entityId: {1}", entityList.LogicalName, entityList.Id));

            var viewConfigurations =
                GetEntityViews()
                .Select(
                    view =>
                    new ViewConfiguration(PortalViewContext.CreatePortalContext(),
                                          PortalViewContext.CreateServiceContext(), entityList, EntityLogicalName, PrimaryKeyName,
                                          view.Id, GridMetadataConfiguration, PortalViewContext.PortalName, LanguageCode,
                                          EnableEntityPermissions, "page", "filter", "query", "sort", "My", 20, "mf", null, null, null, null, null, view.DisplayName))
                .ToList();

            var layouts =
                viewConfigurations.Select(c =>
            {
                try
                {
                    return(new ViewLayout(c, null, PortalViewContext.PortalName, LanguageCode, false,
                                          (c.ItemActionLinks != null && c.ItemActionLinks.Any())));
                }
                catch (SavedQueryNotFoundException ex)
                {
                    ADXTrace.Instance.TraceWarning(TraceCategory.Application, ex.Message);
                    return(null);
                }
            }).Where(l => l != null);


            return(JsonConvert.SerializeObject(layouts));
        }
        private IEnumerable <ForumThreadDrop> GetForumThreadSubscriptions(IPortalLiquidContext portalLiquidContext)
        {
            var user = Entity;

            if (user == null || user.LogicalName != "contact")
            {
                return(Enumerable.Empty <ForumThreadDrop>());
            }

            var portal = PortalViewContext.CreatePortalContext();

            var forumDependencies = new PortalContextDataAdapterDependencies(portal, new PaginatedLatestPostUrlProvider("page", portalLiquidContext.Html.IntegerSetting("Forums/PostsPerPage").GetValueOrDefault(20)));

            var dataAdapter = new ForumThreadAggregationDataAdapter(forumDependencies, true,
                                                                    serviceContext => serviceContext.FetchForumCountsForWebsite(PortalViewContext.Website.EntityReference.Id),
                                                                    serviceContext => (from thread in serviceContext.CreateQuery("adx_communityforumthread")
                                                                                       join alert in serviceContext.CreateQuery("adx_communityforumalert") on
                                                                                       thread.GetAttributeValue <Guid>("adx_communityforumthreadid") equals
                                                                                       alert.GetAttributeValue <EntityReference>("adx_threadid").Id
                                                                                       join forum in serviceContext.CreateQuery("adx_communityforum") on
                                                                                       thread.GetAttributeValue <EntityReference>("adx_forumid").Id equals
                                                                                       forum.GetAttributeValue <Guid>("adx_communityforumid")
                                                                                       where
                                                                                       forum.GetAttributeValue <EntityReference>("adx_websiteid") != null &&
                                                                                       forum.GetAttributeValue <EntityReference>("adx_websiteid").Id == PortalViewContext.Website.EntityReference.Id
                                                                                       where
                                                                                       alert.GetAttributeValue <EntityReference>("adx_subscriberid") != null &&
                                                                                       alert.GetAttributeValue <EntityReference>("adx_subscriberid").Id == user.Id
                                                                                       orderby thread.GetAttributeValue <DateTime>("adx_lastpostdate") descending
                                                                                       orderby thread.GetAttributeValue <string>("adx_name")
                                                                                       select thread),
                                                                    serviceContext => serviceContext.FetchForumThreadTagInfoForWebsite(PortalViewContext.Website.EntityReference.Id),
                                                                    new ForumThreadAggregationDataAdapter.ForumThreadUrlProvider(forumDependencies.GetUrlProvider()));

            var forumThreads = dataAdapter.SelectThreads(0).ToList();

            return(!forumThreads.Any()
                                ? Enumerable.Empty <ForumThreadDrop>()
                                : forumThreads.Select(e => new ForumThreadDrop(portalLiquidContext, forumDependencies, e)));
        }