Hi,
We are trying to change change user defined property value in Vault 2014.
We are performing following steps in code to modify ipt file property:
Folder[] parentFolder = serviceManager.DocumentService.GetFoldersByFileMasterId(selectedFile.MasterId); //Selected file is any .ipt file
string filepath = parentFolder.FirstOrDefault().FullName + "/" + selectedFile.Name;
//1. Check out selected file
File checkedOutFile = serviceManager.DocumentService.CheckoutFile(selectedFile.Id, CheckoutFileOptions.Master, Environment.MachineName, filepath, "Checked out", out array);
//2. Updating file Property
serviceManager.DocumentService.UpdateFileProperties(new long[] { checkedOutFile.MasterId }, new long[] { property.Id }, new object[] { item.Val });
//3. Checkin that file
serviceManager.DocumentService.CheckinUploadedFile(checkedOutFile.MasterId, "Changed", false,
System.DateTime.Now, null, null, false, null, FileClassification.None, false, array);
We are getting exception in Check-In api as : 8000: SOAP Exception. Exception snop shot is attached named as "CheckinException.png".
Please let me know if anyone solve such kind of issue. OR Correct us if we are following wrong steps ?
Thanks,
The Server Error Codes page in the SDK documentation lists error 8000 as TicketInvalid. That means you are trying to transfer a file without a valid upload or download ticket.
The upload/download mechanism has changed greatly in 2014. The recommended approach is to use AcquireFiles, which will take care of all that ticket stuff for you. You can still use web services directly if you want, but it's harder.
Doug ,
I use AcquireFiles, API in C#. But using this API I am able to either download file or Checkout file.
If I chekout file using AcquireFile API, for checkin API I need ByteArray (last parameter for Checkin API)
Following is the code for checkin :-
serviceManager.DocumentService.CheckinUploadedFile(selectedFile.MasterId, "Changed", false,
//System.IO.File.GetLastWriteTime(filepath)
System.DateTime.Now, null, null, false,
null, FileClassification.None, false, array);
If I want to use checkin API , I need to call CheckoutFile API for getting array value.
Still not able to solve the issue.
Is mechanism for checkin is also changed in Vault 2014 like checkout. If these is the case , Please suggest me correct API for Checkin file.
Also suggest me what are the steps to update user defined property value in Vault 2014.
Thanks
Thanks Doug for previous solution. It works .
But we are facing following issue now.
We are trying to change the properties of any ipt(Part) or idw(Drawing) file in Vault.
We are doing following steps :
1. Check out the file which we want to modify.
Code to chekout file :-
VDF.Vault.Settings.AcquireFilesSettings settings ;
VDF.Vault.Currency.Connections.Connection Conn ;
settings.AddFileToAcquire(selectedFile, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout);
VDF.Vault.Results.AcquireFilesResults result = Conn.FileManager.AcquireFiles(settings);
We get the checked out file from result. We are using checked out file to modify the attributes .(Please suggest, Is our **** ?)
2. Modify the attribute value and Update the value of any property of file.
API to updating file
Service1.ServiceManager.DocumentService.UpdateFileProperties(new long[] { checkedOutFiles.FirstOrDefault().File.EntityMasterId },
new long[] { attribute.Id }, new object[] { "xyz"});
3. Chekin that file.
File checkedinFile = Service1.ServiceManager.DocumentService.CheckinUploadedFile(checkedOutFiles.FirstOrDefault().File.EntityMasterId, "Changed Property value", false, System.DateTime.Now, null, null, false, null, FileClassification.None, false, null);
Now , problem statement is :-
We are doing all the following scenarios through code.
1. When we are checkin the checked out file, "ID" of that file is getting changed. Also if we chekcin the associated file (if any idw file is associated with part file) id of that file is also changing.
2. Prior to chekin the file, we are able to see the relation between part and drawing file. But after checkin part and drawing file, relation between both files does not exist anymore.
If I serach for association of chekin Part file, I am not getting its associated files.
3. If we checkin only Part file not the associated drawing file, in that case we are getting its association properly.
Refer attached image named "Association.png" which shows relation between part and drawing file.
Please let me know if anyone has faceed such kind of issue. OR Correct us if we are following wrong steps ?
Regards,
tadakeg.
For finding Association we are using following API :
FileAssocArray[] associationArrays = serviceManager.DocumentService.GetLatestFileAssociationsByMasterIds(
new long[] { selectedFile.MasterId },
FileAssociationTypeEnum.All, true, // parent associations
FileAssociationTypeEnum.All, true, true, // child associations
false, true);
The associations can change for each version, so you need to re-specify the file associations when you check in. You only need to pass in the associations one level down.
I suggest using GetFileAssociationsByIds to find the existing associations. Then use that result to pass in to CheckIn(). You will need to convert from FileAssoc to FileAssocParam, but it's an easy conversion.
How to re-specify the file associations while check in ?
Can you clarify on the below statement :-
"You only need to pass in the associations one level down". What is exactly means ?
Please elaborate it.
Rergads,
Gauri
If you have many levels in your assembly tree, you only need to specify the direct relationships.
For example, in the attached image, if I'm updating the file "Grandpa", the check-in function should only pass in the relationships to "Dad1" and "Dad2". It should not pass in anything about "Son1" or "Son2".
I would recommend using GetFileAssociationLitesByIds (which was new in 2014).
Use Actual for the associationAlgorithm parameter. Do not use Latest for this workflow.
As Doug suggested, you should get the children, but you do not want to recurse for children of your children. You do not need to get parents (nor recurse for them). If you do you will need to filter them out or you will get self-dependency/circular-dependency errors during check-in.
Finally, you should include library and hidden files, but you don't need related documents.
Therefore the call should look something like:
serviceManager.DocumentService.GetFileAssociationLitesByIds(
selectedFile.Id,
FileAssocAlg.Actual,
/*parentAssociationType*/FileAssociationTypeEnum.None, /*parentRecurse*/false,
/*childAssociationType*/FileAssociationTypeEnum.All, /*childRecurse*/false,
/*includeLibraryFiles*/true,
/*includeRelatedDocuments*/false,
/*includeHidden*/true
);
-Dave
Hi Doug and Dev,
I got some understanding from this Image.
But what if I want to update Grandpa As well as Dad1. What is the proper steps to update its attributes and chekin both the files ?
In my case Grandpa is Part and Dad1 is Drawing file.
Regards,
Gauri.
Hi Doug and Dave,
I'm obviously missing something,
I'm using the Acquire file mecanism to download / check-out a file,
then the DocumentService.UpdateFileProperties method to update a property,
and DocumentService.CheckinUploadedFile to check it in back.
Snippet
Dim oFileIteration As New FileIteration(ActiveConnection, oFile)
Dim result As AcquireFilesResults = CheckOut(oFileIteration)
Dim checkedFile as Autodesk.Connectivity.WebService.File = result.FileResults(0).File
ServiceManager.DocumentService.UpdateFileProperties (New Long() {checkedFile.MasterId}, New Long() {propertyDefId}, New Object() {sValue})
ServiceManager.DocumentService.CheckinUploadedFile (checkedFile.MasterId, "test", False, DateTime.Now, Nothing, Nothing, True, checkedFile.Name, checkedFile.FileClass, checkedFile.Hidden, Nothing) 'oBytesArray)
Something is wrong in the check-in part because after this code is executed, the property is not changed.
If I specify the BytesArray for CheckInUploadedFile, an exception is thrown, the file stay in check out and the property is changed.
I also tried to use the FileIteration object, because the File object in FileResult does not indicate check out information, without success.
Any advice on the check-in part would be very useful,
After the check-in, the file need to be refreshed, is it normal?
Thanks,
Francis Harvey