Below is the example of using the SetMs operation to add a scenario to model calculation. The request contains an instance of opened modeling container, parameters of operation execution, and the scenario to be added. After executing the operation returns tree of model scenarios.
{
"Envelope" :
{
"Body" :
{
"SetMs" :
{
"tMs" :
{
"id" : "S115!M!S!C1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"item" :
{
"key" : "2803",
"problem" :
{
"scenarioKey" : "1628",
"scenarios" : "Add"
}
}
},
"meta" :
{
"item" :
{
"k" : "2803",
"type" : "Problem",
"problemMd" :
{
"scenarios" :
{
"its" :
{
"Item" :
{
"k" : "1628",
"id" : "OBJ1628",
"n" : "Basic",
"vis" : "true"
"isProtected" : "false"
}
}
}
}
}
},
"metaGet" :
{
"obInst" : "true",
"scenarios" : "Get"
},
"execParams" :
{
"execSaveProblem" : "true"
}
}
}
}
}
}
{
"Envelope" :
{
"Body" :
{
"SetMsResult" :
{
"id" :
{
"id" : "S115!M!S!C1"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@isShortcut" : "0",
"i" : "MODELSPACE",
"n" : "Modeling container",
"k" : "1581",
"c" : "5121",
"p" : "1580",
"h" : "0"
}
},
"dirty" : "0",
"scenarios" :
{
"nodes" :
{
"it" :
{
"@isFolder" : "0",
"k" : "1628",
"id" : "OBJ1628",
"n" : "Basic",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1628",
"n" : "Basic",
"k" : "1628",
"c" : "5124"
"p" : "1627", "h" : "0" } } } } } } } } }
The SetMsAddScenModel function adds the specified scenario to model calculation. Input parameters:
ms. Opened modeling container instance.
modelKey. Key of the model to be changed.
scen. Scenario added to the model calculation.
After executing the function returns the tree of model scenarios.
public static MsScenarioTree SetMsAddScenModel(MsId ms, ulong modelKey, MsScenarioNode scen)
{
var setMsOp = new SetMs();
setMsOp.tMs = ms;
setMsOp.tArg = new SetMsArg()
{ // Set data change pattern
pattern = new MsMdPattern()
{
item = new MsItemPattern()
{ // Set model key
key = modelKey,
problem = new MsProblemPattern()
{ // Set scenario key
scenarioKey = scen.k,
scenarios = ListOperation.Add
}
}
},
// Set data that must be changed
meta = new MsMd()
{
item = new MsItem()
{
k = modelKey,
type = MsItemType.Problem,
problemMd = new MsProblem()
{
scenarios = new MsScenarioList()
{
its = new MsScenario[]
{
new MsScenario()
{
id = scen.id, k = scen.k, n = scen.n, vis = scen.vis, internalKey = null, isProtected = false } } } }
}
},
// Set changed metadata extraction pattern
metaGet = new MsMdPattern() {scenarios = ListOperation.Get},
execParams = new MsMdExecParams() {execSaveProblem = true}
}; // Create proxy object for operation execution
var somClient = new SomPortTypeClient();
// Set operation execution parameters
var result = somClient.SetMs(setMsOp);
return result.meta.scenarios;
}
See also:
SOAP