I read through Doug's blog and reviewed the 2013 SDK RestrictOperations source code on how to hook to certain Vault events. Is there an event for editing user defined properties? I can't seem to find anything under the PropertyService. These are the only events that seem to be available using the Vault 2013 SDK:
// File Events
DocumentService.AddFileEvents.GetRestrictions += new EventHandler<AddFileCommandEventArgs>(AddFileEvents_GetRestrictions);
DocumentService.CheckinFileEvents.GetRestrictions += new EventHandler<CheckinFileCommandEventArgs>(CheckinFileEvents_GetRestrictions);
DocumentService.CheckoutFileEvents.GetRestrictions += new EventHandler<CheckoutFileCommandEventArgs>(CheckoutFileEvents_GetRestrictions);
DocumentService.DeleteFileEvents.GetRestrictions += new EventHandler<DeleteFileCommandEventArgs>(DeleteFileEvents_GetRestrictions);
DocumentService.DownloadFileEvents.GetRestrictions += new EventHandler<DownloadFileCommandEventArgs>(DownloadFileEvents_GetRestrictions);
DocumentServiceExtensions.UpdateFileLifecycleStateEvents.GetRestrictions += new EventHandler<UpdateFileLifeCycleStateCommandEventArgs>(UpdateFileLifecycleStateEvents_GetRestrictions);
// Folder Events
DocumentService.AddFolderEvents.GetRestrictions += new EventHandler<AddFolderCommandEventArgs>(AddFolderEvents_GetRestrictions);
DocumentService.DeleteFolderEvents.GetRestrictions += new EventHandler<DeleteFolderCommandEventArgs>(DeleteFolderEvents_GetRestrictions);
// Item Events
ItemService.AddItemEvents.GetRestrictions += new EventHandler<AddItemCommandEventArgs>(AddItemEvents_GetRestrictions);
ItemService.CommitItemEvents.GetRestrictions += new EventHandler<CommitItemCommandEventArgs>(CommitItemEvents_GetRestrictions);
ItemService.CommitRollbackItemLifeCycleStatesEvents.GetRestrictions += new EventHandler<RollbackItemLifeCycleStateCommandEventArgs>(CommitRollbackItemLifeCycleStatesEvents_GetRestrictions);
ItemService.DeleteItemEvents.GetRestrictions += new EventHandler<DeleteItemCommandEventArgs>(DeleteItemEvents_GetRestrictions);
ItemService.EditItemEvents.GetRestrictions += new EventHandler<EditItemCommandEventArgs>(EditItemEvents_GetRestrictions);
ItemService.PromoteItemEvents.GetRestrictions += new EventHandler<PromoteItemCommandEventArgs>(PromoteItemEvents_GetRestrictions);
ItemService.UpdateItemLifecycleStateEvents.GetRestrictions += new EventHandler<UpdateItemLifeCycleStateCommandEventArgs>(UpdateItemLifecycleStateEvents_GetRestrictions);
// Change Order Events
ChangeOrderService.AddChangeOrderEvents.GetRestrictions += new EventHandler<AddChangeOrderCommandEventArgs>(AddChangeOrderEvents_GetRestrictions);
ChangeOrderService.CommitChangeOrderEvents.GetRestrictions += new EventHandler<CommitChangeOrderCommandEventArgs>(CommitChangeOrderEvents_GetRestrictions);
ChangeOrderService.DeleteChangeOrderEvents.GetRestrictions += new EventHandler<DeleteChangeOrderCommandEventArgs>(DeleteChangeOrderEvents_GetRestrictions);
ChangeOrderService.EditChangeOrderEvents.GetRestrictions += new EventHandler<EditChangeOrderCommandEventArgs>(EditChangeOrderEvents_GetRestrictions);
ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.GetRestrictions += new EventHandler<UpdateChangeOrderLifeCycleStateCommandEventArgs>(UpdateChangeOrderLifecycleStateEvents_GetRestrictions);
// Custom Entity Events
CustomEntityService.UpdateCustomEntityLifecycleStateEvents.GetRestrictions +=new EventHandler<UpdateCustomEntityLifeCycleStateCommandEventArgs>(UpdateCustomEntityLifecycleStateEvents_GetRestrictions);
I was directed to the solution found in this post. What I needed was a hook to the "CommandBegin" event. This may look familiar if you have worked with the API before. Written in C#
publicvoid OnLogOn(IApplication application)
{
application.CommandBegin +=
newEventHandler<CommandBeginEventArgs>(Application_CommandBegin);
application.CommandEnd +=
newEventHandler<CommandEndEventArgs>(Application_CommandEnd);
}
publicvoid Application_CommandBegin(object s, CommandBeginEventArgs e)
{
try
{
if (e.CommandId.Equals("EditProperties"))
{
MessageBox.Show("Begin edit properties command!");
}
}
catch (Exception error)
{
handleException(error);
}
}
publicvoid Application_CommandEnd(object s, CommandEndEventArgs e)
{
try
{
if (e.CommandId.Equals("EditProperties"))
{
MessageBox.Show("End edit properties command!");
}
}
catch (Exception error)
{
handleException(error);
}
}
Hello Jeff,
Yours posts are very interesting ...
I reproduced this too.
However, i don't find how to detect that the "EditProperties" is for example type "Custom Entity" or type "File" etc ...
When i look in Powershell i see :
$vault.CustomEntityService.PostInvokeEvents
ou :
$vault.CustomEntityService.PreInvokeEvents
What is the best way to get the events fired when a "Custom Entity" property is changed ?.
Don't find how to do.
😞
Any help ?
Hi there,
Well unfortunately there isn't a good way to do this for all EntityTypes but for my application I only needed to know when a "File" property edit was in progress. I noticed that a file property edit also performed a file check out/in operation. So using the "Application_CommandBegin" event (which fires first), I was able to detect that a property edit was in progress and set a global variable to reflect that (bool propEditInProgress = true;).
Next, I intercepted the file check-in event:
DocumentService.CheckinFileEvents.GetRestrictions += new EventHandler<CheckinFileCommandEventArgs>(CheckinFileEvents_GetRestrictions);
From here, I checked if my "propEditInProgress" variable was "true" and that gave me enough information to determine if this was a property edit for the entity type "FILE". Unfortunately I haven't found a similar sequence for ITEM, CO or FLDR.
I seem to recall that I then reset the propEditinProgress back to false in the "Application_CommandEnd" event. This is all from my memory, I don't have the source code to review at the moment.
I hope this helps.
You was quick to reply
Thank u very much.
I understand the
So :
1/
if "EditProperties" then bool propEditInProgress = true
2/
DocumentService.CheckinFileEvents.GetRestrictions
---------
This is ok for type FILE.
But with "Custom Entity" there is no second event to know what is going on.
It's really weird. Only Autodesk's experts can help.