Пример #1
0
        public override SiteMapNode GetParentNode(SiteMapNode node)
        {
            var crmNode = node as CrmSiteMapNode;

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

            var portal  = PortalContext;
            var context = portal.ServiceContext;
            var website = portal.Website;

            var entity = context.MergeClone(crmNode.Entity);

            if (crmNode.HasCrmEntityName("adx_communityforum"))
            {
                var parentPage = entity.GetRelatedEntity(context, "adx_webpage_communityforum");

                // If this association doesn't exist, this is an old schema, return the "Forums" page as the parent.
                if (parentPage == null)
                {
                    var forumsRootPage = OrganizationServiceContextExtensions.GetPageBySiteMarkerName(context, website, "Forums");

                    return(SiteMap.Provider.FindSiteMapNode(context.GetUrl(forumsRootPage)));
                }

                return(SiteMap.Provider.FindSiteMapNode(context.GetUrl(parentPage)));
            }

            if (crmNode.HasCrmEntityName("adx_communityforumthread"))
            {
                var parentForum = entity.GetRelatedEntity(context, "adx_communityforum_communityforumthread");

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

                var parentForumNode = GetForumNode(context, parentForum);

                return(NodeValidator.Validate(context, parentForumNode) ? parentForumNode : null);
            }

            return(null);
        }
Пример #2
0
        private ApplicationPath GetApplicationPathForSiteMarker(OrganizationServiceContext serviceContext, Entity website, IDictionary cache)
        {
            if (serviceContext == null || website == null)
            {
                return(null);
            }

            return(GetApplicationPathForSiteMarker(cache, () =>
            {
                var page = OrganizationServiceContextExtensions.GetPageBySiteMarkerName(serviceContext, website, SiteMarker);

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

                var urlProvider = PortalCrmConfigurationManager.CreateDependencyProvider(PortalName).GetDependency <IEntityUrlProvider>();

                return urlProvider.GetApplicationPath(serviceContext, page);
            }));
        }
Пример #3
0
        protected virtual IEnumerable <SyndicationItem> GetSyndicationItems()
        {
            var portalContext  = PortalCrmConfigurationManager.CreatePortalContext();
            var serviceContext = PortalCrmConfigurationManager.CreateServiceContext();

            var query = from jp in serviceContext.CreateQuery("adx_jobposting")
                        where jp.GetAttributeValue <EntityReference>("adx_websiteid") == portalContext.Website.ToEntityReference()
                        where jp.GetAttributeValue <OptionSetValue>("statecode") != null && jp.GetAttributeValue <OptionSetValue>("statecode").Value == 0
                        orderby jp.GetAttributeValue <DateTime?>("adx_name")
                        select jp;

            var postings = query.ToArray().Where(e => IsOpen(e.GetAttributeValue <DateTime?>("adx_closingon")));

            var applicationPage    = OrganizationServiceContextExtensions.GetPageBySiteMarkerName(portalContext.ServiceContext, portalContext.Website, "Job Application");
            var applicationPageUrl = applicationPage == null ? null : OrganizationServiceContextExtensions.GetUrl(portalContext.ServiceContext, applicationPage);

            return(postings.Select(posting => new SyndicationItem(
                                       posting.GetAttributeValue <string>("adx_name"),
                                       SyndicationContent.CreateHtmlContent(posting.GetAttributeValue <string>("adx_description")),
                                       GetSyndicationItemUri(portalContext, applicationPageUrl, posting),
                                       posting.GetAttributeValue <Guid>("adx_jobpostingid").ToString(),
                                       posting.GetAttributeValue <DateTime?>("modifiedon").GetValueOrDefault(DateTime.UtcNow))));
        }