Hi Dojo
It seems that I'm not able to run an automation script that was launched from a QAction without user interaction.
A web service sets the value of a specific parameter. The value change of that parameter triggers a QAction which launches the automation script. This works fine up until the point where an interaction is needed with the DomHelper class. At that point, a DataMinerSecurityException is thrown. The stack trace is listed down below. Skyline.DataMiner.Net.Exceptions.DataMinerSecurityException: No such remote connection (17fd22f11d). Retried.
Element log
protocol.UserCookie 17FD22F11DDA4B7C8D00DF7CD9C76CF9
protocol.UserInfo Admin
(protocol.GetUserConnection() throws a DataMinerSecurityException: No such remote connection)
Script log
engine.UserLoginName (Script 'Set Request Status')
engine.UserDisplayName Unknown User
engine.UserCookie 17FD22F11DDA4B7C8D00DF7CD9C76CF9
On the other hand, if that automation script gets launched by pressing a button on the element, it executes without any issues.
Element log
protocol.UserCookie 202B80721E6A4BB39E352BCE3D2609CA
protocol.UserInfo MCS
protocol.GetUserConnection().ConnectionID 202b8072-1e6a-4bb3-9e35-2bce3d2609ca
Script log
engine.GetUserConnection().ConnectionID 202b8072-1e6a-4bb3-9e35-2bce3d2609ca
engine.UserLoginName SkylineMCS
engine.UserDisplayName MCS
engine.UserCookie 202B80721E6A4BB39E352BCE3D2609CA
How can I make sure a valid connection gets established to run the script successfully in both cases?
Thank you in advance!
Kind regards
Skyline.DataMiner.Net.Exceptions.DataMinerSecurityException: No such remote connection (17fd22f11d). Retried.
Server stack trace:
at Skyline.DataMiner.Net.Facade.HandleImpersonateMessage(IConnectionInfo originalConnInfo, ImpersonateMessage im)
at Skyline.DataMiner.Net.Facade.HandleMessageInternal(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.Facade.HandleMessage(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.BaseFacade.HandleMessages(IConnectionInfo connInfo, DMSMessage[] msgs)
at Skyline.DataMiner.Net.Facade.HandleMessagesForClient(IConnectionInfo connInfo, DMSMessage[] messages)
at Skyline.DataMiner.Net.Transport.Remoting.InternalHandleMessages(ConnectionToken token, DMSMessage[] inputMessages, ConnectionTransportType ctt)
at Skyline.DataMiner.Net.Transport.Remoting.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages, ConnectionTransportType ctt)
at Skyline.DataMiner.Net.Transport.Remoting.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Skyline.DataMiner.Net.ISLNet.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages)
at Skyline.DataMiner.Net.LegacyRemotingConnection.TransportSpecificHandleMessage(ConnectionToken tok, DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.InternalHandlePackedMessages(ConnectionToken tok, DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.InternalHandleUnpackedMessages(DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.HandleMessages(DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.PersistentConnectionContainer.SendMessages(DMSMessage[] messages)
at Skyline.DataMiner.Automation.Engine.SendSLNetMessages(DMSMessage[] messages)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.<>c__DisplayClass45_0.<WrapWithExtraInfoInjection>b__0(DMSMessage[] messages)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.RetrieveResponse(DMSMessage request)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.RetrieveResponse[TResp](DMSMessage request)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.RetrieveCrudResponse(DMSMessage request)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.InnerRead(IQuery`1 query, IAdditionalOperationMeta operationMeta)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.Read(IQuery`1 query)
at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.Read(FilterElement`1 filter)
at Set_Request_Status_1.Script.Run(Engine engine) (Script 'Set Request Status')
Hi Michiel,
Are you passing the user cookie from the QAction to the automation script? If not, you could try executing your script as follows:
var dms = protocol.GetDms();
var parameters = Enumerable.Empty<DmsAutomationScriptParamValue>();
var dummies = Enumerable.Empty<DmsAutomationScriptDummyValue>();dms.GetScript("My Script").Execute(parameters, dummies, userCookie: protocol.UserCookie);
If that still doesn't work you could maybe try to use the static Engine.SLNetRaw property when setting up the DomHelper instance in your script.
Great, glad to hear the problem is resolved!
Hi Tom. Thank you very much for checking the question. I was able to make it work by passing the Engine.SLNetRaw.SendAsyncOverConnection delegate to the constructor of the DomHelper class in the script: DomHelper domHelper = new DomHelper(Engine.SLNetRaw.SendAsyncOverConnection, moduleId); Thanks for the tip! Much appreciated!