Пример #1
0
        public async Task Run(
            [DurableClient] IDurableOrchestrationClient client,
            [ActivityTrigger] IDurableActivityContext context,
            ILogger log)
        {
            var command      = context.GetInput <UploadCvCommand>();
            var saveCvResult = await _fileWriter.Write(
                FileStore.CvsContainer,
                command.Content,
                command.ContentType,
                _fileNameProvider.GetFileName(context.InstanceId, command.Extension));

            if (!saveCvResult.Success)
            {
                log.LogErrors($"Uploading cv failed instanceId: {context.InstanceId}", saveCvResult.Errors);
                var failedEvent = new CvUploadFailedInternalFunctionEvent(saveCvResult.Errors);
                await client.RaiseEventAsync(context.InstanceId, nameof(CvUploadFailedInternalFunctionEvent), failedEvent);
            }

            var eventToDispatch = new CvUploadedInternalFunctionEvent(saveCvResult.Value);
            await client.RaiseEventAsync(context.InstanceId, nameof(CvUploadedInternalFunctionEvent), eventToDispatch);
        }
Пример #2
0
        public async Task Run(
            [DurableClient] IDurableOrchestrationClient client,
            [ActivityTrigger] IDurableActivityContext context,
            ILogger log)
        {
            _correlationInitializer.Initialize(context.InstanceId);
            var command = context.GetInput <UploadPhotoCommand>();

            var photoSaveResult = await _fileWriter.Write(
                FileStore.PhotosContainer,
                command.Content,
                command.ContentType,
                _fileNameProvider.GetFileName(context.InstanceId, command.Extension));

            if (!photoSaveResult.Success)
            {
                log.LogError($"Uploading photo failed instanceId: {context.InstanceId}", photoSaveResult.Errors, context.InstanceId);
                var failedEvent = new CvUploadFailedInternalFunctionEvent(photoSaveResult.Errors);
                await client.RaiseEventAsync(context.InstanceId, nameof(CvUploadFailedInternalFunctionEvent), failedEvent);
            }

            var eventToDispatch = new PhotoUploadedInternalFunctionEvent(photoSaveResult.Value);
            await client.RaiseEventAsync(context.InstanceId, nameof(PhotoUploadedInternalFunctionEvent), eventToDispatch);
        }