Below is the example of using the OpenWbk operation to open a workbook for read. The request contains a workbook instance and data extraction pattern. The response contains requested data.
{ "OpenWbk" : { "tOb" : { "id" : "S1!M!5505" }, "tArg" : { "args" : {
"openForEdit" : "false" }, "metaGet" : { "obInst" : "true", "series" : "Get", "seriesFilter" : { "includeCollapsed" : "true" },
"period" : "true", "rubrs" : "true", "rubrArg" : { "obInst" : "true", "period" : "true" } } } } }
{ "OpenWbkResult" : { "id" : { "id" : "S1!M!S!W2" }, "meta" :
{ "obInst" : { "obDesc" : { "@isShortcut" : "0", "@isLink" : "0", "i" : "WBK_AD", "n" : "Yearly data", "k" : "5505",
"c" : "2827", "p" : "5471", "h" : "0" }, "openArgs" : "" }, "windowsPosition" : "Vertical", "hasPivot" : "0", "hasLaner" : "1", "series" :
{ "@count" : "3", "its" : { "it" : [ { "k" : "2", "id" : "OBJ2", "n" : "USA|A",
"vis" : "1", "kind" : "Calculate", "selectedUnit" : "", "tag" : "", "hasChildren" : "0", "index" : "0", "expanded" : "0", "level" : "Year", "childrenCount" : "0", "visibleChildrenCount" : "0",
"flags" : "0" }, { "k" : "4", "id" : "OBJ4", "n" : "Canada|A", "vis" : "1", "kind" : "Calculate", "selectedUnit" : "", "tag" : "",
"hasChildren" : "0", "index" : "1", "expanded" : "0", "level" : "Year", "childrenCount" : "0", "visibleChildrenCount" : "0", "flags" : "0" }, { "k" : "6",
"id" : "OBJ6", "n" : "Russia|A", "vis" : "1", "kind" : "Calculate", "selectedUnit" : "", "tag" : "", "hasChildren" : "0", "index" : "2", "expanded" : "0", "level" : "Year",
"childrenCount" : "0", "visibleChildrenCount" : "0", "flags" : "0" } ] }, "displayDataAs" : "CalculatedValues", "autoRecalc" : "1" }, "period" :
{ "start" : "1995-01-01", "end" : "2015-01-01" }, "rubrs" : { "def" : { "k" : "5472", "id" : "TS_DB",
"n" : "Time series database", "vis" : "1", "rubId" : { "id" : "S1!M!S!W2!Rubs!5472" }, "meta" : { "obInst" : {
"obDesc" : { "@isShortcut" : "0", "@isLink" : "0", "i" : "TS_DB", "n" : "Time series database", "k" : "5472", "c" : "2822", "p" : "5471", "h" : "0"
}, "openArgs" : "" }, "period" : { "startYear" : "1980", "endYear" : "2020" }, "properties" : {
"@lightWeight" : "0", "@valuesOnQuery" : "0", "@factsOnQuery" : "0", "@hasMnemonics" : "1", "@revisionsOnQuery" : "0", "@keepHistory" : "1", "@autoUpdateStat" : "1", "@useDistinctSequence" : "0", "@unitIsRequired" : "0", "@compoundFactorKey" : "0",
"@hasEmptyAttribute" : "0" } } }, "its" : { "it" : [ { "k" : "5472",
"id" : "TS_DB", "n" : "Time series database", "vis" : "1", "rubId" : { "id" : "S1!M!S!W2!Rubs!5472" }, "meta" : { "obInst"
{ "obDesc" : { "@isShortcut" : "0", "@isLink" : "0", "i" : "TS_DB", "n" : "Time series database", "k" : "5472", "c" : "2822", "p" : "5471"
"h" : "0" }, "openArgs" : "" }, "period" : { "startYear" : "1980", "endYear" : "2020" }, "properties" :
{ "@lightWeight" : "0", "@valuesOnQuery" : "0", "@factsOnQuery" : "0", "@hasMnemonics" : "1", "@revisionsOnQuery" : "0", "@keepHistory" : "1", "@autoUpdateStat" : "1", "@useDistinctSequence" : "0", "@unitIsRequired" : "0",
"@compoundFactorKey" : "0", "@hasEmptyAttribute" : "0" } } } ] } } } } }
The OpenWbkForRead function opens a workbook to read data. Input parameters:
mb. Repository connection moniker.
wbkId. Workbook identifier.
After executing the function returns the result of workbook opening. The console window displays the requested data.
public static OpenWbkResult OpenWbkForRead(MbId mb, string wbkId) { var tWbk = new OpenWbk() { // Set operation execution parameters tArg = new OpenWbkArg() {// Specify that open workbook for read args = new WbkOpenArgs() { openForEdit = false },// Set data extraction pattern metaGet = new WbkMdPattern() { viewMode = true, // view mode series = ListOperation.Get, // data series seriesFilter = new LnSeriesFilter() {// Extract collapsed series includeCollapsed = true }, period = true, // data display period parameters rubrs = true, // data sources rubrArg = new RubMdPattern() {period = true} } },// Specify a workbook used to execute operation tOb = new OdId() { id = mb.id + "!" + FindObjectById(mb, wbkId).k } }; // Create proxy object for operation execution var somClient = new SomPortTypeClient(); // Execute operation var tResult = somClient.OpenWbk(tWbk); Console.WriteLine("Workbook is opened: " + tResult.id.id); WbkMd openWbk = tResult.meta; LnPeriod period = openWbk.period; Console.WriteLine("Data display period:"); Console.WriteLine("".PadRight(3) + "- start: " + period.start.ToShortDateString()); Console.WriteLine("".PadRight(3) + "- end: " + period.end.ToShortDateString()); Console.WriteLine("Workbook display mode: " + openWbk.viewMode.Value); Console.WriteLine("Number of series: " + openWbk.series.count.ToString()); LnRubs rubrs = openWbk.rubrs; Console.WriteLine("Default source identifier: " + rubrs.def.id); Console.WriteLine("All data sources:"); foreach (LnRub rub in (rubrs.its)) { Console.Write("".PadRight(3) + "- name '" + rub.n); Console.WriteLine("'; identifier '" + rub.id + "'"); Console.WriteLine("".PadRight(6) + "calendar start: " + rub.meta.period.startYear.ToString()); Console.WriteLine("".PadRight(6) + "calendar end: " + rub.meta.period.endYear.ToString()); } return tResult; }
See also: