Skip to content

Commit

Permalink
Add stop workflow to netcore
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Feb 10, 2024
1 parent 2760026 commit f1c58cb
Show file tree
Hide file tree
Showing 95 changed files with 145 additions and 144 deletions.
13 changes: 6 additions & 7 deletions src/netcore/Wexflow.Core/Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,11 @@ public Guid StartAsync(string startedBy)
_jobsQueue.Enqueue(job);
return Guid.Empty;
}
else if (IsRunning && EnableParallelJobs)

if (IsRunning && EnableParallelJobs)
{
Workflow workflow = new(
WexflowEngine
WexflowEngine
, ++ParallelJobId
, Jobs
, DbId
Expand All @@ -975,7 +976,7 @@ public Guid StartAsync(string startedBy)
, XsdPath
, Database
, GlobalVariables
)
)
{
RestVariables = RestVariables,
StartedBy = startedBy
Expand Down Expand Up @@ -1204,7 +1205,7 @@ public bool StartSync(string startedBy, Guid instanceId, ref bool resultWarning)
Database.DecrementRunningCount();
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
_stopCalled = true;
}
Expand Down Expand Up @@ -1726,9 +1727,7 @@ public bool Stop(string stoppedBy)
_stopCalled = true;
if (_thread != null)
{
#pragma warning disable SYSLIB0006 // Le type ou le membre est obsolète
_thread.Abort();
#pragma warning restore SYSLIB0006 // Le type ou le membre est obsolète
_thread.Interrupt();
_thread.Join();
}
foreach (var task in Tasks)
Expand Down
12 changes: 7 additions & 5 deletions src/netcore/Wexflow.Server/WexflowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ private void StopWorkflow()
{
_ = _endpoints.MapPost(GetPattern("stop"), async context =>
{
var res = false;
var auth = GetAuth(context.Request);
var username = auth.Username;
var password = auth.Password;
Expand All @@ -591,19 +593,19 @@ private void StopWorkflow()
{
if (user.UserProfile == Core.Db.UserProfile.SuperAdministrator)
{
WexflowServer.WexflowEngine.StopWorkflow(workflowId, instanceId, username);
await context.Response.WriteAsync(string.Empty);
res = WexflowServer.WexflowEngine.StopWorkflow(workflowId, instanceId, username);
}
else if (user.UserProfile == Core.Db.UserProfile.Administrator)
{
var workflowDbId = WexflowServer.WexflowEngine.Workflows.First(w => w.Id == workflowId).DbId;
var check = WexflowServer.WexflowEngine.CheckUserWorkflow(user.GetDbId(), workflowDbId);
if (check)
{
WexflowServer.WexflowEngine.StopWorkflow(workflowId, instanceId, username);
await context.Response.WriteAsync(string.Empty);
res = WexflowServer.WexflowEngine.StopWorkflow(workflowId, instanceId, username);
}
}
await context.Response.WriteAsync(JsonConvert.SerializeObject(res));
}
else
{
Expand Down Expand Up @@ -3717,7 +3719,7 @@ private void DownloadFile()
{
var path = context.Request.Query["p"].ToString();
var fileName = Path.GetFileName(path);
context.Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{fileName}\"");
context.Response.Headers.Append("Content-Disposition", $"attachment; filename=\"{fileName}\"");
await context.Response.SendFileAsync(path);
}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.Approval/Approval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override TaskStatus Run()
status = Status.Error;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override TaskStatus Run()
success = false;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand All @@ -66,7 +66,7 @@ public override TaskStatus Run()
}
SharedMemory.Add(smKey, recordIds.ToArray());
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public override TaskStatus Run()
success = false;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand All @@ -118,7 +118,7 @@ public override TaskStatus Run()
}
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.ApproveRecord/ApproveRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ record = Workflow.Database.GetRecord(RecordId);
status = Core.Status.Error;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
var record = Workflow.Database.GetRecord(RecordId);
if (record != null)
Expand Down
4 changes: 2 additions & 2 deletions src/netcore/Wexflow.Tasks.CsvToJson/CsvToJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
success = ConvertFiles(ref atLeastOneSuccess);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down Expand Up @@ -71,7 +71,7 @@ private bool ConvertFiles(ref bool atLeastOneSuccess)
atLeastOneSuccess = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.CsvToSql/CsvToSql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override TaskStatus Run()
}
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.CsvToXml/CsvToXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
4 changes: 2 additions & 2 deletions src/netcore/Wexflow.Tasks.CsvToYaml/CsvToYaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
success = ConvertFiles(ref atLeastOneSuccess);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down Expand Up @@ -71,7 +71,7 @@ private bool ConvertFiles(ref bool atLeastOneSuccess)
atLeastOneSuccess = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()
InfoFormat("The value of the environment variable '{0}' is: {1}", VariableName, value);
succeeded = true;
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.ExecPython/ExecPython.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override Core.TaskStatus Run()
atLeastOneSuccess = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override TaskStatus Run()
success = false;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FileExists/FileExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()

InfoFormat(success ? "The file {0} exists." : "The file {0} does not exists.", File);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FileMatch/FileMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override TaskStatus Run()
InfoFormat("No file was found in the directory {0} matching the pattern {1}.", Dir, Pattern);
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesConcat/FilesConcat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesCopier/FilesCopier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesDecryptor/FilesDecryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override TaskStatus Run()
status = Status.Error;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesDiff/FilesDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override TaskStatus Run()
CheckFiles();
ts = new TaskStatus(Status.Success);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesEncryptor/FilesEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override TaskStatus Run()
status = Status.Error;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesEqual/FilesEqual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override TaskStatus Run()
Files.Add(new FileInf(xmlPath, Id));
InfoFormat("The result has been written in: {0}", xmlPath);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesExist/FilesExist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override TaskStatus Run()
Files.Add(new FileInf(xmlPath, Id));
InfoFormat("The result has been written in: {0}", xmlPath);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesInfo/FilesInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesJoiner/FilesJoiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private bool JoinFiles(string fileName, FileInf[] files)
using var input = File.OpenRead(file.Path);
input.CopyTo(output);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesLoader/FilesLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override TaskStatus Run()
}
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesLoaderEx/FilesLoaderEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public override TaskStatus Run()
AddFiles(tmpFiles);
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesMover/FilesMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesRemover/FilesRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesRenamer/FilesRenamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override TaskStatus Run()
Files.Add(new FileInf(destPath, file.TaskId));
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FilesSplitter/FilesSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override TaskStatus Run()
atLeastOneSucceed = true;
}
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion src/netcore/Wexflow.Tasks.FolderExists/FolderExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()

InfoFormat(success ? "The folder {0} exists." : "The folder {0} does not exist.", Folder);
}
catch (ThreadAbortException)
catch (ThreadInterruptedException)
{
throw;
}
Expand Down
Loading

0 comments on commit f1c58cb

Please sign in to comment.