Page 1 of 1

FindVersionsByCRCs

Posted: Tue May 26, 2009 6:29 am
by poschdi
Hi,

I wanted to determine the current local file version and I find the FindVersionsByCRCs function.
I tried it with this code:

Code: Select all

FileCRC32 crc = new FileCRC32();
UInt32 icrc = crc.GetCRC(localFile);
VaultClientFile vcf = RepositoryUtil.FindVaultFileAtReposOrLocalPath(repFile);
Int64 version = ServerOperations.client.ClientInstance.FindVersionsByCRCs(vcf.ObjVerID,icrc);
Version was by all tests -1. If I compare the crc32 from this 2 files they are the same.
If the ObjVerID the correct parameter? Or where is my fault?

regards Florian

Re: FindVersionsByCRCs

Posted: Tue May 26, 2009 7:20 am
by shannon
The parameter is the objid not objverid. So you'd want to pass vcf.ID.

However, this function is going to return the ObjVerID, not a user-friendly Version, is that really what you're looking for?

Re: FindVersionsByCRCs

Posted: Tue May 26, 2009 10:50 am
by poschdi
I want to determine which version a local file has. The function name sound good for that. That is the best function to analyse a file and get the versionnumber?

Re: FindVersionsByCRCs

Posted: Tue May 26, 2009 11:02 am
by shannon
I think I need to know more about what you're doing, so that I can better answer your questions. Is there always going to be a working folder set for the item you're looking at? You're basically looking for the number that the GUI client displays in the Local Version column?

Re: FindVersionsByCRCs

Posted: Tue May 26, 2009 3:15 pm
by poschdi
No there isnĀ“t set a working folder. I write a build tool with client and server functions. The client send command to the server with file he should get and build. Now I needed to know which local version is already exists to decide if the server can get this file or if there trouble with other changes. If there exists any function to do that? If not I had to save the latest get version manually.

Re: FindVersionsByCRCs

Posted: Wed May 27, 2009 7:58 am
by shannon
Try something like this:

Code: Select all

FileCRC32 crc = new FileCRC32();
UInt32 icrc = crc.GetCRC(localFile);
VaultClientFile vcf = RepositoryUtil.FindVaultFileAtReposOrLocalPath(repFile);
VaultVersionByCRCRequest[] req = new VaultVersionByCRCRequest[1];
req[0] = new VaultVersionByCRCRequest();
req[0].ObjID = vcf.ID;
req[0].CRC = icrc;

int retval = FindVersionsByCRCs(ref req);
if (retval == VaultStatusCode.Success)
	Int64 version = req[0].FoundVersion;
Note: if it doesn't find a version matching that crc, req.FoundVersion will be -1.

Re: FindVersionsByCRCs

Posted: Thu May 28, 2009 6:48 am
by poschdi
Thy for this code example. I tried it but I get only this compiler error.
The name 'FindVersionsByCRCs' does not exist in the current context
Which assembly is needed for that function?

Re: FindVersionsByCRCs

Posted: Thu May 28, 2009 7:21 am
by shannon
Sorry, add this in front, like you did before:

ServerOperations.client.ClientInstance.

so the line will be this now:

int retval = ServerOperations.client.ClientInstance.FindVersionsByCRCs(ref req);

Re: FindVersionsByCRCs

Posted: Thu May 28, 2009 8:10 am
by poschdi
Sorry I should be able to solve this by my self ;)

I my first tests and it look great. Exactly what I am looking for. Thy very much.

Re: FindVersionsByCRCs

Posted: Thu May 28, 2009 8:19 am
by shannon
Great, sorry for the typo.

If you need more help, let us know.