public FetchXmlIndexDocumentFactory(ICrmEntityIndex index, FetchXml fetchXml, string titleAttributeLogicalName, FetchXmlLocaleConfig localeConfig) { if (index == null) { throw new ArgumentNullException("index"); } if (fetchXml == null) { throw new ArgumentNullException("fetchXml"); } if (titleAttributeLogicalName == null) { throw new ArgumentNullException("titleAttributeLogicalName"); } if (localeConfig == null) { throw new ArgumentNullException("localeConfig"); } _index = index; _contentMapProvider = AdxstudioCrmConfigurationManager.CreateContentMapProvider(); _fetchXml = fetchXml; _titleAttributeLogicalName = titleAttributeLogicalName; _localeConfig = localeConfig; _dataContext = _index.DataContext; }
public SavedQuery(Entity savedQuery) { if (savedQuery == null) { throw new ArgumentNullException("savedQuery"); } _fetchxml = new FetchXml(XDocument.Parse(savedQuery.GetAttributeValue <string>("fetchxml"))); _layoutxml = XDocument.Parse(savedQuery.GetAttributeValue <string>("layoutxml")); string titleAttributeLogicalName; if (TryGetFirstAttribute(_layoutxml, "//row/cell", "name", out titleAttributeLogicalName)) { TitleAttributeLogicalName = titleAttributeLogicalName; } else { throw new InvalidOperationException("Unable to extract title attribute logical name from layoutxml."); } }
internal FetchXmlIndexer(ICrmEntityIndex index, FetchXml fetchXml, string titleAttributeLogicalName) { if (index == null) { throw new ArgumentNullException("index"); } if (fetchXml == null) { throw new ArgumentNullException("fetchXml"); } if (titleAttributeLogicalName == null) { throw new ArgumentNullException("titleAttributeLogicalName"); } _index = index; _fetchXml = fetchXml; _titleAttributeLogicalName = titleAttributeLogicalName; if (!this._fetchXml.ContainsAttribute("modifiedon") && this._fetchXml.LogicalName != "annotation") { this._fetchXml.AddAttribute("modifiedon"); } if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching)) { if (this._fetchXml.LogicalName == "adx_blog") { if (!this._fetchXml.ContainsAttribute("adx_parentpageid")) { this._fetchXml.AddAttribute("adx_parentpageid"); } } if (this._fetchXml.LogicalName == "adx_blogpost") { if (!this._fetchXml.ContainsAttribute("adx_blogid")) { this._fetchXml.AddAttribute("adx_blogid"); } // Add the published attribute as we need it for indexing for CMS if (!this._fetchXml.ContainsAttribute("adx_published")) { this._fetchXml.AddAttribute("adx_published"); } if (!this._fetchXml.ContainsLinkEntity("adx_blog_blogpost")) { this._fetchXml.AddLinkEntity("adx_blog", "adx_blogid", "adx_blogid", "adx_blog_blogpost", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_blog_blogpost", "adx_parentpageid"); this._fetchXml.AddLinkEntityAttribute("adx_blog_blogpost", "adx_partialurl"); if (!this._fetchXml.ContainsAttribute("adx_partialurl")) { this._fetchXml.AddAttribute("adx_partialurl"); } } if (this._fetchXml.LogicalName == "adx_idea") { if (!this._fetchXml.ContainsAttribute("adx_ideaforumid")) { this._fetchXml.AddAttribute("adx_ideaforumid"); } // Add the approved flag as this is needed for indexing CMS this._fetchXml.AddConditionalStatement("and", "adx_approved", "eq", "true"); if (!this._fetchXml.ContainsLinkEntity("adx_idea_ideaforum")) { this._fetchXml.AddLinkEntity("adx_ideaforum", "adx_ideaforumid", "adx_ideaforumid", "adx_idea_ideaforum", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_idea_ideaforum", "adx_partialurl"); this._fetchXml.AddConditionalStatement("and", "adx_partialurl", "not-null", null, "adx_idea_ideaforum"); this._fetchXml.AddConditionalStatement("and", "adx_partialurl", "not-null"); this._fetchXml.AddAttribute("adx_partialurl"); } if (this._fetchXml.LogicalName == "adx_communityforumthread") { if (!this._fetchXml.ContainsAttribute("adx_forumid")) { this._fetchXml.AddAttribute("adx_forumid"); } } if (this._fetchXml.LogicalName == "adx_communityforumpost") { if (!this._fetchXml.ContainsLinkEntity("adx_communityforumpost_communityforumthread")) { this._fetchXml.AddLinkEntity("adx_communityforumthread", "adx_communityforumthreadid", "adx_forumthreadid", "adx_communityforumpost_communityforumthread", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_communityforumpost_communityforumthread", "adx_forumid"); } if (this._fetchXml.LogicalName == "adx_webfile") { if (!this._fetchXml.ContainsAttribute("adx_parentpageid")) { this._fetchXml.AddAttribute("adx_parentpageid"); } if (!this._fetchXml.ContainsAttribute("adx_partialurl")) { this._fetchXml.AddAttribute("adx_partialurl"); } } if (this._fetchXml.LogicalName == "incident") { // It is marked as Resolved (1) this._fetchXml.AddConditionalStatement("and", "statecode", "eq", "1"); this._fetchXml.AddConditionalStatement("and", "adx_publishtoweb", "eq", "1"); } // CMS filtering for KnowledgeArticles if they don't have these rules then don't add to index. if (this._fetchXml.LogicalName == "knowledgearticle") { // make sure statecode is published = 3 this._fetchXml.AddConditionalStatement("and", "statecode", "eq", "3"); this._fetchXml.AddConditionalStatement("and", "isrootarticle", "eq", "false"); this._fetchXml.AddConditionalStatement("and", "isinternal", "eq", "false"); // Add this filter for url filtering this._fetchXml.AddConditionalStatement("and", "articlepublicnumber", "not-null"); this.AddRelatedEntityFetch("connection", "connectionid", "record1id", "knowledgearticleid", "record2id", "product", "productid", "record2id", "productid"); if (this._index.DataContext.AssertEntityExists("adx_contentaccesslevel")) { this.AddRelatedEntityFetch("adx_knowledgearticlecontentaccesslevel", "adx_knowledgearticlecontentaccesslevelid", "knowledgearticleid", "knowledgearticleid", "adx_contentaccesslevelid", "adx_contentaccesslevel", "adx_contentaccesslevelid", "adx_contentaccesslevelid", "adx_contentaccesslevelid"); } } } // Add the language fields since the related fields cannot be included in a view using the savedquery editor if (_fetchXml.LogicalName == "knowledgearticle") { _fetchXml.AddLinkEntity("languagelocale", "languagelocaleid", "languagelocaleid", "language_localeid", "outer"); _fetchXml.AddLinkEntityAttribute("language_localeid", "localeid"); _fetchXml.AddLinkEntityAttribute("language_localeid", "code"); _fetchXml.AddLinkEntityAttribute("language_localeid", "region"); _fetchXml.AddLinkEntityAttribute("language_localeid", "name"); _fetchXml.AddLinkEntityAttribute("language_localeid", "language"); // This ensures we get knowledge article search result along with annotation in case knowledge article doesn't have keywords contained in annotation if (_index.DisplayNotes) { this.AddNotesLinkEntity(_index.NotesFilter); } _localeConfig = FetchXmlLocaleConfig.CreateKnowledgeArticleConfig(); } else { _localeConfig = FetchXmlLocaleConfig.CreatePortalLanguageConfig(); } if (_fetchXml.LogicalName == "annotation") { _fetchXml.AddConditionalStatement("and", "filename", "not-null"); this.AddNotesFilter(_index.NotesFilter); this.AddRelatedKnowledgeArticleAndProductFetch(); } }