Below is the example of using the SetWbkMd operation to transform series values. The request contains an instance of opened workbook, data change pattern, series transformation parameters, and the pattern for getting changed data. The response contains description of workbook series.
{
"SetWbkMd" :
{
"tWbk" :
{
"id" : "S1!M!S!W12"
},
"tArg" :
{
"refresh" : "",
"pattern" :
{
"obInst" : "false",
"useGridAutoAdjust" : "true",
"series" : "Change",
"seriesDisplayParams" : "true"
},
"meta" :
{
"series" :
{
"its" :
{
"it" :
[
{
"k" : "2",
"id" : "OBJ2",
"n" : "USA|A",
"vis" : "true",
"kind" : "Calculate",
"dependencies" : "",
"selectedUnit" : "",
"displayParams" :
{
"inversion" : "Diff",
"inversionLag" : "PrecidingYear",
"previousInversionLag" : "3",
"setDefault" : "false"
},
"tag" : "",
"hasChildren" : "false",
"index" : "0",
"expanded" : "false",
"level" : "Year",
"childrenCount" : "0",
"visibleChildrenCount" : "0",
"flags" : "0"
}
]
}
}
},
"metaGet" :
{
"obInst" : "true",
"title" : "false",
"useGridAutoAdjust" : "true",
"series" : "Get",
"seriesDependencies" : "false",
"seriesDependents" : "false",
"seriesAtts" : "false",
"seriesPrimaryAttsForEmpty" : "false",
"seriesDisplayParams" : "false"
}
}
}
}
{
"SetWbkMdResult" :
{
"refresh" : "",
"id" :
{
"id" : "S1!M!S!W12"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "2",
"@hf" : "0",
"i" : "WBK_AD",
"n" : "Annual data",
"k" : "5505",
"c" : "2827",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "1",
"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",
"createDerivedSeries" : "Default",
"permanentData" : "0"
}
}
}
}
public static SetWbkMdResult SetWbkTransformSerie(WbkId wbkId, WbkMd wbk)
{
if (!wbk.hasLaner.Value) { return null; };
// Get the first series in workbook
LnSerie transfSerie = wbk.series.its.GetValue(0) as LnSerie;
// Set parameters for transforming series values
transfSerie.displayParams = new LnSerieDisplayParams();
LnSerieDisplayParams par = transfSerie.displayParams;
par.inversion = TsInversionType.Diff;
par.inversionLag = TsInversionLag.PrecidingYear;
par.previousInversionLag = 3;
par.setDefault = false;
// Set operation execution parameters
var tOp = new SetWbkMd
{ // Specify workbook to be changed
tWbk = wbkId,
tArg = new SetWbkMdArg()
{ // Set pattern for changing data
pattern = new WbkMdPattern()
{
obInst = false,
series = ListOperation.Change,
seriesDisplayParams = true
},// Set parameters for changing data
meta = new WbkMd()
},// Set parameters for transforming data
series = new LnSeries()
{
its = new LnSerie[]{transfSerie}
}
},
refresh = new EaxRefresh { },
// Set pattern for getting changed data
metaGet = new WbkMdPattern
{
title = false,
series = ListOperation.Get,
seriesAtts = false,
seriesPrimaryAttsForEmpty = false,
seriesDependencies = false,
seriesDependents = false,
seriesDisplayParams = false
}
}
};
// Create proxy object for operation execution
var somClient = new SomPortTypeClient();
// Execute operation
var sRes = somClient.SetWbkMd(tOp);
return sRes;
}
See also: