Below is the example of using the GetMs operation to create a modeling variable. The request contains an instance of opened modeling container, a pattern for creating a variable and parameters of operation execution. The response contains an instance of the created variable.
{ "GetMs" : { "tMs" : { "id" : "PNFNKEBJINJBFOAEPBFMMOMJFBKHLMJEJJOCFGDCJFPIKDAA!M!S!CIBNLEFBJINJBFOAEPAMCIOMNKJACDBEEHJCOCFBOLMEFOMMM" }, "tArg" : { "pattern" : { "obInst" : "true", "item" : { "key" : "89669", "problem" : { "metamodel" : { "calculationChain" : "Get" } } } }, "execParams" : { "k" : "0", "execCreateVariable" : { "name" : "MyInputVavable", "level" : "Year" } } } } }
{ "GetMsResult" : { "id" : { "id" : "PNFNKEBJINJBFOAEPBFMMOMJFBKHLMJEJJOCFGDCJFPIKDAA!M!S!CIBNLEFBJINJBFOAEPAMCIOMNKJACDBEEHJCOCFBOLMEFOMMM" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "1", "@hf" : "0", "i" : "MODELSPACE", "n" : "Modeling container", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0", "hasPrv" : "0", "ic" : "0", "isPermanent" : "1", "isTemp" : "0" } }, "dirty" : "0", "item" : { "k" : "89669", "id" : "MODEL_NEW", "n" : "MODEL_NEW", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : { "k" : "89670", "calculationChain" : { "its" : { "Item" : { "k" : "1", "n" : "MyInputVavable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "", "chainVariable" : { "slice" : { "k" : "0", "id" : "MyInputVavable|A", "n" : "MyInputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "1" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "MyInputVavable|A", "originalName" : "MyInputVavable", "originalShortName" : "MyInputVavable", "useCustomName" : "0" } } } }, "visualController" : { "chainEntry" : { "k" : "1", "n" : "MyInputVavable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "", "chainVariable" : { "slice" : { "k" : "0", "id" : "MyInputVavable|A", "n" : "MyInputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "1" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "MyInputVavable|A", "originalName" : "MyInputVavable", "originalShortName" : "MyInputVavable", "useCustomName" : "0", "variableExists" : "0" } }, "userRPath" : "", "isRExist" : "0" }, "suppressEmptyFilter" : { "suppressEmpty" : "0", "suppressEmptyArea" : "SerieBounds" }, "readOnly" : "0", "variableTestUseR" : "0", "calculateIdentOnFact" : "0" }, "useScenarios" : "0", "readOnly" : "0" } } } } }
The GetMsNewVarable function creates a new variable. An instance of the modeling container, key of the model where the variable is created and the name of the created variable are sent as input parameters. After executing the function returns the slice that corresponds to the created variable.
public static MsFormulaTransformSlice GetMsNewVarable(MsId ms, ulong modelKey, string varName) { var getMsOp = new GetMs(); // Set operation execution parameters getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { execParams = new MsMdExecParams() { execCreateVariable = new MsMdExecCreateVariable() { level = DimCalendarLvl.Year, name = varName }, k = 0 }, pattern = new MsMdPattern() { item = new MsItemPattern() { // Set key of the model that contains variable key = modelKey, problem = new MsProblemPattern() { metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Get } } } } }; // Create a proxy object for operation calculation var somClient = new SomPortTypeClient(); GetMsResult getMsResult = somClient.GetMs(getMsOp); MsItem newVarable = getMsResult.meta.item; MsMetaModelVisualController visualController = newVarable.problemMd.metamodel.visualController; MsFormulaTransformSlice varSlice = visualController.chainEntry.chainVariable.slice; return varSlice; }
See also: