diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs index 601d5ce8..6446af85 100644 --- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs +++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs @@ -15,7 +15,6 @@ using System; using Microsoft.Extensions.DependencyInjection; using System.Text.Json; using System.Net; -using Oqtane.Infrastructure.Interfaces; namespace Oqtane.Controllers { diff --git a/Oqtane.Server/Controllers/ThemeController.cs b/Oqtane.Server/Controllers/ThemeController.cs index c4bafe6a..cf1c24fc 100644 --- a/Oqtane.Server/Controllers/ThemeController.cs +++ b/Oqtane.Server/Controllers/ThemeController.cs @@ -12,10 +12,8 @@ using Oqtane.Infrastructure; using Oqtane.Repository; using System.Text.Json; using System.Net; -using System.Reflection.Metadata; using System; using Microsoft.Extensions.DependencyInjection; -using Oqtane.Infrastructure.Interfaces; // ReSharper disable StringIndexOfIsCultureSpecific.1 diff --git a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs index 32fd81ba..20a11ced 100644 --- a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs +++ b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs @@ -18,7 +18,6 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; using Oqtane.Infrastructure; -using Oqtane.Infrastructure.Interfaces; using Oqtane.Interfaces; using Oqtane.Managers; using Oqtane.Modules; diff --git a/Oqtane.Server/Infrastructure/AliasAccessor.cs b/Oqtane.Server/Infrastructure/AliasAccessor.cs index 87cbecd3..cd095b94 100644 --- a/Oqtane.Server/Infrastructure/AliasAccessor.cs +++ b/Oqtane.Server/Infrastructure/AliasAccessor.cs @@ -4,6 +4,11 @@ using Oqtane.Models; namespace Oqtane.Infrastructure { + public interface IAliasAccessor + { + Alias Alias { get; } + } + public class AliasAccessor : IAliasAccessor { private readonly IHttpContextAccessor _httpContextAccessor; diff --git a/Oqtane.Server/Infrastructure/ConfigManager.cs b/Oqtane.Server/Infrastructure/ConfigManager.cs index d6b0d8d9..ee7388e5 100644 --- a/Oqtane.Server/Infrastructure/ConfigManager.cs +++ b/Oqtane.Server/Infrastructure/ConfigManager.cs @@ -10,6 +10,24 @@ using Oqtane.Shared; namespace Oqtane.Infrastructure { + public interface IConfigManager + { + public IConfigurationSection GetSection(string sectionKey); + public T GetSetting(string settingKey, T defaultValue); + public T GetSetting(string sectionKey, string settingKey, T defaultValue); + public Dictionary GetSettings(string sectionKey); + void AddOrUpdateSetting(string key, T value, bool reload); + void AddOrUpdateSetting(string file, string key, T value, bool reload); + void RemoveSetting(string key, bool reload); + void RemoveSetting(string file, string key, bool reload); + void Reload(); + + public string GetConnectionString(); + public string GetConnectionString(string name); + public bool IsInstalled(); + public string GetInstallationId(); + } + public class ConfigManager : IConfigManager { private readonly IConfigurationRoot _config; diff --git a/Oqtane.Server/Infrastructure/DatabaseManager.cs b/Oqtane.Server/Infrastructure/DatabaseManager.cs index ff06f408..e31fd6b4 100644 --- a/Oqtane.Server/Infrastructure/DatabaseManager.cs +++ b/Oqtane.Server/Infrastructure/DatabaseManager.cs @@ -22,6 +22,13 @@ using Microsoft.Extensions.Logging; namespace Oqtane.Infrastructure { + public interface IDatabaseManager + { + Installation IsInstalled(); + Installation Install(); + Installation Install(InstallConfig install); + } + public class DatabaseManager : IDatabaseManager { private readonly IConfigManager _config; diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index 1591c150..ca09616c 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -18,6 +18,15 @@ using Oqtane.Shared; namespace Oqtane.Infrastructure { + public interface IInstallationManager + { + void InstallPackages(); + bool UninstallPackage(string PackageName); + int RegisterAssemblies(); + Task UpgradeFramework(bool backup); + void RestartApplication(); + } + public class InstallationManager : IInstallationManager { private readonly IHostApplicationLifetime _hostApplicationLifetime; diff --git a/Oqtane.Server/Infrastructure/Interfaces/IAliasAccessor.cs b/Oqtane.Server/Infrastructure/Interfaces/IAliasAccessor.cs deleted file mode 100644 index fc54d683..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IAliasAccessor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Oqtane.Models; - -namespace Oqtane.Infrastructure -{ - public interface IAliasAccessor - { - Alias Alias { get; } - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/IConfigManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IConfigManager.cs deleted file mode 100644 index 2f5ba875..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IConfigManager.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using Microsoft.Extensions.Configuration; - -namespace Oqtane.Infrastructure -{ - public interface IConfigManager - { - public IConfigurationSection GetSection(string sectionKey); - public T GetSetting(string settingKey, T defaultValue); - public T GetSetting(string sectionKey, string settingKey, T defaultValue); - public Dictionary GetSettings(string sectionKey); - void AddOrUpdateSetting(string key, T value, bool reload); - void AddOrUpdateSetting(string file, string key, T value, bool reload); - void RemoveSetting(string key, bool reload); - void RemoveSetting(string file, string key, bool reload); - void Reload(); - - public string GetConnectionString(); - public string GetConnectionString(string name); - public bool IsInstalled(); - public string GetInstallationId(); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/IDatabaseManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IDatabaseManager.cs deleted file mode 100644 index 6257db16..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IDatabaseManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Oqtane.Models; -using Oqtane.Shared; - -namespace Oqtane.Infrastructure -{ - public interface IDatabaseManager - { - Installation IsInstalled(); - Installation Install(); - Installation Install(InstallConfig install); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs deleted file mode 100644 index 1d1648c7..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; - -namespace Oqtane.Infrastructure -{ - public interface IInstallationManager - { - void InstallPackages(); - bool UninstallPackage(string PackageName); - int RegisterAssemblies(); - Task UpgradeFramework(bool backup); - void RestartApplication(); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/ILocalizationManager.cs b/Oqtane.Server/Infrastructure/Interfaces/ILocalizationManager.cs deleted file mode 100644 index b6de309a..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/ILocalizationManager.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Oqtane.Infrastructure -{ - public interface ILocalizationManager - { - string GetDefaultCulture(); - string[] GetSupportedCultures(); - string[] GetInstalledCultures(); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/ILogManager.cs b/Oqtane.Server/Infrastructure/Interfaces/ILogManager.cs deleted file mode 100644 index bd52214c..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/ILogManager.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Oqtane.Enums; -using Oqtane.Models; -using Oqtane.Shared; - -namespace Oqtane.Infrastructure -{ - public interface ILogManager - { - void Log(LogLevel level, object @class, LogFunction function, string message, params object[] args); - void Log(LogLevel level, object @class, LogFunction function, Exception exception, string message, params object[] args); - void Log(int siteId, LogLevel level, object @class, LogFunction function, string message, params object[] args); - void Log(int siteId, LogLevel level, object @class, LogFunction function, Exception exception, string message, params object[] args); - void Log(Log log); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/IServerStateManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IServerStateManager.cs deleted file mode 100644 index 48115fe7..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IServerStateManager.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Oqtane.Infrastructure -{ - public interface IServerStateManager - { - ServerState GetServerState(string siteKey); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/ISyncManager.cs b/Oqtane.Server/Infrastructure/Interfaces/ISyncManager.cs deleted file mode 100644 index 88784519..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/ISyncManager.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using Oqtane.Models; - -namespace Oqtane.Infrastructure -{ - public interface ISyncManager - { - event EventHandler EntityChanged; - List GetSyncEvents(int tenantId, DateTime lastSyncDate); - void AddSyncEvent(Alias alias, string entityName, int entityId, string action); - void AddSyncEvent(int tenantId, int siteId, string entityName, int entityId, string action); - - [Obsolete("AddSyncEvent(int tenantId, string entityName, int entityId, string action) is deprecated. Use AddSyncEvent(Alias alias, string entityName, int entityId, string action) instead.", false)] - void AddSyncEvent(int tenantId, string entityName, int entityId, string action); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/ITenantManager.cs b/Oqtane.Server/Infrastructure/Interfaces/ITenantManager.cs deleted file mode 100644 index c4388714..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/ITenantManager.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Oqtane.Models; - -namespace Oqtane.Infrastructure -{ - public interface ITenantManager - { - Alias GetAlias(); - Tenant GetTenant(); - void SetAlias(Alias alias); - void SetAlias(int tenantId, int siteId); - void SetTenant(int tenantId); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/ITokenReplace.cs b/Oqtane.Server/Infrastructure/Interfaces/ITokenReplace.cs deleted file mode 100644 index ff934a17..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/ITokenReplace.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using Oqtane.Interfaces; - -namespace Oqtane.Infrastructure.Interfaces -{ - public interface ITokenReplace - { - void AddSource(ITokenSource source); - - void AddSource(Func> sourceFunc); - - void AddSource(IDictionary source); - - void AddSource(string key, object value); - - void AddSource(string name, ITokenSource source); - - void AddSource(string name, Func> sourceFunc); - - void AddSource(string name, IDictionary source); - - void AddSource(string name, string key, object value); - - string ReplaceTokens(string source); - } -} diff --git a/Oqtane.Server/Infrastructure/Interfaces/IUpgradeManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IUpgradeManager.cs deleted file mode 100644 index e941bbfd..00000000 --- a/Oqtane.Server/Infrastructure/Interfaces/IUpgradeManager.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Oqtane.Models; - -namespace Oqtane.Infrastructure -{ - public interface IUpgradeManager - { - void Upgrade(Tenant tenant, string version); - } -} diff --git a/Oqtane.Server/Infrastructure/LocalizationManager.cs b/Oqtane.Server/Infrastructure/LocalizationManager.cs index 2051d2b5..0d083c4f 100644 --- a/Oqtane.Server/Infrastructure/LocalizationManager.cs +++ b/Oqtane.Server/Infrastructure/LocalizationManager.cs @@ -9,6 +9,13 @@ using Oqtane.Shared; namespace Oqtane.Infrastructure { + public interface ILocalizationManager + { + string GetDefaultCulture(); + string[] GetSupportedCultures(); + string[] GetInstalledCultures(); + } + public class LocalizationManager : ILocalizationManager { private static readonly string DefaultCulture = Constants.DefaultCulture; diff --git a/Oqtane.Server/Infrastructure/LogManager.cs b/Oqtane.Server/Infrastructure/LogManager.cs index 91f128ee..f9238c2e 100644 --- a/Oqtane.Server/Infrastructure/LogManager.cs +++ b/Oqtane.Server/Infrastructure/LogManager.cs @@ -12,6 +12,15 @@ using Oqtane.Shared; namespace Oqtane.Infrastructure { + public interface ILogManager + { + void Log(Shared.LogLevel level, object @class, LogFunction function, string message, params object[] args); + void Log(Shared.LogLevel level, object @class, LogFunction function, Exception exception, string message, params object[] args); + void Log(int siteId, Shared.LogLevel level, object @class, LogFunction function, string message, params object[] args); + void Log(int siteId, Shared.LogLevel level, object @class, LogFunction function, Exception exception, string message, params object[] args); + void Log(Log log); + } + public class LogManager : ILogManager { private readonly ILogRepository _logs; diff --git a/Oqtane.Server/Infrastructure/ServerStateManager.cs b/Oqtane.Server/Infrastructure/ServerStateManager.cs index 66747393..649617e7 100644 --- a/Oqtane.Server/Infrastructure/ServerStateManager.cs +++ b/Oqtane.Server/Infrastructure/ServerStateManager.cs @@ -4,6 +4,11 @@ using System.Linq; namespace Oqtane.Infrastructure { // singleton + public interface IServerStateManager + { + ServerState GetServerState(string siteKey); + } + public class ServerStateManager : IServerStateManager { private List _serverStates { get; set; } diff --git a/Oqtane.Server/Infrastructure/SyncManager.cs b/Oqtane.Server/Infrastructure/SyncManager.cs index 52e2796f..9953e574 100644 --- a/Oqtane.Server/Infrastructure/SyncManager.cs +++ b/Oqtane.Server/Infrastructure/SyncManager.cs @@ -6,6 +6,17 @@ using System.Linq; namespace Oqtane.Infrastructure { + public interface ISyncManager + { + event EventHandler EntityChanged; + List GetSyncEvents(int tenantId, DateTime lastSyncDate); + void AddSyncEvent(Alias alias, string entityName, int entityId, string action); + void AddSyncEvent(int tenantId, int siteId, string entityName, int entityId, string action); + + [Obsolete("AddSyncEvent(int tenantId, string entityName, int entityId, string action) is deprecated. Use AddSyncEvent(Alias alias, string entityName, int entityId, string action) instead.", false)] + void AddSyncEvent(int tenantId, string entityName, int entityId, string action); + } + public class SyncManager : ISyncManager { private List SyncEvents { get; set; } diff --git a/Oqtane.Server/Infrastructure/TenantManager.cs b/Oqtane.Server/Infrastructure/TenantManager.cs index ea342fc7..33c5abbe 100644 --- a/Oqtane.Server/Infrastructure/TenantManager.cs +++ b/Oqtane.Server/Infrastructure/TenantManager.cs @@ -7,6 +7,15 @@ using Oqtane.Shared; namespace Oqtane.Infrastructure { + public interface ITenantManager + { + Alias GetAlias(); + Tenant GetTenant(); + void SetAlias(Alias alias); + void SetAlias(int tenantId, int siteId); + void SetTenant(int tenantId); + } + public class TenantManager : ITenantManager { private readonly IHttpContextAccessor _httpContextAccessor; diff --git a/Oqtane.Server/Infrastructure/TokenReplace.cs b/Oqtane.Server/Infrastructure/TokenReplace.cs index d2b40db4..75493758 100644 --- a/Oqtane.Server/Infrastructure/TokenReplace.cs +++ b/Oqtane.Server/Infrastructure/TokenReplace.cs @@ -2,12 +2,31 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Text; -using Oqtane.Infrastructure.Interfaces; using Oqtane.Interfaces; -using Oqtane.Models; namespace Oqtane.Infrastructure { + public interface ITokenReplace + { + void AddSource(ITokenSource source); + + void AddSource(Func> sourceFunc); + + void AddSource(IDictionary source); + + void AddSource(string key, object value); + + void AddSource(string name, ITokenSource source); + + void AddSource(string name, Func> sourceFunc); + + void AddSource(string name, IDictionary source); + + void AddSource(string name, string key, object value); + + string ReplaceTokens(string source); + } + public class TokenReplace : ITokenReplace { public const string GenericName = "generic"; diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs index 421be775..4b40f3ae 100644 --- a/Oqtane.Server/Infrastructure/UpgradeManager.cs +++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs @@ -15,6 +15,10 @@ using System.Reflection; namespace Oqtane.Infrastructure { + public interface IUpgradeManager + { + void Upgrade(Tenant tenant, string version); + } public class UpgradeManager : IUpgradeManager { private readonly IServiceScopeFactory _serviceScopeFactory; diff --git a/Oqtane.Server/Managers/Interfaces/IUserManager.cs b/Oqtane.Server/Managers/Interfaces/IUserManager.cs deleted file mode 100644 index 4fde062c..00000000 --- a/Oqtane.Server/Managers/Interfaces/IUserManager.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Oqtane.Models; - -namespace Oqtane.Managers -{ - public interface IUserManager - { - User GetUser(int userid, int siteid); - User GetUser(string username, int siteid); - User GetUser(string username, string email, int siteid); - Task AddUser(User user); - Task UpdateUser(User user); - Task DeleteUser(int userid, int siteid); - Task LoginUser(User user, bool setCookie, bool isPersistent); - Task LogoutUserEverywhere(User user); - Task VerifyEmail(User user, string token); - Task ForgotPassword(User user); - Task ResetPassword(User user, string token); - User VerifyTwoFactor(User user, string token); - Task LinkExternalAccount(User user, string token, string type, string key, string name); - Task ValidateUser(string username, string email, string password); - Task ValidatePassword(string password); - Task> ImportUsers(int siteId, string filePath, bool notify); - } -} diff --git a/Oqtane.Server/Managers/UserManager.cs b/Oqtane.Server/Managers/UserManager.cs index 76411019..d6d4afa0 100644 --- a/Oqtane.Server/Managers/UserManager.cs +++ b/Oqtane.Server/Managers/UserManager.cs @@ -17,6 +17,26 @@ using Oqtane.Shared; namespace Oqtane.Managers { + public interface IUserManager + { + User GetUser(int userid, int siteid); + User GetUser(string username, int siteid); + User GetUser(string username, string email, int siteid); + Task AddUser(User user); + Task UpdateUser(User user); + Task DeleteUser(int userid, int siteid); + Task LoginUser(User user, bool setCookie, bool isPersistent); + Task LogoutUserEverywhere(User user); + Task VerifyEmail(User user, string token); + Task ForgotPassword(User user); + Task ResetPassword(User user, string token); + User VerifyTwoFactor(User user, string token); + Task LinkExternalAccount(User user, string token, string type, string key, string name); + Task ValidateUser(string username, string email, string password); + Task ValidatePassword(string password); + Task> ImportUsers(int siteId, string filePath, bool notify); + } + public class UserManager : IUserManager { private readonly IUserRepository _users;