Ниже приведён пример использования операции SetMbUpdate для добавления новых объектов в обновление. В запросе передаётся список новых объектов, параметры их обновления и шаблон, указывающий необходимость добавить новые объекты. В ответе приходит обновлённая информация о дереве элементов обновления.
{
"SetMbUpdate" :
{
"tMbUpdate" :
{
"id" : "S1!M!S!MbUpd1"
},
"tArg" :
{
"pattern" :
{
"changeNodesPattern" :
{
"operation" : "Add",
"addObjectWithChildren" : "true"
}
},
"meta" :
{
"changeNodes" :
{
"it" :
[
{
"type" : "Folder",
"label" : "Folder for Object",
"enabled" : "true"
},
{
"type" : "Object",
"parentNode" : "1",
"object" :
{
"object" :
{
"@isShortcut" : "false",
"@isLink" : "false",
"@hf" : "false",
"i" : "M_UPDATE",
"n" : "Модуль обновления",
"k" : "198414",
"c" : "1537",
"p" : "198413",
"h" : "false",
"hasPrv" : "false",
"ic" : "false"
},
"updatePart" : "Metadata",
"boundType" : "ById"
}
},
{
"type" : "Object",
"parentNode" : "1",
"object" :
{
"object" :
{
"@isShortcut" : "false",
"@isLink" : "false",
"@hf" : "false",
"i" : "D_COMPANY",
"n" : "Справочник",
"k" : "198421",
"c" : "3076",
"p" : "198413",
"h" : "false",
"hasPrv" : "false",
"ic" : "false"
},
"updatePart" : "DataMetadata",
"includeData" : "true",
"boundType" : "ById"
}
}
]
}
},
"metaGet" :
{
"node" : "true",
"nodePattern" :
{
"customProperties" : "false",
"folder" :
{
"children" : "true",
"childrenRecursive" : "true"
},
"object" :
{
"extendedParams" : ""
}
}
}
}
}
}
{
"SetMbUpdateResult" :
{
"id" :
{
"id" : "S1!M!S!MbUpd1"
},
"meta" :
{
"rootFolder" :
{
"k" : "4294967295",
"index" : "-1",
"type" : "Folder",
"label" : "",
"condition" : "",
"enabled" : "1",
"folder" :
{
"childrenCount" : "1",
"children" :
{
"it" :
{
"k" : "1",
"index" : "0",
"type" : "Folder",
"label" : "Folder for Object",
"condition" : "",
"parentNode" : "4294967295",
"enabled" : "1",
"folder" :
{
"childrenCount" : "2",
"children" :
{
"it" :
[
{
"k" : "2",
"index" : "0",
"type" : "Object",
"label" : "Модуль обновления",
"condition" : "",
"parentNode" : "1",
"enabled" : "1",
"folder" :
{
"childrenCount" : "0",
"children" : ""
},
"object" :
{
"object" :
{
"@ts" : "2020-04-14T10:19:08.502Z",
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "3",
"@hf" : "0",
"i" : "M_UPDATE",
"n" : "Модуль обновления",
"k" : "198414",
"c" : "1537",
"p" : "198413",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"isSaved" : "0",
"updatePart" : "Metadata",
"updateType" :
{
"it" :
[
"Bound",
"BindById"
]
},
"parent" : "3",
"includeChildrenDependencies" : "2",
"updateOrder" : "Default",
"includeData" : "0",
"alterType" : "Default",
"objectId" : "M_UPDATE",
"objectName" : "Модуль обновления",
"objectOldKey" : "198414",
"constraint" : "None",
"boundType" : "ById",
"unboundType" : "Bound",
"forceUniqueId" : "0",
"forceKeepId" : "0",
"accessTokenOptions" : "Default",
"sdApplyLog" : "",
"version" : "0",
"originalMetabase" : ""
}
},
{
"k" : "5",
"index" : "1",
"type" : "DataObject",
"label" : "Справочник",
"condition" : "",
"parentNode" : "1",
"enabled" : "1",
"folder" :
{
"childrenCount" : "0",
"children" : ""
},
"object" :
{
"object" :
{
"@ts" : "2020-04-14T10:49:39.000Z",
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "3",
"@hf" : "0",
"i" : "D_COMPANY",
"n" : "Справочник",
"k" : "198421",
"c" : "3076",
"p" : "198413",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"isSaved" : "0",
"updatePart" : "DataMetadata",
"updateType" :
{
"it" :
[
"Bound",
"BindById"
]
},
"parent" : "3",
"includeChildrenDependencies" : "2",
"updateOrder" : "Default",
"includeData" : "1",
"alterType" : "Default",
"objectId" : "D_COMPANY",
"objectName" : "Справочник",
"objectOldKey" : "198421",
"constraint" : "None",
"boundType" : "ById",
"unboundType" : "Bound",
"forceUniqueId" : "0",
"forceKeepId" : "0",
"accessTokenOptions" : "Default",
"sdApplyLog" : "",
"version" : "0",
"originalMetabase" : "",
"dataObject" :
{
"method" : "All",
"primaryKey" : "",
"referenceConstraintsHandling" : "Default",
"batchMode" : "Override",
"updateRdsSequence" : "0",
"requestAdminCredentials" : "0",
"isIdentity" : "0",
"allowExistingRubricatorUpdate" : "0"
}
}
}
]
}
}
}
}
}
}
}
}
}
public static SetMbUpdateResult AddObjectInUpdate(MbId mb, string moniker)
{
var somClient = new SomPortTypeClient(); //Прокси-объект для выполнения операций
//Параметры выполнения операции
var tSet = new SetMbUpdate()
{
tArg = new SetMbUpdateArg()
{
pattern = new MbUpdateMdPattern()
{
changeNodesPattern = new MbUpdateSetNodePattern()
{
operation = ListOperation.Add,
addObjectWithChildren = true
}
},
meta = new MbUpdateMd()
{
changeNodes = new MbUpdateNode[]
{
new MbUpdateNode() // Папка
{
type = MbUpdateNodeType.Folder,
label = "Folder for Object",
enabled = true
},
new MbUpdateNode() //Модуль, будет использоваться как модуль обновления
{
type = MbUpdateNodeType.Object,
parentNode = 1,
@object = new MbUpdateObjectNode()
{
@object = FindObjectById(mb, "M_UPDATE"),
updatePart = MbObjectUpdatePart.Metadata,
boundType = MbObjectUpdateBoundType.ById
}
},
new MbUpdateNode() //Табличный справочник НСИ
{
type = MbUpdateNodeType.Object,
parentNode = 1,
@object = new MbUpdateObjectNode()
{
@object = FindObjectById(mb, "D_COMPANY"),
updatePart = MbObjectUpdatePart.DataMetadata,
includeData = true,
boundType = MbObjectUpdateBoundType.ById
}
}
}
},
metaGet = new MbUpdateMdPattern()
{
node = true,
nodePattern = new MbUpdateNodePattern()
{
customProperties = false,
folder = new MbUpdateFolderNodePattern()
{
children = true,
childrenRecursive = true
},
@object = new MbUpdateObjectNodePattern()
{
extendedParams = new MbUpdateObjectNodeExtendedParamsPattern()
}
}
}
},
tMbUpdate = new MbUpdateId() { id = moniker }
};
//Настройка обновления
var result = somClient.SetMbUpdate(tSet);
return result;
}
См. также: