GetThingPropertyValues
描述
GetThingPropertyValues 會大量擷取內容值,以限制填入傳回資料集所需的快取呼叫數。如果請求的內容不在請求的物件上,會傳回空白值。
輸入
參數名稱
描述
基礎類型
thingReferences
包含物件清單的資料負載。
資料負載的預期資料形式為 EntityReference
INFOTABLE
dataShapeName
資料形式的名稱,該資料形式用於封裝查詢要傳回的內容值。
資料形式必須存在於 ThingWorx 模型中。資料形式可以是系統實體或使用者定義的實體。
DATASHAPENAME
輸出
參數名稱
描述
基礎類型
result
傳回資料負載,其中包含針對 thingReferences 輸入中請求的每個物件,在資料形式中請求的內容值。
傳回資料負載的資料形式,其中將包含物件名稱與輸入資料形式中的所有內容。
INFOTABLE
範例
在此範例中,使用不同內容定義了三個物件、一個資料形式與一個串流。
實體
內容
Thing1
Property1
Thing2
Property1, Property2
Thing3
Property1, Property2, Property3
TestStream
Property1, Property2, Property3
TestDatashape
Property1, Property3, Property4
以下是範例程式碼。
// Create a thingRef Infotable with the datashape EntityReference
var thingRefInfoTableParams = {
infoTableName : "InfoTable",
dataShapeName : "EntityReference"
};
var thingRef = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(thingRefInfoTableParams);
// populate thingRef InfoTable
var thing1Entry = new Object();
thing1Entry.name = "Thing1"; // STRING
thing1Entry.type = "Thing"; // STRING
var thing2Entry = new Object();
thing2Entry.name = "Thing2"; // STRING
thing2Entry.type = "Thing"; // STRING
var thing3Entry = new Object();
thing3Entry.name = "Thing3"; // STRING
thing3Entry.type = "Thing"; // STRING
var streamEntry = new Object();
streamEntry.name = "TestStream"; // STRING
streamEntry.type = "Thing"; // STRING
thingRef.AddRow(thing1Entry);
thingRef.AddRow(thing2Entry);
thingRef.AddRow(thing3Entry);
thingRef.AddRow(streamEntry);
// result: INFOTABLE dataShape: "RootEntityList"
result = Resources["EntityServices"].GetThingPropertyValues({
thingReferences: thingRef /* INFOTABLE */,
dataShapeName: "TestDatashape" /* DATASHAPENAME */
});
下表顯示上述查詢的輸出。Property4 為空白,因為請求的物件未定義任何 Property4Thing1Thing2Property3 為空白,因為二者均未定義 Property3
thingName
Property1
Property3
Property4
Thing1
11
Thing2
21
Thing3
31
33
TestStream
S1
S3
這是否有幫助?