public TaskLogger(TaskProperties taskProperties, TaskClient taskClient)
 {
     this.taskProperties = taskProperties;
     this.taskClient     = taskClient;
     pageId      = Guid.NewGuid().ToString();
     pagesFolder = Path.Combine(Path.GetTempPath(), "pages");
     Directory.CreateDirectory(pagesFolder);
 }
        public async Task CreateTaskTimelineRecordIfRequired(TaskClient taskClient, CancellationToken cancellationToken)
        {
            if (taskProperties.TaskInstanceId.Equals(Guid.Empty))
            {
                taskProperties.TaskInstanceId = Guid.NewGuid();
            }

            var timelineRecord = new TimelineRecord
            {
                Id         = taskProperties.TaskInstanceId,
                RecordType = "task",
                StartTime  = DateTime.UtcNow,
                ParentId   = taskProperties.JobId,
            };

            if (!string.IsNullOrWhiteSpace(taskProperties.TaskInstanceName))
            {
                timelineRecord.Name = taskProperties.TaskInstanceName;
            }

            // this is an upsert call
            await taskClient.UpdateTimelineRecordAsync(timelineRecord, cancellationToken).ConfigureAwait(false);
        }