Search Functions(搜索函数(Search Functions))¶
Search Functions enable users to quickly find and evaluate possible solutions to the specific, unique problems that arise in their scheduling workflow.
Each Search Function is backed by a TypeScript function. The flexible interface allows builders to write functions that can return pucks, time slots, or a combination of both. Additionally, Search Functions can be row-based or puck-based.
For row-based Search Functions, users must right-click on an empty space and pass in row object and time as function inputs. For puck-based Search Functions, users must right-click on a puck to pass in object and time as function inputs.
The image below displays the interface for a Search Function returning pucks.

The image below displays the interface for a Search Function returning time slots.

After a Search Function is executed, a new search group will be created in the Scheduling Gantt Chart with the results highlighted in yellow. Search groups can be collapsed and expanded by selecting the caret symbol (^) on the right side of the group header. Additionally, users can view search results in detail by selecting the Results Overview option to open a panel with the output of the Search Function, as displayed in the below image.

Functions interface¶
The types below represent the necessary information to write a Search Function when triggered from either a row or a puck, including details about the search group.
type IPuckSearch = (puck: ObjectReference) => ISearchResult
type IRowSearch = (rowId: string, selectedTime: Timestamp) => ISearchResult
/*
Search Functions can return time slots, pucks, or both. SLOT and PUCK
are used as types in IHighlight.
*/
export enum HighlightType {
SLOT = "SLOT",
PUCK = "PUCK",
}
/*
Used in IHighlight for functions that will return a set of timeslots.
*/
export interface IDomain {
start: Long;
end: Long;
}
/*
Used to determine what is highlighted in the UI after search function is run
*/
export interface IHighlight {
type: string;
// needed for "SLOT"
domain?: IDomain;
containerId?: string;
// needed for "PUCK"
schedulableObjectPrimaryKey?: string;
schedulableObjectTypeId?: string;
// optional
comment?: string;
}
/*
Defines the title of newly created search group and the rows the
function returns.
*/
export interface IRowGroup {
title: string;
containerIds: string[];
highlights: IHighlight[];
}
/*
Overall return type of function.
*/
export interface ISearchResult {
rowGroup?: IRowGroup;
sourcePuckIds?: string[];
error?: string;
}
中文翻译¶
搜索函数(Search Functions)¶
搜索函数(Search Functions)使用户能够快速查找和评估其调度工作流中出现的特定、独特问题的可能解决方案。
每个搜索函数都由一个 TypeScript 函数支持。灵活的接口允许构建者编写能够返回调度块(pucks)、时间段(time slots)或两者组合的函数。此外,搜索函数可以是基于行(row-based)的或基于调度块(puck-based)的。
对于基于行的搜索函数,用户必须右键单击空白区域,并将行对象和时间作为函数输入传入。对于基于调度块的搜索函数,用户必须右键单击调度块,将对象和时间作为函数输入传入。
下图显示了返回调度块的搜索函数界面。

下图显示了返回时间段的搜索函数界面。

执行搜索函数后,将在调度甘特图(Scheduling Gantt Chart)中创建一个新的搜索组,结果以黄色高亮显示。通过选择组标题右侧的插入符号(^),可以折叠和展开搜索组。此外,用户可以通过选择结果概览(Results Overview)选项来详细查看搜索结果,该选项会打开一个面板,显示搜索函数的输出,如下图所示。

函数接口(Functions interface)¶
以下类型表示从行或调度块触发时编写搜索函数所需的信息,包括搜索组的详细信息。
type IPuckSearch = (puck: ObjectReference) => ISearchResult
type IRowSearch = (rowId: string, selectedTime: Timestamp) => ISearchResult
/*
搜索函数可以返回时间段、调度块或两者。SLOT 和 PUCK
在 IHighlight 中用作类型。
*/
export enum HighlightType {
SLOT = "SLOT",
PUCK = "PUCK",
}
/*
用于 IHighlight 中,适用于返回一组时间段的函数。
*/
export interface IDomain {
start: Long;
end: Long;
}
/*
用于确定搜索函数运行后在 UI 中高亮显示的内容
*/
export interface IHighlight {
type: string;
// 对于 "SLOT" 类型需要
domain?: IDomain;
containerId?: string;
// 对于 "PUCK" 类型需要
schedulableObjectPrimaryKey?: string;
schedulableObjectTypeId?: string;
// 可选
comment?: string;
}
/*
定义新创建的搜索组的标题以及函数返回的行。
*/
export interface IRowGroup {
title: string;
containerIds: string[];
highlights: IHighlight[];
}
/*
函数的整体返回类型。
*/
export interface ISearchResult {
rowGroup?: IRowGroup;
sourcePuckIds?: string[];
error?: string;
}