I am trying to do a catch on the Vault Change order, when the user hits submit, I need a validation code to run. The question comes up how do I identify the Change order selected when the right click is used to move to submit? And how do I catch the Change order when using the Change Order Dialogue and then hit submit. The CurrentSelectionSet does not work on the command.
Dim vaultObj As ISelection In m_Conn.Context.CurrentSelectionSet
Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
vApp = application
AddHandler application.CommandBegin, AddressOf application_CommandBegin
End Sub
Private Sub application_CommandBegin(sender As Object, e As CommandBeginEventArgs)
Dim m_Conn As Connection = sender.Connection
If e.CommandId = "CO.Submit" Then
'do something
End If
End Sub
I am trying to do a catch on the Vault Change order, when the user hits submit, I need a validation code to run. The question comes up how do I identify the Change order selected when the right click is used to move to submit? And how do I catch the Change order when using the Change Order Dialogue and then hit submit. The CurrentSelectionSet does not work on the command.
Dim vaultObj As ISelection In m_Conn.Context.CurrentSelectionSet
Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
vApp = application
AddHandler application.CommandBegin, AddressOf application_CommandBegin
End Sub
Private Sub application_CommandBegin(sender As Object, e As CommandBeginEventArgs)
Dim m_Conn As Connection = sender.Connection
If e.CommandId = "CO.Submit" Then
'do something
End If
End Sub
You could try using the PreInvokeEvents and PostInvokeEvents of the ChangeOrderService.
public void OnLogOn(IApplication application)
{
application.Connection.WebServiceManager.ChangeOrderService.PreInvokeEvents += ChangeOrderService_PreInvokeEvents;
application.Connection.WebServiceManager.ChangeOrderService.PostInvokeEvents += ChangeOrderService_PostInvokeEvents;
}
In your Pre and Post events use the MethodName parameter to identify the method that Vault is calling to filter out what you want to handle, in your case "StartChangeOrderActivity" and "CommitChangeOrderActivity" would probably be what you're looking for.
private void ChangeOrderService_PreInvokeEvents(object sender, WebServiceInvokeEventArgs e)
{
switch (e.MethodName)
{
case "StartChangeOrderActivity":
/* Do some stuff before the call.. */
break;
case "CommitChangeOrderActivity":
/* Do some stuff before the call.. */
break;
}
}
private void ChangeOrderService_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
{
switch (e.MethodName)
{
case "StartChangeOrderActivity":
/* Do some stuff after the call.. */
break;
case "CommitChangeOrderActivity":
/* Do some stuff after the call.. */
break;
}
}
StartChangeOrderActivity and CommitChangeOrderActivity get called on any change order activity, so you'll want to use the e.Parameters property to further filter down to the exact state you want to handle by its ID.
Double check this, but I think the parameters always in the following order:
[0] Change Order ID
[1] To State ID
[2] From State ID
[3] Creation Date (Only populated after moving to Work state, I think?)
Hope that at least points you in the right direction.
You could try using the PreInvokeEvents and PostInvokeEvents of the ChangeOrderService.
public void OnLogOn(IApplication application)
{
application.Connection.WebServiceManager.ChangeOrderService.PreInvokeEvents += ChangeOrderService_PreInvokeEvents;
application.Connection.WebServiceManager.ChangeOrderService.PostInvokeEvents += ChangeOrderService_PostInvokeEvents;
}
In your Pre and Post events use the MethodName parameter to identify the method that Vault is calling to filter out what you want to handle, in your case "StartChangeOrderActivity" and "CommitChangeOrderActivity" would probably be what you're looking for.
private void ChangeOrderService_PreInvokeEvents(object sender, WebServiceInvokeEventArgs e)
{
switch (e.MethodName)
{
case "StartChangeOrderActivity":
/* Do some stuff before the call.. */
break;
case "CommitChangeOrderActivity":
/* Do some stuff before the call.. */
break;
}
}
private void ChangeOrderService_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
{
switch (e.MethodName)
{
case "StartChangeOrderActivity":
/* Do some stuff after the call.. */
break;
case "CommitChangeOrderActivity":
/* Do some stuff after the call.. */
break;
}
}
StartChangeOrderActivity and CommitChangeOrderActivity get called on any change order activity, so you'll want to use the e.Parameters property to further filter down to the exact state you want to handle by its ID.
Double check this, but I think the parameters always in the following order:
[0] Change Order ID
[1] To State ID
[2] From State ID
[3] Creation Date (Only populated after moving to Work state, I think?)
Hope that at least points you in the right direction.
I went another direction. But having trouble when the ChangeOrder changes it fires UpdateFileLifecycleStateEvents_GetRestrictions twice and then the Post twice also. Cannot Identify why it is doubling. Any thoughts.
Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.GetRestrictions, AddressOf UpdateChangeOrderLifeCycleStateEvents_GetRestrictions
AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.Post, AddressOf UpdateFileLifecycleStateEvents_Post
End Sub
Public Sub UpdateChangeOrderLifeCycleStateEvents_GetRestrictions(ByVal s As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
If s.GetChangeOrdersByIds({e.ChangeOrderId})(0).statename = "Open" Then 'Submit to Work
CheckChangeOrderFilesForState(s, e, "Work", "Release") 'Special Case
End If
End Sub
Sub CheckChangeOrderFilesForState(s As Object, ByVal eventArgs As UpdateChangeOrderLifeCycleStateCommandEventArgs, ECOnewState As String, FileStateCheck As String)
If IsNothing(webMgr) Then
webMgr = s.WebServiceManager
End If
Dim oFileIds() As Long = webMgr.ChangeOrderService.GetAssociationsByChangeOrderIDs({eventArgs.ChangeOrderId}, EntityClassIds.Files)(0).EntIdArray
For Each ofile As ACW.File In webMgr.DocumentService.GetFilesByIds(oFileIds)
If ofile.FileLfCyc.LfCycStateName <> FileStateCheck And ofile.FileLfCyc.LfCycStateName <> "Release" Then
eventArgs.AddRestriction(New ExtensionRestriction(oChangeOrder.Num, String.Format("The Change Order cannot be ""{0}"" because all of the files are not in" & " the ""{1}"" state.", ECOnewState, FileStateCheck)))
GoTo exitSub
End If
Next
exitSub:
End Sub
Sub UpdateFileLifecycleStateEvents_Post(ByVal sender As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
Dim msgForm As New msgBuilder
msgBuilder.ShowDialog()
msgBuilder.Close()
End Sub
I went another direction. But having trouble when the ChangeOrder changes it fires UpdateFileLifecycleStateEvents_GetRestrictions twice and then the Post twice also. Cannot Identify why it is doubling. Any thoughts.
Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.GetRestrictions, AddressOf UpdateChangeOrderLifeCycleStateEvents_GetRestrictions
AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.Post, AddressOf UpdateFileLifecycleStateEvents_Post
End Sub
Public Sub UpdateChangeOrderLifeCycleStateEvents_GetRestrictions(ByVal s As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
If s.GetChangeOrdersByIds({e.ChangeOrderId})(0).statename = "Open" Then 'Submit to Work
CheckChangeOrderFilesForState(s, e, "Work", "Release") 'Special Case
End If
End Sub
Sub CheckChangeOrderFilesForState(s As Object, ByVal eventArgs As UpdateChangeOrderLifeCycleStateCommandEventArgs, ECOnewState As String, FileStateCheck As String)
If IsNothing(webMgr) Then
webMgr = s.WebServiceManager
End If
Dim oFileIds() As Long = webMgr.ChangeOrderService.GetAssociationsByChangeOrderIDs({eventArgs.ChangeOrderId}, EntityClassIds.Files)(0).EntIdArray
For Each ofile As ACW.File In webMgr.DocumentService.GetFilesByIds(oFileIds)
If ofile.FileLfCyc.LfCycStateName <> FileStateCheck And ofile.FileLfCyc.LfCycStateName <> "Release" Then
eventArgs.AddRestriction(New ExtensionRestriction(oChangeOrder.Num, String.Format("The Change Order cannot be ""{0}"" because all of the files are not in" & " the ""{1}"" state.", ECOnewState, FileStateCheck)))
GoTo exitSub
End If
Next
exitSub:
End Sub
Sub UpdateFileLifecycleStateEvents_Post(ByVal sender As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
Dim msgForm As New msgBuilder
msgBuilder.ShowDialog()
msgBuilder.Close()
End Sub
I use Fiddler a lot to track Vault API calls and I can tell you the double calling seems to be a very common occurrence. My only assumption is that it could be somehow related to the pre and post events, but to me the call should still only happen once; especially on a method that posts changes to the server. Sorry I don't have more of an answer on this one.
I use Fiddler a lot to track Vault API calls and I can tell you the double calling seems to be a very common occurrence. My only assumption is that it could be somehow related to the pre and post events, but to me the call should still only happen once; especially on a method that posts changes to the server. Sorry I don't have more of an answer on this one.
Thank you, never used Fiddler before but seems very powerful and helpful. I am looking forward to trying to use it with Vault and Programming. Even with Fiddler I cannot seem to find out why the call is doing a double call. Thank you for your help. I am just going to have to do a workaround somehow.
Thank you, never used Fiddler before but seems very powerful and helpful. I am looking forward to trying to use it with Vault and Programming. Even with Fiddler I cannot seem to find out why the call is doing a double call. Thank you for your help. I am just going to have to do a workaround somehow.
Won't really help you with this issue, but if you're interested in using Fiddler for future Vault development, I'm creating a Fiddler extension that helps track info about Vault API calls. It's still in development, but I can post a link here once it's done. It will be free to use and will only be supported via donations.
Won't really help you with this issue, but if you're interested in using Fiddler for future Vault development, I'm creating a Fiddler extension that helps track info about Vault API calls. It's still in development, but I can post a link here once it's done. It will be free to use and will only be supported via donations.
Can't find what you're looking for? Ask the community or share your knowledge.