public static bool uploadFiletoVaultFolder(VDF.Vault.Currency.Connections.Connection connection, string destinationTempFolder, string folderID, string comment, string fileName, byte[] fileBytes) { try { VDF.Vault.Currency.Entities.Folder fld = FolderHelper.getFolderusingID(connection, folderID); List <FileAssocParam> fileAssocParamList = new List <FileAssocParam>(); FileAssocParam fileAssocArray = new FileAssocParam(); FileAssocParam[] paramArray = fileAssocParamList.ToArray(); BOM _bom = new BOM(); //string destinationFile = System.IO.Path.GetTempPath() + fileName; System.IO.File.WriteAllBytes(destinationTempFolder, fileBytes); VDF.Currency.FilePathAbsolute FPA = new VDF.Currency.FilePathAbsolute(destinationTempFolder); FileIteration FI = connection.FileManager.AddFile(fld, comment, paramArray, _bom, FileClassification.None, false, FPA); //cehck if file exists if (FI.FolderId.ToString() == folderID) { ZGHCC.writeLog("File uplaoded and it Exists: " + folderID + " | " + comment); boolRes = true; } else { boolRes = false; } } catch (SystemException ex) { ZGHCC.writeLog("uploadFiletoVaultFolder EX: " + ex.ToString()); statusMess = null; Debug.Write("\nError: " + ex.ToString()); statusMess = "Error: \n" + ex.ToString(); boolRes = false; } return(boolRes); }
public static string getFileIDsinCSV(VDF.Vault.Currency.Connections.Connection connection, List <ISelection> filesColl) { resultVal = null; try { //var settings = new VDF.Vault.Settings.AcquireFilesSettings(Global.variables.connection, updateFileReferences: false); //settings.LocalPath = new VDF.Currency.FolderPathAbsolute(Global.variables.fileStore); if (filesColl.Count > 0) { foreach (var file in filesColl) { File selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(file.Id); // Look of the File object. if (selectedFile != null) { resultVal += selectedFile.Id + "-"; } //MessageBox.Show(String.Format("Hello World! The file {0} size is: {1} bytes", selectedFile.Name, selectedFile.FileSize)); } char last = resultVal[resultVal.Length - 1]; if (last.Equals("-")) { resultVal = resultVal.Remove(resultVal.Length - 1); } ZGHCC.writeLog("FileIDS CSV: " + resultVal); statusMess = "Success"; } } catch (SystemException ex) { ZGHCC.writeLog("\nError: " + ex.ToString()); } return(resultVal); }
public static string getFilePropertyValuebyKey(VDF.Vault.Currency.Connections.Connection connection, File selectedFile, string key) { Dictionary <string, string> dict = new Dictionary <string, string>(); try { var propDefs = connection.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll); var propSvc = connection.WebServiceManager.PropertyService; var properties = propSvc.GetPropertiesByEntityIds("FILE", new long[] { selectedFile.Id }); //Dictionary<PropInst, PropInst> dict = properties.ToDictionary(x => x, x => x); foreach (var item in properties) { string keyItem = propDefs.Keys.ToArray()[item.PropDefId - 1]; string val = item.Val.ToString(); dict.Add(keyItem, val); ZGHCC.writeLog("==LIB ==" + propDefs.Keys.ToArray()[item.PropDefId - 1] + " | " + item.PropDefId.ToString() + " | " + item.Val.ToString()); if (keyItem == key) { resultVal = val; } else { resultVal = null; } } } catch (SystemException ex) { Debug.Write("\nError: " + ex.ToString()); } return(resultVal); }
public static Dictionary <string, string> PrintProperties(VDF.Vault.Currency.Connections.Connection connection, File selectedFile) { Dictionary <string, string> dict = new Dictionary <string, string>(); try { ZGHCC.writeLog("DesignVisAttmtStatus: " + selectedFile.DesignVisAttmtStatus.ToString()); VDF.Vault.Currency.Entities.FileIteration fileInteration = new FileIteration(connection, selectedFile); var propDefs = connection.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll); foreach (var key in propDefs.Keys) { // Print the Name from the Definition and the Value from the Property object propValue = connection.PropertyManager.GetPropertyValue(fileInteration, propDefs[key], null); dict.Add(propDefs[key].DisplayName.ToString(), propValue == null ? "" : propValue.ToString()); ZGHCC.writeLog(string.Format("== LIB 1 DICT == >> '{0}' = '{1}'", propDefs[key].DisplayName.ToString(), propValue == null ? "" : propValue.ToString())); } dict.Add("Id", fileInteration.EntityMasterId.ToString()); dict.Add("EntityClass", "File"); } catch (SystemException ex) { ZGHCC.writeLog(ex.ToString()); } return(dict); }
public static string downloadVaultFilebyID(VDF.Vault.Currency.Connections.Connection connection, string path, long selectedFileID) { try { using (WebServiceManager serviceManager = connection.WebServiceManager) { Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(selectedFileID); var FileDownloadTicket = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { selectedFileID }); FilestoreService fileStoreService = serviceManager.FilestoreService; var fileBytes = fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false); //MessageBox.Show(path + "\\" + localFile.Name); System.IO.File.WriteAllBytes(path + "\\" + localFile.Name, fileBytes); //Check if file exist if (!System.IO.File.Exists(path + "\\" + localFile.Name)) { //failedFiles.Add(file); statusMess = "File Download Failed!"; ZGHCC.writeLog(statusMess); } else { statusMess = path + "\\" + localFile.Name; //fileExt = System.IO.Path.GetExtension(localFile.Name); ZGHCC.writeLog(statusMess); } } //statusMess = "Success"; } catch (SystemException ex) { statusMess = null; Debug.Write("\nError: " + ex.ToString()); statusMess = "Error: \n" + ex.ToString(); } return(statusMess); //Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id); }