Difference between revisions of "DCS Using Script"

From Catglobe Wiki
Jump to: navigation, search
(Created page with "Category:Answer_sheet_data_caches")
 
Line 1: Line 1:
 
[[Category:Answer_sheet_data_caches]]
 
[[Category:Answer_sheet_data_caches]]
 +
 +
 +
 +
[[File:2018-10-23_11-04-50.png]]
 +
 +
DCS using with script, required a workflow. The workflow get 5 parameters:
 +
 +
1: Any parameter you have specified in the setup
 +
 +
2: The DateTime (or Empty) from which to include data in a partial rebuild
 +
 +
3: The Entire array of Non Unique Ids from last rebuild (or empty if full rebuild)
 +
 +
4: The Entire array of Unique Ids from last rebuild (or empty if full rebuild)
 +
 +
5: The extraParameter, can be set when the rebuild is instanciated from cgscript
 +
 +
And must return CustomDataCacheSpecificationBuildResult
 +
 +
The first parameter can be set on UI or by cgscript
 +
 +
[[File:2018-10-23_12-20-06.png]]
 +
 +
Or can set by cgscript:
 +
<source lang="javascript">
 +
Dictionary d1 = {"Key1":1, "Key2": 2};
 +
Dictionary d2 = {"": "xxxx"};
 +
DataCacheSpecification dcs = new DataCacheSpecification(dcsRId);
 +
dcs.BuildUsingWorkflowScriptResourceId = workflowRId;
 +
//dcs.BuildUsingWorkflowScriptParameter=1;// number
 +
//dcs.BuildUsingWorkflowScriptParameter="xyz"; // string
 +
//dcs.BuildUsingWorkflowScriptParameter={"xyz",1};// array of string and number
 +
dcs.BuildUsingWorkflowScriptParameter={d1,d2};// array of Dictionary
 +
dcs.Save();
 +
</source>
 +
 +
The fifth parameter can be set when rebuild DCS
 +
<source lang="javascript">
 +
dcs.Rebuild(true, true, 0, true, "abc");
 +
</source>
 +
 +
Example for using script:
 +
 +
A simple DCS with 5 rows and one column "test"; value for each row is a random number
 +
 +
[[File:2018-10-25_11-22-00.png]]
 +
 +
How to do it:
 +
 +
- Create a new DCS:
 +
 +
+ Choose using script
 +
 +
+ Add a custom column
 +
 +
[[File:2018-10-25_11-29-38.png]]
 +
 +
- Create a workflow and insert the workflow in to the DCS
 +
 +
[[File:2018-10-25_11-40-05.png]]
 +
 +
Code on workflow must return CustomDataCacheSpecificationBuildResult, how many rows on DCS belonging the length of res.
 +
In this example, res is returned with array 5 items, therefor the DCS have 5 rows
 +
 +
<source lang="javascript">
 +
CustomDataCacheSpecificationBuildResult res = new CustomDataCacheSpecificationBuildResult();
 +
res.NonUniqueIds.AddRange({1,2,3,4,5});
 +
res.Ids.AddRange({5,6,7,8,9});
 +
return res;
 +
</source>
 +
 +
Let continue with another example using parameter

Revision as of 05:58, 25 October 2018



2018-10-23 11-04-50.png

DCS using with script, required a workflow. The workflow get 5 parameters:

1: Any parameter you have specified in the setup

2: The DateTime (or Empty) from which to include data in a partial rebuild

3: The Entire array of Non Unique Ids from last rebuild (or empty if full rebuild)

4: The Entire array of Unique Ids from last rebuild (or empty if full rebuild)

5: The extraParameter, can be set when the rebuild is instanciated from cgscript

And must return CustomDataCacheSpecificationBuildResult

The first parameter can be set on UI or by cgscript

2018-10-23 12-20-06.png

Or can set by cgscript:

Dictionary d1 = {"Key1":1, "Key2": 2};
Dictionary d2 = {"": "xxxx"};
DataCacheSpecification dcs = new DataCacheSpecification(dcsRId);
dcs.BuildUsingWorkflowScriptResourceId = workflowRId;
//dcs.BuildUsingWorkflowScriptParameter=1;// number 
//dcs.BuildUsingWorkflowScriptParameter="xyz"; // string 
//dcs.BuildUsingWorkflowScriptParameter={"xyz",1};// array of string and number 
dcs.BuildUsingWorkflowScriptParameter={d1,d2};// array of Dictionary 
dcs.Save();

The fifth parameter can be set when rebuild DCS

dcs.Rebuild(true, true, 0, true, "abc");

Example for using script:

A simple DCS with 5 rows and one column "test"; value for each row is a random number

2018-10-25 11-22-00.png

How to do it:

- Create a new DCS:

+ Choose using script

+ Add a custom column

2018-10-25 11-29-38.png

- Create a workflow and insert the workflow in to the DCS

2018-10-25 11-40-05.png

Code on workflow must return CustomDataCacheSpecificationBuildResult, how many rows on DCS belonging the length of res. In this example, res is returned with array 5 items, therefor the DCS have 5 rows

CustomDataCacheSpecificationBuildResult res = new CustomDataCacheSpecificationBuildResult();
res.NonUniqueIds.AddRange({1,2,3,4,5});
res.Ids.AddRange({5,6,7,8,9});
return res;

Let continue with another example using parameter