consolidate Infrastructure interface and implementation classes
This commit is contained in:
@ -15,7 +15,6 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Oqtane.Infrastructure.Interfaces;
|
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
@ -12,10 +12,8 @@ using Oqtane.Infrastructure;
|
|||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Oqtane.Infrastructure.Interfaces;
|
|
||||||
|
|
||||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ using Microsoft.Extensions.Hosting;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Infrastructure.Interfaces;
|
|
||||||
using Oqtane.Interfaces;
|
using Oqtane.Interfaces;
|
||||||
using Oqtane.Managers;
|
using Oqtane.Managers;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
@ -4,6 +4,11 @@ using Oqtane.Models;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface IAliasAccessor
|
||||||
|
{
|
||||||
|
Alias Alias { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public class AliasAccessor : IAliasAccessor
|
public class AliasAccessor : IAliasAccessor
|
||||||
{
|
{
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
@ -10,6 +10,24 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface IConfigManager
|
||||||
|
{
|
||||||
|
public IConfigurationSection GetSection(string sectionKey);
|
||||||
|
public T GetSetting<T>(string settingKey, T defaultValue);
|
||||||
|
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue);
|
||||||
|
public Dictionary<string, string> GetSettings(string sectionKey);
|
||||||
|
void AddOrUpdateSetting<T>(string key, T value, bool reload);
|
||||||
|
void AddOrUpdateSetting<T>(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
|
public class ConfigManager : IConfigManager
|
||||||
{
|
{
|
||||||
private readonly IConfigurationRoot _config;
|
private readonly IConfigurationRoot _config;
|
||||||
|
@ -22,6 +22,13 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface IDatabaseManager
|
||||||
|
{
|
||||||
|
Installation IsInstalled();
|
||||||
|
Installation Install();
|
||||||
|
Installation Install(InstallConfig install);
|
||||||
|
}
|
||||||
|
|
||||||
public class DatabaseManager : IDatabaseManager
|
public class DatabaseManager : IDatabaseManager
|
||||||
{
|
{
|
||||||
private readonly IConfigManager _config;
|
private readonly IConfigManager _config;
|
||||||
|
@ -18,6 +18,15 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface IInstallationManager
|
||||||
|
{
|
||||||
|
void InstallPackages();
|
||||||
|
bool UninstallPackage(string PackageName);
|
||||||
|
int RegisterAssemblies();
|
||||||
|
Task UpgradeFramework(bool backup);
|
||||||
|
void RestartApplication();
|
||||||
|
}
|
||||||
|
|
||||||
public class InstallationManager : IInstallationManager
|
public class InstallationManager : IInstallationManager
|
||||||
{
|
{
|
||||||
private readonly IHostApplicationLifetime _hostApplicationLifetime;
|
private readonly IHostApplicationLifetime _hostApplicationLifetime;
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
using Oqtane.Models;
|
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface IAliasAccessor
|
|
||||||
{
|
|
||||||
Alias Alias { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<T>(string settingKey, T defaultValue);
|
|
||||||
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue);
|
|
||||||
public Dictionary<string, string> GetSettings(string sectionKey);
|
|
||||||
void AddOrUpdateSetting<T>(string key, T value, bool reload);
|
|
||||||
void AddOrUpdateSetting<T>(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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using Oqtane.Models;
|
|
||||||
using Oqtane.Shared;
|
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface IDatabaseManager
|
|
||||||
{
|
|
||||||
Installation IsInstalled();
|
|
||||||
Installation Install();
|
|
||||||
Installation Install(InstallConfig install);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface ILocalizationManager
|
|
||||||
{
|
|
||||||
string GetDefaultCulture();
|
|
||||||
string[] GetSupportedCultures();
|
|
||||||
string[] GetInstalledCultures();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface IServerStateManager
|
|
||||||
{
|
|
||||||
ServerState GetServerState(string siteKey);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Oqtane.Models;
|
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface ISyncManager
|
|
||||||
{
|
|
||||||
event EventHandler<SyncEvent> EntityChanged;
|
|
||||||
List<SyncEvent> 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<IDictionary<string, object>> sourceFunc);
|
|
||||||
|
|
||||||
void AddSource(IDictionary<string, object> source);
|
|
||||||
|
|
||||||
void AddSource(string key, object value);
|
|
||||||
|
|
||||||
void AddSource(string name, ITokenSource source);
|
|
||||||
|
|
||||||
void AddSource(string name, Func<IDictionary<string, object>> sourceFunc);
|
|
||||||
|
|
||||||
void AddSource(string name, IDictionary<string, object> source);
|
|
||||||
|
|
||||||
void AddSource(string name, string key, object value);
|
|
||||||
|
|
||||||
string ReplaceTokens(string source);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
using Oqtane.Models;
|
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
|
||||||
{
|
|
||||||
public interface IUpgradeManager
|
|
||||||
{
|
|
||||||
void Upgrade(Tenant tenant, string version);
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,6 +9,13 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface ILocalizationManager
|
||||||
|
{
|
||||||
|
string GetDefaultCulture();
|
||||||
|
string[] GetSupportedCultures();
|
||||||
|
string[] GetInstalledCultures();
|
||||||
|
}
|
||||||
|
|
||||||
public class LocalizationManager : ILocalizationManager
|
public class LocalizationManager : ILocalizationManager
|
||||||
{
|
{
|
||||||
private static readonly string DefaultCulture = Constants.DefaultCulture;
|
private static readonly string DefaultCulture = Constants.DefaultCulture;
|
||||||
|
@ -12,6 +12,15 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
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
|
public class LogManager : ILogManager
|
||||||
{
|
{
|
||||||
private readonly ILogRepository _logs;
|
private readonly ILogRepository _logs;
|
||||||
|
@ -4,6 +4,11 @@ using System.Linq;
|
|||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
// singleton
|
// singleton
|
||||||
|
public interface IServerStateManager
|
||||||
|
{
|
||||||
|
ServerState GetServerState(string siteKey);
|
||||||
|
}
|
||||||
|
|
||||||
public class ServerStateManager : IServerStateManager
|
public class ServerStateManager : IServerStateManager
|
||||||
{
|
{
|
||||||
private List<ServerState> _serverStates { get; set; }
|
private List<ServerState> _serverStates { get; set; }
|
||||||
|
@ -6,6 +6,17 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface ISyncManager
|
||||||
|
{
|
||||||
|
event EventHandler<SyncEvent> EntityChanged;
|
||||||
|
List<SyncEvent> 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
|
public class SyncManager : ISyncManager
|
||||||
{
|
{
|
||||||
private List<SyncEvent> SyncEvents { get; set; }
|
private List<SyncEvent> SyncEvents { get; set; }
|
||||||
|
@ -7,6 +7,15 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
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
|
public class TenantManager : ITenantManager
|
||||||
{
|
{
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
@ -2,12 +2,31 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Oqtane.Infrastructure.Interfaces;
|
|
||||||
using Oqtane.Interfaces;
|
using Oqtane.Interfaces;
|
||||||
using Oqtane.Models;
|
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface ITokenReplace
|
||||||
|
{
|
||||||
|
void AddSource(ITokenSource source);
|
||||||
|
|
||||||
|
void AddSource(Func<IDictionary<string, object>> sourceFunc);
|
||||||
|
|
||||||
|
void AddSource(IDictionary<string, object> source);
|
||||||
|
|
||||||
|
void AddSource(string key, object value);
|
||||||
|
|
||||||
|
void AddSource(string name, ITokenSource source);
|
||||||
|
|
||||||
|
void AddSource(string name, Func<IDictionary<string, object>> sourceFunc);
|
||||||
|
|
||||||
|
void AddSource(string name, IDictionary<string, object> source);
|
||||||
|
|
||||||
|
void AddSource(string name, string key, object value);
|
||||||
|
|
||||||
|
string ReplaceTokens(string source);
|
||||||
|
}
|
||||||
|
|
||||||
public class TokenReplace : ITokenReplace
|
public class TokenReplace : ITokenReplace
|
||||||
{
|
{
|
||||||
public const string GenericName = "generic";
|
public const string GenericName = "generic";
|
||||||
|
@ -15,6 +15,10 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
public interface IUpgradeManager
|
||||||
|
{
|
||||||
|
void Upgrade(Tenant tenant, string version);
|
||||||
|
}
|
||||||
public class UpgradeManager : IUpgradeManager
|
public class UpgradeManager : IUpgradeManager
|
||||||
{
|
{
|
||||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||||
|
@ -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<User> AddUser(User user);
|
|
||||||
Task<User> UpdateUser(User user);
|
|
||||||
Task DeleteUser(int userid, int siteid);
|
|
||||||
Task<User> LoginUser(User user, bool setCookie, bool isPersistent);
|
|
||||||
Task LogoutUserEverywhere(User user);
|
|
||||||
Task<User> VerifyEmail(User user, string token);
|
|
||||||
Task ForgotPassword(User user);
|
|
||||||
Task<User> ResetPassword(User user, string token);
|
|
||||||
User VerifyTwoFactor(User user, string token);
|
|
||||||
Task<User> LinkExternalAccount(User user, string token, string type, string key, string name);
|
|
||||||
Task<UserValidateResult> ValidateUser(string username, string email, string password);
|
|
||||||
Task<bool> ValidatePassword(string password);
|
|
||||||
Task<Dictionary<string, string>> ImportUsers(int siteId, string filePath, bool notify);
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,6 +17,26 @@ using Oqtane.Shared;
|
|||||||
|
|
||||||
namespace Oqtane.Managers
|
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<User> AddUser(User user);
|
||||||
|
Task<User> UpdateUser(User user);
|
||||||
|
Task DeleteUser(int userid, int siteid);
|
||||||
|
Task<User> LoginUser(User user, bool setCookie, bool isPersistent);
|
||||||
|
Task LogoutUserEverywhere(User user);
|
||||||
|
Task<User> VerifyEmail(User user, string token);
|
||||||
|
Task ForgotPassword(User user);
|
||||||
|
Task<User> ResetPassword(User user, string token);
|
||||||
|
User VerifyTwoFactor(User user, string token);
|
||||||
|
Task<User> LinkExternalAccount(User user, string token, string type, string key, string name);
|
||||||
|
Task<UserValidateResult> ValidateUser(string username, string email, string password);
|
||||||
|
Task<bool> ValidatePassword(string password);
|
||||||
|
Task<Dictionary<string, string>> ImportUsers(int siteId, string filePath, bool notify);
|
||||||
|
}
|
||||||
|
|
||||||
public class UserManager : IUserManager
|
public class UserManager : IUserManager
|
||||||
{
|
{
|
||||||
private readonly IUserRepository _users;
|
private readonly IUserRepository _users;
|
||||||
|
Reference in New Issue
Block a user