/// <summary>
 /// Dispose
 /// </summary>
 public async void Dispose()
 {
     if (PublishEvent != null)
     {
         await PublishEvent.DisposeAsync();
     }
 }
Example #2
0
 public void Notify(string str)
 {
     if (PublishEvent != null)
     {
         PublishEvent.Invoke(string.Format("我是{0},我发布{1}消息", _publisherName, str));
     }
 }
Example #3
0
        public async Task <ApiResult> Publish(PublishEvent request)
        {
            request.CompanyUid = await _currentCompanyProvider.GetCompanyUid();

            request.UserUid = _currentUserProvider.GetUserUid();

            return(await _mediator.Send(request));
        }
Example #4
0
        /// <summary>
        /// Enqueues an <see cref="PublishEvent" /> for a later republish regardless of the value of
        /// <see cref="IPublish{T}.Republish" />.
        /// </summary>
        /// <param name="publishEvent">The <see cref="PublishEvent" /> to republish.</param>
        public static void ForceEnqueue(PublishEvent publishEvent)
        {
            if (publishEvent == null)
            {
                throw new ArgumentNullException("publishEvent");
            }

            EventQueue.AddEvent(publishEvent);
        }
Example #5
0
    public void Unsubscribe <T>(PublishEvent e) where T : Events
    {
        var name = typeof(T).ToString();

        if (publishDict.ContainsKey(name))
        {
            publishDict[name] -= e;
        }
    }
 public void SelectFloor()
 {
     if (!IsFloorSelected)
     {
         IsFloorSelected = true;
         IBaseEvent baseEvent = new PublishEvent(EventType.FloorSelected, DateTime.Now, FloorId.ToString());
         messagePublisher.Publish(ChannelName, baseEvent);
     }
 }
Example #7
0
 public void Notify(PublishEvent ev, object data)
 {
     if (observerMap.ContainsKey(ev))
     {
         foreach (var sub in observerMap[ev])
         {
             sub.Handle(data);
         }
     }
 }
        public void Drop(TreeNavigationItem draggedTreeNavigationItem, TreeNavigationItem targetTreeNavigationItem)
        {
            Connection.GetInstance().StartTransaction();
            IMoveAwareCRUDService moveAwareCRUDService = ServiceActivator.Get <IFolderCRUDService>();

            moveAwareCRUDService.Move(draggedTreeNavigationItem.Id, targetTreeNavigationItem.Id);
            Connection.GetInstance().EndTransaction();
            Publisher.GetInstance().Publish(PublishEvent.CreateDeletionEvent(draggedTreeNavigationItem.Id, draggedTreeNavigationItem.GetParentId()));
            Publisher.GetInstance().Publish(PublishEvent.CreateCreationEvent(draggedTreeNavigationItem.Id, targetTreeNavigationItem.GetParentId()));
        }
Example #9
0
 //实现接口
 public void Notify(string str)
 {
     if (PublishEvent != null)
     {
         //使用发布委托(传入参数,这里参数是:string.Format("我是{0},我发布{1}消息", _publisherName, str))
         //使用的委托来自订阅器,所以接下来去执行订阅器的方法
         //str来自main方法中Notify()调用传入的参数
         //委托链长度为1
         PublishEvent.Invoke(string.Format("我是{0},我发布{1}消息", _publisherName, str));
     }
 }
Example #10
0
 public void UnSubscribe(PublishEvent ev, ISubscriber sub)
 {
     if (!observerMap.ContainsKey(ev))
     {
         return;
     }
     if (observerMap[ev].Contains(sub))
     {
         observerMap[ev].Remove(sub);
     }
 }
Example #11
0
    public void Subscribe <T>(PublishEvent e) where T : Events
    {
        var name = typeof(T).ToString();

        if (!publishDict.ContainsKey(name))
        {
            publishDict.Add(name, e);
        }
        else
        {
            publishDict[name] += e;
        }
    }
Example #12
0
        /// <summary>
        /// Enqueues the specified <see cref="PublishEvent" /> for a later republish but only if
        /// <see cref="IPublish{T}.Republish" /> is True.
        /// </summary>
        /// <param name="publishEvent">The <see cref="PublishEvent" /> to republish.</param>
        public static void Enqueue(PublishEvent publishEvent)
        {
            if (publishEvent == null)
            {
                throw new ArgumentNullException("publishEvent");
            }

            if (!publishEvent.PipelineArgs.Publish.Republish)
            {
                return;
            }

            EventQueue.AddEvent(publishEvent);
        }
        public async void HandleCustomEvent(object sender, PublishEvent e)
        {
            var(ol, pd) = GameLogic.GetStatePM(e.PlayerDict, e.ObjectDict);

            PositionUpdateDTO positionUpdateDTO = new PositionUpdateDTO
            {
                type       = "RECEIVE_POSITIONS_UPDATE",
                ObjectList = ol,
                PlayerDict = pd
            };
            await _hubContext.Clients.All.ReceiveMessage(positionUpdateDTO);

            lastUpdate = DateTime.Now;
        }
Example #14
0
        public async Task <IActionResult> Publish([FromBody] PublishEvent data)
        {
            var eventMessage = _mapper.Map <TankMonitorProducerEvent>(data);

            eventMessage.RequestId = Guid.NewGuid();
            try
            {
                _eventBus.PublishTankMonitor(EventBusConstants.TankMonitorQueue, eventMessage);
            }
            catch (Exception)
            {
                throw;
            }

            return(Accepted());
        }
Example #15
0
 public void Subscribe(PublishEvent ev, ISubscriber sub)
 {
     if (!observerMap.ContainsKey(ev))
     {
         var newSubList = new List <ISubscriber>();
         newSubList.Add(sub);
         observerMap.Add(ev, newSubList);
     }
     else
     {
         if (!observerMap[ev].Contains(sub))
         {
             observerMap[ev].Add(sub);
         }
     }
 }
        public void OnEvent(PublishEvent publishEvent)
        {
            switch (publishEvent.EventType)
            {
            case EventType.CREATE:
                OnCreate(publishEvent);
                break;

            case EventType.UPDATE:
                OnUpdate(publishEvent);
                break;

            case EventType.DELETE:
                OnDelete(publishEvent);
                break;
            }
        }
        protected virtual void OnCreate(PublishEvent publishEvent)
        {
            TreeNavigationItem parentTreeNavigationItem = Find(Roots, publishEvent.ParentObjectId.Value);

            if (parentTreeNavigationItem == null)
            {
                return;
            }
            parentTreeNavigationItem.SetChildren(_service.GetChildren(NavigationContext.CreateNavigationContext(), parentTreeNavigationItem));
            parentTreeNavigationItem.IsExpanded = true;
            TreeNavigationItem affectedTreeNavigationItem = Find(Roots, publishEvent.AffectedObjectId);

            if (affectedTreeNavigationItem != null)
            {
                affectedTreeNavigationItem.IsSelected = true;
            }
        }
        protected override void OnCreate(PublishEvent publishEvent)
        {
            TreeNavigationItem parentTreeNavigationItem = Find(Roots, publishEvent.AffectedObjectId);

            if (parentTreeNavigationItem == null)
            {
                return;
            }
            parentTreeNavigationItem.SetChildren(_service.GetChildren(MasterNavigationContext.CreateMasterNavigationContext(_masterNavigationItem), parentTreeNavigationItem));
            parentTreeNavigationItem.IsExpanded = true;

            TreeNavigationItem affectedTreeNavigationItem = Find(Roots, publishEvent.AffectedObjectId);

            if (affectedTreeNavigationItem != null)
            {
                affectedTreeNavigationItem.IsSelected = true;
            }
        }
Example #19
0
        public void Drop(TreeNavigationItem draggedTreeNavigationItem, TreeNavigationItem targetTreeNavigationItem)
        {
            string name = Guid.NewGuid().ToString().Substring(0, 7);
            ICompositeTypeElementCRUDService compositeTypeElementCRUDService = ServiceActivator.Get <ICompositeTypeElementCRUDService>();
            CompositeTypeElementDto          compositeTypeElementDto         = new CompositeTypeElementDto();

            compositeTypeElementDto.Description          = name;
            compositeTypeElementDto.UniqueName           = name;
            compositeTypeElementDto.RuntimeId            = Guid.NewGuid();
            compositeTypeElementDto.ProjectId            = targetTreeNavigationItem.ProjectId;
            compositeTypeElementDto.OwningTypeId         = targetTreeNavigationItem.Id;
            compositeTypeElementDto.State                = State.NEW;
            compositeTypeElementDto.ElementTypeReference = new ReferenceString(draggedTreeNavigationItem.Id, draggedTreeNavigationItem.Name);
            Connection.GetInstance().StartTransaction();
            compositeTypeElementDto = compositeTypeElementCRUDService.Persist(compositeTypeElementDto);
            Connection.GetInstance().EndTransaction();
            Publisher.GetInstance().Publish(PublishEvent.CreateCreationEvent(compositeTypeElementDto.Id, compositeTypeElementDto.OwningTypeId));
        }
        protected virtual void OnDelete(PublishEvent publishEvent)
        {
            TreeNavigationItem treeNavigationItem = Find(Roots, publishEvent.AffectedObjectId);

            if (treeNavigationItem == null)
            {
                return;
            }
            if (treeNavigationItem.GetParentId() == null)
            {
                Roots.Remove(treeNavigationItem);
            }
            else
            {
                TreeNavigationItem parentTreeNavigationItem = treeNavigationItem.Parent;
                parentTreeNavigationItem.Children.Remove(treeNavigationItem);
            }
        }
        protected virtual void OnUpdate(PublishEvent publishEvent)
        {
            TreeNavigationItem treeNavigationItem = Find(Roots, publishEvent.AffectedObjectId);

            if (treeNavigationItem == null)
            {
                return;
            }
            TreeNavigationItem parentTreeNavigationItem = treeNavigationItem.Parent;

            if (parentTreeNavigationItem == null)
            {
                DoUpdate(Roots, parentTreeNavigationItem, treeNavigationItem);
            }
            else
            {
                DoUpdate(parentTreeNavigationItem.Children, parentTreeNavigationItem, treeNavigationItem);
            }
        }
