Ejemplo n.º 1
0
 public static void FreeExecutionContext(IMExSession context)
 {
     if (MExEvents.mexRuntime == null)
     {
         throw new InvalidOperationException("Initialize() must be called before FreeExecutionContext()");
     }
     context.Close();
 }
Ejemplo n.º 2
0
        private static void OnAgentInvokeStart(object dispatcher, IMExSession context)
        {
            IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope();

            if (currentActivityScope != null)
            {
                currentActivityScope.Action = context.CurrentAgent.Name;
            }
        }
Ejemplo n.º 3
0
        private static void OnAgentInvokeReturns(object dispatcher, IMExSession context)
        {
            IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope();

            if (currentActivityScope != null)
            {
                currentActivityScope.Action = null;
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 public static IMExSession CloneExecutionContext(IMExSession mexSession)
 {
     return((IMExSession)mexSession.Clone());
 }