Adds DatabaseServerRegistrar and ServerRegistrationEventHandler, we can now ensure that all server add themselves to the
database table automatically.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
|
||||
public ServerRegistration BuildEntity(ServerRegistrationDto dto)
|
||||
{
|
||||
return new ServerRegistration(dto.Id, dto.ComputerName, dto.Address, dto.DateRegistered, dto.LastNotified);
|
||||
return new ServerRegistration(dto.Id, dto.Address, dto.ComputerName, dto.DateRegistered, dto.LastNotified);
|
||||
}
|
||||
|
||||
public ServerRegistrationDto BuildDto(ServerRegistration entity)
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Umbraco.Core.Services
|
||||
private Lazy<DataTypeService> _dataTypeService;
|
||||
private Lazy<FileService> _fileService;
|
||||
private Lazy<LocalizationService> _localizationService;
|
||||
private Lazy<ServerRegistrationService> _serverRegistrationService;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
@@ -47,6 +48,9 @@ namespace Umbraco.Core.Services
|
||||
var provider = dbUnitOfWorkProvider;
|
||||
var fileProvider = fileUnitOfWorkProvider;
|
||||
|
||||
if (_serverRegistrationService == null)
|
||||
_serverRegistrationService = new Lazy<ServerRegistrationService>(() => new ServerRegistrationService(provider, repositoryFactory.Value));
|
||||
|
||||
if (_userService == null)
|
||||
_userService = new Lazy<UserService>(() => new UserService(provider, repositoryFactory.Value));
|
||||
|
||||
@@ -72,6 +76,14 @@ namespace Umbraco.Core.Services
|
||||
_localizationService = new Lazy<LocalizationService>(() => new LocalizationService(provider, repositoryFactory.Value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ServerRegistrationService"/>
|
||||
/// </summary>
|
||||
internal ServerRegistrationService ServerRegistrationService
|
||||
{
|
||||
get { return _serverRegistrationService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IContentService"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Sync
|
||||
{
|
||||
|
||||
23
src/Umbraco.Core/Sync/DatabaseServerRegistrar.cs
Normal file
23
src/Umbraco.Core/Sync/DatabaseServerRegistrar.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Sync
|
||||
{
|
||||
/// <summary>
|
||||
/// A registrar that stores registered server nodes in a database
|
||||
/// </summary>
|
||||
internal class DatabaseServerRegistrar : IServerRegistrar
|
||||
{
|
||||
private readonly ServerRegistrationService _registrationService;
|
||||
|
||||
public DatabaseServerRegistrar(ServerRegistrationService registrationService)
|
||||
{
|
||||
_registrationService = registrationService;
|
||||
}
|
||||
|
||||
public IEnumerable<IServerAddress> Registrations
|
||||
{
|
||||
get { return _registrationService.GetActiveServers(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -676,6 +676,7 @@
|
||||
<Compile Include="Services\ServerRegistrationService.cs" />
|
||||
<Compile Include="Services\ServiceContext.cs" />
|
||||
<Compile Include="Services\UserService.cs" />
|
||||
<Compile Include="Sync\DatabaseServerRegistrar.cs" />
|
||||
<Compile Include="Sync\DefaultServerMessenger.cs" />
|
||||
<Compile Include="Sync\ICacheRefresher.cs" />
|
||||
<Compile Include="Sync\ServerSyncWebServiceClient.cs">
|
||||
|
||||
Reference in New Issue
Block a user