Admin ItemDeleter, Logging

This commit is contained in:
2023-07-26 11:30:26 +02:00
parent 66113ee9a0
commit 3de71cbdbe
15 changed files with 157 additions and 27 deletions

View File

@@ -7,4 +7,5 @@ public interface IRemoteConnection
Task Exit();
Task CreateContainerAsync(string contentProviderId, FullName fullName);
Task CreateElementAsync(string contentProviderId, FullName fullName);
Task DeleteItemAsync(string contentProviderId, FullName fullName);
}

View File

@@ -5,4 +5,5 @@ public interface ISignalRHub
Task Exit();
Task CreateContainerAsync(string contentProviderId, string fullName);
Task CreateElementAsync(string contentProviderId, string fullName);
Task DeleteItemAsync(string contentProviderId, string fullName);
}

View File

@@ -39,4 +39,10 @@ public class SignalRConnection : IRemoteConnection, IAsyncInitable<string>
var client = CreateClient();
await client.CreateElementAsync(contentProviderId, fullName.Path);
}
public async Task DeleteItemAsync(string contentProviderId, FullName fullName)
{
var client = CreateClient();
await client.DeleteItemAsync(contentProviderId, fullName.Path);
}
}

View File

@@ -42,4 +42,11 @@ public class ConnectionHub : Hub<ISignalRClient>, ISignalRHub
var itemCreator = _contentAccessorFactory.GetItemCreator(contentProvider);
await itemCreator.CreateElementAsync(contentProvider, new FullName(fullName));
}
public async Task DeleteItemAsync(string contentProviderId, string fullName)
{
var contentProvider = _contentProviderRegistry.ContentProviders.First(p => p.Name == contentProviderId);
var itemDeleter = _contentAccessorFactory.GetItemDeleter(contentProvider);
await itemDeleter.DeleteAsync(contentProvider, new FullName(fullName));
}
}

View File

@@ -5,6 +5,7 @@ using FileTime.Providers.Local;
using FileTime.Server.App;
using FileTime.Server.Common;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Serilog;
@@ -52,7 +53,8 @@ IContainer CreateRootDiContainer(IConfigurationRoot configuration)
var serviceCollection = DependencyInjection
.RegisterDefaultServices(configuration)
.AddLocalProviderServices()
.AddServerServices();
.AddServerServices()
.AddLogging(loggingBuilder => loggingBuilder.AddSerilog());
serviceCollection.TryAddSingleton<IApplicationStopper>(
new ApplicationStopper(() => applicationCancellation.Cancel())