Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="10.0.2" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="10.0.2" />
<PackageVersion Include="System.Data.Odbc" Version="10.0.2" />
<PackageVersion Include="System.Data.SqlClient" Version="4.9.0" />

<PackageVersion Include="System.ServiceProcess.ServiceController" Version="10.0.2" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="10.0.2" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.2" />
Expand Down
5 changes: 3 additions & 2 deletions src/BAUERGROUP.Shared.API/API/GenericAPIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public GenericAPIClient(String url, Int32 timeout = 10 * 1000, IWebProxy? proxy
})
);

Initalize();
Initialize();
Authenticate();
}

private void Initalize()
private void Initialize()
{
Client.AddDefaultHeader(KnownHeaders.Accept, "application/json");
}
Expand Down Expand Up @@ -102,6 +102,7 @@ private void Validate(RestClientOptions clientOptions)
public void Dispose()
{
Client?.Dispose();
GC.SuppressFinalize(this);
}

protected async Task<T> ExceptionHandlerAsync<T>(Func<Task<T>> action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class CloudinaryImageManager : IDisposable
/// </summary>
protected Cloudinary Client { get; private set; } = null!;

/// <summary>
/// Gets or sets the maximum number of results returned by list operations. Default is 500.
/// </summary>
public int MaxListResults { get; set; } = 500;

/// <summary>
/// Initializes a new instance of the <see cref="CloudinaryImageManager"/> class.
/// </summary>
Expand All @@ -32,10 +37,10 @@ public CloudinaryImageManager(CloudinaryImageManagerConfiguration configuration)
{
Configuration = configuration;

Initalize();
Initialize();
}

private void Initalize()
private void Initialize()
{
var account = new Account(Configuration.Name, Configuration.APIKey, Configuration.APISecret);
Client = new Cloudinary(account);
Expand All @@ -46,7 +51,7 @@ private void Initalize()
/// </summary>
public void Dispose()
{

GC.SuppressFinalize(this);
}

/// <summary>
Expand Down Expand Up @@ -183,7 +188,7 @@ public Resource[] List(String? uniqueIdentifier = null, CloudinaryContentType co
{
var listParameters = new ListResourcesParams()
{
MaxResults = 500,
MaxResults = MaxListResults,
ResourceType = contentType == CloudinaryContentType.Image ? ResourceType.Image : ResourceType.Video
};

Expand Down
5 changes: 3 additions & 2 deletions src/BAUERGROUP.Shared.Cloud/FixerIO/FixerIOClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public FixerIOClient(FixerIOConfiguration configuration)
})
);

Initalize();
Initialize();
}

private void Validate()
Expand All @@ -78,7 +78,7 @@ private void Validate()
throw new FixerIOClientException($"Invalid API URL '{Configuration.URL}'.", new ArgumentException("Invalid URL"));
}

private void Initalize()
private void Initialize()
{
Client.AddDefaultHeader(KnownHeaders.Accept, "application/json");
}
Expand All @@ -97,6 +97,7 @@ private static string GetUserAgent()
public void Dispose()
{
Client.Dispose();
GC.SuppressFinalize(this);
}

protected async Task<T> ExceptionHandlerAsync<T>(Func<Task<T>> action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ namespace BAUERGROUP.Shared.Core.Application
/// <summary>
/// Base class for application lifecycle management.
/// </summary>
public class ApplicationController: IDisposable
public class ApplicationController : IDisposable
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationController"/> class.
/// </summary>
public ApplicationController()
{

}

/// <summary>
/// Releases all resources used by the <see cref="ApplicationController"/>.
/// Subclasses should override this method to release managed resources.
/// </summary>
public void Dispose()
public virtual void Dispose()
{

GC.SuppressFinalize(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static string GetDefaultRelease()
var version = assembly.GetName().Version;
return $"{name}@{version}";
}
catch
catch (Exception)
{
return "unknown";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public BGErrorTrackingConfiguration()
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
ApplicationName = Path.GetFileNameWithoutExtension(assembly.Location);
}
catch
catch (Exception)
{
ApplicationName = "Unknown";
}
Expand Down
2 changes: 2 additions & 0 deletions src/BAUERGROUP.Shared.Core/Files/CSVFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public void Dispose()

_cr = null;
_sr = null;

GC.SuppressFinalize(this);
}

public void Close()
Expand Down
2 changes: 2 additions & 0 deletions src/BAUERGROUP.Shared.Core/Files/CSVFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public void Dispose()

_cw = null;
_sw = null;

GC.SuppressFinalize(this);
}

