public void DataCheckTest() { this._context = this.InitContext().Result; TaskServiceTest tst = new TaskServiceTest(); tst.FileSetup(); Workflow newWorkflow = new Workflow() { id = "test12345678", inputFolder = "app_files\\TestFiles\\Input", outputFolder = "app_files\\TestFiles\\Output", active = true, name = "workflow_test123456", processor = "masslynx", interval = 10, message = "" }; this._context.Workflows.Add(newWorkflow); LimsServer.Entities.Task tsk = new LimsServer.Entities.Task() { id = "001", workflowID = "test12345678", start = DateTime.Now.AddMinutes(5), taskID = "1234567890", status = "SCHEDULED" }; LimsServer.Entities.Task tsk2 = new LimsServer.Entities.Task() { id = "002", workflowID = "test12345678", start = DateTime.Now.AddMinutes(5), taskID = "1234567890", status = "SCHEDULED" }; this._context.Tasks.Add(tsk); this._context.Tasks.Add(tsk2); this._context.SaveChanges(); TaskService ts = new TaskService(this._context); var tsResult = ts.RunTask(tsk.id); DataBackup db = new DataBackup(); var results = db.DataCheck("000", this._context); Assert.Contains("No task ID found", results); var results2 = db.DataCheck(tsk.id, this._context); Assert.Equal("", ""); var results3 = db.DataCheck(tsk2.id, this._context); Assert.Contains("Backup expired.", results3); }
public async Task <IActionResult> GetTaskData(string id) { DataBackup db = new DataBackup(); string check = db.DataCheck(id, this._context); if (check.Length > 0) { return(BadRequest(check)); } try { string fileName = id + "_backup.zip"; byte[] dataBytes = db.GetTaskData(id, this._context); if (dataBytes == null) { return(View()); } else if (dataBytes.Length == 0) { return(View()); } var mimeType = "application/...."; return(new FileContentResult(dataBytes, mimeType) { FileDownloadName = fileName }); } catch (Exception ex) { Log.Warning(ex, "Error downloading task data."); return(BadRequest("Invalid data request.")); } }