Example #22
0
File: SP.cs Project: ghconn/mich
 public void Notify(string s)
 {
     PublishEvent?.Invoke($"{_pubname}发布{s}");
 }
Example #23
0
        public async Task <bool> LoadFromAssembly(FileInfo assemblyFile, IKernel kernel, PublishEvent publishEvent)
        {
            if (assemblyFile == null)
            {
                throw new ArgumentNullException(nameof(assemblyFile));
            }

            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            var assembly       = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyFile.FullName);
            var extensionTypes = assembly
                                 .ExportedTypes
                                 .Where(t => t.CanBeInstantiated() && typeof(IKernelExtension).IsAssignableFrom(t))
                                 .ToArray();

            foreach (var extensionType in extensionTypes)
            {
                var extension = (IKernelExtension)Activator.CreateInstance(extensionType);

                try
                {
                    await extension.OnLoadAsync(kernel);

                    publishEvent(new ExtensionLoaded(assemblyFile));
                }
                catch (Exception e)
                {
                    publishEvent(new KernelExtensionLoadException($"Extension {assemblyFile.FullName} threw exception {e.Message}"));
                }
            }

            return(extensionTypes.Length > 0);
        }
        protected void SetEventPolicy()
        {
            var value = ConfigurationManager.AppSettings[Constants.PerfItPublishEvent] ?? PublishEvent.ToString();

            PublishEvent = Convert.ToBoolean(value);
        }
Example #25
0
 public async Task LoadFromAssembliesInDirectory(IDirectoryAccessor directory, IKernel kernel, PublishEvent publishEvent)
 {
     if (directory.RootDirectoryExists())
     {
         var extensionDlls = directory.GetAllFiles().Where(file => file.Extension == ".dll").Select(file => directory.GetFullyQualifiedFilePath(file));
         foreach (var extensionDll in extensionDlls)
         {
             await LoadFromAssembly(extensionDll, kernel, publishEvent);
         }
     }
 }
 protected override void OnSuccessful(ExecutionEvent executionEvent, Guid affectedObjectId)
 {
     Publisher.GetInstance().Publish(PublishEvent.CreateCreationEvent(IdConstants.PRESET_FOLDER_ID, executionEvent.GetFirstSelectedTreeNavigationItem().Id));
 }
Example #27
0
        private void onFloorStop(int floorId)
        {
            IBaseEvent baseEvent = new PublishEvent(EventType.FloorReached, DateTime.Now, floorId.ToString());

            messagePublisher.Publish(ChannelName, baseEvent);
        }
Example #28
0
 protected override void OnSuccessful(ExecutionEvent executionEvent, Guid affectedObjectId)
 {
     Log.Info(string.Format("Entity '{0}' was craeted", affectedObjectId));
     Publisher.GetInstance().Publish(PublishEvent.CreateCreationEvent(affectedObjectId, executionEvent.GetFirstSelectedTreeNavigationItem().Id));
 }
Example #29
0
 internal EventPublisher(WapEndPoint ep, PublishEvent <T> publishDelegate)
 {
     Endpoint   = ep;
     _publisher = publishDelegate;
 }
 protected override void OnSuccessful(ExecutionEvent executionEvent, Guid affectedObjectId)
 {
     Log.Info(string.Format("Entity '{0}' was deleted", affectedObjectId));
     Publisher.GetInstance().Publish(PublishEvent.CreateDeletionEvent(affectedObjectId, null));
 }