generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
110 changed files
with
5,053 additions
and
4,380 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 |
---|---|---|
@@ -1,14 +1,77 @@ | ||
# For more information do to https://github.com/Kentico/Home/wiki/CI-and-Automation-Guidelines | ||
|
||
name: "Build" # Represents the name of the whole action. | ||
on: # Specifies the section where we describe our build triggers. | ||
push: # The action runs with push. | ||
pull_request: # The action runs with a pull request. | ||
schedule: # Specifies the section where we describe the schedule of running the action. | ||
- cron: '0 18 * * 1' # The CRON expression describes when to run the action. | ||
jobs: # Specifies the section where we describe our jobs. | ||
Build: # Specific job section. | ||
runs-on: ubuntu-latest # Describes the environment. | ||
steps: # Specifies the section where we describe the job's steps. | ||
- name: Output some string | ||
run: echo "Set some actual CI steps" | ||
name: "CI: Build and Test" | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- "**.cs" | ||
- "**.tsx" | ||
- "**.js" | ||
- "**.csproj" | ||
- "**.props" | ||
- "**.targets" | ||
- "**.sln" | ||
pull_request: | ||
branches: [master] | ||
paths: | ||
- ".github/workflows/build.yml" | ||
- "**.cs" | ||
- "**.cshtml" | ||
- "**.tsx" | ||
- "**.js" | ||
- "**.json" | ||
- "**.csproj" | ||
- "**.props" | ||
- "**.targets" | ||
- "**.sln" | ||
|
||
jobs: | ||
dotnet-format: | ||
name: .Net Format Check | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run dotnet format | ||
run: dotnet format --exclude ./examples/** --verify-no-changes | ||
|
||
build_and_test: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
needs: dotnet-format | ||
defaults: | ||
run: | ||
shell: pwsh | ||
|
||
env: | ||
ASPNETCORE_ENVIRONMENT: CI | ||
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | ||
DOTNET_NOLOGO: 1 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
global-json-file: global.json | ||
|
||
- name: Install dependencies | ||
run: | | ||
dotnet restore ` | ||
--locked-mode | ||
- name: Build Solution | ||
run: | | ||
dotnet build ` | ||
--configuration Release ` | ||
--no-restore | ||
- name: Test Solution | ||
run: | | ||
dotnet test ` | ||
--configuration Release ` | ||
--no-build ` | ||
--no-restore |
198 changes: 99 additions & 99 deletions
198
KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs
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 |
---|---|---|
@@ -1,100 +1,100 @@ | ||
namespace Migration.Toolkit.Source.Contexts; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
using Migration.Toolkit.Common; | ||
using Migration.Toolkit.Common.Services.Ipc; | ||
using Migration.Toolkit.Source.Model; | ||
|
||
public class SourceInstanceContext( | ||
IpcService ipcService, | ||
ILogger<SourceInstanceContext> logger, | ||
ToolkitConfiguration configuration, | ||
ModelFacade modelFacade) | ||
{ | ||
private readonly Dictionary<string, SourceInstanceDiscoveredInfo> _cachedInfos = new(StringComparer.InvariantCultureIgnoreCase); | ||
|
||
private bool _sourceInfoLoaded; | ||
|
||
public bool HasInfo => _cachedInfos.Count > 0 && _sourceInfoLoaded; | ||
|
||
public bool IsQuerySourceInstanceEnabled() | ||
{ | ||
return configuration.OptInFeatures?.QuerySourceInstanceApi?.Enabled ?? false; | ||
} | ||
|
||
public async Task<bool> RequestSourceInstanceInfo() | ||
{ | ||
if (!_sourceInfoLoaded) | ||
{ | ||
var result = await ipcService.GetSourceInstanceDiscoveredInfos(); | ||
foreach (var (key, value) in result) | ||
{ | ||
_cachedInfos.Add(key, value); | ||
logger.LogInformation("Source instance info loaded for site '{SiteName}' successfully", key); | ||
} | ||
|
||
_sourceInfoLoaded = true; | ||
} | ||
|
||
return _sourceInfoLoaded; | ||
} | ||
|
||
public List<EditingFormControlModel>? GetWidgetPropertyFormComponents(string siteName, string widgetIdentifier) | ||
{ | ||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.WidgetProperties != null && info.WidgetProperties.TryGetValue(widgetIdentifier, out var widgetProperties) | ||
? widgetProperties | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetPageTemplateFormComponents(string siteName, string pageTemplateIdentifier) | ||
{ | ||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.PageTemplateProperties != null && info.PageTemplateProperties.TryGetValue(pageTemplateIdentifier, out var pageTemplate) | ||
? pageTemplate | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetWidgetPropertyFormComponents(int siteId, string widgetIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
return GetWidgetPropertyFormComponents(siteName, widgetIdentifier); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetPageTemplateFormComponents(int siteId, string pageTemplateIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
return GetPageTemplateFormComponents(siteName, pageTemplateIdentifier); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetSectionFormComponents(int siteId, string sectionIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.SectionProperties != null && info.SectionProperties.TryGetValue(sectionIdentifier, out var sectionFcs) | ||
? sectionFcs | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
namespace Migration.Toolkit.Source.Contexts; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
using Migration.Toolkit.Common; | ||
using Migration.Toolkit.Common.Services.Ipc; | ||
using Migration.Toolkit.Source.Model; | ||
|
||
public class SourceInstanceContext( | ||
IpcService ipcService, | ||
ILogger<SourceInstanceContext> logger, | ||
ToolkitConfiguration configuration, | ||
ModelFacade modelFacade) | ||
{ | ||
private readonly Dictionary<string, SourceInstanceDiscoveredInfo> _cachedInfos = new(StringComparer.InvariantCultureIgnoreCase); | ||
|
||
private bool _sourceInfoLoaded; | ||
|
||
public bool HasInfo => _cachedInfos.Count > 0 && _sourceInfoLoaded; | ||
|
||
public bool IsQuerySourceInstanceEnabled() | ||
{ | ||
return configuration.OptInFeatures?.QuerySourceInstanceApi?.Enabled ?? false; | ||
} | ||
|
||
public async Task<bool> RequestSourceInstanceInfo() | ||
{ | ||
if (!_sourceInfoLoaded) | ||
{ | ||
var result = await ipcService.GetSourceInstanceDiscoveredInfos(); | ||
foreach (var (key, value) in result) | ||
{ | ||
_cachedInfos.Add(key, value); | ||
logger.LogInformation("Source instance info loaded for site '{SiteName}' successfully", key); | ||
} | ||
|
||
_sourceInfoLoaded = true; | ||
} | ||
|
||
return _sourceInfoLoaded; | ||
} | ||
|
||
public List<EditingFormControlModel>? GetWidgetPropertyFormComponents(string siteName, string widgetIdentifier) | ||
{ | ||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.WidgetProperties != null && info.WidgetProperties.TryGetValue(widgetIdentifier, out var widgetProperties) | ||
? widgetProperties | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetPageTemplateFormComponents(string siteName, string pageTemplateIdentifier) | ||
{ | ||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.PageTemplateProperties != null && info.PageTemplateProperties.TryGetValue(pageTemplateIdentifier, out var pageTemplate) | ||
? pageTemplate | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetWidgetPropertyFormComponents(int siteId, string widgetIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
return GetWidgetPropertyFormComponents(siteName, widgetIdentifier); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetPageTemplateFormComponents(int siteId, string pageTemplateIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
return GetPageTemplateFormComponents(siteName, pageTemplateIdentifier); | ||
} | ||
|
||
public List<EditingFormControlModel>? GetSectionFormComponents(int siteId, string sectionIdentifier) | ||
{ | ||
var siteName = | ||
modelFacade.SelectById<ICmsSite>(siteId)?.SiteName | ||
?? throw new InvalidOperationException($"Source site with SiteID '{siteId}' not exists"); | ||
|
||
if (_cachedInfos.TryGetValue(siteName, out var info)) | ||
{ | ||
return info.SectionProperties != null && info.SectionProperties.TryGetValue(sectionIdentifier, out var sectionFcs) | ||
? sectionFcs | ||
: null; | ||
} | ||
|
||
throw new InvalidOperationException($"No info was loaded for site '{siteName}'"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
namespace Migration.Toolkit.Source.Helpers; | ||
|
||
using CMS.Helpers; | ||
|
||
public static class KenticoHelper | ||
{ | ||
public static void CopyCustomData(ContainerCustomData target, string? sourceXml) | ||
{ | ||
var customNodeData = new ContainerCustomData(); | ||
customNodeData.LoadData(sourceXml); | ||
foreach (var columnName in customNodeData.ColumnNames) | ||
{ | ||
target.SetValue(columnName, customNodeData.GetValue(columnName)); | ||
} | ||
} | ||
namespace Migration.Toolkit.Source.Helpers; | ||
|
||
using CMS.Helpers; | ||
|
||
public static class KenticoHelper | ||
{ | ||
public static void CopyCustomData(ContainerCustomData target, string? sourceXml) | ||
{ | ||
var customNodeData = new ContainerCustomData(); | ||
customNodeData.LoadData(sourceXml); | ||
foreach (var columnName in customNodeData.ColumnNames) | ||
{ | ||
target.SetValue(columnName, customNodeData.GetValue(columnName)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
namespace Migration.Toolkit.Source.Helpers; | ||
|
||
public static class PrintHelper | ||
{ | ||
public static string PrintDictionary(Dictionary<string, object?> dictionary) => | ||
string.Join(", ", dictionary.Select(x => $"{x.Key}:{x.Value ?? "<null>"}")); | ||
namespace Migration.Toolkit.Source.Helpers; | ||
|
||
public static class PrintHelper | ||
{ | ||
public static string PrintDictionary(Dictionary<string, object?> dictionary) => | ||
string.Join(", ", dictionary.Select(x => $"{x.Key}:{x.Value ?? "<null>"}")); | ||
} |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
namespace Migration.Toolkit.Source; | ||
|
||
using System.Data; | ||
using Migration.Toolkit.Common; | ||
|
||
public interface ISourceModel<out T> | ||
{ | ||
static abstract bool IsAvailable(SemanticVersion version); | ||
static abstract string GetPrimaryKeyName(SemanticVersion version); | ||
static abstract string TableName { get; } | ||
static abstract string GuidColumnName { get; } | ||
static abstract T FromReader(IDataReader reader, SemanticVersion version); | ||
namespace Migration.Toolkit.Source; | ||
|
||
using System.Data; | ||
using Migration.Toolkit.Common; | ||
|
||
public interface ISourceModel<out T> | ||
{ | ||
static abstract bool IsAvailable(SemanticVersion version); | ||
static abstract string GetPrimaryKeyName(SemanticVersion version); | ||
static abstract string TableName { get; } | ||
static abstract string GuidColumnName { get; } | ||
static abstract T FromReader(IDataReader reader, SemanticVersion version); | ||
} |
Oops, something went wrong.