Add project files.
This commit is contained in:
6
ManagementApp/AServices/Microsoft365/IMicrosoft365.cs
Normal file
6
ManagementApp/AServices/Microsoft365/IMicrosoft365.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace ManagementApp.AServices.Microsoft365
|
||||
{
|
||||
public interface IMicrosoft365
|
||||
{
|
||||
}
|
||||
}
|
11
ManagementApp/AServices/Microsoft365/Microsoft365.cs
Normal file
11
ManagementApp/AServices/Microsoft365/Microsoft365.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace ManagementApp.AServices.Microsoft365
|
||||
{
|
||||
public class Microsoft365: IMicrosoft365
|
||||
{
|
||||
public Microsoft365()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
11
ManagementApp/AServices/Microsoft365/Microsoft365Options.cs
Normal file
11
ManagementApp/AServices/Microsoft365/Microsoft365Options.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace ManagementApp.AServices.Microsoft365
|
||||
{
|
||||
public class Microsoft365Options
|
||||
{
|
||||
public string TenantID { set; get; } = "";
|
||||
public string ClientID { set; get; } = "";
|
||||
|
||||
public string SecretValue { set; get; } = "";
|
||||
public string SecretID { set; get; } = "";
|
||||
}
|
||||
}
|
6
ManagementApp/AServices/Microsoft365/SharePointOption.cs
Normal file
6
ManagementApp/AServices/Microsoft365/SharePointOption.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace ManagementApp.AServices.Microsoft365
|
||||
{
|
||||
public class SharePointOption
|
||||
{
|
||||
}
|
||||
}
|
49
ManagementApp/AServices/Microsoft365Service.cs
Normal file
49
ManagementApp/AServices/Microsoft365Service.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using ManagementApp.AServices.Microsoft365;
|
||||
using ManagementApp.AServices.ThreadManage;
|
||||
using Microsoft.Identity.Web;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace ManagementApp.AServices
|
||||
{
|
||||
public class Microsoft365Service : BackgroundService, IDisposable
|
||||
{
|
||||
|
||||
private readonly IConcurrentTasks _task;
|
||||
public Microsoft365Service(IConcurrentTasks tasks) {
|
||||
_task = tasks;
|
||||
}
|
||||
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await DoWork(stoppingToken);
|
||||
}
|
||||
|
||||
private async Task DoWork(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
var workItem = await _task.First(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
await workItem(stoppingToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await base.StopAsync(stoppingToken);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace ManagementApp.AServices.ThreadManage
|
||||
{
|
||||
|
||||
public class ConcurrentDictionaryThread<T>: IConcurrentTasks<T>, IConcurrentTasks
|
||||
{
|
||||
|
||||
private readonly ConcurrentDictionary<T, Func<CancellationToken, ValueTask>> listTask;
|
||||
public ConcurrentDictionaryThread() {
|
||||
this.listTask = new ConcurrentDictionary<T, Func<CancellationToken, ValueTask>> ();
|
||||
}
|
||||
|
||||
public async ValueTask Add(Func<CancellationToken, ValueTask> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public async ValueTask<bool> Add(T key, Func<CancellationToken, ValueTask> value)
|
||||
{
|
||||
return await Task<bool>.Run(() => {
|
||||
return listTask.TryAdd(key, value);
|
||||
}) ;
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> Last(CancellationToken cancellationToken)
|
||||
{
|
||||
return await Task<Func<CancellationToken, ValueTask>>.Run(() => {
|
||||
var d = listTask.Last();
|
||||
listTask.TryRemove(d);
|
||||
return d.Value;
|
||||
});
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> First(CancellationToken cancellationToken)
|
||||
{
|
||||
return await Task<Func<CancellationToken, ValueTask>>.Run(() => {
|
||||
var d = listTask.First();
|
||||
listTask.TryRemove(d);
|
||||
return d.Value;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> Search(T key, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> Update(T key, CancellationToken cancellationToken, Func<CancellationToken, ValueTask> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace ManagementApp.AServices.ThreadManage
|
||||
{
|
||||
public class ConcurrentQueueThread: IConcurrentTasks
|
||||
{
|
||||
private readonly Channel<Func<CancellationToken, ValueTask>> queue;
|
||||
public ConcurrentQueueThread(int capacity) {
|
||||
var options = new BoundedChannelOptions(capacity)
|
||||
{
|
||||
FullMode = BoundedChannelFullMode.Wait
|
||||
};
|
||||
queue = Channel.CreateBounded<Func<CancellationToken, ValueTask>>(options);
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask Add(Func<CancellationToken, ValueTask> value)
|
||||
{
|
||||
await queue.Writer.WriteAsync(value);
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> Last(CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async ValueTask<Func<CancellationToken, ValueTask>> First(CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
return await queue.Reader.ReadAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
21
ManagementApp/AServices/ThreadManage/IConcurrentTasks.cs
Normal file
21
ManagementApp/AServices/ThreadManage/IConcurrentTasks.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace ManagementApp.AServices.ThreadManage
|
||||
{
|
||||
public interface IConcurrentTasks<T>
|
||||
{
|
||||
ValueTask Add(Func<CancellationToken, ValueTask> value);
|
||||
|
||||
ValueTask<Func<CancellationToken, ValueTask>> Search(T key, CancellationToken cancellationToken);
|
||||
|
||||
ValueTask<Func<CancellationToken, ValueTask>> Update(T key, CancellationToken cancellationToken, Func<CancellationToken, ValueTask> value);
|
||||
|
||||
}
|
||||
|
||||
public interface IConcurrentTasks
|
||||
{
|
||||
ValueTask Add(Func<CancellationToken, ValueTask> value);
|
||||
ValueTask<Func<CancellationToken, ValueTask>> Last(CancellationToken cancellationToken);
|
||||
|
||||
ValueTask<Func<CancellationToken, ValueTask>> First(CancellationToken cancellationToken);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user