-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
c46b414
commit e1d9f28
Showing
68 changed files
with
2,113 additions
and
2,033 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
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,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/> | ||
</packageSources> | ||
</configuration> |
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
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,64 +1,67 @@ | ||
// Copyright (c) 2022 DrBarnabus | ||
|
||
using DacTools.Deployment.Core.Common; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using DacTools.Deployment.Core.Common; | ||
using DacTools.Deployment.Core.DatabaseListGenerators; | ||
using DacTools.Deployment.Core.Logging; | ||
|
||
namespace DacTools.Deployment.Core.AsyncTasks | ||
namespace DacTools.Deployment.Core.AsyncTasks; | ||
|
||
public abstract class AsyncTaskBase : IAsyncTask | ||
{ | ||
public abstract class AsyncTaskBase : IAsyncTask | ||
{ | ||
private readonly ILog _log; | ||
private readonly IActiveBuildServer _buildServer; | ||
private readonly IActiveBuildServer _buildServer; | ||
private readonly ILog _log; | ||
|
||
protected AsyncTaskBase(Arguments arguments, ILog log, IActiveBuildServer buildServer) | ||
{ | ||
Arguments = arguments; | ||
_log = log; | ||
_buildServer = buildServer; | ||
} | ||
protected AsyncTaskBase(Arguments arguments, ILog log, IActiveBuildServer buildServer) | ||
{ | ||
Arguments = arguments; | ||
_log = log; | ||
_buildServer = buildServer; | ||
} | ||
|
||
protected Arguments Arguments { get; } | ||
protected Arguments Arguments { get; } | ||
|
||
protected Action<IAsyncTask, bool, long>? ProgressUpdate { get; private set; } | ||
protected Action<IAsyncTask, bool, long>? ProgressUpdate { get; private set; } | ||
|
||
public DatabaseInfo? DatabaseInfo { get; private set; } | ||
public DatabaseInfo? DatabaseInfo { get; private set; } | ||
|
||
public void Setup(DatabaseInfo databaseInfo, Action<IAsyncTask, bool, long> progressUpdate) | ||
{ | ||
DatabaseInfo = databaseInfo ?? throw new ArgumentNullException(nameof(databaseInfo)); | ||
ProgressUpdate = progressUpdate ?? throw new ArgumentNullException(nameof(progressUpdate)); | ||
} | ||
public void Setup(DatabaseInfo databaseInfo, Action<IAsyncTask, bool, long> progressUpdate) | ||
{ | ||
DatabaseInfo = databaseInfo ?? throw new ArgumentNullException(nameof(databaseInfo)); | ||
ProgressUpdate = progressUpdate ?? throw new ArgumentNullException(nameof(progressUpdate)); | ||
} | ||
|
||
public abstract Task Run(CancellationToken cancellationToken); | ||
public abstract Task Run(CancellationToken cancellationToken); | ||
|
||
protected void LogError(string source, string formatString, params object[] args) | ||
{ | ||
_log.Error($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
protected void LogError(string source, string formatString, params object[] args) | ||
{ | ||
_log.Error($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
|
||
if (_buildServer.IsActive && _buildServer.Instance is not null) | ||
_log.WriteRaw(LogLevel.Error, _buildServer.Instance.GenerateLogIssueErrorMessage(string.Format($"'{DatabaseInfo}' {source} - {formatString}", args))); | ||
} | ||
if (_buildServer.IsActive && _buildServer.Instance is not null) | ||
_log.WriteRaw(LogLevel.Error, | ||
_buildServer.Instance.GenerateLogIssueErrorMessage( | ||
string.Format($"'{DatabaseInfo}' {source} - {formatString}", args))); | ||
} | ||
|
||
protected void LogWarning(string source, string formatString, params object[] args) | ||
{ | ||
_log.Warning($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
protected void LogWarning(string source, string formatString, params object[] args) | ||
{ | ||
_log.Warning($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
|
||
if (_buildServer.IsActive && _buildServer.Instance is not null) | ||
_log.WriteRaw(LogLevel.Warn, _buildServer.Instance.GenerateLogIssueWarningMessage(string.Format($"'{DatabaseInfo}' {source} - {formatString}", args))); | ||
} | ||
if (_buildServer.IsActive && _buildServer.Instance is not null) | ||
_log.WriteRaw(LogLevel.Warn, | ||
_buildServer.Instance.GenerateLogIssueWarningMessage( | ||
string.Format($"'{DatabaseInfo}' {source} - {formatString}", args))); | ||
} | ||
|
||
protected void LogInfo(string source, string formatString, params object[] args) | ||
{ | ||
_log.Info($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
} | ||
protected void LogInfo(string source, string formatString, params object[] args) | ||
{ | ||
_log.Info($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
} | ||
|
||
protected void LogDebug(string source, string formatString, params object[] args) | ||
{ | ||
_log.Debug($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
} | ||
protected void LogDebug(string source, string formatString, params object[] args) | ||
{ | ||
_log.Debug($"'{DatabaseInfo}' {source} - {formatString}", args); | ||
} | ||
} |
32 changes: 17 additions & 15 deletions
32
src/DacTools.Deployment.Core/AsyncTasks/AsyncTaskFactory.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,26 +1,28 @@ | ||
// Copyright (c) 2022 DrBarnabus | ||
|
||
using DacTools.Deployment.Core.Common; | ||
using System; | ||
using DacTools.Deployment.Core.Common; | ||
using DacTools.Deployment.Core.Logging; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace DacTools.Deployment.Core.AsyncTasks | ||
namespace DacTools.Deployment.Core.AsyncTasks; | ||
|
||
public class AsyncTaskFactory<TAsyncTask> : IAsyncTaskFactory<TAsyncTask> | ||
where TAsyncTask : AsyncTaskBase | ||
{ | ||
public class AsyncTaskFactory<TAsyncTask> : IAsyncTaskFactory<TAsyncTask> | ||
where TAsyncTask : AsyncTaskBase | ||
{ | ||
private readonly Arguments _arguments; | ||
private readonly ILog _log; | ||
private readonly IActiveBuildServer _buildServer; | ||
private readonly Arguments _arguments; | ||
private readonly IActiveBuildServer _buildServer; | ||
private readonly ILog _log; | ||
|
||
public AsyncTaskFactory(IOptions<Arguments> arguments, ILog log, IActiveBuildServer buildServer) | ||
{ | ||
_arguments = arguments.Value; | ||
_log = log; | ||
_buildServer = buildServer; | ||
} | ||
public AsyncTaskFactory(IOptions<Arguments> arguments, ILog log, IActiveBuildServer buildServer) | ||
{ | ||
_arguments = arguments.Value; | ||
_log = log; | ||
_buildServer = buildServer; | ||
} | ||
|
||
public TAsyncTask CreateAsyncTask() => (TAsyncTask)Activator.CreateInstance(typeof(TAsyncTask), _arguments, _log, _buildServer); | ||
public TAsyncTask CreateAsyncTask() | ||
{ | ||
return (TAsyncTask)Activator.CreateInstance(typeof(TAsyncTask), _arguments, _log, _buildServer); | ||
} | ||
} |
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
Oops, something went wrong.