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.
{ "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" } } } } } }
{
"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" } } } } }
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 getting pattern metaGet = new MsMdPattern() {scenarios = ListOperation.Get}, execParams = new MsMdExecParams() {execSaveProblem = true} }; // Create a proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.SetMs(setMsOp); return result.meta.scenarios; }
See also: