/// <inheritdoc /> public ISnapshotResponse Snapshot(ISnapshotRequest snapshotRequest) { return(this.Dispatch <ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse>( snapshotRequest, (p, d) => this.RawDispatch.SnapshotCreateDispatch <SnapshotResponse>(p, d) )); }
/// <inheritdoc /> public ISnapshotResponse Snapshot(ISnapshotRequest snapshotRequest) { return this.Dispatch<ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse>( snapshotRequest, (p, d) => this.RawDispatch.SnapshotCreateDispatch<SnapshotResponse>(p, d) ); }
/// <inheritdoc /> public Task <ISnapshotResponse> SnapshotAsync(ISnapshotRequest snapshotRequest) { return(this.DispatchAsync <ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( snapshotRequest, (p, d) => this.RawDispatch.SnapshotCreateDispatchAsync <SnapshotResponse>(p, d) )); }
/// <inheritdoc /> public Task<ISnapshotResponse> SnapshotAsync(ISnapshotRequest snapshotRequest) { return this.DispatchAsync<ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( snapshotRequest, (p, d) => this.RawDispatch.SnapshotCreateDispatchAsync<SnapshotResponse>(p, d) ); }
public static Task ClearLastKeyboard(this TelegramBotClient client, ISnapshotRequest request, CancellationToken cancellationToken = default) { CallbackQuery query = ((SnapshotRequest)request).Query; return(client.ClearLastKeyboard(query, cancellationToken)); }
public SnapshotStatusHumbleObject(IElasticClient elasticClient, ISnapshotRequest snapshotRequest) { elasticClient.ThrowIfNull("elasticClient"); snapshotRequest.ThrowIfNull("snapshotRequest"); _elasticClient = elasticClient; _snapshotRequest = snapshotRequest; }
public SnapshotObservable(IElasticClient elasticClient, ISnapshotRequest snapshotRequest, TimeSpan interval) : this(elasticClient, snapshotRequest) { interval.ThrowIfNull(nameof(interval)); if (interval.Ticks < 0) { throw new ArgumentOutOfRangeException(nameof(interval)); } _interval = interval; }
public SnapshotObservable(IElasticClient elasticClient, ISnapshotRequest snapshotRequest) { elasticClient.ThrowIfNull(nameof(elasticClient)); snapshotRequest.ThrowIfNull(nameof(snapshotRequest)); _elasticClient = elasticClient; _snapshotRequest = snapshotRequest; _snapshotStatusHumbleObject = new SnapshotStatusHumbleObject(elasticClient, snapshotRequest); _snapshotStatusHumbleObject.Completed += StopTimer; _snapshotStatusHumbleObject.Error += StopTimer; }
public static Task <Message> SendSnapshotFailure(this TelegramBotClient client, Snapshot snapshot, ISnapshotRequest request, Node nodeToNavigate, CancellationToken cancellationToken = default) { CallbackQuery query = ((SnapshotRequest)request).Query; // send a new text message string markdown = MessageHelpers.GetFailureMarkdown(snapshot); InlineKeyboardMarkup replyMarkup = MessageHelpers.GetReplyMarkup(nodeToNavigate); return(client.SendTextMessageAsync(query.Message.Chat.Id, markdown, ParseMode.Markdown, replyMarkup: replyMarkup, cancellationToken: cancellationToken)); }
public SnapshotObservable(IOpenSearchClient opensearchClient, ISnapshotRequest snapshotRequest) { opensearchClient.ThrowIfNull(nameof(opensearchClient)); snapshotRequest.ThrowIfNull(nameof(snapshotRequest)); _opensearchClient = opensearchClient; _snapshotRequest = snapshotRequest; _snapshotRequest.RequestParameters.SetRequestMetaData(RequestMetaDataFactory.SnapshotHelperRequestMetaData()); _snapshotStatusHumbleObject = new SnapshotStatusHumbleObject(opensearchClient, snapshotRequest); _snapshotStatusHumbleObject.Completed += StopTimer; _snapshotStatusHumbleObject.Error += StopTimer; }
public static Task <Message> SendSnapshotSuccess(this TelegramBotClient client, Snapshot snapshot, ISnapshotRequest request, Node nodeToNavigate, TelegramOptions options, CancellationToken cancellationToken = default) { CallbackQuery query = ((SnapshotRequest)request).Query; // post the snapshot and navigation controls in a new message var photo = new InputOnlineFile(snapshot.Stream); string caption = MessageHelpers.GetCaptionMarkdown(snapshot, options.HoursOffset, options.DateTimeFormat); IReplyMarkup replyMarkup = MessageHelpers.GetReplyMarkup(snapshot.Node.Parent); return(client.SendPhotoAsync(query.Message.Chat.Id, photo, caption, ParseMode.Markdown, replyMarkup: replyMarkup, cancellationToken: cancellationToken)); }
public async Task Navigate(Node node, ISnapshotRequest request, string alert = null, CancellationToken cancellationToken = default) { if (!_started) { throw new InvalidOperationException("Messenger was not started."); } await _client.Navigate(node, request, alert, cancellationToken); _logger.LogInformation("User {UserName} navigated to {NodeName}", ((SnapshotRequest)request).Query.From.Username, node.Name); }
public async Task SendSnapshotAndNavigate(Snapshot snapshot, ISnapshotRequest request, Node nodeToNavigate, CancellationToken cancellationToken = default) { if (!_started) { throw new InvalidOperationException("Messenger was not started."); } await _client.ClearLastKeyboard(request, cancellationToken).ConfigureAwait(false); Message message = snapshot.Success ? await _client.SendSnapshotSuccess(snapshot, request, nodeToNavigate, _options, cancellationToken).ConfigureAwait(false) : await _client.SendSnapshotFailure(snapshot, request, nodeToNavigate, cancellationToken).ConfigureAwait(false); _logger.LogInformation("Sent snapshot message to {UserName}", message.Chat.Username); }
public async Task Handle(ISnapshotRequest request, CancellationToken cancellationToken) { using IServiceScope scope = _serviceScopeFactory.CreateScope(); var registry = scope.ServiceProvider.GetRequiredService <ICameraRegistry>(); Node node = await registry.GetNode(request.Id, cancellationToken).ConfigureAwait(false); if (node == null) { // invalid node, fallback to root Node root = await registry.GetRootNode(cancellationToken).ConfigureAwait(false); // update navigation controls to the root's children await _messenger .Navigate(root, request, alert : "The camera has been moved or deleted.", cancellationToken) .ConfigureAwait(false); return; } if (!node.IsLeaf()) { // navigate to the selected node await _messenger.Navigate(node, request, cancellationToken : cancellationToken).ConfigureAwait(false); return; } // show the node's view var cameraService = scope.ServiceProvider.GetService <ICameraService>(); using Snapshot snapshot = await cameraService .GetSnapshot(node, cancellationToken) .ConfigureAwait(false); await _messenger .SendSnapshotAndNavigate(snapshot, request, node.Parent, cancellationToken) .ConfigureAwait(false); }
/// <inheritdoc /> public IObservable <ISnapshotStatusResponse> SnapshotObservable(TimeSpan interval, ISnapshotRequest snapshotRequest) { snapshotRequest.ThrowIfNull("snapshotRequest"); var observable = new SnapshotObservable(this, snapshotRequest); return(observable); }
/// <inheritdoc/> public IObservable<ISnapshotStatusResponse> SnapshotObservable(TimeSpan interval, ISnapshotRequest request) => new SnapshotObservable(this, request);
/// <inheritdoc /> public IObservable<ISnapshotStatusResponse> SnapshotObservable(TimeSpan interval, ISnapshotRequest snapshotRequest) { snapshotRequest.ThrowIfNull("snapshotRequest"); var observable = new SnapshotObservable(this, snapshotRequest); return observable; }
public static async Task <Message> Navigate(this TelegramBotClient client, Node node, ISnapshotRequest request, string alert = null, CancellationToken cancellationToken = default) { CallbackQuery query = ((SnapshotRequest)request).Query; long chatId = query.Message.Chat.Id; int requestMessageId = query.Message.MessageId; // show alert or silently acknowledge bool showAlert = !string.IsNullOrWhiteSpace(alert); string text = showAlert ? alert : null; await client.AnswerCallbackQueryAsync(query.Id, text : text, showAlert : showAlert, cancellationToken : cancellationToken) .ConfigureAwait(false); // update navigation controls in the current message InlineKeyboardMarkup replyMarkup = MessageHelpers.GetReplyMarkup(node); return(await client.EditMessageReplyMarkupAsync(chatId, requestMessageId, replyMarkup, cancellationToken) .ConfigureAwait(false)); }
/// <summary> /// <c>PUT</c> request to the <c>snapshot.create</c> API, read more about this API online: /// <para></para> /// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html</a> /// </summary> public Task <SnapshotResponse> SnapshotAsync(ISnapshotRequest request, CancellationToken ct = default) => DoRequestAsync <ISnapshotRequest, SnapshotResponse>(request, request.RequestParameters, ct);
/// <summary> /// <c>PUT</c> request to the <c>snapshot.create</c> API, read more about this API online: /// <para></para> /// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html</a> /// </summary> public SnapshotResponse Snapshot(ISnapshotRequest request) => DoRequest <ISnapshotRequest, SnapshotResponse>(request, request.RequestParameters);
/// <inheritdoc /> public Task <ISnapshotResponse> SnapshotAsync(ISnapshotRequest request, CancellationToken cancellationToken = default(CancellationToken)) => Dispatcher.DispatchAsync <ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( request, cancellationToken, LowLevelDispatch.SnapshotCreateDispatchAsync <SnapshotResponse> );
/// <inheritdoc /> public IObservable <ISnapshotStatusResponse> SnapshotObservable(TimeSpan interval, ISnapshotRequest request) => new SnapshotObservable(this, request);
/// <inheritdoc/> public ISnapshotResponse Snapshot(ISnapshotRequest request) => this.Dispatcher.Dispatch<ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse>( request, this.LowLevelDispatch.SnapshotCreateDispatch<SnapshotResponse> );
/// <inheritdoc/> public ISnapshotResponse Snapshot(ISnapshotRequest request) => this.Dispatcher.Dispatch <ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse>( request, this.LowLevelDispatch.SnapshotCreateDispatch <SnapshotResponse> );
/// <inheritdoc/> public Task<ISnapshotResponse> SnapshotAsync(ISnapshotRequest request) => this.Dispatcher.DispatchAsync<ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( request, this.LowLevelDispatch.SnapshotCreateDispatchAsync<SnapshotResponse> );
public static SnapshotResponse Snapshot(this IElasticClient client, ISnapshotRequest request) => client.Snapshot.Snapshot(request);
/// <inheritdoc/> public Task <ISnapshotResponse> SnapshotAsync(ISnapshotRequest request) => this.Dispatcher.DispatchAsync <ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( request, this.LowLevelDispatch.SnapshotCreateDispatchAsync <SnapshotResponse> );
public static Task <SnapshotResponse> SnapshotAsync(this IElasticClient client, ISnapshotRequest request, CancellationToken ct = default) => client.Snapshot.SnapshotAsync(request, ct);
/// <inheritdoc/> public Task<ISnapshotResponse> SnapshotAsync(ISnapshotRequest request, CancellationToken cancellationToken = default(CancellationToken)) => this.Dispatcher.DispatchAsync<ISnapshotRequest, SnapshotRequestParameters, SnapshotResponse, ISnapshotResponse>( request, cancellationToken, this.LowLevelDispatch.SnapshotCreateDispatchAsync<SnapshotResponse> );
public SnapshotRequestedEventArgs(ISnapshotRequest snapshotRequest, CancellationToken cancellationToken = default) { SnapshotRequest = snapshotRequest; CancellationToken = cancellationToken; }