示例#1
0
 /// <summary>
 /// Publish the event with eventName.
 /// Publisher and subscriber of this event are responsible for keeping type consistency of argument e
 /// This is synchronized invocation
 /// </summary>
 /// <param name="publisher"></param>
 /// <param name="eventName"></param>
 /// <param name="e"></param>
 public List<object> PublishEvent(object publisher, string eventName, object data)
 {
     if (!m_EventLock.Keys.Contains(eventName))
         m_EventLock.Add(eventName, new ReaderWriterLock());
     m_EventLock[eventName].AcquireReaderLock(Timeout.Infinite);
     var arguments = new List<object>();
     try
     {
         var subscriberlist = FindSubscriber(eventName);
         foreach (var sub in subscriberlist)
         {
             var args = new SkusEventArgs { Name = eventName, Data = data };
             arguments.Add(args);
             sub.Handler.Invoke(publisher, args);
         }
     }
     finally
     {
         m_EventLock[eventName].ReleaseReaderLock();
     }
     return arguments;
 }
示例#2
0
        private void OnNewDesignShared(object sender, SkusEventArgs args)
        {
            var publishEvent = args.Data as PublishEvent;
            var workspaceId = publishEvent.WorkspaceId;
            //var entityId = new EntityId(publishEvent.EntityIds[0]);
            var entityType = publishEvent.EntityType;
            var isFirstTImePublished = publishEvent.IsFirstTimePublished;
            var actionType = isFirstTImePublished ? "shared" : "updated";

            var notificationVo = GetNotificationVo(entityType, workspaceId, publishEvent.PublishTime, actionType);

            SendNotification(entityType, actionType, notificationVo);
            notificationRepository.Insert(notificationVo);
        }