Exemple #1
0
        /// <summary>
        /// Create a result block query action for a Query Rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="blockTitle">The result block Title</param>
        /// <param name="queryTemplate">The search query template in KQL format</param>
        /// <param name="resultSourceId">The search result source Id</param>
        /// <param name="routingLabel">A routing label for a content search WebPart</param>
        /// <param name="numberOfItems">The number of result to retrieve</param>
        public void CreateResultBlockAction(QueryRule rule, string blockTitle, string queryTemplate, Guid resultSourceId, string routingLabel, string numberOfItems)
        {
            var queryAction = (CreateResultBlockAction)rule.CreateQueryAction(QueryActionType.CreateResultBlock);

            queryAction.ResultTitle.DefaultLanguageString = blockTitle;

            if (!string.IsNullOrEmpty(queryTemplate))
            {
                queryAction.QueryTransform.QueryTemplate = queryTemplate;
            }

            queryAction.QueryTransform.SourceId = resultSourceId;

            if (!string.IsNullOrEmpty(routingLabel))
            {
                queryAction.ResultTableType = routingLabel;
            }

            if (!string.IsNullOrEmpty(numberOfItems))
            {
                queryAction.QueryTransform.OverrideProperties             = new QueryTransformProperties();
                queryAction.QueryTransform.OverrideProperties["RowLimit"] = int.Parse(numberOfItems, CultureInfo.InvariantCulture);
                queryAction.QueryTransform.OverrideProperties["TotalRowsExactMinimum"] = int.Parse(numberOfItems, CultureInfo.InvariantCulture);
            }

            rule.Update();
        }
Exemple #2
0
        /// <summary>
        /// Create a promoted link action for a a query rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="bestBetId">The bestBetIds</param>
        public void CreatePromotedResultAction(QueryRule rule, Guid bestBetId)
        {
            var queryAction = (AssignBestBetsAction)rule.CreateQueryAction(QueryActionType.AssignBestBet);

            queryAction.BestBetIds.Add(bestBetId);

            rule.Update();
        }
Exemple #3
0
        /// <summary>
        /// Create a change query action for a Query Rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="queryTemplate">The search query template in KQL format</param>
        /// <param name="resultSourceId">The search result source Id</param>
        public void CreateChangeQueryAction(QueryRule rule, string queryTemplate, Guid resultSourceId)
        {
            var queryAction = (ChangeQueryAction)rule.CreateQueryAction(QueryActionType.ChangeQuery);

            if (!string.IsNullOrEmpty(queryTemplate))
            {
                queryAction.QueryTransform.QueryTemplate = queryTemplate;
            }

            queryAction.QueryTransform.SourceId = resultSourceId;

            rule.Update();
        }
        /// <summary>
        /// Create a promoted link action for a a query rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="bestBetId">The bestBetIds</param>
        public void CreatePromotedResultAction(QueryRule rule, Guid bestBetId)
        {
            var queryAction = (AssignBestBetsAction)rule.CreateQueryAction(QueryActionType.AssignBestBet);

            queryAction.BestBetIds.Add(bestBetId);

            rule.Update();
        }
        /// <summary>
        /// Create a result block query action for a Query Rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="blockTitle">The result block Title</param>
        /// <param name="queryTemplate">The search query template in KQL format</param>
        /// <param name="resultSourceId">The search result source Id</param>
        /// <param name="routingLabel">A routing label for a content search WebPart</param>
        /// <param name="numberOfItems">The number of result to retrieve</param>
        public void CreateResultBlockAction(QueryRule rule, string blockTitle, string queryTemplate, Guid resultSourceId, string routingLabel, string numberOfItems)
        {
            var queryAction = (CreateResultBlockAction)rule.CreateQueryAction(QueryActionType.CreateResultBlock);

            queryAction.ResultTitle.DefaultLanguageString = blockTitle;

            if (!string.IsNullOrEmpty(queryTemplate))
            {
                queryAction.QueryTransform.QueryTemplate = queryTemplate;
            }

            queryAction.QueryTransform.SourceId = resultSourceId;

            if (!string.IsNullOrEmpty(routingLabel))
            {
                queryAction.ResultTableType = routingLabel;
            }

            if (!string.IsNullOrEmpty(numberOfItems))
            {
                queryAction.QueryTransform.OverrideProperties = new QueryTransformProperties();
                queryAction.QueryTransform.OverrideProperties["RowLimit"] = int.Parse(numberOfItems, CultureInfo.InvariantCulture);
                queryAction.QueryTransform.OverrideProperties["TotalRowsExactMinimum"] = int.Parse(numberOfItems, CultureInfo.InvariantCulture);
            }

            rule.Update();
        }
        /// <summary>
        /// Create a change query action for a Query Rule
        /// </summary>
        /// <param name="rule">The query rule object</param>
        /// <param name="queryTemplate">The search query template in KQL format</param>
        /// <param name="resultSourceId">The search result source Id</param>
        public void CreateChangeQueryAction(QueryRule rule, string queryTemplate, Guid resultSourceId)
        {
            var queryAction = (ChangeQueryAction)rule.CreateQueryAction(QueryActionType.ChangeQuery);

            if (!string.IsNullOrEmpty(queryTemplate))
            {
                queryAction.QueryTransform.QueryTemplate = queryTemplate;
            }

            queryAction.QueryTransform.SourceId = resultSourceId;

            rule.Update();
        }