示例#1
0
 public async Task <Either <ActionResult, Unit> > CancelImport(Guid releaseId, Guid fileId)
 {
     return(await _releaseFileRepository.CheckFileExists(releaseId, fileId, FileType.Data)
            .OnSuccess(_userService.CheckCanCancelFileImport)
            .OnSuccessVoid(async file =>
     {
         var import = await _dataImportRepository.GetByFileId(file.Id);
         await _queueService.AddMessageAsync(ImportsCancellingQueue, new CancelImportMessage(import.Id));
     }));
 }
示例#2
0
        /// <summary>
        /// Retry a stage of the publishing workflow
        /// </summary>
        /// <remarks>
        /// This results in the Publisher updating the latest ReleaseStatus for this Release rather than creating a new one.
        /// </remarks>
        /// <param name="releaseId"></param>
        /// <param name="stage"></param>
        /// <returns></returns>
        public async Task <Either <ActionResult, Unit> > RetryReleaseStage(Guid releaseId, RetryStage stage)
        {
            return(await _persistenceHelper
                   .CheckEntityExists <Release>(releaseId)
                   .OnSuccess(release => _userService.CheckCanPublishRelease(release))
                   .OnSuccess(async release =>
            {
                if (release.Status != ReleaseStatus.Approved)
                {
                    return ValidationActionResult(ReleaseNotApproved);
                }

                await _storageQueueService.AddMessageAsync(
                    RetryStageQueue, new RetryStageMessage(releaseId, stage));

                _logger.LogTrace($"Sent retry stage message for Release: {releaseId}");
                return new Either <ActionResult, Unit>(Unit.Instance);
            }));
        }
        public async Task Import(Guid releaseId,
                                 string dataFileName,
                                 string metaFileName,
                                 IFormFile dataFile,
                                 bool isZip)
        {
            // TODO - EES-1250
            var numRows = isZip ? 0 : FileStorageUtils.CalculateNumberOfRows(dataFile.OpenReadStream());
            var message = BuildMessage(dataFileName, metaFileName, releaseId, isZip ? dataFile.FileName.ToLower() : "");

            await UpdateImportTableRow(
                releaseId,
                dataFileName,
                numRows,
                message);

            await _queueService.AddMessageAsync("imports-pending", message);

            _logger.LogInformation($"Sent import message for data file: {dataFileName}, releaseId: {releaseId}");
        }
示例#4
0
文件: AddTask.cs 项目: numb3rss/dev
        protected override async Task <Result> OnExecuteAsync(StorageTask input)
        {
            try
            {
                await _storageQueueService.AddMessageAsync(input);

                return(new Result {
                    Status = Status.Success
                });
            }
            catch (Exception)
            {
                return(new Result {
                    Status = Status.Fail
                });
            }
        }