public static void FreeExecutionContext(IMExSession context) { if (MExEvents.mexRuntime == null) { throw new InvalidOperationException("Initialize() must be called before FreeExecutionContext()"); } context.Close(); }
private static void OnAgentInvokeStart(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = context.CurrentAgent.Name; } }
private static void OnAgentInvokeReturns(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = null; } }
public static IMExSession GetExecutionContext(StoreDriverServer storeDriverServer) { if (MExEvents.mexRuntime == null) { throw new InvalidOperationException("Initialize() must be called before GetExecutionContext()"); } IMExSession imexSession = MExEvents.mexRuntime.CreateSession(storeDriverServer, "SD"); imexSession.Dispatcher.OnAgentInvokeStart += new AgentInvokeStartHandler(MExEvents.OnAgentInvokeStart); imexSession.Dispatcher.OnAgentInvokeEnd += new AgentInvokeEndHandler(MExEvents.OnAgentInvokeReturns); return(imexSession); }
public static void RaiseEvent(IMExSession mexSession, string eventTopic, params object[] contexts) { if (MExEvents.mexRuntime == null) { throw new InvalidOperationException("Initialize() must be called before RaiseEvent()"); } IAsyncResult asyncResult = null; try { asyncResult = mexSession.BeginInvoke(eventTopic, contexts[0], contexts[1], null, null); mexSession.EndInvoke(asyncResult); } catch (LocalizedException e) { MExEvents.HandleAgentExchangeExceptions(mexSession, e); } MExAsyncResult mexAsyncResult = (MExAsyncResult)asyncResult; if (mexAsyncResult != null && mexAsyncResult.AsyncException != null) { throw new StoreDriverAgentRaisedException(mexAsyncResult.FaultyAgentName, mexAsyncResult.AsyncException); } }
public static void HandleAgentExchangeExceptions(IMExSession mexSession, LocalizedException e) { TraceHelper.ExtensibilityTracer.TraceFail <string, string, LocalizedException>(TraceHelper.MessageProbeActivityId, 0L, "Agent {0} running in context {1} hit Unhandled Exception {2}", (mexSession.CurrentAgent == null) ? null : mexSession.CurrentAgent.Name, mexSession.EventTopic, e); }
public static IMExSession CloneExecutionContext(IMExSession mexSession) { return((IMExSession)mexSession.Clone()); }