-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from JaimeStill/service
initial processing library + service test
- Loading branch information
Showing
7 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Arma.Demo.Core.Processing; | ||
public class Package | ||
{ | ||
public static Guid Key => Guid.NewGuid(); | ||
public string Name { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Arma.Demo.Core.Processing; | ||
public class Process | ||
{ | ||
public string Name { get; set; } | ||
|
||
public List<ProcessTask> Tasks { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Arma.Demo.Core.Processing; | ||
public class ProcessTask | ||
{ | ||
public int Step { get; set; } | ||
public string Name { get; set; } | ||
public string Section { get; set; } | ||
public int Duration { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Arma.Demo.Core.Processing; | ||
|
||
namespace Processor; | ||
public static class PackageGenerator | ||
{ | ||
public static Package ApprovalPackage() => | ||
new() { Name = "Demo Approval" }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Arma.Demo.Core.Processing; | ||
|
||
namespace Processor; | ||
public static class ProcessGenerator | ||
{ | ||
public static Process ApprovalProcess() => | ||
new() | ||
{ | ||
Name = "Demo Approval Process", | ||
Tasks = new() | ||
{ | ||
new() | ||
{ | ||
Name = "Security Review", | ||
Section = "Cybersecurity", | ||
Step = 1, | ||
Duration = 800 | ||
}, | ||
new() | ||
{ | ||
Name = "Legal Review", | ||
Section = "Legal", | ||
Step = 2, | ||
Duration = 1100 | ||
}, | ||
new() | ||
{ | ||
Name = "Informal Review", | ||
Section = "Operational Review Board", | ||
Step = 3, | ||
Duration = 500 | ||
}, | ||
new() | ||
{ | ||
Name = "Formal Review", | ||
Section = "Command Review Board", | ||
Step = 4, | ||
Duration = 1800 | ||
}, | ||
new() | ||
{ | ||
Name = "Final Approval", | ||
Section = "Headquarters Commander", | ||
Step = 5, | ||
Duration = 1000 | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Arma.Demo.Core\Arma.Demo.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Arma.Demo.Core.Processing; | ||
using Processor; | ||
|
||
Package package = PackageGenerator.ApprovalPackage(); | ||
|
||
Console.WriteLine($"Submitting package {package.Name} for approval"); | ||
|
||
await Task.Delay(1200); | ||
|
||
Process process = ProcessGenerator.ApprovalProcess(); | ||
|
||
Console.WriteLine($"Package {package.Name} assigned process {process.Name}"); | ||
|
||
foreach (ProcessTask task in process.Tasks) | ||
{ | ||
Console.WriteLine($"Current step: {task.Name}"); | ||
await Task.Delay(task.Duration); | ||
Console.WriteLine($"Package {package.Name} was approved by {task.Section}"); | ||
} | ||
|
||
Console.WriteLine($"Package {package.Name} was successfully approved"); |