Vault Customization

Reply
Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 1 of 19 (611 Views)
Accepted Solution

Update Attachment

611 Views, 18 Replies
01-29-2013 12:45 AM

Hello,

I am using Vault Professional 2013 and customzing using C#. I am stuck up with updating issue.

 

Problem: My current problem is to update only attachment file, not the original file.

 

Lets consider we have dwg file and its assiciated dwf. I download this dwf make certain changes and upload to vault.

 

How to update only attachment file.

 

 

Regards

Amit

Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 2 of 19 (599 Views)

Re: Update Attachment

01-30-2013 05:15 AM in reply to: amitk_189

You check out the attachment, make your updates on disk, and check in the attachment.



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 3 of 19 (594 Views)

Re: Update Attachment

01-30-2013 08:37 PM in reply to: amitk_189

Thanks for reply Doug, I actually did this but the associativity between dwg and dwf is lost.

 

When i click in dwg it won't display this preview. Can you suggest me some methods on how to do this.

 

 

Rgds

Amit

Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 4 of 19 (578 Views)

Re: Update Attachment

01-31-2013 04:38 AM in reply to: amitk_189

What does your check-in code look like?  Are you keeping the same classification and hidden values?



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 5 of 19 (573 Views)

Re: Update Attachment

01-31-2013 09:57 AM in reply to: amitk_189

This is my code for checkin

 

I refered from this below link and made some modification to suit my requirement

 

http://adndevblog.typepad.com/manufacturing/2012/06/using-vault-apis-to-check-inout-files-from-an-in...

 

 

// Check in the file
public Autodesk.Connectivity.WebServices.File Checkin(Autodesk.Connectivity.WebServices.File file, FileClassification fileClassification, Boolean hidden)

{
Autodesk.Connectivity.WebServices.File retFile = null;
string filePath = Path.Combine(kCheckOutPath, file.Name);

using (FileStream stream = new FileStream(filePath, FileMode.Open,FileAccess.Read))
{
byte[] fileData = new byte[stream.Length];
stream.Read(fileData, 0, fileData.Length);

ByteArray IFileData=new ByteArray();
IFileData.Bytes=new byte[stream.Length];
stream.Read(IFileData.Bytes, 0, IFileData.Bytes.Length);
// Perform the upload

 

if (fileClassification == FileClassification.DesignVisualization)
{
retFile = mgr.DocumentService.CheckinFile(file.MasterId, "",false, System.IO.File.GetLastWriteTime(filePath),null , null, false,file.Name, file.FileClass, hidden, IFileData);

for (int i = 0; i < fileAssocParamList.Count; i++)
{
FileAssocParam param1 = (FileAssocParam)fileAssocParamList[i];
if (param1.CldFileId == file.Id)
{
param1.CldFileId = retFile.Id;
}
}
System.IO.FileAttributes attr = System.IO.File.GetAttributes(filePath);
//the local file can't be read only.
if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
{
System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
}
}
else
{
// Get bom
Autodesk.Connectivity.WebServices.BOM tbom =mgr.DocumentService.GetBOMByFileId(file.Id);

FileAssocParam[] paramArray = (FileAssocParam[])fileAssocParamList.ToArray(typeof(FileAssocParam));

//retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm,false, System.IO.File.GetLastWriteTime(filePath),paramArray, tbom, true,file.Name, file.FileClass, hidden, IFileData);
retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm, false, System.IO.File.GetLastWriteTime(filePath), paramArray, tbom, true, file.Name, file.FileClass, hidden, IFileData);
if (System.IO.File.Exists(filePath) == true)
{
System.IO.FileAttributes attr =
System.IO.File.GetAttributes(filePath);

//the local file can't be read only.
if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
{
System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
}
}
}


}

return retFile;
}

 

 

Thanks and Regards

Amit

Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 6 of 19 (568 Views)

Re: Update Attachment

01-31-2013 12:40 PM in reply to: amitk_189

That code looks correct to me.  The next thing to try is AddDesignVisualizationFileAttachment.  Use that function to create a new link from the parent DWG to your new DWF version.



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 7 of 19 (563 Views)

Re: Update Attachment

01-31-2013 08:56 PM in reply to: amitk_189

Ok Doug, thanks for information. I will work on it and get back to you.

 

 

Rgds

Amit

Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 8 of 19 (555 Views)

Re: Update Attachment

02-01-2013 02:21 AM in reply to: Redmond.D

No Doug, i am not able to use AddDesignVisualizationFileAttachment. I am still under confusion on how to achieve this. 

Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 9 of 19 (549 Views)

Re: Update Attachment

02-01-2013 04:20 AM in reply to: amitk_189

You need to be more specific.  Are you getting an error when using AddDesignVisualizationFileAttachment?  Are you confused on what to pass in?



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Mentor
amitk_189
Posts: 234
Registered: ‎12-15-2011
Message 10 of 19 (545 Views)

Re: Update Attachment

02-01-2013 07:45 AM in reply to: amitk_189

Yes Doug, you are absolutely right I am getting confused on what to pass.

I tried to get AddDesignVisualizationFileAttachment in place of FileDesignVisualization, but the object doesn't exists. What exactly should i pass to methods.

 

 

Rgds

Amit

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community