Community
Vault Forum
Welcome to Autodesk’s Vault Forums. Share your knowledge, ask questions, and explore popular Vault topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Out of date after check in - API

10 REPLIES 10
Reply
Message 1 of 11
joerituijn
766 Views, 10 Replies

Out of date after check in - API

Hi,

If I do this:

DocSvc.AddFile(Folder.Id, IO.Path.GetFileName(FileName), Comments, System.IO.File.GetLastWriteTime(FileName), DFIDS, DSRCS, ATTIDS, ATTSRC, Bom, DocumentSvc.FileClassification.None, Hidden, bytes)

(Vault 2010)

the checked in file is out of date (newer) right away. How can I prevent this? The same happens when I perform a checkin.

Regards,
Joeri
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: joerituijn

The code you posted looks fine. It's possible that the bits are not
correct. I suggest using System.IO.File.ReadAllBytes.
Another thing you might want to do is set the local file to read-only before
calling the upload function.

You say that "The same happens when I perform a checkin". Do you mean that
if you check in through Vault Explorer or the CAD application? If so, than
the problem is not related to your API code.

--
Doug Redmond
Software Engineer, Autodesk Inc.
http://justonesandzeros.typepad.com/
Message 3 of 11
joerituijn
in reply to: joerituijn

Hi Doug,

Thanks for your reply, I use both the 'addfile' and 'checkinfile' functionality:

Dim FI As New IO.FileInfo(FileName)
FI.IsReadOnly = True
F = DocSvc.AddFile(Folder.Id, IO.Path.GetFileName(FileName), Comments, FI.LastWriteTimeUtc, DFIDS, DSRCS, ATTIDS, ATTSRC, BOM, DocumentSvc.FileClassification.None, Hidden, IO.File.ReadAllBytes(FileName))

Dim FI As New IO.FileInfo(FileName)
FI.IsReadOnly = True
F = DocSvc.CheckinFile(F.MasterId, Comments, KeepCheckedOut, FI.LastWriteTime, DFIDS, DSRCS, ATTIDS, ATTSRC, BOM, False, "", F.FileClass, F.Hidden, IO.File.ReadAllBytes(FileName))

Both methods cause the same issue, right after check in the checked in file is out of date (local copy newer). The files are read-only before check in (I've tried after check in as well). The checksums are the same and so is the file size. I'm a bit lost here... It all worked smooth in Vault2009, but now that we've gone to 2010 it doesn't. So something must have changed?
Message 4 of 11
Rene-J
in reply to: joerituijn

The create date of the file needs to match the check-in Date/Time of the
version.

Dim F As DocumentSvc.File

Dim FI As New IO.FileInfo(FileName)
FI.IsReadOnly = True
F = DocSvc.AddFile(Folder.Id, IO.Path.GetFileName(FileName), Comments, FI.LastWriteTimeUtc, DFIDS, DSRCS, ATTIDS, ATTSRC, BOM, DocumentSvc.FileClassification.None, Hidden, IO.File.ReadAllBytes(FileName))

Dim FI As New IO.FileInfo(FileName)
FI.IsReadOnly = True
F = DocSvc.CheckinFile(F.MasterId, Comments, KeepCheckedOut, FI.LastWriteTime, DFIDS, DSRCS, ATTIDS, ATTSRC, BOM, False, "", F.FileClass, F.Hidden, IO.File.ReadAllBytes(FileName))

After checkin file or add file
Change the files create date to check-in Date/Time of the
version.

If System.IO.File.Exists(FileName) = True Then
System.IO.File.SetAttributes(FileName, FileAttributes.Normal)
System.IO.File.SetCreationTime(FileName, F.CkInDate)
System.IO.File.SetAttributes(FileName, FileAttributes.ReadOnly)
End If

René J
Message 5 of 11
joerituijn
in reply to: joerituijn

That's it! Thanks a lot!
Message 6 of 11
Johannes0
in reply to: joerituijn

Hello! Thank you very much for this reply - I had exactly the same problem and this solved it.

One additional comment from my side: We took lots of efforts to get Vault connected from Java (using Apache AXIS 1.3 after testing several other frameworks). We survived from Vault4, 5, ... to 2009 Tower including MIME and DIME, WSE2 and 3, etc.
This is now finally the first time Java failed: There is simply no Java API to modify the creation date of a local file. So we needed an non Java workaround here 😞
Message 7 of 11
joerituijn
in reply to: Rene-J

I have the same issue again, this time in Vault2012 and Vault2011. What are the conditions for a file to be up to date? I keep getting the out of date symbol in Vault when I use download latest. It is no longer enough to just set the creation time. Please help!

 

 

Message 8 of 11
Redmond.D
in reply to: joerituijn

The creation date and the read-only bit should be the only 2 things you need to set.  Here is an article on the topic, with code samples included.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 9 of 11
joerituijn
in reply to: joerituijn

Isn't that weird?

I used this:

 

IO.File.SetCreationTime(FileName, File.CreateDate)               

IO.File.SetAttributes(FileName, IO.FileAttributes.ReadOnly)

 

Which gave me that remark that the local file was different.

 

Now I use this (from your website):

 

Dim info As System.IO.FileInfo = NewFileInfo(localPath) 

info.CreationTime = file.CreateDate 

info.Attributes = info.Attributes OrFileAttributes.[ReadOnly] 

 

And now it works?! Beats me... Thanks anyway!


 


 

Message 10 of 11
Redmond.D
in reply to: joerituijn

IO.File.SetAttributes(FileName, IO.FileAttributes.ReadOnly)

 

... is not the same as ...

 

info.Attributes = info.Attributes Or FileAttributes.[ReadOnly]

 



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 11 of 11
joerituijn
in reply to: joerituijn

True, it's not. I just copied and tested the code from Rene-j which worked. I never looked long enough at the code to realize that I removed all attributes except for one. But the first quick try out worked and I never looked at it again. It worked fine for 2010, but not for 2011 or 2012, so why does that differ for Vault? Are there other attributes that a file should have? 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report