Below is the example of using the GetMs operation to retrieve the limited number of objects from a modeling container. The request contains an instance of opened modeling container, a pattern and filter for data getting. The response contains the obtained objects.
{ "GetMs" : { "tMs" : { "id" : "S111!M!S!C1" }, "tArg" : {
"pattern" : { "obInst" : "true", "items" : "Get", "item" : { "key" : "2804", "metaModel" : { "filter" : "",
"calcChainPattern" : { "modelPattern" : { "transform" : { "transformVariable" : { "slices" : "Get", "transformSlice" :
{ "selection" : "Get" } } } } }, "visualControllerPattern" : { "variableRubricatorKey" : "true",
"chainWorkbookKey" : "true", "freeVariables" : "true" } } } }, "filter" : { "items" : {
"range" : { "count" : "2" } } } } } } } }
{ "GetMsResult" : { "id" : { "id" : "S111!M!S!C1"
}, "meta" : { "obInst" : { "obDesc" : { "@isShortcut" : "0", "i" : "MODELSPACE", "n" : "Modeling container",
"k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0", "items" : { "its" :
{ "it" : [ { "k" : "1627", "id" : "SCEN$TREE", "n" : "Scenario tree", "vis" : "1", "type" : "Folder" },
{ "k" : "2564", "id" : "OBJ2564", "n" : "Model", "vis" : "1", "type" : "Problem" } ] } },
"item" : { "k" : "2804", "id" : "OBJ2804", "n" : "Model", "vis" : "1", "type" : "MetaModel", "metaModelMd" : { "k" : "2804",
"visualController" : { "variableRubricatorKey" : "2805", "chainWorkbookKey" : "2837", "freeVariables" : { "its" : { "Item" : {
"k" : "0", "id" : "261", "n" : "MyInputVavable", "vis" : "1", "variableKey" : "2839", "stubKey" : "2805", "selections" : { "its" : {
"Item" : { "id" : { "id" : "2818" }, "variant" : "261" } } },
"aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" }
} }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "None"
} } } } } } }
public static MsItem GetMsFilter(MsId ms, ulong mModelKey) { var getMsOp = new GetMs(); getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { // Set data getting pattern pattern = new MsMdPattern()
{ items = ListOperation.Get, item = new MsItemPattern() { // Set calculation chain key key = mModelKey, metaModel = new MsMetaModelPattern() { // Do not use filtering filter = new MsMetaModelFilter() { calculationChain = null,
mmParams = null }, // Set calculation chain getting pattern calcChainPattern = new MsCalculationChainPattern() { modelPattern = new MsModelPattern() { transform = new MsFormulaTransformPattern() { transformVariable = new MsFormulaTransformVariablePattern() {
slices = ListOperation.Get, transformSlice = new MsFormulaTransformSlicePattern() { selection = ListOperation.Get } } } } }, visualControllerPattern = new MsMetaModelVisualControllerPattern() { variableRubricatorKey = true, chainWorkbookKey = true,
freeVariables = true } } } }, // Set filter filter = new MsMdFilter() { // Get only 3 objects items = new ListFilter() {range = new ListRange() { count = 2}} }
}; // Create a proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.GetMs(getMsOp); MsItems its = result.meta.items; Console.WriteLine("Geted objects:"); foreach (MsItem it in its.its) {Console.WriteLine("".PadRight(3) + it.n);}; Console.Write("Calculation chain is opened from model '"); MsItem mModel = result.meta.item; Console.WriteLine(mModel.n + "'");
MsFormulaTransformSlices fVars = mModel.metaModelMd.visualController.freeVariables; if (fVars.its.Length != 0) { Console.WriteLine("".PadRight(3) + "Free variables:"); foreach (MsFormulaTransformSlice slice in fVars.its) {Console.WriteLine("".PadRight(6) + slice.n);} } else {Console.WriteLine("".PadRight(3) + "Model does not contain free variables");} return mModel; }
See also: