Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 Done and working #5

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: SonarQube Cloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build and analyze
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner

- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Trubador_SaaS-Factory" /o:"trubador" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
Get-ChildItem -Recurse -Filter *.csproj -Path Code | ForEach-Object { dotnet build $_.FullName }
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
4 changes: 2 additions & 2 deletions DidactCore/Blocks/ActionBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace DidactCore.Blocks
/// <typeparam name="T"></typeparam>
public class ActionBlock<T>
{
private readonly ILogger _logger;
private readonly ILogger<ActionBlock<T>> _logger;
private readonly IBlockRepository _blockRepository;

/// <summary>
Expand Down Expand Up @@ -84,7 +84,7 @@ public class ActionBlock<T>
public bool SoftTimeoutExceeded { get; private set; }


public ActionBlock(ILogger logger, IBlockRepository blockRepository)
public ActionBlock(ILogger<ActionBlock<T>> logger, IBlockRepository blockRepository)
{
_logger = logger;
_blockRepository = blockRepository;
Expand Down
6 changes: 5 additions & 1 deletion DidactCore/Blocks/ActionTaskBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace DidactCore.Blocks
{
/// <summary>
/// An asynchronous execution wrapper that takes an input of type T and returns no output.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ActionTaskBlock
{
private readonly ILogger<ActionTaskBlock> _logger;
Expand All @@ -15,7 +19,7 @@ public ActionTaskBlock(ILogger<ActionTaskBlock> logger)
_logger = logger;
}

public async Task ExecuteDelegateAsyn()
public async Task ExecuteDelegateAsync()
{
_logger.LogInformation("Executing delegate...");
await Executor.Invoke().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using DidactCore.DependencyInjection;
using System.Threading.Tasks;

namespace DidactCore.Blocks.CustomActionBlocks.Boligportal
{
public class BoligportalOrchestratorActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
// call all the other action task blocks in the correct order - plus ability to rerun specific action task blocks that failed while preserving the state of the other action task blocks and data allready fetched and saved to database

// GetListOfAllPropertiesActionTaskBlock in batch of 18 per page
// GetSpecificPropertyActionTaskBlock for batch of 18 properties
// ParseBoligportalHTMLPageToJsonActionTaskBlock
//ConvertBoligportalPropertyToCustomPropertyModelActionTaskBlock
// UploadPropertiesToDatabaseActionTaskBlock
}

public BoligportalOrchestratorActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using DidactCore.DependencyInjection;
using System.Threading.Tasks;

namespace DidactCore.Blocks.GenericActionBlocks
{
public class ConvertBoligportalPropertyToCustomPropertyModelActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{

}

public ConvertBoligportalPropertyToCustomPropertyModelActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using DidactCore.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DidactCore.Blocks.CustomActionBlocks.Boligportal
{
public class GetListOfAllPropertiesActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{

}

public GetListOfAllPropertiesActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using DidactCore.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DidactCore.Blocks.GenericActionBlocks
{
public class GetSpecificPropertyDataActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{

}

public GetSpecificPropertyDataActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using DidactCore.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DidactCore.Blocks.GenericActionBlocks
{
public class UploadPropertiesToDatabaseActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
}

public UploadPropertiesToDatabaseActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
25 changes: 25 additions & 0 deletions DidactCore/Blocks/CustomActionBlocks/OnedriveActionTaskBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using DidactCore.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DidactCore.Blocks.CustomActionBlocks
{
public class OnedriveActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
// call one api to get file metadata
}

public OnedriveActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
27 changes: 27 additions & 0 deletions DidactCore/Blocks/CustomActionBlocks/SupabaseActionTaskBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using DidactCore.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DidactCore.Blocks.CustomActionBlocks
{
public class SupabaseActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
// call supabase api to insert a new row

// call supabase api to read all rows
}

public SupabaseActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
4 changes: 2 additions & 2 deletions DidactCore/Blocks/DelegateBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace DidactCore.Blocks
{
public class DelegateBlock
{
private readonly ILogger _logger;
private readonly ILogger<DelegateBlock> _logger;
private readonly IBlockRepository _blockRepository;

public Delegate Delegate { get; private set; } = null!;

public object[] Arguments { get; private set; } = null!;

public DelegateBlock(ILogger logger, IBlockRepository blockRepository)
public DelegateBlock(ILogger<DelegateBlock> logger, IBlockRepository blockRepository)
{
_logger = logger;
_blockRepository = blockRepository;
Expand Down
34 changes: 34 additions & 0 deletions DidactCore/Blocks/GenericActionBlocks/HttpActionTaskBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using DidactCore.DependencyInjection;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace DidactCore.Blocks.GenericActionBlocks
{
public class HttpActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
Console.WriteLine("call google.dk");

HttpClient client = new HttpClient();
HttpResponseMessage httpResponseMessage1 = await client.GetAsync("https://www.google.dk");
HttpResponseMessage httpResponseMessage = httpResponseMessage1;
HttpResponseMessage response = httpResponseMessage;
var content = await response.Content.ReadAsStringAsync();

Console.WriteLine(content);

// show raw response to console

Console.WriteLine("ran HTTP action task block!");
}

public HttpActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
22 changes: 22 additions & 0 deletions DidactCore/Blocks/GenericActionBlocks/SqlActionTaskBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using DidactCore.DependencyInjection;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace DidactCore.Blocks.GenericActionBlocks
{
public class SqlActionTaskBlock
{
private readonly IDidactDependencyInjector _didactDependencyInjector;

public async Task ExecuteAsync()
{
// SQL CRUD operations
}

public SqlActionTaskBlock(IDidactDependencyInjector didactDependencyInjector)
{
_didactDependencyInjector = didactDependencyInjector;
}
}
}
25 changes: 23 additions & 2 deletions DidactCore/DependencyInjection/DidactDependencyInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@ namespace DidactCore.DependencyInjection
{
public class DidactDependencyInjector : IDidactDependencyInjector
{
public IServiceCollection ApplicationServiceCollection { get; set; }
//public IServiceCollection ApplicationServiceCollection { get; set; }

public IServiceCollection FlowServiceCollection { get; set; }
//public IServiceCollection FlowServiceCollection { get; set; }

//public IServiceProvider ApplicationServiceCollection { get; set; }

//public IServiceProvider FlowServiceCollection { get; set; }

//public IServiceProvider FlowServiceProvider { get; set; }

public IServiceCollection ApplicationServiceCollection { get; set; }
public IServiceCollection FlowServiceCollection { get; set; }
public IServiceProvider FlowServiceProvider { get; set; }

public DidactDependencyInjector(IServiceCollection applicationServiceCollection)
{
//FlowServiceCollection = new ServiceCollection();


ApplicationServiceCollection = applicationServiceCollection;
FlowServiceCollection = applicationServiceCollection;
FlowServiceProvider = FlowServiceCollection.BuildServiceProvider();

//ApplicationServiceCollection = applicationServiceCollection;
//FlowServiceCollection = new ServiceCollection();

//FlowServiceProvider = FlowServiceCollection.BuildServiceProvider();

}

public void ResetServiceCollection()
Expand Down Expand Up @@ -44,5 +61,9 @@ public object CreateInstance(Type type, params object[] parameters)
{
return ActivatorUtilities.CreateInstance(FlowServiceProvider, type, parameters);
}
public void BuildFlowServiceProvider()
{
FlowServiceProvider = FlowServiceCollection.BuildServiceProvider();
}
}
}
Loading