private void registerDcManyToManyChange(object linkObject, XPMemberInfo propMember, object element, ProtocolEventType protocolEventType, bool recurse) { var oppositeProp = (from p in propMember.Owner.ObjectProperties.Cast <XPMemberInfo>() where p.Name.EndsWith(SpecificWords.LinkedPostfix) && p != propMember select p).FirstOrDefault(); if (oppositeProp != null) { var targetObject = oppositeProp.GetValue(linkObject); if (targetObject != null) { var targetModelClass = XafDeltaModule.XafApp.FindModelClass(targetObject.GetType()); if (targetModelClass != null) { var nameArray = propMember.Name.Split('_').ToList(); if (nameArray.Count > 2) { nameArray.RemoveAt(0); nameArray.RemoveAt(nameArray.Count - 1); var targetListName = string.Join("_", nameArray.ToArray()); var protEvent = new ProtocolEvent { Target = targetObject, OldValue = element, PropertyName = targetListName, ProtocolEventType = protocolEventType, ReplicationKey = ExtensionsHelper.GetReplicationKey(targetObject) }; var session = ((ISessionProvider)targetObject).Session; Collector.RegisterProtocolEvent(session, protEvent); if (!recurse) { registerDcManyToManyChange(linkObject, oppositeProp, targetObject, protocolEventType, true); } } } } } }
/// <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); } }