mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 01:22:50 -05:00
upgrade to aspnet core 3.1
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Repositories;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.Queue;
|
||||
using Azure.Storage.Queues;
|
||||
using Newtonsoft.Json;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
@ -10,8 +8,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
public class AzureQueueEventWriteService : IEventWriteService
|
||||
{
|
||||
private readonly CloudQueue _queue;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly QueueClient _queueClient;
|
||||
|
||||
private JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
@ -19,28 +16,21 @@ namespace Bit.Core.Services
|
||||
};
|
||||
|
||||
public AzureQueueEventWriteService(
|
||||
IEventRepository eventRepository,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
var storageAccount = CloudStorageAccount.Parse(globalSettings.Events.ConnectionString);
|
||||
var queueClient = storageAccount.CreateCloudQueueClient();
|
||||
|
||||
_queue = queueClient.GetQueueReference("event");
|
||||
_globalSettings = globalSettings;
|
||||
_queueClient = new QueueClient(globalSettings.Events.ConnectionString, "event");
|
||||
}
|
||||
|
||||
public async Task CreateAsync(IEvent e)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(e, _jsonSettings);
|
||||
var message = new CloudQueueMessage(json);
|
||||
await _queue.AddMessageAsync(message);
|
||||
await _queueClient.SendMessageAsync(json);
|
||||
}
|
||||
|
||||
public async Task CreateManyAsync(IList<IEvent> e)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(e, _jsonSettings);
|
||||
var message = new CloudQueueMessage(json);
|
||||
await _queue.AddMessageAsync(message);
|
||||
await _queueClient.SendMessageAsync(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user