The example of using the SaveObjectAs operation to overwrite one repository object with another. The request contains a source object moniker and description of the object, which contents must be overwritten. The response contains description of the object, the content of which is overwritten.
{ "SaveObjectAs" : { "tObject" : { "id" : "S1!M!64" }, "tArg" : { "destination" : { "operation" : "OverwriteExisting", "overwrite" : { "object" : { "@isShortcut" : "false", "@isLink" : "false", "@hf" : "false", "i" : "REPORT_COPY", "n" : "Regular report (Copy)", "k" : "8083", "c" : "2562", "p" : "4294967295", "h" : "false" } }, "autoGenerateName" : "true" } } } }
{ "SaveObjectAsResult" : { "object" : { "@isShortcut" : "0", "@isLink" : "0", "i" : "REPORT_COPY", "n" : "Regular report(Copy)", "k" : "8083", "c" : "2562", "p" : "65", "h" : "0", "obId" : { "id" : "S1!M!8083" } } } }
The OverwriteObj function specified below overwrites the content of one object with the the content of another object of the repository. Identifiers of source object and destination object are sent by means of the sourcedObj and destinationObj input parameters. This example uses the FindObjectById function. Code of this function see in the example Get Description of Object by Its Identifier. The result of the operation is the result of the function.
public static SaveObjectAsResult OverwriteObj(MbId mb, string sourcedObj, string destinationObj) { var somClient = new SomPortTypeClient(); //Proxy object for operation execution //Operation execution parameters var tSave = new SaveObjectAs() { tArg = new SaveObjectAsArg() { destination = new ObjectCopyInfo() { //Action - overwrite existing object operation = ObjectCopyOperation.OverwriteExisting, overwrite = new ObjectOverwriteInfo() { //Object to be overwritten @object = FindObjectById(mb, destinationObj) } } }, tObject = new OdId() { id = mb.id + "!" + FindObjectById(mb, sourcedObj).k } }; //Object overwriting var result = somClient.SaveObjectAs(tSave); return result; }
See also: