public async Task AddAsync(IMeasurement item, CancellationToken cancellationToken = default) { EnsureArg.IsNotNull(item, nameof(item)); var partitionKey = Ensure.String.IsNotNullOrWhiteSpace(item.DeviceId, nameof(item.DeviceId)); var measurementContent = JsonConvert.SerializeObject(item, Formatting.None); var contentBytes = Encoding.UTF8.GetBytes(measurementContent); using (var eventData = new EventData(contentBytes)) { await _eventHubService.SendAsync(eventData, partitionKey).ConfigureAwait(false); } }
public async Task ForPeer(int id, PeerType peerType, string userId, int offset, int maxId) { IInputPeer peer = GetPeer(id, peerType); IClientApi client = await _telegramService.BuildAsync(userId); IMessages history = await TelegramRequest.HandleAsync(() => { return(client.MessagesService.GetHistoryAsync(peer, offset, maxId, 100)); }); List <Message> messages = MessagesParser.Parse(history, id, peerType); await _eventHub.SendAsync(messages); if (messages.Count > 0) { BackgroundJob.Schedule <GetMessages>( job => job.ForPeer(id, peerType, userId, offset + 100, 0), TimeSpan.FromSeconds(_randomService.Random.Next(5, 20))); } }
public void Send([FromBody] Message message) { _eventHubService.SendAsync(message.Text); }
public async Task SendAsync <TCommand>(TCommand command) where TCommand : ICommand, IHubCommand { await _hubService.SendAsync(command).ConfigureAwait(false); }