Exemplo n.º 1
0
        /// <summary>
        /// Process tagfile request
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request = item as CompactionTagFileRequest;

            var result = new ContractExecutionResult((int)TRexTagFileResultCode.TRexUnknownException, "TRex unknown result (TagFileExecutor.ProcessEx)");

            try
            {
                log.LogInformation($"#In# TagFileExecutor. Process tag file:{request.FileName}, Project:{request.ProjectUid}, TCCOrgID:{request.OrgId}, TreatAsJohnDoe = {request.TreatAsJohnDoe}");

                var submitRequest = new SubmitTAGFileRequest();

                var arg = new SubmitTAGFileRequestArgument
                {
                    ProjectID       = request.ProjectUid,
                    AssetID         = null, // not available via TagFileController APIs
                    TreatAsJohnDoe  = request.TreatAsJohnDoe,
                    TAGFileName     = request.FileName,
                    TagFileContent  = request.Data,
                    TCCOrgID        = request.OrgId,
                    SubmissionFlags = TAGFiles.Models.TAGFileSubmissionFlags.AddToArchive,
                    OriginSource    = request.OriginSource
                };

                var res = await submitRequest.ExecuteAsync(arg);

                if (res.Success)
                {
                    result = TagFileResult.Create(0, ContractExecutionResult.DefaultMessage);
                }
                else
                {
                    result = TagFileResult.Create(res.Code, res.Message);
                }
            }
            finally
            {
                if (request != null)
                {
                    log.LogInformation($"#Out# TagFileExecutor. Process tagfile:{request.FileName}, Project:{request.ProjectUid}, Submission Code: {result.Code}, Message:{result.Message}");
                }
                else
                {
                    log.LogInformation("#Out# TagFileExecutor. Invalid request");
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task Test_TAGFileSubmission_SubmitTAGFile_Failure()
        {
            InjectTAGFileBufferQueueMock(false);

            var submission = new SubmitTAGFileRequest();

            Assert.True(null != submission, "Failed to create SubmitTAGFileRequest instance");

            string tagFileName = "TestTAGFile-TAGFile-Read-Stream.tag";
            var    assetID     = Guid.NewGuid();

            var response = await submission.ExecuteAsync(RequestArgument(assetID, tagFileName));

            response.Success.Should().BeFalse($"Response is successful!!! [When it should not be]. Filename={response.FileName}, exception={response.Message}");
            response.Code.Should().Be((int)TRexTagFileResultCode.TRexQueueSubmissionError);
            response.Message.Should().Be("SubmitTAGFileResponse. Failed to submit tag file to processing queue. Request already exists");
        }
Exemplo n.º 3
0
        public async Task Test_TAGFileSubmission_SubmitTAGFile_Success()
        {
            InjectTAGFileBufferQueueMock(true);

            var submission = new SubmitTAGFileRequest();

            Assert.True(null != submission, "Failed to create SubmitTAGFileRequest instance");

            string tagFileName = "TestTAGFile-TAGFile-Read-Stream.tag";
            var    assetID     = Guid.NewGuid();

            var response = await submission.ExecuteAsync(RequestArgument(assetID, tagFileName));

            response.Success.Should().BeTrue($"Response is not successful. Filename={response.FileName}, exception={response.Message}");
            response.Code.Should().Be((int)TRexTagFileResultCode.Valid);
            response.Message.Should().BeEmpty();
        }