public async Task AppendToJobLogAsync(AppendLogDto dto)
        {
            var container = Client.GetContainerReference(_config.ContainerName);
            await container.CreateIfNotExistsAsync();

            var appendBlob = container.GetAppendBlobReference(this.GetPrimaryKeyLong().ToString());

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes($"{DateTimeOffset.Now}:{dto.Content}{Environment.NewLine}")))
            {
                try
                {
                    if (await appendBlob.ExistsAsync())
                    {
                        await appendBlob.AppendBlockAsync(ms);
                    }
                    else
                    {
                        await appendBlob.UploadFromStreamAsync(ms);
                    }
                }
                catch
                {
                    DeactivateOnIdle();
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
        public override async Task <bool> AppendToJobLogAsync(long jobId, AppendLogDto dto)
        {
            var resp = await SendRequestAsync <string, AppendLogDto>(HttpMethod.Put, $"api/jobTracker/AppendLog/{jobId}",
                                                                     dto);

            if (resp.Result)
            {
                return(resp.Result);
            }

            throw new Exception($"{nameof(AppendToJobLogAsync)} failed {resp.Msg}");
        }
Ejemplo n.º 3
0
 public abstract Task <bool> AppendToJobLogAsync(long jobId, AppendLogDto dto);
Ejemplo n.º 4
0
        public async Task <ReturnDto <string> > AppendToJobLogAsync([FromRoute] long id, [FromBody][Required] AppendLogDto dto)
        {
            await _service.AppendToJobLogAsync(id, dto);

            return(new ReturnDto <string>("OK"));
        }
 public async Task AppendToJobLogAsync(long id, AppendLogDto dto)
 {
     var logger = _client.GetGrain <IJobLoggerGrain>(id);
     await logger.AppendToJobLogAsync(dto);
 }