|
7 | 7 | using ACW = Autodesk.Connectivity.WebServices;
|
8 | 8 | using VDF = Autodesk.DataManagement.Client.Framework;
|
9 | 9 | using VltBase = Connectivity.Application.VaultBase;
|
| 10 | +using Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties; |
10 | 11 |
|
11 | 12 | namespace QuickstartiLogicLibrary
|
12 | 13 | {
|
@@ -58,6 +59,7 @@ public VDF.Vault.Currency.Connections.Connection GetVaultConnection()
|
58 | 59 | return null;
|
59 | 60 | }
|
60 | 61 |
|
| 62 | + /// <summary> |
61 | 63 | /// Adds local file to Vault.
|
62 | 64 | /// </summary>
|
63 | 65 | /// <param name="FullFileName">File path and name of file to add in local working folder.</param>
|
@@ -299,7 +301,10 @@ public string GetFileByFullFilePath(string VaultFullFileName, ref Dictionary<str
|
299 | 301 |
|
300 | 302 |
|
301 | 303 | /// <summary>
|
302 |
| - /// |
| 304 | + /// Downloads Vault file using full file path, e.g. "$/Designs/Base.ipt". Returns full file name in local working folder(download enforces override, if local file exists), |
| 305 | + /// returns nothing if the file does not exist at indicated location. |
| 306 | + /// File and Item property dictionaries return all values converted to text. Access the value using the Vault property display name as key. |
| 307 | + /// Preset Options: Download Children (recursively) = Enabled, Enforce Overwrite = True |
303 | 308 | /// </summary>
|
304 | 309 | /// <param name="VaultFullFileName"></param>
|
305 | 310 | /// <param name="VaultFileProperties"></param>
|
@@ -363,6 +368,59 @@ public string GetFileByFullFilePath(string VaultFullFileName, ref Dictionary<str
|
363 | 368 | return null;
|
364 | 369 | }
|
365 | 370 |
|
| 371 | + |
| 372 | + /// <summary> |
| 373 | + /// Get the local file's status in Vault. Validate the ErrorState = "None" to get all return values. |
| 374 | + /// </summary> |
| 375 | + /// <param name="LocalFullFileName">Local path and file name, e.g., ThisDoc.FullFileName</param> |
| 376 | + /// <returns>ErrorState only if file does not exist, otherwise CheckOutState, ConsumableState, ErrorState, LocalEditsState, LockState, RevisionState, VersionState</returns> |
| 377 | + public Dictionary<string, string> GetVaultFileStatus(string LocalFullFileName) |
| 378 | + { |
| 379 | + Dictionary<string, string> keyValues = new Dictionary<string, string>(); |
| 380 | + |
| 381 | + //convert the local path to the corresponding Vault path |
| 382 | + string FileName = null; |
| 383 | + System.IO.FileInfo fileInfo = new System.IO.FileInfo(LocalFullFileName); |
| 384 | + if (fileInfo.Exists) |
| 385 | + { |
| 386 | + FileName = fileInfo.Name; |
| 387 | + } |
| 388 | + else |
| 389 | + { |
| 390 | + keyValues.Add("ErrorState", "Local file not found"); |
| 391 | + return keyValues; |
| 392 | + } |
| 393 | + string VaultFilePath = ConvertLocalPathToVaultPath(LocalFullFileName) + "/" + FileName; |
| 394 | + |
| 395 | + //get the file object consuming the Vault Path; if the file does not exist return the file-non-exist status information |
| 396 | + Autodesk.Connectivity.WebServicesTools.WebServiceManager mWsMgr = conn.WebServiceManager; |
| 397 | + ACW.File mFile = mWsMgr.DocumentService.FindLatestFilesByPaths(new string[] { VaultFilePath }).FirstOrDefault(); |
| 398 | + |
| 399 | + if (mFile.Id == -1)// file not found |
| 400 | + { |
| 401 | + keyValues.Add("ErrorState", "File does not exist in Vault."); |
| 402 | + return keyValues; |
| 403 | + } |
| 404 | + |
| 405 | + VDF.Vault.Currency.Entities.FileIteration mFileIteration = new VDF.Vault.Currency.Entities.FileIteration(conn, mFile); |
| 406 | + |
| 407 | + PropertyDefinitionDictionary mProps = conn.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, null, PropertyDefinitionFilter.IncludeAll); |
| 408 | + |
| 409 | + PropertyDefinition mVaultStatus = mProps[PropertyDefinitionIds.Client.VaultStatus]; |
| 410 | + |
| 411 | + EntityStatusImageInfo status = conn.PropertyManager.GetPropertyValue(mFileIteration, mVaultStatus, null) as EntityStatusImageInfo; |
| 412 | + |
| 413 | + keyValues.Add("CheckOutState", status.Status.CheckoutState.ToString()); |
| 414 | + keyValues.Add("ConsumableState", status.Status.ConsumableState.ToString()); |
| 415 | + keyValues.Add("ErrorState", status.Status.ErrorState.ToString()); |
| 416 | + keyValues.Add("LocalEditsState", status.Status.LocalEditsState.ToString()); |
| 417 | + keyValues.Add("LockState", status.Status.LockState.ToString()); |
| 418 | + keyValues.Add("RevisionState", status.Status.RevisionState.ToString()); |
| 419 | + keyValues.Add("VersionState", status.Status.VersionState.ToString()); |
| 420 | + |
| 421 | + return keyValues; |
| 422 | + } |
| 423 | + |
366 | 424 | /// <summary>
|
367 | 425 | /// Copy Vault file on file server and download using full file path, e.g. "$/Designs/Base.ipt".
|
368 | 426 | /// Create new file name using default or named numbering scheme.
|
|
0 commit comments