private void DownloadFile(ADSK.File file, string filePath) { // remove the read-only attribute if (System.IO.File.Exists(filePath)) { System.IO.File.SetAttributes(filePath, System.IO.FileAttributes.Normal); } VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection); Vault.Currency.Entities.FileIteration fIter = new Vault.Currency.Entities.FileIteration(connection, file); settings.AddFileToAcquire(fIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download, new VDF.Currency.FilePathAbsolute(filePath)); connection.FileManager.AcquireFiles(settings); }
void downloadFile(VDF.Vault.Currency.Connections.Connection connection, VDF.Vault.Currency.Entities.FileIteration file, string folderPath) { VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection); settings.AddEntityToAcquire(file); if (file.EntityName.EndsWith(".iam")) { settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true; settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = true; // this forces all the files to go into one folder, it doesn't replicate the vault's folder structure.. // this is needed so that Inventor view knows where to find the file settings.OrganizeFilesRelativeToCommonVaultRoot = false; } else { settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = false; settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = false; settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = false; } settings.LocalPath = new VDF.Currency.FolderPathAbsolute(folderPath); connection.FileManager.AcquireFiles(settings); }
void BomItemExportOdooCommandHandler(object s, CommandItemEventArgs e) { try { VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection; // The Context part of the event args tells us information about what is selected. // Run some checks to make sure that the selection is valid. if (e.Context.CurrentSelectionSet.Count() == 0) { MessageBox.Show("Nothing is selected"); } else if (e.Context.CurrentSelectionSet.Count() > 1) { MessageBox.Show("This function does not support multiple selections"); } else { // we only have one item selected, which is the expected behavior ISelection selection = e.Context.CurrentSelectionSet.First(); // Look of the File object. How we do this depends on what is selected. Autodesk.Connectivity.WebServices.Item selectedItem = null; if (selection.TypeId == SelectionTypeId.Bom) { // our ISelection.Id is really a File.MasterId selectedItem = connection.WebServiceManager.ItemService.GetItemsByIds(new long[] { selection.Id }).First(); } //else if (selection.TypeId == SelectionTypeId.FileVersion) //{ // // our ISelection.Id is really a File.Id // selectedItem = connection.WebServiceManager.DocumentService.GetFileById(selection.Id); //} if (selectedItem == null) { MessageBox.Show("Selection is not an item."); } else { // this is the message we hope to see //MessageBox.Show(String.Format("Hello World! The file size is: {0} bytes", //selectedFile.FileSize)); } VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection); //VDF.Vault.Currency.Entities.FileIteration selFiles = new Vault.Currency.Entities.FileIteration(connection, selectedFile); //Vault.Currency.Entities.FileIteration file = selFiles; okToProcess = false; ExecuteOdoo(selectedItem, connection, okToProcess); } } catch (Exception ex) { // If something goes wrong, we don't want the exception to bubble up to Vault Explorer. MessageBox.Show("Error: " + ex.Message); } }
void BomItemExportCommandHandler(object s, CommandItemEventArgs e) { try { VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection; // The Context part of the event args tells us information about what is selected. // Run some checks to make sure that the selection is valid. if (e.Context.CurrentSelectionSet.Count() == 0) { MessageBox.Show("Nothing is selected"); } else if (e.Context.CurrentSelectionSet.Count() > 1) { MessageBox.Show("This function does not support multiple selections"); } else { // we only have one item selected, which is the expected behavior ISelection selection = e.Context.CurrentSelectionSet.First(); // Look of the File object. How we do this depends on what is selected. Autodesk.Connectivity.WebServices.Item selectedItem = null; if (selection.TypeId == SelectionTypeId.Bom) { // our ISelection.Id is really a File.MasterId selectedItem = connection.WebServiceManager.ItemService.GetItemsByIds(new long[] { selection.Id }).First(); } if (selectedItem == null) { MessageBox.Show("Selection is not an item."); } else { VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection); ItemAssoc[] subItemAssociations = GetChildItems(selectedItem, connection); // first update the top level item UpdateItem(selectedItem, connection); // then also all the child items ItemService itemSvc = connection.WebServiceManager.ItemService; foreach (ItemAssoc subItemAssoc in subItemAssociations) { long subID = subItemAssoc.CldItemID; Item subItem = itemSvc.GetItemsByIds(new long[] { subID })[0]; if (subItem != null) { UpdateItem(subItem, connection); } } // attempt to update all items at once, i didn't get it to work yet... //Item[] itemArray = new Item[subItemAssociations.Count() + 1]; //itemArray[0] = selectedItem; //int index = 1; //ItemService itemSvc = connection.WebServiceManager.ItemService; //foreach (ItemAssoc assoc in subItemAssociations) //{ // long subID = assoc.CldItemID; // Item subItem = itemSvc.GetItemsByIds(new long[] { subID })[0]; // itemArray[index] = subItem; // index++; //} //UpdateItems(itemArray, connection); okToProcess = true; Execute(selectedItem, connection, okToProcess); } } } catch (Exception ex) { // If something goes wrong, we don't want the exception to bubble up to Vault Explorer. MessageBox.Show("Error: " + ex.Message); } }