Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionData"/> class.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="collector">The collector.</param>
 public SessionData(Session session, Collector collector)
 {
     if (session == null) throw new ArgumentNullException("session");
     Session = session;
     Collector = collector;
     SessionId = Guid.NewGuid();
     StartedOn = DateTime.UtcNow;
     trackedObjects = new TrackedObjectBag(this);
     subscribeToSessionEvents(session);
 }
Esempio n. 2
0
 public ProtocolService(XafDeltaModule owner, ILoadService loadService)
     : base(owner)
 {
     LoadService = loadService;
     Collector = new Collector(this);
 }
Esempio n. 3
0
        /// <summary>
        /// Enters the method.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="callContext">The call context.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="args">The args.</param>
        public void EnterMethod(Session session, object callContext, string methodName, params object[] args)
        {
            if (AuditTrailService.Instance.AuditDataStore != null)
            {
                return;
            }
            if (LoadService.IsLoading)
            {
                return;
            }

            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (callContext == null)
            {
                throw new ArgumentNullException("callContext");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }

            var contextObject = callContext is Type ? null : callContext;
            var contextClass  = callContext is Type ? (Type)callContext : callContext.GetType();
            var methodInfo    = contextClass.GetMethod(methodName);

            if (methodInfo == null)
            {
                return;
            }

            var replicationKey = "";

            if (contextObject != null)
            {
                replicationKey = ExtensionsHelper.GetReplicationKey(contextObject);
            }

            var protocolEvent = new ProtocolEvent
            {
                Target            = contextObject,
                ProtocolEventType = ProtocolEventType.MethodCall,
                OldValue          = MethodCallParams.CreateForArgs(DevExpress.ExpressApp.ObjectSpace.FindObjectSpaceByObject(contextObject), args),
                PropertyName      = methodName,
                ReplicationKey    = replicationKey
            };

            Collector.RegisterProtocolEvent(session, protocolEvent);

            lock (callRegistry)
            {
                Dictionary <Thread, Stack <string> > sessionThreads;
                if (!callRegistry.TryGetValue(session, out sessionThreads))
                {
                    sessionThreads = new Dictionary <Thread, Stack <string> >();
                    callRegistry.Add(session, sessionThreads);
                }

                var            currentThread = Thread.CurrentThread;
                Stack <string> callsStack;
                if (!sessionThreads.TryGetValue(currentThread, out callsStack))
                {
                    callsStack = new Stack <string>();
                    sessionThreads.Add(currentThread, callsStack);
                }

                callsStack.Push(methodName);
            }
        }
Esempio n. 4
0
 public ProtocolService(XafDeltaModule owner, ILoadService loadService) : base(owner)
 {
     LoadService = loadService;
     Collector   = new Collector(this);
 }