
In Vault 2015, PromoteFiles has been removed from the ItemService. Previously, the quickest way was to call PromoteFiles followed by UpdateAndCommitItems. Of course, more complex cases would require more API calls and data checks. Anyway, the simple workflow just got more complex in 2015. That’s sometimes the price you pay for better functionality.
Before I dive into the new code, let me explain the reason for the change. First, PromoteFiles was not very efficient. It tried to do the entire BOM at once, which is bad for server performance and scalability. Next, it favored a file-first workflow (the files need to get created before the items). In Vault 2015, there is much better support for item-first workflows, which I’ll go over in other articles.
For now, let’s go back to the simple file-first case. You have an Inventor assembly checked-in and you want to create the BOM in Vault.
Here is the code for doing that…
|
// C#
ItemService itemSvc = m_conn.WebServiceManager.ItemService; itemSvc.AddFilesToPromote(fileIds, ItemAssignAll.Default, false);
DateTime timestamp; GetPromoteOrderResults promoteOrder = itemSvc.GetPromoteComponentOrder(out timestamp); itemSvc.PromoteComponents(timestamp, promoteOrder.PrimaryArray); ItemsAndFiles itemsAndFiles = itemSvc.GetPromoteComponentsResults(timestamp);
// TODO: edit the items if needed
itemSvc.UpdateAndCommitItems(itemsAndFiles.ItemRevArray); |
|
' VB.NET
Dim itemSvc AsItemService = m_conn.WebServiceManager.ItemService itemSvc.AddFilesToPromote(fileIds, ItemAssignAll.Default, False) Dim timestamp AsDateTime Dim promoteOrder As GetPromoteOrderResults = itemSvc.GetPromoteComponentOrder(timestamp) itemSvc.PromoteComponents(timestamp, promoteOrder.PrimaryArray) Dim itemsAndFiles AsItemsAndFiles = itemSvc.GetPromoteComponentsResults(timestamp)
' edit the items as needed
itemSvc.UpdateAndCommitItems(itemsAndFiles.ItemRevArray) |
Basically, PromoteFiles has been replaced by 4 function calls: AddFilesToPromote, GetPromoteComponentOrder, PromoteComponents, and GetPromoteComponentsResults. The "timestamp" variable is the thread that ties together the four calls. When you want to finalize the operation, call UpdateAndCommitItems just like before.
Yes, it seems like 4 function calls makes things worse than before. It's definitely more work for a client, but it makes and improvement on the server side. Less is done in a single call, which means that transactions are smaller and quicker. That, in turn, means more concurrency and throughput.
Click here for an article on how to update an Item in response to File updates

Leave a Reply