public void Close()
Expand Down
1 change: 1 addition & 0 deletions src/BAUERGROUP.Shared.Core/Files/FileChangesMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void OnFileChanged(Object sender, FileSystemEventArgs e)
public void Dispose()
{
_fsw.Dispose();
GC.SuppressFinalize(this);
}
}
}
15 changes: 13 additions & 2 deletions src/BAUERGROUP.Shared.Core/Files/FileManagementUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ public static void CopyDirectoryContents(String sourceDirectory, String destinat
if (sourceDirectory == destinationDirectory)
throw new ArgumentException("Source and destination cannot be the same directory.");

// Normalize paths to ensure consistent trailing separator
var normalizedSource = Path.GetFullPath(sourceDirectory)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
+ Path.DirectorySeparatorChar;

foreach (var path in Directory.GetDirectories(sourceDirectory, "*", SearchOption.AllDirectories))
Directory.CreateDirectory(path.Replace(sourceDirectory, destinationDirectory));
{
var relativePath = path.Substring(normalizedSource.Length);
Directory.CreateDirectory(Path.Combine(destinationDirectory, relativePath));
}

foreach (var path in Directory.GetFiles(sourceDirectory, "*.*", SearchOption.AllDirectories))
File.Copy(path, path.Replace(sourceDirectory, destinationDirectory), true);
{
var relativePath = path.Substring(normalizedSource.Length);
File.Copy(path, Path.Combine(destinationDirectory, relativePath), true);
}
}
}
}
1 change: 1 addition & 0 deletions src/BAUERGROUP.Shared.Core/Files/ZIPFileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public List<Stream> GetFilesAsStreamList()
public void Dispose()
{
ZIP.Close();
GC.SuppressFinalize(this);
}
}
}
12 changes: 6 additions & 6 deletions src/BAUERGROUP.Shared.Core/Logging/BGLoggerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public BGLoggerConfiguration()
"Logging");

//Instances
InitalizeTargets();
InitalizeRules();
InitializeTargets();
InitializeRules();

//Set default Ports
NetworkPort = DefaultNetworkPort;
Expand Down Expand Up @@ -69,7 +69,7 @@ public BGLoggerConfiguration()
Debug = true;
#endif

InitalizeCustomTargets();
InitializeCustomTargets();
}

public static String ApplicationName
Expand Down Expand Up @@ -538,7 +538,7 @@ public void AllTargets(bool enable = true)
Network = Mail = File = Console = Debug = NLogViewer = enable;
}

private void InitalizeTargets()
private void InitializeTargets()
{
Targets = new LoggingConfiguration();

Expand Down Expand Up @@ -648,7 +648,7 @@ private void InitalizeTargets()
TargetErrorTracking.ContextProperties.Add(new TargetPropertyWithContext("CallSite", "${callsite:includeNamespace=true}"));
}

private void InitalizeRules()
private void InitializeRules()
{
LoggingRuleFile = new LoggingRule("*", LogLevel.Debug, TargetFile);
LoggingRuleDebug = new LoggingRule("*", LogLevel.Debug, TargetDebug);
Expand Down Expand Up @@ -707,7 +707,7 @@ public void Reconfigure()
LogManager.ReconfigExistingLoggers();
}

protected virtual void InitalizeCustomTargets()
protected virtual void InitializeCustomTargets()
{
/*
var x = new WebServiceTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
GC.SuppressFinalize(this);
}
}
}
9 changes: 7 additions & 2 deletions src/BAUERGROUP.Shared.Core/PeriodicExecution/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class Scheduler : IScheduler
private readonly object _lock = new();
private bool _disposed;

/// <summary>
/// Gets or sets the timeout for waiting on running jobs during stop. Default is 30 seconds.
/// </summary>
public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromSeconds(30);

/// <inheritdoc />
public IReadOnlyList<ISchedulerObject> Jobs => _jobs.AsReadOnly();

Expand Down Expand Up @@ -102,10 +107,10 @@ public async Task StopAsync(CancellationToken cancellationToken = default)
try
{
#if NET6_0_OR_GREATER
await Task.WhenAll(tasksToWait).WaitAsync(TimeSpan.FromSeconds(30), cancellationToken);
await Task.WhenAll(tasksToWait).WaitAsync(ShutdownTimeout, cancellationToken);
#else
var allTasks = Task.WhenAll(tasksToWait);
var completedTask = await Task.WhenAny(allTasks, Task.Delay(TimeSpan.FromSeconds(30), cancellationToken));
var completedTask = await Task.WhenAny(allTasks, Task.Delay(ShutdownTimeout, cancellationToken));
if (completedTask != allTasks)
{
BGLogger.Warn("Scheduler stop timed out waiting for jobs to complete");
Expand Down
3 changes: 1 addition & 2 deletions src/BAUERGROUP.Shared.Core/Streams/StreamUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public static Boolean CopyRessourceToFile(String ressource, String filename, Typ
if (resourceStream == null)
return false;

FileStream fileStream = new FileStream(filename, FileMode.Create);
using var fileStream = new FileStream(filename, FileMode.Create);
resourceStream.CopyTo(fileStream);
fileStream.Close();
}

return true;
Expand Down
1 change: 1 addition & 0 deletions src/BAUERGROUP.Shared.Core/Utilities/LockingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public LockingList(String name)
public void Dispose()
{
_mc.Dispose();
GC.SuppressFinalize(this);
}

/// <summary>
Expand Down
Loading
Loading