Below is the example of using the GetWbkMd operation to save a calculated series as a modeling problem. The request contains an instance of opened workbook and a pattern for saving the modeling problem. The response contains description of the created problem.
IMPORTANT. Before saving a calculated series as a modeling problem, determine values of all the mandatory attributes for this series.
{
"GetWbkMd" :
{
"tWbk" :
{
"id" : "S1!M!S!W5"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"action" :
{
"saveAsProblem" :
{
"createInfo" :
{
"name" : "Modeling problem",
"id" : "",
"permanent" : "true"
},
"series" : ""
}
}
}
}
}
}
{
"GetWbkMdResult" :
{
"id" :
{
"id" : "S1!M!S!W5"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@isShortcut" : "0",
"@isLink" : "0",
"i" : "WBK_CALC",
"n" : "Calculated series",
"k" : "5541",
"c" : "2827",
"p" : "5471",
"h" : "0"
}
},
"dirty" : "1",
"windowsPosition" : "Vertical",
"hasPivot" : "0",
"hasLaner" : "1",
"series" :
{
"@count" : "4",
"its" : ""
},
"action" :
{
"saveAsProblem" :
{
"object" :
{
"@isShortcut" : "0",
"@isLink" : "0",
"i" : "OBJ8170",
"n" : "Modeling problem",
"k" : "8170",
"c" : "5123",
"p" : "5474",
"h" : "0",
"obId" :
{
"id" : ""
}
}
}
}
}
}
}
The GetWbkSaveAsProblem function saves a calculated series as a modeling problem. Input parameters:
wbk. Workbook instance.
series. Array of calculated series' keys. Values of all the mandatory attributes must be determined for these series.
After executing the function returns the result of saving. The console window displays identifier of the created problem.
public static WbkSaveAsProblemResult GetWbkSaveAsProblem(WbkId wbk, ItKey[] series)
{// Set operation execution parameters
var tOp = new GetWbkMd
{
tWbk = wbk,
tArg = new GetWbkMdArg
{// Set data extraction pattern
pattern = new WbkMdPattern
{
action = new WbkActionArg()
{
saveAsProblem = new WbkSaveAsProblemArg()
{
createInfo = new ObjectCreateBaseInfo()
{
id = "",
name = "Modeling porblem",
permanent = true
},
series = series
}
}
}
}
};
// Create proxy object for operation execution
var somClient = new SomPortTypeClient();
// Execute operation
var gRes = somClient.GetWbkMd(tOp);
WbkActionResult actRes = gRes.meta.action;
WbkSaveAsProblemResult saveProblRes = actRes.saveAsProblem;
Console.WriteLine("Created problem identifier: " + saveProblRes.@object.i);
return saveProblRes;
}
See also:
SOAP