Just in case - I'm a complete newbie to both PowerShell and Vault API.
I'd like to write script that would warn Vault user about some bad things.
First thing came to my mind that worth to bother - system-controlled status for visualisation.
AFAIK there is no way to prevent user from uploading own visualisation to Inventor or AutoCAD files, right?
But let imagine that one of vault admins goal is to provide system-controlled DWF for each and every CAD-file. And believe me I'm a bit fed up to controll this manually.
Some users don't mind admins recomendations and forget to switchON "send to Job Server" option, some files can't be DWFed due to errors and thus would be removed from job-queue by Q-tools, files that were changed inside Vault usualy don't get their DWF auto-created. So there are destructive tendetion to be fixed.
I'd like my script found all CAD files that:
a) were uploaded by particular user (that, who are logged in).
b) don't have system-controlled visualisation (DWF).
c) don't have job of type "Create.DWF" and status "Pending" in the Job Queue.
I've at least two "stuck places":
1) "ALL files". Files are not in the same folder thus I wonder if I should use recursion to gather them in one list or if there some easier/faster/smarter way?
2) How to get list of Jobs from Job Server?
Thanks in advance.
PS: I'd like my script generate warning (WARNING, this database contain ## inventor documents of <username> responsibility that neither have system-controlled visualisation nor waiting their order to be DWFed. It is highly recommended that you add Create.DWF task for these files.) just before user log-out, if possible.
If there is no ready utility for doing what you are looking for, then you have to use Vault API to do the customization. I'd suggest you to use Visual Studio .NET to write the code, because it has more functionalities, especially debugging related tools, that are very helpful for the programmer, but PowerShell has not. I don't know if PowerShell can provide a warning dialog to the UI, you can search Internet for the answers.
To detect if the DWF is in system controlled status, you can check the design file (in Vault) property "DwsignVisAttmtStatus", for example:
if (myFile.DesignVisAttmtStatus == DesignVisualizationAttachmentStatus.NotSyncronized
//you will see this warnng in Vault: "Warning: This visualization file is not a system controlledvisualization file. Use //Update View."
You want to know all files' status, so your code can use Vault API GetFolderRoot to get the root folder, then call GetFoldersByParentId method to get every subfolders.The second parameter to GetFoldersByParentId is a recurse parameter.So you can get all folders with just 2 API calls:
Folder root = docSvc.GetFolderRoot();
Folder folders = docSvc.GetFoldersByParentId( root.Id,true);
After this, you can call GetLatestFilesByFolderId to get all files.
jobs can be obtains by GetJobsByDate from JobService, e.g.:
Dim jobs() As Job = serviceManager.JobService.GetJobsByDate(100, DateTime.MinValue)
Vault SDK has a sample demonstrating how to use JobService API, you can start from there.
Some articles in Vault API help document are very worthy to read, for example "Handling Exceptions in Your Custom Command", which tells a good programming practice. I would suggest you to view them before you starts to write program.
Since "visualization Attachment" is a property you can search on. Using DocumentService.FindFilesBySearchConditions is a much better way to find your files than scanning though all the folders.
I saw your comment on my blog. I'll try to get some example scripts posted by the end of the week.
Access a broad range of knowledge to help get the most out of your products and services.
Download & InstallationGetting your Software