コード例 #1
0
        public KeyDocumentProofResponse ProofKeyDocument(KeyDocumentProofRequest request)
        {
            //return new KeyDocumentProofResponse()
            //{
            //    data = new KeyDocumentProofResponseData() { JobId = "2984" }
            //};
            KeyDocumentProofResponse response = new KeyDocumentProofResponse();
            var keyDocumentDetails            = _repo.GetKeyDocument(new KeyDocumentRequest()
            {
                KeyDocumentId = request.KeyDocumentId
            }).data;

            if (keyDocumentDetails != null && (!string.IsNullOrEmpty(keyDocumentDetails.CampaignId)) &&
                keyDocumentDetails.DesignFileId.HasValue &&
                keyDocumentDetails.DesignFileId > 0)
            {
                var keyDocumentResponse = _repo.GetKeyDocument(new KeyDocumentRequest()
                {
                    KeyDocumentId = request.KeyDocumentId
                });

                Customization[] customizations = GenerateCustomizationsForKeyDocument(keyDocumentDetails.KeyDocumentId, keyDocumentResponse);

                var jobTicketId = _uproduceRepo.CreateJobTicket(keyDocumentDetails.DocumentId, keyDocumentDetails.DataSourceId, "PROOF");
                if (!string.IsNullOrEmpty(jobTicketId))
                {
                    List <JobDataSource> dataSources = GenerateCSVForPersonalizedAndCustomizedVariables(keyDocumentResponse, jobTicketId);

                    var jobId = _uproduceRepo.ProduceDocument(keyDocumentDetails.DocumentId, keyDocumentDetails.DataSourceId, customizations, "PROOF", jobTicketId, dataSources);

                    if (string.IsNullOrEmpty(jobId))
                    {
                        response.Error = CreateCustomError("Error while submitting job", "Error occurred while submitting proofing job");
                    }
                    else
                    {
                        response.data.JobId = jobId;
                    }
                }
                else
                {
                    response.Error = CreateCustomError("Unable to generate job ticket for the keydocument",
                                                       "Error while creating a job ticket for proof request");
                }
            }
            else
            {
                response.Error = CreateCustomError("Unable to generate proof for the keydocument",
                                                   "Requested template is missing campaignid or Designfile in Uproduce");
            }

            return(response);
        }
コード例 #2
0
        public void KeyDocumentService_ProofKeyDocument_RepoReturnsData_ServiceReturnsTheDataWithoutError()
        {
            //Arrange
            KeyDocumentProofRequest request = new KeyDocumentProofRequest() { KeyDocumentId = 2 };
            string returnedResponse = "2";
            KeyDocument keyDocumentResponse = new KeyDocument() { CampaignId = "2", DesignFileId = 3, DocumentId = "2", DataSourceId = "3", KeyDocumentId = 1 };
            List<vwKeyDocumentSearch> keyListResponse = new List<vwKeyDocumentSearch>() { new vwKeyDocumentSearch { FieldName = "test", FieldValue = "testvalue" } };
            var uproduceRepo = new Mock<IUProduceRepository>();
            var keyDocRepo = new Mock<IKeyDocumentRepository>();
            var templateRepo = new Mock<ITemplateRepository>();
            keyDocRepo.Setup(p => p.GetKeyDocument(It.IsAny<KeyDocumentRequest>())).Returns(new KeyDocumentResponse() { data = keyDocumentResponse });
            keyDocRepo.Setup(p => p.GetKeyDocumentItems(It.IsAny<int>())).Returns(keyListResponse);
            uproduceRepo.Setup(p => p.ProduceDocument(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Customization[]>(), It.IsAny<string>(), It.IsAny<string>(), null)).Returns(returnedResponse);
            // Act.
            KeyDocumentService svc = new KeyDocumentService(keyDocRepo.Object, uproduceRepo.Object, templateRepo.Object);
            var response = svc.ProofKeyDocument(request);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.data.JobId);
            Assert.IsNull(response.Error);
        }
コード例 #3
0
        public void KeyDocumentService_ProofKeyDocument_RepoReturnsData_ServiceReturnsTheDataWithoutError()
        {
            //Arrange
            KeyDocumentProofRequest request = new KeyDocumentProofRequest()
            {
                KeyDocumentId = 2
            };
            string      returnedResponse    = "2";
            KeyDocument keyDocumentResponse = new KeyDocument()
            {
                CampaignId = "2", DesignFileId = 3, DocumentId = "2", DataSourceId = "3", KeyDocumentId = 1
            };
            List <vwKeyDocumentSearch> keyListResponse = new List <vwKeyDocumentSearch>()
            {
                new vwKeyDocumentSearch {
                    FieldName = "test", FieldValue = "testvalue"
                }
            };
            var uproduceRepo = new Mock <IUProduceRepository>();
            var keyDocRepo   = new Mock <IKeyDocumentRepository>();
            var templateRepo = new Mock <ITemplateRepository>();

            keyDocRepo.Setup(p => p.GetKeyDocument(It.IsAny <KeyDocumentRequest>())).Returns(new KeyDocumentResponse()
            {
                data = keyDocumentResponse
            });
            keyDocRepo.Setup(p => p.GetKeyDocumentItems(It.IsAny <int>())).Returns(keyListResponse);
            uproduceRepo.Setup(p => p.ProduceDocument(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Customization[]>(), It.IsAny <string>(), It.IsAny <string>(), null)).Returns(returnedResponse);
            // Act.
            KeyDocumentService svc = new KeyDocumentService(keyDocRepo.Object, uproduceRepo.Object, templateRepo.Object);
            var response           = svc.ProofKeyDocument(request);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.data.JobId);
            Assert.IsNull(response.Error);
        }
コード例 #4
0
        public KeyDocumentProofResponse ProofKeyDocument(KeyDocumentProofRequest request)
        {
            //return new KeyDocumentProofResponse()
            //{
            //    data = new KeyDocumentProofResponseData() { JobId = "2984" }
            //};
            KeyDocumentProofResponse response = new KeyDocumentProofResponse();
            var keyDocumentDetails = _repo.GetKeyDocument(new KeyDocumentRequest() { KeyDocumentId = request.KeyDocumentId }).data;
            if (keyDocumentDetails != null && (!string.IsNullOrEmpty(keyDocumentDetails.CampaignId)) &&
                    keyDocumentDetails.DesignFileId.HasValue &&
                    keyDocumentDetails.DesignFileId > 0)
            {

                var keyDocumentResponse = _repo.GetKeyDocument(new KeyDocumentRequest() { KeyDocumentId = request.KeyDocumentId });

                Customization[] customizations = GenerateCustomizationsForKeyDocument(keyDocumentDetails.KeyDocumentId, keyDocumentResponse);

                var jobTicketId = _uproduceRepo.CreateJobTicket(keyDocumentDetails.DocumentId, keyDocumentDetails.DataSourceId, "PROOF");
                if (!string.IsNullOrEmpty(jobTicketId))
                {
                    List<JobDataSource> dataSources = GenerateCSVForPersonalizedAndCustomizedVariables(keyDocumentResponse, jobTicketId);

                    var jobId = _uproduceRepo.ProduceDocument(keyDocumentDetails.DocumentId, keyDocumentDetails.DataSourceId, customizations, "PROOF", jobTicketId, dataSources);

                    if (string.IsNullOrEmpty(jobId))
                    {
                        response.Error = CreateCustomError("Error while submitting job", "Error occurred while submitting proofing job");
                    }
                    else
                    {
                        response.data.JobId = jobId;
                    }
                }
                else
                {
                    response.Error = CreateCustomError("Unable to generate job ticket for the keydocument",
                    "Error while creating a job ticket for proof request");
                }
            }
            else
            {
                response.Error = CreateCustomError("Unable to generate proof for the keydocument",
                    "Requested template is missing campaignid or Designfile in Uproduce");
            }

            return response;
        }