Community
Imports Autodesk.DataManagement.Client.Framework.Vault Imports Autodesk.Connectivity.WebServices Imports VDF = Autodesk.DataManagement.Client.Framework Imports ACW = Autodesk.Connectivity.WebServices Imports AWS = Autodesk.Connectivity.WebServices Imports VB = Connectivity.Application.VaultBase Imports Autodesk.DataManagement.Client.Framework.Vault.Currency AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll" AddReference "Autodesk.DataManagement.Client.Framework.dll" AddReference "Connectivity.Application.VaultBase.dll" AddReference "Autodesk.Connectivity.WebServices.dll"
Dim oFilePath As String = ThisDoc.Document.FullDocumentName Dim oVaultConnection As VDF.Vault.Currency.Connections.Connection oVaultConnection = VB.ConnectionManager.Instance.Connection If oVaultConnection Is Nothing Then MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.") Exit Sub End If VaultPath = oFilePath.Replace("C:\VaultWS\", "$/") VaultPath = VaultPath.Replace("\", "/") Dim VaultPaths() As String = New String() {VaultPath } Dim wsFiels() As AWS.File = oVaultConnection.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths) Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(oVaultConnection, wsFiels(0)) If mFileIt.LifecycleInfo.StateId = 22 Then '22 = released Logger.Info("Drawing already released. Exiting rule.") Return End If If mFileIt.IsCheckedOut = True Then Logger.Info("Drawing checked out. Drawing must be checked in to release. Exiting rule.") Return End If MessageBox.Show("You are exiting a checked in, WIP drawing. Would you like to release?", "Release?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If result = DialogResult.Yes Then ' Change the lifecycle state to "Released" Else Return End If
Solved! Go to Solution.
Solved by m_baczewski. Go to Solution.
Hi,
In my opinion, you should use the method located in WebServiceManager.DocumentServiceExtensions.UpdateFileLifeCycleStates
I am sharing with you my method, which I wrote to change the lifecycle of a given item in the vault. I also use other methods in it, but I’m sure you’ll understand what it’s about.
public static void UpdateFileState(Connection mVault, string fileName)
{
try
{
LfCycDef[] states = mVault.WebServiceManager.LifeCycleService.GetAllLifeCycleDefinitions();
Dictionary<string, long> dicState = new Dictionary<string, long>();
foreach (LfCycDef state in states)
{
if (state.DispName == "Standardowy cykl zwolnienia plików projektowych")
{
foreach (LfCycState lfState in state.StateArray)
{
dicState.Add(lfState.DispName, lfState.Id);
}
break;
}
}
File[] files = FilesInFolder.GetFilesIdFromFolder(mVault, fileName);
List<long> filesToChangeState = new List<long>();
List<long> stateIds = new List<long>();
foreach (File file in files)
{
filesToChangeState.Add(long.Parse(file.MasterId.ToString()));
try
{
stateIds.Add(dicState["Do przeglądu"]);
}
catch
{
throw new Exception("Nieznany typ stanu");
}
}
mVault.WebServiceManager.DocumentServiceExtensions.UpdateFileLifeCycleStates(filesToChangeState.ToArray(), stateIds.ToArray(), "W trakcie przeglądu");
}
catch(Exception ex)
{
throw ex;
}
}
Can't find what you're looking for? Ask the community or share your knowledge.