Ejemplo n.º 1
0
        private void InvalidateSearchIndex(List <OrganizationServiceCachePluginMessage> batchedPluginMessage, Dictionary <Guid, SearchIndexBuildRequest.SearchIndexInvalidationData> searchInvalidationDatum)
        {
            foreach (var message in batchedPluginMessage)
            {
                if (message.Target == null || SearchMetadataCache.Instance.SearchEnabledEntities.Contains(message.Target.LogicalName))
                {
                    SearchIndexBuildRequest.SearchIndexInvalidationData searchInvalidationData = null;

                    if (message.Target != null)
                    {
                        searchInvalidationDatum.TryGetValue(message.Target.Id, out searchInvalidationData);
                    }

                    retryPolicy.Value.ExecuteAction(() => SearchIndexBuildRequest.ProcessMessage(message, searchInvalidationData, CrmChangeTrackingManager.Instance.OrganizationServiceContext));
                }
            }
        }
Ejemplo n.º 2
0
        private SearchIndexBuildRequest.SearchIndexInvalidationData GetSearchIndexInvalidationData(OrganizationServiceCachePluginMessage message)
        {
            if (message.Target == null || string.IsNullOrEmpty(message.Target.LogicalName) || message.Target.Id == Guid.Empty)
            {
                return(null);
            }

            var searchIndexInvalidationData = new SearchIndexBuildRequest.SearchIndexInvalidationData();

            IContentMapProvider contentMapProvider = AdxstudioCrmConfigurationManager.CreateContentMapProvider();

            contentMapProvider.Using(contentMap =>
            {
                if (message.Target.LogicalName == "adx_webpage")
                {
                    WebPageNode webPageNode;

                    if (contentMap.TryGetValue(new EntityReference(message.Target.LogicalName, message.Target.Id), out webPageNode))
                    {
                        searchIndexInvalidationData.PartialUrl = webPageNode.PartialUrl;

                        if (webPageNode.Parent != null)
                        {
                            searchIndexInvalidationData.ParentPage = new EntityReference("adx_webpage", webPageNode.Parent.Id);
                        }

                        if (webPageNode.Website != null)
                        {
                            searchIndexInvalidationData.Website = new EntityReference("adx_website", webPageNode.Website.Id);
                        }

                        if (webPageNode.PublishingState != null)
                        {
                            searchIndexInvalidationData.PublishingState = new EntityReference("adx_publishingstate", webPageNode.PublishingState.Id);
                        }
                    }
                }

                if (message.Target.LogicalName == "adx_webpageaccesscontrolrule_webrole")
                {
                    WebPageAccessControlRuleToWebRoleNode webAccessControlToWebRoleNode;

                    if (contentMap.TryGetValue(new EntityReference(message.Target.LogicalName, message.Target.Id), out webAccessControlToWebRoleNode))
                    {
                        WebPageAccessControlRuleNode webAccessControlNode = webAccessControlToWebRoleNode.WebPageAccessControlRule;
                        if (webAccessControlNode != null && webAccessControlNode.WebPage != null)
                        {
                            searchIndexInvalidationData.WebPage = new EntityReference("adx_webpage", webAccessControlNode.WebPage.Id);
                        }
                    }
                }

                if (message.Target.LogicalName == "adx_webpageaccesscontrolrule")
                {
                    WebPageAccessControlRuleNode webAccessControlNode;

                    if (contentMap.TryGetValue(new EntityReference(message.Target.LogicalName, message.Target.Id), out webAccessControlNode))
                    {
                        if (webAccessControlNode.WebPage != null)
                        {
                            searchIndexInvalidationData.WebPage = new EntityReference("adx_webpage", webAccessControlNode.WebPage.Id);
                        }
                    }
                }

                if (message.Target.LogicalName == "adx_communityforumaccesspermission")
                {
                    ForumAccessPermissionNode forumAccessNode;

                    if (contentMap.TryGetValue(new EntityReference(message.Target.LogicalName, message.Target.Id), out forumAccessNode))
                    {
                        if (forumAccessNode.Forum != null)
                        {
                            searchIndexInvalidationData.Forum = new EntityReference("adx_communityforum", forumAccessNode.Forum.Id);
                        }
                    }
                }
            });

            return(searchIndexInvalidationData);
        }