* Added method to Delete task

* Added WorkingDirectory to RunProcess method
This commit is contained in:
2025-02-16 17:42:10 +01:00
parent 8aad585ce9
commit 06efb220dc
4 changed files with 39 additions and 4 deletions

View File

@@ -83,6 +83,21 @@ public class HangfireJobsController(JobStorage jobStorage, IRecurringJobManager
return Ok("Zadanie zostało dodane.");
}
[HttpPost("DeleteTask")]
public async Task<IActionResult> DeleteTask([FromBody] TaskSchedulerDto taskSchedulerDto)
{
int result = await service.DeleteTaskScheduler(taskSchedulerDto.RowPointer);
if (result == 0)
{
return BadRequest("Nie udało się usunąć zadania.");
}
recurringJobManager.RemoveIfExists(taskSchedulerDto.Name);
return Ok("Zadanie zostało usunięte.");
}
[HttpGet("GetTasks")]
public async Task<ActionResult<IEnumerable<TaskSchedulerDto>>> GetTasks()
{
@@ -117,7 +132,8 @@ public class HangfireJobsController(JobStorage jobStorage, IRecurringJobManager
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
CreateNoWindow = true,
WorkingDirectory = Path.GetDirectoryName(pathToApp)
}
};
process.Start();