Vault customization in .net - namespace error

Vault customization in .net - namespace error

Anonymous
Not applicable
1,321 Views
6 Replies
Message 1 of 7

Vault customization in .net - namespace error

Anonymous
Not applicable

Hi,

 

I am upgrading Vault 2014 to Vault 2017. I am working on vault Add ins in .net.

 

Please let me know what is the replacement for Autodesk.Connectivity.Webservices.FixedLycycDef() GetAllLifeCycleDefinitons

 

Thanks,

0 Likes
Accepted solutions (1)
1,322 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Is this what you're looking for?

 

var docservEx = Connection.WebServiceManager.DocumentServiceExtensions;
            
            Autodesk.Connectivity.WebServices.LfCycDef[] LifeCycleArray = docservEx.GetAllLifeCycleDefinitions();
0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for your reply.

Could you please help me with the code below. I am getting error on the line highlighted in red, Idpair and GetLifeCycleStateIdsByFileMasterIds were in the namespace for Vault 2014 but no longer exist in Vault 2017. what would be the replacement for this code. TIA

 

public void ChangeState(List<long> selectedMasterFileIds, string projectValue, long releaseState)

{

try

{

List<File> updatedFileIds = new List<File>();

List<long> filesWithNoOrDifferentLifecycle = new List<long>();

List<long> filesWithBasicLifecycle = new List<long>();

IdPair[] states = util.DocSvcExt.GetLifeCycleStateIdsByFileMasterIds(selectedMasterFileIds.ToArray());

 

 

foreach (IdPair idpair in states)

{

if (util.FileLifeCycleStateMap().ContainsKey(idpair.ValId))

{

filesWithBasicLifecycle.Add(idpair.EntityId);

}

else

{

filesWithNoOrDifferentLifecycle.Add(idpair.EntityId);

}

}

long[] lifecycleStateIds = new long[filesWithNoOrDifferentLifecycle.Count];

long[] lifecycleDefinitionIds = new long[filesWithNoOrDifferentLifecycle.Count];

File[] newVersions = new File[0];

File[] moreNewVersions = new File[0];

if (filesWithNoOrDifferentLifecycle.Count > 0)

{

#region updating files that don't have a lifecycle definition or have a different one from the basic

for (int z = 0; z < lifecycleStateIds.Length; z++)

{

lifecycleStateIds[z] = releaseState;

lifecycleDefinitionIds[z] = util.FileLifeCycleDefinitionMap()["Project Design Lifecycle"].Id;

}

newVersions = util.DocSvcExt.UpdateFileLifeCycleDefinitions(filesWithNoOrDifferentLifecycle.ToArray(), lifecycleDefinitionIds, lifecycleStateIds, projectValue);

#endregion

}

if (filesWithBasicLifecycle.Count > 0)

{

#region updating files that already belong to the basic lifecycle definition or have a different one from the basic

lifecycleStateIds = new long[filesWithBasicLifecycle.Count];

for (int z = 0; z < lifecycleStateIds.Length; z++)

{

lifecycleStateIds[z] = releaseState;

}

moreNewVersions = util.DocSvcExt.UpdateFileLifeCycleStates(filesWithBasicLifecycle.ToArray(), lifecycleStateIds, projectValue);

#endregion

}

}

 

}

 

0 Likes
Message 4 of 7

Anonymous
Not applicable

Thanks for your reply.

Please see my code below using Vault 2014. I am getting error on the line highlighted in red. Idpair and GetLifeCycleStateIdsByFileMasterIds does not exist in Vault 2017 namespaces. What would be the replacement code for this. TIA

 

public void ChangeState(List<long> selectedMasterFileIds, string projectValue, long releaseState)

{

try

{

List<File> updatedFileIds = new List<File>();

List<long> filesWithNoOrDifferentLifecycle = new List<long>();

List<long> filesWithBasicLifecycle = new List<long>();

IdPair[] states = util.DocSvcExt.GetLifeCycleStateIdsByFileMasterIds(selectedMasterFileIds.ToArray());

 

 

foreach (IdPair idpair in states)

{

if (util.FileLifeCycleStateMap().ContainsKey(idpair.ValId))

{

filesWithBasicLifecycle.Add(idpair.EntityId);

}

else

{

filesWithNoOrDifferentLifecycle.Add(idpair.EntityId);

}

}

long[] lifecycleStateIds = new long[filesWithNoOrDifferentLifecycle.Count];

long[] lifecycleDefinitionIds = new long[filesWithNoOrDifferentLifecycle.Count];

File[] newVersions = new File[0];

File[] moreNewVersions = new File[0];

if (filesWithNoOrDifferentLifecycle.Count > 0)

{

#region updating files that don't have a lifecycle definition or have a different one from the basic

for (int z = 0; z < lifecycleStateIds.Length; z++)

{

lifecycleStateIds[z] = releaseState;

lifecycleDefinitionIds[z] = util.FileLifeCycleDefinitionMap()["Project Design Lifecycle"].Id;

}

newVersions = util.DocSvcExt.UpdateFileLifeCycleDefinitions(filesWithNoOrDifferentLifecycle.ToArray(), lifecycleDefinitionIds, lifecycleStateIds, projectValue);

#endregion

}

if (filesWithBasicLifecycle.Count > 0)

{

#region updating files that already belong to the basic lifecycle definition or have a different one from the basic

lifecycleStateIds = new long[filesWithBasicLifecycle.Count];

for (int z = 0; z < lifecycleStateIds.Length; z++)

{

lifecycleStateIds[z] = releaseState;

}

moreNewVersions = util.DocSvcExt.UpdateFileLifeCycleStates(filesWithBasicLifecycle.ToArray(), lifecycleStateIds, projectValue);

#endregion

}

}

 

0 Likes
Message 5 of 7

Anonymous
Not applicable

I'm sorry. I misread your question. I haven't upgraded to Vault 2017 yet, so I can't look it up.

 

If I did have it installed, I'd be looking in the Vault SDK documentation for 2017 (It comes with the install and ends up here: C:\Program Files\Autodesk\Vault Professional 2017\SDK\)? Usually if they deprecate something, they indicate a replacement. My guess is you already tried this.

 

For what it's worth, I never knew this idpair option existed. We just use the command I mentioned above and then get the state for each file. Wish I knew about this feature...before they got rid of it, that is.

0 Likes
Message 6 of 7

psaarloos
Collaborator
Collaborator
Accepted solution

Hi,

 

You should be able to build such a lookup list yourself using Linq. Here is a sample (haven't tested it). You'll need to pass in an array with masterIds.

 

FileArray[] fileArray = VaultCom.Connection.WebServiceManager.DocumentService.GetFilesByMasterIds(new long[] { fileMasterIds });
            Dictionary<long, long> demo = new Dictionary<long, long>();
            demo = fileArray[0].Files.Select(x => new { x.MasterId, x.FileLfCyc.LfCycStateId }).ToDictionary(x => x.MasterId, x => x.LfCycStateId);

 

Hope it helps!

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
Message 7 of 7

Anonymous
Not applicable

Thanks for your reply. I was thinking about the same solution. I will try to implement this and see if it works out.

0 Likes