Example #1
0
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        while (!stoppingToken.IsCancellationRequested)
        {
            if (DateTime.Now.Minute == 0 && DateTime.Now.Second == 0)
            {
                try
                {
                    await _gitFileService.PushAsync(":alarm_clock: sever schedule");
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, $"{nameof(DbDataHostedService)}.{nameof(ExecuteAsync)} failed.");
                }
            }

            await Task.Delay(TimeSpan.FromMilliseconds(900), stoppingToken);
        }
    }
Example #2
0
    public async Task <IActionResult> PersistentAsync()
    {
        try
        {
            using var sr = new StreamReader(Request.Body, Encoding.UTF8);
            var message = await sr.ReadToEndAsync();

            await _gitFileService.PushAsync(message);

            return(Ok());
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, $"{nameof(PersistentAsync)} failed.");
            return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
        }
    }
    public async Task <MiscGrpcResponse> PersistentGitFileAsync(MiscGrpcRequest request, CallContext context = default)
    {
        var response = new MiscGrpcResponse();

        try
        {
            await _gitFileService.PushAsync(request.Message);
        }
        catch (Exception ex)
        {
            response.IsOk    = false;
            response.Message = ex.Message;
            _logger.LogError(ex, $"{nameof(PersistentGitFileAsync)} failed.");
        }

        return(response);
    }