예제 #1
0
        /// <summary>
        /// Update search Result Type with specified data
        /// </summary>
        /// <param name="resultTypeId">Existing Result Type Id</param>
        /// <param name="type">Data transfer object used for updating</param>
        /// <returns></returns>
        public ResultItemType UpdateResultType(int resultTypeId, ResultTypeDTO type)
        {
            var resultTypesManager = new ResultItemTypeManager(_searchProxy);
            var resultType         = resultTypesManager.GetResultItemTypeByID(resultTypeId, _searchOwner);

            resultType.Name = type.Name;
            resultType.DisplayTemplateUrl = type.DisplayTemplateUrl;
            resultType.RulePriority       = type.Priority;

            if (!string.IsNullOrEmpty(type.ResultSource))
            {
                var source = GetResultsSource(type.ResultSource);
                resultType.SourceID = source.Id;
            }

            var rules = new PropertyRuleCollection();

            foreach (var builtInRule in type.BuiltInRules)
            {
                rules.Add(GetBuiltInPropertyRule(builtInRule));
            }
            foreach (var rule in type.CustomRules)
            {
                rules.Add(CreatePropertyRule(rule.ManagedPropertyName, rule.Operator, rule.Values));
            }
            resultType.Rules = rules;

            return(resultTypesManager.UpdateResultItemType(resultType));
        }
예제 #2
0
        public void EnsureGlymaResultTypesSynced()
        {
            string displayProperties = GetDisplayTemplateDisplayProperties(GlymaDisplayTemplateUrl);

            foreach (ResultItemType currentResultType in _resultTypeManager.GetResultItemTypes(_searchOwner, false))
            {
                if (currentResultType.DisplayTemplateUrl.Equals(GlymaDisplayTemplateUrl, StringComparison.OrdinalIgnoreCase))
                {
                    // Ensure the managed properties of the result type is always in-sync with the display template referenced by the DisplayTemplateUrl property.
                    if (!currentResultType.DisplayProperties.Equals(displayProperties, StringComparison.OrdinalIgnoreCase))
                    {
                        currentResultType.DisplayProperties = displayProperties;
                        _resultTypeManager.UpdateResultItemType(currentResultType);
                    }
                }
            }
        }