private async Task writeStatusLogFileAsync()

in DIXFSamples/RecurringIntegrationApp/Runtime/DefaultDataFlowNetwork.cs [390:428]


        private async Task writeStatusLogFileAsync(DataJobStatusDetail jobStatusDetail, 
            ClientDataMessage targetDataMessage, 
            HttpResponseMessage httpResponse)
        {
            if (targetDataMessage == null)
                return;

            string logData = string.Empty;

            IDataSource<ClientDataMessage> logDataSource =
                        DataSourceFactory.GetDataSourceForMessage(targetDataMessage);

            var logFilePath = Path.Combine(Path.GetDirectoryName(targetDataMessage.FullPath),
                        (Path.GetFileNameWithoutExtension(targetDataMessage.FullPath) + 
                        "_log.txt"));

            if (null != jobStatusDetail)
            {
                logData = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(jobStatusDetail));
            }
            else if (null != httpResponse)
            {
                logData = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(httpResponse));
            }

            var targetLogDataMessage = new ClientDataMessage()
            {
                Name = Path.GetFileName(logFilePath),
                FullPath = logFilePath,
                MessageStatus = targetDataMessage.MessageStatus
            };

            
            using (var logMemoryStream = new MemoryStream(Encoding.Default.GetBytes(logData)))
            {
                logDataSource.Create(logMemoryStream, targetLogDataMessage);
            }

        }