private static void HandlePostTransaction(MaterialCMSSession session)
        {
            while (GetNextAddedEventInfoForPostTransaction(session) != null)
            {
                EventInfo obj = GetNextAddedEventInfoForPostTransaction(session);
                obj.PostTransactionHandled = true;
                Publish(obj, session, typeof(IOnAdded <>), (info, ses, t) => info.GetTypedInfo(t).ToAddedArgs(ses, t));
            }

            while (GetNextUpdatedEventInfoForPostTransaction(session) != null)
            {
                UpdatedEventInfo obj = GetNextUpdatedEventInfoForPostTransaction(session);
                obj.PostTransactionHandled = true;
                Publish(obj, session, typeof(IOnUpdated <>),
                        (info, ses, t) => info.GetTypedInfo(t).ToUpdatedArgs(ses, t));
            }

            while (GetNextDeletedEventInfoForPostTransaction(session) != null)
            {
                EventInfo obj = GetNextDeletedEventInfoForPostTransaction(session);
                obj.PostTransactionHandled = true;
                Publish(obj, session, typeof(IOnDeleted <>),
                        (info, ses, t) => info.GetTypedInfo(t).ToDeletedArgs(ses, t));
            }
        }
示例#2
0
        public static void Publish(this UpdatedEventInfo updatedEventInfo, ISession session, Type eventType,
                                   Func <UpdatedEventInfo, ISession, Type, object> getArgs)
        {
            Type type = updatedEventInfo.GetType().GenericTypeArguments[0];

            List <Type> types = GetEntityTypes(type).Reverse().ToList();

            types.ForEach(
                t => EventContext.Instance.Publish(eventType.MakeGenericType(t), getArgs(updatedEventInfo, session, t)));
        }
 private void AddUpdateEvent(SystemEntity obj)
 {
     if (Updated.All(info => info.ObjectBase != obj))
     {
         SystemEntity     originalVersion = GetOriginalVersion(obj);
         UpdatedEventInfo eventInfo       = obj.GetUpdatedEventInfo(originalVersion);
         Updated.Add(eventInfo);
         eventInfo.PreTransactionHandled = true;
         eventInfo.Publish(this, typeof(IOnUpdating <>),
                           (info, ses, t) => info.GetTypedInfo(t).ToUpdatingArgs(ses, t));
     }
 }