public void Handle(TopicCreated message)
 {
     if (message.gid != this._gid)
     {
         return;
     }
     Execute.ExecuteOnUIThread((Action)(() => this.LoadData(true, true)));
 }
示例#2
0
        public void Handle(TopicCreated payload, IState request)
        {
            Topic topic = this.topicRepo.Read(t => t.Id == payload.Topic.Id);

            if (topic.IsVisible())
            {
                this.InformForumFollowers(topic.Forum, topic);
            }
        }
示例#3
0
        public XNodeEventService(ILogger <SystemService> logger,
                                 string agentId,
                                 XNodeConfiguration nodeConfig,
                                 DataStorageConfiguration dataStorageConfig,
                                 AgentConfiguration agentConfiguration,
                                 IXNodeConnectionRepository xNodeConnectionRepository,
                                 TenantIOService tenantIOService,
                                 ProducerIOService producerIOService,
                                 ConsumerIOService consumerIOService,
                                 MessageIOService messageIOService)
        {
            this.logger = logger;
            this.xNodeConnectionRepository = xNodeConnectionRepository;
            this.tenantIOService           = tenantIOService;
            this.producerIOService         = producerIOService;
            this.consumerIOService         = consumerIOService;
            this.messageIOService          = messageIOService;
            this.agentId    = agentId;
            this.nodeConfig = nodeConfig;

            var provider = new XNodeConnectionProvider(nodeConfig, dataStorageConfig, agentConfiguration, agentId);

            _connection = provider.GetHubConnection();

            _connection.On <AgentConnectedArgs>("StorageConnected", connectedArgs => StorageConnected?.Invoke(connectedArgs));
            _connection.On <AgentDisconnectedArgs>("StorageDisconnected", disconnectedArgs => StorageDisconnected?.Invoke(disconnectedArgs));

            _connection.On <TenantCreatedArgs>("TenantCreated", tenantCreated => TenantCreated?.Invoke(tenantCreated));
            _connection.On <TenantUpdatedArgs>("TenantUpdated", tenantUpdated => TenantUpdated?.Invoke(tenantUpdated));

            _connection.On <ProductCreatedArgs>("ProductCreated", productCreated => ProductCreated?.Invoke(productCreated));
            _connection.On <ProductUpdatedArgs>("ProductUpdated", productUpdated => ProductUpdated?.Invoke(productUpdated));

            _connection.On <ComponentCreatedArgs>("ComponentCreated", componentCreated => ComponentCreated?.Invoke(componentCreated));
            _connection.On <ComponentUpdatedArgs>("ComponentUpdated", componentUpdated => ComponentUpdated?.Invoke(componentUpdated));

            _connection.On <TopicCreatedArgs>("TopicCreated", topicCreated => TopicCreated?.Invoke(topicCreated));
            _connection.On <TopicUpdatedArgs>("TopicUpdated", topicUpdated => TopicUpdated?.Invoke(topicUpdated));

            _connection.On <ProducerConnectedArgs>("ProducerConnected", producerConnected => ProducerConnected?.Invoke(producerConnected));
            _connection.On <ProducerDisconnectedArgs>("ProducerDisconnected", producerDisconnected => ProducerDisconnected?.Invoke(producerDisconnected));

            _connection.On <ConsumerConnectedArgs>("ConsumerConnected", consumerConnected => ConsumerConnected?.Invoke(consumerConnected));
            _connection.On <ConsumerDisconnectedArgs>("ConsumerDisconnected", consumerDisconnected => ConsumerDisconnected?.Invoke(consumerDisconnected));
            _connection.On <ConsumerConnectedArgs>("ConsumerUnacknowledgedMessagesRequested", consumerConnected => ConsumerUnacknowledgedMessagesRequested?.Invoke(consumerConnected));
            _connection.On <MessageAcknowledgedArgs>("MessageAcknowledged", messageAcked => MessageAcknowledged?.Invoke(messageAcked));

            _connection.On <MessageStoredArgs>("MessageStored", msgStored => MessageStored?.Invoke(msgStored));

            InitializeEventHandlers();

            ConnectAsync();

            xNodeConnectionRepository.AddService(nodeConfig.ServiceUrl, agentId, this);
        }
示例#4
0
        public Topic Create(String forumId, String subject, String text, TopicType?type = default(TopicType?))
        {
            if (String.IsNullOrWhiteSpace(forumId))
            {
                throw new ArgumentNullException(nameof(forumId));
            }
            if (String.IsNullOrWhiteSpace(subject))
            {
                throw new ArgumentNullException(nameof(subject));
            }
            if (String.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (!type.HasValue)
            {
                type = TopicType.Regular;
            }

            this.loggingService.Application.DebugWriteFormat("Create called on TopicService, ForumId: {0}, Subject: {1}, Text: {2}, Type: {3}", forumId, subject, text, type);

            IAuthenticatedUser currentUser = this.userProvider.CurrentUser;

            if (currentUser == null /* TODO !currentUser.Can(this.permissionService)*/)
            {
                this.loggingService.Application.DebugWriteFormat("User does not have permissions to create a new topic, ForumId: {0}", forumId);
                throw new PermissionException("create topic", currentUser);
            }

            if (type.Value != TopicType.Regular)
            {
                // TODO: Permissions!
            }

            Topic output = this.dataStore.CreateTopic(currentUser.Id, forumId, subject, text, type.Value);

            this.loggingService.Application.DebugWriteFormat("Topic created in TopicService, Id: {0}", output.Id);

            // TODO:
            TopicCreated afterEvent = new TopicCreated {
                //Subject = output.Subject,
                //Text = output.Text,
                //Type = output.
                //ForumId = output.Id,
                //Author = this.userProvider.CurrentUser
            };

            this.eventPublisher.Publish <TopicCreated>(afterEvent);

            return(output);
        }
示例#5
0
 private void RaiseTopicCreated(IWampTopic wampTopic)
 {
     TopicCreated?.Invoke(this, new WampTopicCreatedEventArgs(wampTopic));
 }
示例#6
0
 private void RaiseTopicCreated(WampTopicCreatedEventArgs e)
 {
     TopicCreated?.Invoke(this, e);
 }