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" } } } } }
public static MsFormulaTransformSlice GetMsNewVarable(MsId ms, uint modelKey, string varName)
{
// Set operation execution parameters
var getMsOp = new GetMs()
{
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 model containing variable
key = modelKey,
problem = new MsProblemPattern()
{
metamodel = new MsMetaModelPattern()
{
visualControllerPattern = new MsMetaModelVisualControllerPattern()
{
levelFormat = MsLevelFormat.Short,
useSourceName = false,
variableRubricatorKey = true
}
}
}
}
}
},
tMs = ms
};
// Create a proxy object for operation execution
var somClient = new SomPortTypeClient();
var result = somClient.GetMs(getMsOp);
var newVarable = result.meta.item;
var visualController = newVarable.problemMd.metamodel.visualController;
var varSlice = visualController.chainEntry.chainVariable.slice;
return varSlice;
}
See also: