public async Task <byte[]> WebAPICall(AccessibleConversionJob accj) { //return Encoding.ASCII.GetBytes("test"); byte[] byteRes = null; AccessibleConversionRepository accJobRepo = new AccessibleConversionRepository(); Guid jobID = await accJobRepo.SubmitWorkItem(accj); while (accJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(2000); } if (accJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = accJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); }
static async Task <byte[]> WebAPICall(BrailleJob brj) { //return Encoding.ASCII.GetBytes("test"); byte[] byteRes = null; BrailleJobRepository brJobRepo = new BrailleJobRepository(); Guid jobID = await brJobRepo.SubmitWorkItem(brj); while (brJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (brJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = brJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); File.WriteAllBytes(resultPath + @"\api.txt", byteRes); } else { //fail //throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); }
public async Task <byte[]> WebAPICall(Job accj) { //return Encoding.ASCII.GetBytes("test"); byte[] byteRes = null; if (format.Equals("EPUB3WMO")) { DaisyRepository daisyJobRepo = new DaisyRepository(); Guid jobID = await daisyJobRepo.SubmitWorkItem((DaisyJob)accj); while (daisyJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (daisyJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = daisyJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); } else { EBookRepository ebookJobRepo = new EBookRepository(); Guid jobID = await ebookJobRepo.SubmitWorkItem((EBookJob)accj); while (ebookJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (ebookJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = ebookJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); } }
public void TestModelTextToSign() { SignLanguageJob sgnj = new SignLanguageJob() { Id = Guid.NewGuid(), FileContent = Encoding.UTF8.GetBytes("This is the first translation job."), UserId = Guid.Parse("d2b97532-e8c5-e411-8270-f0def103cfd0"), FileExtension = "txt", FileName = "test", MimeType = "text/plain", Status = JobStatus.Started, SubmitTime = DateTime.Now, DownloadCounter = 0, InputFileHash = new byte[8], SourceTextLanguage = Language.enGB.ToString(), TargetSignLanguage = Language.enGB.ToString(), SignLanguageForm = SignLanguageType.DeafSignLanguage }; var repo = new SignLanguageRepository(); var jobID = repo.SubmitWorkItem(sgnj).Result; while (repo.GetWorkStatus(jobID) == 2) { //wait Task.Delay(200); } byte[] res = null; if (repo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = repo.GetResultContents(jobID); res = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } NUnit.Framework.Assert.AreEqual("This is the first translation job.", Encoding.UTF8.GetString(res)); }
static async Task <byte[]> WebAPICall(BrailleJob brj) { byte[] byteRes = null; var brJobRepo = new BrailleRepository(); Guid jobID = await brJobRepo.SubmitWorkItem(brj); while (brJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (brJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = brJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail } return(byteRes); }
public async Task <byte[]> WebAPICall(MSOfficeJob OfficeJob) { byte[] byteRes = null; MSOfficeRepository repo = new MSOfficeRepository(); Guid jobID = await repo.SubmitWorkItem(OfficeJob); while (repo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(2000); } if (repo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = repo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); }
public async Task <byte[]> WebAPICall(DaisyJob dj) { byte[] byteRes = null; DaisyRepository daisyJobRepo = new DaisyRepository(); Guid jobID = await daisyJobRepo.SubmitWorkItem(dj); while (daisyJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (daisyJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = daisyJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); }
public async Task <byte[]> WebAPICall(OcrConversionJob ocrj) { byte[] byteRes = null; OcrConversionRepository ocrJobRepo = new OcrConversionRepository(); Guid jobID = await ocrJobRepo.SubmitWorkItem(ocrj); while (ocrJobRepo.GetWorkStatus(jobID) == 2) { //wait await Task.Delay(200); } if (ocrJobRepo.GetWorkStatus(jobID) == 1) { //sucess FileResult result = ocrJobRepo.GetResultContents(jobID); byteRes = result.getFileContents(); } else { //fail throw new Exception("Task with job ID: " + jobID + " failed"); } return(byteRes); }