mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 10:55:43 -05:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@ -12,11 +12,11 @@ namespace Bit.Core.Repositories
|
||||
|
||||
public BaseRepository(string connectionString, string readOnlyConnectionString)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(connectionString))
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(connectionString));
|
||||
}
|
||||
if(string.IsNullOrWhiteSpace(readOnlyConnectionString))
|
||||
if (string.IsNullOrWhiteSpace(readOnlyConnectionString))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(readOnlyConnectionString));
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<ICollection<TableModel.Organization>> GetManyByEnabledAsync()
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var organizations = await GetDbSet(dbContext).Where(e => e.Enabled).ToListAsync();
|
||||
@ -36,7 +36,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
public async Task<ICollection<TableModel.Organization>> SearchAsync(string name, string userEmail, bool? paid,
|
||||
int skip, int take)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
// TODO: more filters
|
||||
@ -51,7 +51,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task UpdateStorageAsync(Guid id)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var ciphers = await dbContext.Ciphers
|
||||
@ -75,7 +75,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<ICollection<DataModel.OrganizationAbility>> GetManyAbilitiesAsync()
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext)
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public virtual async Task<T> GetByIdAsync(TId id)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var entity = await GetDbSet(dbContext).FindAsync(id);
|
||||
@ -32,7 +32,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public virtual async Task CreateAsync(T obj)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var entity = Mapper.Map<TEntity>(obj);
|
||||
@ -44,11 +44,11 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public virtual async Task ReplaceAsync(T obj)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var entity = await GetDbSet(dbContext).FindAsync(obj.Id);
|
||||
if(entity != null)
|
||||
if (entity != null)
|
||||
{
|
||||
var mappedEntity = Mapper.Map<TEntity>(obj);
|
||||
dbContext.Entry(entity).CurrentValues.SetValues(mappedEntity);
|
||||
@ -59,7 +59,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public virtual async Task UpsertAsync(T obj)
|
||||
{
|
||||
if(obj.Id.Equals(default(T)))
|
||||
if (obj.Id.Equals(default(T)))
|
||||
{
|
||||
await CreateAsync(obj);
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public virtual async Task DeleteAsync(T obj)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var entity = Mapper.Map<TEntity>(obj);
|
||||
|
@ -19,7 +19,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<TableModel.User> GetByEmailAsync(string email)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext).FirstOrDefaultAsync(e => e.Email == email);
|
||||
@ -28,7 +28,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<DataModel.UserKdfInformation> GetKdfInformationByEmailAsync(string email)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext).Where(e => e.Email == email)
|
||||
@ -42,7 +42,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<ICollection<TableModel.User>> SearchAsync(string email, int skip, int take)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var users = await GetDbSet(dbContext)
|
||||
@ -56,7 +56,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<ICollection<TableModel.User>> GetManyByPremiumAsync(bool premium)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var users = await GetDbSet(dbContext).Where(e => e.Premium == premium).ToListAsync();
|
||||
@ -66,7 +66,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<string> GetPublicKeyAsync(Guid id)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext).Where(e => e.Id == id).Select(e => e.PublicKey).SingleOrDefaultAsync();
|
||||
@ -75,7 +75,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task<DateTime> GetAccountRevisionDateAsync(Guid id)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext).Where(e => e.Id == id).Select(e => e.AccountRevisionDate)
|
||||
@ -85,7 +85,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task UpdateStorageAsync(Guid id)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var ciphers = await dbContext.Ciphers.Where(e => e.UserId == id).ToListAsync();
|
||||
@ -108,7 +108,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
|
||||
public async Task UpdateRenewalReminderDateAsync(Guid id, DateTime renewalReminderDate)
|
||||
{
|
||||
using(var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var user = new EFModel.User
|
||||
|
@ -17,7 +17,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
protected static string SnakeCase(string input)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(input))
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
{
|
||||
var dp = new DynamicParameters();
|
||||
var properties = typeof(T).GetProperties();
|
||||
foreach(var property in properties)
|
||||
foreach (var property in properties)
|
||||
{
|
||||
dp.Add($"_{SnakeCase(property.Name)}", property.GetValue(obj));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
public Repository(string connectionString, string readOnlyConnectionString, string table = null)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(table))
|
||||
if (!string.IsNullOrWhiteSpace(table))
|
||||
{
|
||||
Table = table;
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public virtual async Task<T> GetByIdAsync(TId id)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<T>(
|
||||
$"{Table}_read_by_id",
|
||||
@ -43,7 +43,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
public virtual async Task CreateAsync(T obj)
|
||||
{
|
||||
obj.SetNewId();
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"{Table}_create",
|
||||
@ -54,7 +54,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public virtual async Task ReplaceAsync(T obj)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"{Table}_update",
|
||||
@ -65,7 +65,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public virtual async Task UpsertAsync(T obj)
|
||||
{
|
||||
if(obj.Id.Equals(default(TId)))
|
||||
if (obj.Id.Equals(default(TId)))
|
||||
{
|
||||
await CreateAsync(obj);
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public virtual async Task DeleteAsync(T obj)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"{Table}_delete_by_id",
|
||||
|
@ -27,7 +27,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<User> GetByEmailAsync(string email)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
"user_read_by_email",
|
||||
@ -40,7 +40,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<UserKdfInformation> GetKdfInformationByEmailAsync(string email)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<UserKdfInformation>(
|
||||
"user_read_kdf_by_email",
|
||||
@ -53,7 +53,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<ICollection<User>> SearchAsync(string email, int skip, int take)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ReadOnlyConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ReadOnlyConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
"user_search",
|
||||
@ -67,7 +67,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<ICollection<User>> GetManyByPremiumAsync(bool premium)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
"user_read_by_premium",
|
||||
@ -80,7 +80,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<ICollection<User>> GetManyByPremiumRenewalAsync()
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
"user_read_by_premium_renewal",
|
||||
@ -92,7 +92,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<string> GetPublicKeyAsync(Guid id)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<string>(
|
||||
"user_read_public_key_by_id",
|
||||
@ -105,7 +105,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task<DateTime> GetAccountRevisionDateAsync(Guid id)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<DateTime>(
|
||||
"user_read_account_revision_date_by_id",
|
||||
@ -123,7 +123,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public override async Task DeleteAsync(User user)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"user_delete_by_id",
|
||||
@ -135,7 +135,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task UpdateStorageAsync(Guid id)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"user_update_storage",
|
||||
@ -147,7 +147,7 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
|
||||
public async Task UpdateRenewalReminderDateAsync(Guid id, DateTime renewalReminderDate)
|
||||
{
|
||||
using(var connection = new NpgsqlConnection(ConnectionString))
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"user_update_renewal_reminder_date",
|
||||
|
@ -25,7 +25,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<CipherDetails> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherDetails>(
|
||||
$"[{Schema}].[CipherDetails_ReadByIdUserId]",
|
||||
@ -38,7 +38,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<CipherOrganizationDetails> GetOrganizationDetailsByIdAsync(Guid id, bool deleted = false)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherDetails>(
|
||||
$"[{Schema}].[CipherOrganizationDetails_ReadById]",
|
||||
@ -51,7 +51,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<bool> GetCanEditByIdAsync(Guid userId, Guid cipherId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var result = await connection.QueryFirstOrDefaultAsync<bool>(
|
||||
$"[{Schema}].[Cipher_ReadCanEditByIdUserId]",
|
||||
@ -65,7 +65,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<ICollection<CipherDetails>> GetManyByUserIdAsync(Guid userId, bool withOrganizations = true, bool deleted = false)
|
||||
{
|
||||
string sprocName = null;
|
||||
if(withOrganizations)
|
||||
if (withOrganizations)
|
||||
{
|
||||
sprocName = $"[{Schema}].[CipherDetails_ReadByUserId]";
|
||||
}
|
||||
@ -74,7 +74,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
sprocName = $"[{Schema}].[CipherDetails_ReadWithoutOrganizationsByUserId]";
|
||||
}
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherDetails>(
|
||||
sprocName,
|
||||
@ -90,7 +90,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Cipher>> GetManyByOrganizationIdAsync(Guid organizationId, bool deleted = false)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Cipher>(
|
||||
$"[{Schema}].[Cipher_ReadByOrganizationId]",
|
||||
@ -107,7 +107,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithCollections = JsonConvert.DeserializeObject<CipherWithCollections>(
|
||||
JsonConvert.SerializeObject(cipher));
|
||||
objWithCollections.CollectionIds = collectionIds.ToGuidIdArrayTVP();
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_CreateWithCollections]",
|
||||
@ -119,7 +119,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task CreateAsync(CipherDetails cipher)
|
||||
{
|
||||
cipher.SetNewId();
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CipherDetails_Create]",
|
||||
@ -134,7 +134,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithCollections = JsonConvert.DeserializeObject<CipherDetailsWithCollections>(
|
||||
JsonConvert.SerializeObject(cipher));
|
||||
objWithCollections.CollectionIds = collectionIds.ToGuidIdArrayTVP();
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CipherDetails_CreateWithCollections]",
|
||||
@ -145,7 +145,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task ReplaceAsync(CipherDetails obj)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CipherDetails_Update]",
|
||||
@ -156,7 +156,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpsertAsync(CipherDetails cipher)
|
||||
{
|
||||
if(cipher.Id.Equals(default(Guid)))
|
||||
if (cipher.Id.Equals(default(Guid)))
|
||||
{
|
||||
await CreateAsync(cipher);
|
||||
}
|
||||
@ -172,7 +172,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.CollectionIds = collectionIds.ToGuidIdArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var result = await connection.ExecuteScalarAsync<int>(
|
||||
$"[{Schema}].[Cipher_UpdateWithCollections]",
|
||||
@ -184,7 +184,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdatePartialAsync(Guid id, Guid userId, Guid? folderId, bool favorite)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_UpdatePartial]",
|
||||
@ -195,7 +195,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateAttachmentAsync(CipherAttachment attachment)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_UpdateAttachment]",
|
||||
@ -206,7 +206,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAttachmentAsync(Guid cipherId, string attachmentId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_DeleteAttachment]",
|
||||
@ -217,7 +217,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAsync(Cipher obj, bool permanent = true)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_DeleteById]",
|
||||
@ -228,7 +228,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAsync(IEnumerable<Guid> ids, Guid userId, bool permanent = true)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_Delete]",
|
||||
@ -239,7 +239,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task MoveAsync(IEnumerable<Guid> ids, Guid? folderId, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_Move]",
|
||||
@ -250,7 +250,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_DeleteByUserId]",
|
||||
@ -261,7 +261,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Cipher_DeleteByOrganizationId]",
|
||||
@ -272,24 +272,24 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public Task UpdateUserKeysAndCiphersAsync(User user, IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
using(var transaction = connection.BeginTransaction())
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. Update user.
|
||||
|
||||
using(var cmd = new SqlCommand("[dbo].[User_UpdateKeys]", connection, transaction))
|
||||
using (var cmd = new SqlCommand("[dbo].[User_UpdateKeys]", connection, transaction))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.Add("@Id", SqlDbType.UniqueIdentifier).Value = user.Id;
|
||||
cmd.Parameters.Add("@SecurityStamp", SqlDbType.NVarChar).Value = user.SecurityStamp;
|
||||
cmd.Parameters.Add("@Key", SqlDbType.VarChar).Value = user.Key;
|
||||
|
||||
if(string.IsNullOrWhiteSpace(user.PrivateKey))
|
||||
if (string.IsNullOrWhiteSpace(user.PrivateKey))
|
||||
{
|
||||
cmd.Parameters.Add("@PrivateKey", SqlDbType.VarChar).Value = DBNull.Value;
|
||||
}
|
||||
@ -313,16 +313,16 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
INTO #TempFolder
|
||||
FROM [dbo].[Folder]";
|
||||
|
||||
using(var cmd = new SqlCommand(sqlCreateTemp, connection, transaction))
|
||||
using (var cmd = new SqlCommand(sqlCreateTemp, connection, transaction))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// 3. Bulk copy into temp tables.
|
||||
|
||||
if(ciphers.Any())
|
||||
if (ciphers.Any())
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "#TempCipher";
|
||||
var dataTable = BuildCiphersTable(bulkCopy, ciphers);
|
||||
@ -330,9 +330,9 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
if(folders.Any())
|
||||
if (folders.Any())
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "#TempFolder";
|
||||
var dataTable = BuildFoldersTable(bulkCopy, folders);
|
||||
@ -344,7 +344,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
var sql = string.Empty;
|
||||
|
||||
if(ciphers.Any())
|
||||
if (ciphers.Any())
|
||||
{
|
||||
sql += @"
|
||||
UPDATE
|
||||
@ -361,7 +361,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
C.[UserId] = @UserId";
|
||||
}
|
||||
|
||||
if(folders.Any())
|
||||
if (folders.Any())
|
||||
{
|
||||
sql += @"
|
||||
UPDATE
|
||||
@ -381,7 +381,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
DROP TABLE #TempCipher
|
||||
DROP TABLE #TempFolder";
|
||||
|
||||
using(var cmd = new SqlCommand(sql, connection, transaction))
|
||||
using (var cmd = new SqlCommand(sql, connection, transaction))
|
||||
{
|
||||
cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = user.Id;
|
||||
cmd.ExecuteNonQuery();
|
||||
@ -402,16 +402,16 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateCiphersAsync(Guid userId, IEnumerable<Cipher> ciphers)
|
||||
{
|
||||
if(!ciphers.Any())
|
||||
if (!ciphers.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
using(var transaction = connection.BeginTransaction())
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -422,13 +422,13 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
INTO #TempCipher
|
||||
FROM [dbo].[Cipher]";
|
||||
|
||||
using(var cmd = new SqlCommand(sqlCreateTemp, connection, transaction))
|
||||
using (var cmd = new SqlCommand(sqlCreateTemp, connection, transaction))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// 2. Bulk copy into temp tables.
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "#TempCipher";
|
||||
var dataTable = BuildCiphersTable(bulkCopy, ciphers);
|
||||
@ -458,7 +458,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
DROP TABLE #TempCipher";
|
||||
|
||||
using(var cmd = new SqlCommand(sql, connection, transaction))
|
||||
using (var cmd = new SqlCommand(sql, connection, transaction))
|
||||
{
|
||||
cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = userId;
|
||||
cmd.ExecuteNonQuery();
|
||||
@ -482,22 +482,22 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task CreateAsync(IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders)
|
||||
{
|
||||
if(!ciphers.Any())
|
||||
if (!ciphers.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
using(var transaction = connection.BeginTransaction())
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
if(folders.Any())
|
||||
if (folders.Any())
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[Folder]";
|
||||
var dataTable = BuildFoldersTable(bulkCopy, folders);
|
||||
@ -505,7 +505,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[Cipher]";
|
||||
var dataTable = BuildCiphersTable(bulkCopy, ciphers);
|
||||
@ -531,38 +531,38 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task CreateAsync(IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections,
|
||||
IEnumerable<CollectionCipher> collectionCiphers)
|
||||
{
|
||||
if(!ciphers.Any())
|
||||
if (!ciphers.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
using(var transaction = connection.BeginTransaction())
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[Cipher]";
|
||||
var dataTable = BuildCiphersTable(bulkCopy, ciphers);
|
||||
bulkCopy.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
if(collections.Any())
|
||||
if (collections.Any())
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[Collection]";
|
||||
var dataTable = BuildCollectionsTable(bulkCopy, collections);
|
||||
bulkCopy.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
if(collectionCiphers.Any())
|
||||
if (collectionCiphers.Any())
|
||||
{
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[CollectionCipher]";
|
||||
var dataTable = BuildCollectionCiphersTable(bulkCopy, collectionCiphers);
|
||||
@ -590,7 +590,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
private DataTable BuildCiphersTable(SqlBulkCopy bulkCopy, IEnumerable<Cipher> ciphers)
|
||||
{
|
||||
var c = ciphers.FirstOrDefault();
|
||||
if(c == null)
|
||||
if (c == null)
|
||||
{
|
||||
throw new ApplicationException("Must have some ciphers to bulk import.");
|
||||
}
|
||||
@ -618,7 +618,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var revisionDateColumn = new DataColumn(nameof(c.RevisionDate), c.RevisionDate.GetType());
|
||||
ciphersTable.Columns.Add(revisionDateColumn);
|
||||
|
||||
foreach(DataColumn col in ciphersTable.Columns)
|
||||
foreach (DataColumn col in ciphersTable.Columns)
|
||||
{
|
||||
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
}
|
||||
@ -627,7 +627,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
keys[0] = idColumn;
|
||||
ciphersTable.PrimaryKey = keys;
|
||||
|
||||
foreach(var cipher in ciphers)
|
||||
foreach (var cipher in ciphers)
|
||||
{
|
||||
var row = ciphersTable.NewRow();
|
||||
|
||||
@ -651,7 +651,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
private DataTable BuildFoldersTable(SqlBulkCopy bulkCopy, IEnumerable<Folder> folders)
|
||||
{
|
||||
var f = folders.FirstOrDefault();
|
||||
if(f == null)
|
||||
if (f == null)
|
||||
{
|
||||
throw new ApplicationException("Must have some folders to bulk import.");
|
||||
}
|
||||
@ -669,7 +669,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var revisionDateColumn = new DataColumn(nameof(f.RevisionDate), f.RevisionDate.GetType());
|
||||
foldersTable.Columns.Add(revisionDateColumn);
|
||||
|
||||
foreach(DataColumn col in foldersTable.Columns)
|
||||
foreach (DataColumn col in foldersTable.Columns)
|
||||
{
|
||||
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
}
|
||||
@ -678,7 +678,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
keys[0] = idColumn;
|
||||
foldersTable.PrimaryKey = keys;
|
||||
|
||||
foreach(var folder in folders)
|
||||
foreach (var folder in folders)
|
||||
{
|
||||
var row = foldersTable.NewRow();
|
||||
|
||||
@ -697,7 +697,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
private DataTable BuildCollectionsTable(SqlBulkCopy bulkCopy, IEnumerable<Collection> collections)
|
||||
{
|
||||
var c = collections.FirstOrDefault();
|
||||
if(c == null)
|
||||
if (c == null)
|
||||
{
|
||||
throw new ApplicationException("Must have some collections to bulk import.");
|
||||
}
|
||||
@ -715,7 +715,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var revisionDateColumn = new DataColumn(nameof(c.RevisionDate), c.RevisionDate.GetType());
|
||||
collectionsTable.Columns.Add(revisionDateColumn);
|
||||
|
||||
foreach(DataColumn col in collectionsTable.Columns)
|
||||
foreach (DataColumn col in collectionsTable.Columns)
|
||||
{
|
||||
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
}
|
||||
@ -724,7 +724,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
keys[0] = idColumn;
|
||||
collectionsTable.PrimaryKey = keys;
|
||||
|
||||
foreach(var collection in collections)
|
||||
foreach (var collection in collections)
|
||||
{
|
||||
var row = collectionsTable.NewRow();
|
||||
|
||||
@ -743,7 +743,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
private DataTable BuildCollectionCiphersTable(SqlBulkCopy bulkCopy, IEnumerable<CollectionCipher> collectionCiphers)
|
||||
{
|
||||
var cc = collectionCiphers.FirstOrDefault();
|
||||
if(cc == null)
|
||||
if (cc == null)
|
||||
{
|
||||
throw new ApplicationException("Must have some collectionCiphers to bulk import.");
|
||||
}
|
||||
@ -755,7 +755,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var cipherIdColumn = new DataColumn(nameof(cc.CipherId), cc.CipherId.GetType());
|
||||
collectionCiphersTable.Columns.Add(cipherIdColumn);
|
||||
|
||||
foreach(DataColumn col in collectionCiphersTable.Columns)
|
||||
foreach (DataColumn col in collectionCiphersTable.Columns)
|
||||
{
|
||||
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
}
|
||||
@ -765,7 +765,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
keys[1] = cipherIdColumn;
|
||||
collectionCiphersTable.PrimaryKey = keys;
|
||||
|
||||
foreach(var collectionCipher in collectionCiphers)
|
||||
foreach (var collectionCipher in collectionCiphers)
|
||||
{
|
||||
var row = collectionCiphersTable.NewRow();
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<CollectionCipher>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CollectionCipher>(
|
||||
"[dbo].[CollectionCipher_ReadByUserId]",
|
||||
@ -35,7 +35,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<CollectionCipher>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CollectionCipher>(
|
||||
"[dbo].[CollectionCipher_ReadByOrganizationId]",
|
||||
@ -48,7 +48,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<CollectionCipher>> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CollectionCipher>(
|
||||
"[dbo].[CollectionCipher_ReadByUserIdCipherId]",
|
||||
@ -61,7 +61,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateCollectionsAsync(Guid cipherId, Guid userId, IEnumerable<Guid> collectionIds)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[CollectionCipher_UpdateCollections]",
|
||||
@ -72,7 +72,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateCollectionsForAdminAsync(Guid cipherId, Guid organizationId, IEnumerable<Guid> collectionIds)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[CollectionCipher_UpdateCollectionsAdmin]",
|
||||
@ -84,7 +84,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task UpdateCollectionsForCiphersAsync(IEnumerable<Guid> cipherIds, Guid userId,
|
||||
Guid organizationId, IEnumerable<Guid> collectionIds)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[CollectionCipher_UpdateCollectionsForCiphers]",
|
||||
|
@ -24,7 +24,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<int> GetCountByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteScalarAsync<int>(
|
||||
"[dbo].[Collection_ReadCountByOrganizationId]",
|
||||
@ -37,7 +37,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Tuple<Collection, ICollection<SelectionReadOnly>>> GetByIdWithGroupsAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryMultipleAsync(
|
||||
$"[{Schema}].[Collection_ReadWithGroupsById]",
|
||||
@ -54,7 +54,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<Tuple<CollectionDetails, ICollection<SelectionReadOnly>>> GetByIdWithGroupsAsync(
|
||||
Guid id, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryMultipleAsync(
|
||||
$"[{Schema}].[Collection_ReadWithGroupsByIdUserId]",
|
||||
@ -70,7 +70,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Collection>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Collection>(
|
||||
$"[{Schema}].[{Table}_ReadByOrganizationId]",
|
||||
@ -83,7 +83,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<CollectionDetails> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CollectionDetails>(
|
||||
$"[{Schema}].[Collection_ReadByIdUserId]",
|
||||
@ -96,7 +96,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<CollectionDetails>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CollectionDetails>(
|
||||
$"[{Schema}].[Collection_ReadByUserId]",
|
||||
@ -117,7 +117,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithGroups = JsonConvert.DeserializeObject<CollectionWithGroups>(JsonConvert.SerializeObject(obj));
|
||||
objWithGroups.Groups = groups.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Collection_CreateWithGroups]",
|
||||
@ -131,7 +131,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithGroups = JsonConvert.DeserializeObject<CollectionWithGroups>(JsonConvert.SerializeObject(obj));
|
||||
objWithGroups.Groups = groups.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Collection_UpdateWithGroups]",
|
||||
@ -142,7 +142,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task CreateUserAsync(Guid collectionId, Guid organizationUserId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CollectionUser_Create]",
|
||||
@ -153,7 +153,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteUserAsync(Guid collectionId, Guid organizationUserId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CollectionUser_Delete]",
|
||||
@ -164,7 +164,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateUsersAsync(Guid id, IEnumerable<SelectionReadOnly> users)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[CollectionUser_UpdateUsers]",
|
||||
@ -175,7 +175,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<SelectionReadOnly>> GetManyUsersByIdAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<SelectionReadOnly>(
|
||||
$"[{Schema}].[CollectionUser_ReadByCollectionId]",
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<Device> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
var device = await GetByIdAsync(id);
|
||||
if(device == null || device.UserId != userId)
|
||||
if (device == null || device.UserId != userId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Device> GetByIdentifierAsync(string identifier)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Device>(
|
||||
$"[{Schema}].[{Table}_ReadByIdentifier]",
|
||||
@ -48,7 +48,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Device> GetByIdentifierAsync(string identifier, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Device>(
|
||||
$"[{Schema}].[{Table}_ReadByIdentifierUserId]",
|
||||
@ -65,7 +65,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Device>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Device>(
|
||||
$"[{Schema}].[{Table}_ReadByUserId]",
|
||||
@ -78,7 +78,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task ClearPushTokenAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_ClearPushTokenById]",
|
||||
|
@ -65,7 +65,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task CreateAsync(IEvent e)
|
||||
{
|
||||
if(!(e is Event ev))
|
||||
if (!(e is Event ev))
|
||||
{
|
||||
ev = new Event(e);
|
||||
}
|
||||
@ -75,21 +75,21 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task CreateManyAsync(IList<IEvent> entities)
|
||||
{
|
||||
if(!entities?.Any() ?? true)
|
||||
if (!entities?.Any() ?? true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(entities.Count == 1)
|
||||
if (entities.Count == 1)
|
||||
{
|
||||
await CreateAsync(entities.First());
|
||||
return;
|
||||
}
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
using(var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, null))
|
||||
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, null))
|
||||
{
|
||||
bulkCopy.DestinationTableName = "[dbo].[Event]";
|
||||
var dataTable = BuildEventsTable(bulkCopy, entities.Select(e => e is Event ? e as Event : new Event(e)));
|
||||
@ -102,7 +102,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
IDictionary<string, object> sprocParams, DateTime startDate, DateTime endDate, PageOptions pageOptions)
|
||||
{
|
||||
DateTime? beforeDate = null;
|
||||
if(!string.IsNullOrWhiteSpace(pageOptions.ContinuationToken) &&
|
||||
if (!string.IsNullOrWhiteSpace(pageOptions.ContinuationToken) &&
|
||||
long.TryParse(pageOptions.ContinuationToken, out var binaryDate))
|
||||
{
|
||||
beforeDate = DateTime.SpecifyKind(DateTime.FromBinary(binaryDate), DateTimeKind.Utc);
|
||||
@ -116,13 +116,13 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
parameters.Add("@EndDate", endDate.ToUniversalTime(), DbType.DateTime2, null, 7);
|
||||
parameters.Add("@BeforeDate", beforeDate, DbType.DateTime2, null, 7);
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var events = (await connection.QueryAsync<Event>(sprocName, parameters,
|
||||
commandType: CommandType.StoredProcedure)).ToList();
|
||||
|
||||
var result = new PagedResult<IEvent>();
|
||||
if(events.Any() && events.Count >= pageOptions.PageSize)
|
||||
if (events.Any() && events.Count >= pageOptions.PageSize)
|
||||
{
|
||||
result.ContinuationToken = events.Last().Date.ToBinary().ToString();
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
private DataTable BuildEventsTable(SqlBulkCopy bulkCopy, IEnumerable<Event> events)
|
||||
{
|
||||
var e = events.FirstOrDefault();
|
||||
if(e == null)
|
||||
if (e == null)
|
||||
{
|
||||
throw new ApplicationException("Must have some events to bulk import.");
|
||||
}
|
||||
@ -168,7 +168,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var dateColumn = new DataColumn(nameof(e.Date), e.Date.GetType());
|
||||
eventsTable.Columns.Add(dateColumn);
|
||||
|
||||
foreach(DataColumn col in eventsTable.Columns)
|
||||
foreach (DataColumn col in eventsTable.Columns)
|
||||
{
|
||||
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
}
|
||||
@ -177,7 +177,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
keys[0] = idColumn;
|
||||
eventsTable.PrimaryKey = keys;
|
||||
|
||||
foreach(var ev in events)
|
||||
foreach (var ev in events)
|
||||
{
|
||||
ev.SetNewId();
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<Folder> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
var folder = await GetByIdAsync(id);
|
||||
if(folder == null || folder.UserId != userId)
|
||||
if (folder == null || folder.UserId != userId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Folder>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Folder>(
|
||||
$"[{Schema}].[Folder_ReadByUserId]",
|
||||
|
@ -21,7 +21,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Grant> GetByKeyAsync(string key)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Grant>(
|
||||
"[dbo].[Grant_ReadByKey]",
|
||||
@ -34,7 +34,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Grant>> GetManyAsync(string subjectId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Grant>(
|
||||
"[dbo].[Grant_ReadBySubjectId]",
|
||||
@ -47,7 +47,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task SaveAsync(Grant obj)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_Save]",
|
||||
@ -58,7 +58,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAsync(string key)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_DeleteByKey]",
|
||||
@ -69,7 +69,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAsync(string subjectId, string clientId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_DeleteBySubjectIdClientId]",
|
||||
@ -80,7 +80,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteAsync(string subjectId, string clientId, string type)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_DeleteBySubjectIdClientIdType]",
|
||||
|
@ -24,7 +24,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Tuple<Group, ICollection<SelectionReadOnly>>> GetByIdWithCollectionsAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryMultipleAsync(
|
||||
$"[{Schema}].[Group_ReadWithCollectionsById]",
|
||||
@ -40,7 +40,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Group>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Group>(
|
||||
$"[{Schema}].[Group_ReadByOrganizationId]",
|
||||
@ -53,7 +53,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Guid>> GetManyIdsByUserIdAsync(Guid organizationUserId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Guid>(
|
||||
$"[{Schema}].[GroupUser_ReadGroupIdsByOrganizationUserId]",
|
||||
@ -66,7 +66,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Guid>> GetManyUserIdsByIdAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Guid>(
|
||||
$"[{Schema}].[GroupUser_ReadOrganizationUserIdsByGroupId]",
|
||||
@ -79,7 +79,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<GroupUser>> GetManyGroupUsersByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<GroupUser>(
|
||||
$"[{Schema}].[GroupUser_ReadByOrganizationId]",
|
||||
@ -96,7 +96,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithCollections = JsonConvert.DeserializeObject<GroupWithCollections>(JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.Collections = collections.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Group_CreateWithCollections]",
|
||||
@ -110,7 +110,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
var objWithCollections = JsonConvert.DeserializeObject<GroupWithCollections>(JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.Collections = collections.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[Group_UpdateWithCollections]",
|
||||
@ -121,7 +121,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteUserAsync(Guid groupId, Guid organizationUserId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[GroupUser_Delete]",
|
||||
@ -132,7 +132,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateUsersAsync(Guid groupId, IEnumerable<Guid> organizationUserIds)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[GroupUser_UpdateUsers]",
|
||||
|
@ -17,7 +17,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateStatisticsAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[AzureSQLMaintenance]",
|
||||
@ -29,7 +29,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DisableCipherAutoStatsAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"sp_autostats",
|
||||
@ -40,7 +40,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task RebuildIndexesAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[AzureSQLMaintenance]",
|
||||
@ -52,7 +52,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteExpiredGrantsAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_DeleteExpired]",
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Organization>> GetManyByEnabledAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Organization>(
|
||||
"[dbo].[Organization_ReadByEnabled]",
|
||||
@ -34,7 +34,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Organization>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Organization>(
|
||||
"[dbo].[Organization_ReadByUserId]",
|
||||
@ -48,7 +48,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<ICollection<Organization>> SearchAsync(string name, string userEmail, bool? paid,
|
||||
int skip, int take)
|
||||
{
|
||||
using(var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
using (var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Organization>(
|
||||
"[dbo].[Organization_Search]",
|
||||
@ -62,7 +62,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateStorageAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Organization_UpdateStorage]",
|
||||
@ -74,7 +74,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<OrganizationAbility>> GetManyAbilitiesAsync()
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationAbility>(
|
||||
"[dbo].[Organization_ReadAbilities]",
|
||||
|
@ -25,7 +25,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<int> GetCountByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteScalarAsync<int>(
|
||||
"[dbo].[OrganizationUser_ReadCountByOrganizationId]",
|
||||
@ -38,7 +38,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<int> GetCountByFreeOrganizationAdminUserAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteScalarAsync<int>(
|
||||
"[dbo].[OrganizationUser_ReadCountByFreeOrganizationAdminUser]",
|
||||
@ -51,7 +51,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<int> GetCountByOnlyOwnerAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteScalarAsync<int>(
|
||||
"[dbo].[OrganizationUser_ReadCountByOnlyOwner]",
|
||||
@ -64,7 +64,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<int> GetCountByOrganizationAsync(Guid organizationId, string email, bool onlyRegisteredUsers)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var result = await connection.ExecuteScalarAsync<int>(
|
||||
"[dbo].[OrganizationUser_ReadCountByOrganizationIdEmail]",
|
||||
@ -77,7 +77,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<OrganizationUser> GetByOrganizationAsync(Guid organizationId, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUser>(
|
||||
"[dbo].[OrganizationUser_ReadByOrganizationIdUserId]",
|
||||
@ -90,7 +90,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<OrganizationUser>> GetManyByUserAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUser>(
|
||||
"[dbo].[OrganizationUser_ReadByUserId]",
|
||||
@ -104,7 +104,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<ICollection<OrganizationUser>> GetManyByOrganizationAsync(Guid organizationId,
|
||||
OrganizationUserType? type)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUser>(
|
||||
"[dbo].[OrganizationUser_ReadByOrganizationId]",
|
||||
@ -117,7 +117,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Tuple<OrganizationUser, ICollection<SelectionReadOnly>>> GetByIdWithCollectionsAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryMultipleAsync(
|
||||
"[dbo].[OrganizationUser_ReadWithCollectionsById]",
|
||||
@ -132,7 +132,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<OrganizationUserUserDetails> GetDetailsByIdAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUserUserDetails>(
|
||||
"[dbo].[OrganizationUserUserDetails_ReadById]",
|
||||
@ -145,7 +145,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<Tuple<OrganizationUserUserDetails, ICollection<SelectionReadOnly>>>
|
||||
GetDetailsByIdWithCollectionsAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryMultipleAsync(
|
||||
"[dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]",
|
||||
@ -160,7 +160,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUserUserDetails>(
|
||||
"[dbo].[OrganizationUserUserDetails_ReadByOrganizationId]",
|
||||
@ -174,7 +174,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public async Task<ICollection<OrganizationUserOrganizationDetails>> GetManyDetailsByUserAsync(Guid userId,
|
||||
OrganizationUserStatusType? status = null)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationUserOrganizationDetails>(
|
||||
"[dbo].[OrganizationUserOrganizationDetails_ReadByUserIdStatus]",
|
||||
@ -187,7 +187,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateGroupsAsync(Guid orgUserId, IEnumerable<Guid> groupIds)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
"[dbo].[GroupUser_UpdateGroups]",
|
||||
@ -203,7 +203,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.Collections = collections.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[OrganizationUser_CreateWithCollections]",
|
||||
@ -218,7 +218,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
JsonConvert.SerializeObject(obj));
|
||||
objWithCollections.Collections = collections.ToArrayTVP();
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[OrganizationUser_UpdateWithCollections]",
|
||||
|
@ -21,7 +21,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
{ }
|
||||
public async Task<Policy> GetByOrganizationIdTypeAsync(Guid organizationId, PolicyType type)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Policy>(
|
||||
$"[{Schema}].[{Table}_ReadByOrganizationIdType]",
|
||||
@ -34,7 +34,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Policy>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Policy>(
|
||||
$"[{Schema}].[{Table}_ReadByOrganizationId]",
|
||||
@ -47,7 +47,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Policy>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Policy>(
|
||||
$"[{Schema}].[{Table}_ReadByUserId]",
|
||||
|
@ -16,12 +16,12 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
string schema = null, string table = null)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(table))
|
||||
if (!string.IsNullOrWhiteSpace(table))
|
||||
{
|
||||
Table = table;
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(schema))
|
||||
if (!string.IsNullOrWhiteSpace(schema))
|
||||
{
|
||||
Schema = schema;
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public virtual async Task<T> GetByIdAsync(TId id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<T>(
|
||||
$"[{Schema}].[{Table}_ReadById]",
|
||||
@ -46,7 +46,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public virtual async Task CreateAsync(T obj)
|
||||
{
|
||||
obj.SetNewId();
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_Create]",
|
||||
@ -57,7 +57,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public virtual async Task ReplaceAsync(T obj)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_Update]",
|
||||
@ -68,7 +68,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public virtual async Task UpsertAsync(T obj)
|
||||
{
|
||||
if(obj.Id.Equals(default(TId)))
|
||||
if (obj.Id.Equals(default(TId)))
|
||||
{
|
||||
await CreateAsync(obj);
|
||||
}
|
||||
@ -80,7 +80,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public virtual async Task DeleteAsync(T obj)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_DeleteById]",
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByUserId]",
|
||||
@ -35,7 +35,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByOrganizationId]",
|
||||
@ -48,7 +48,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<Transaction> GetByGatewayIdAsync(GatewayType gatewayType, string gatewayId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByGatewayId]",
|
||||
|
@ -21,7 +21,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<U2f>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<U2f>(
|
||||
$"[{Schema}].[U2f_ReadByUserId]",
|
||||
@ -34,7 +34,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task DeleteManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[U2f_DeleteByUserId]",
|
||||
|
@ -27,7 +27,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<User> GetByEmailAsync(string email)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
$"[{Schema}].[{Table}_ReadByEmail]",
|
||||
@ -40,7 +40,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<UserKdfInformation> GetKdfInformationByEmailAsync(string email)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<UserKdfInformation>(
|
||||
$"[{Schema}].[{Table}_ReadKdfByEmail]",
|
||||
@ -53,7 +53,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<User>> SearchAsync(string email, int skip, int take)
|
||||
{
|
||||
using(var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
using (var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
$"[{Schema}].[{Table}_Search]",
|
||||
@ -67,7 +67,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<ICollection<User>> GetManyByPremiumAsync(bool premium)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
"[dbo].[User_ReadByPremium]",
|
||||
@ -80,7 +80,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<string> GetPublicKeyAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<string>(
|
||||
$"[{Schema}].[{Table}_ReadPublicKeyById]",
|
||||
@ -93,7 +93,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task<DateTime> GetAccountRevisionDateAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<DateTime>(
|
||||
$"[{Schema}].[{Table}_ReadAccountRevisionDateById]",
|
||||
@ -111,7 +111,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public override async Task DeleteAsync(User user)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_DeleteById]",
|
||||
@ -123,7 +123,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateStorageAsync(Guid id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_UpdateStorage]",
|
||||
@ -135,7 +135,7 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
|
||||
public async Task UpdateRenewalReminderDateAsync(Guid id, DateTime renewalReminderDate)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[User_UpdateRenewalReminderDate]",
|
||||
|
@ -53,7 +53,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
public async Task CreateAsync(IEvent e)
|
||||
{
|
||||
if(!(e is EventTableEntity entity))
|
||||
if (!(e is EventTableEntity entity))
|
||||
{
|
||||
throw new ArgumentException(nameof(e));
|
||||
}
|
||||
@ -63,12 +63,12 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
public async Task CreateManyAsync(IList<IEvent> e)
|
||||
{
|
||||
if(!e?.Any() ?? true)
|
||||
if (!e?.Any() ?? true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(e.Count == 1)
|
||||
if (e.Count == 1)
|
||||
{
|
||||
await CreateAsync(e.First());
|
||||
return;
|
||||
@ -76,10 +76,10 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
var entities = e.Where(ev => ev is EventTableEntity).Select(ev => ev as EventTableEntity);
|
||||
var entityGroups = entities.GroupBy(ent => ent.PartitionKey);
|
||||
foreach(var group in entityGroups)
|
||||
foreach (var group in entityGroups)
|
||||
{
|
||||
var groupEntities = group.ToList();
|
||||
if(groupEntities.Count == 1)
|
||||
if (groupEntities.Count == 1)
|
||||
{
|
||||
await CreateEntityAsync(groupEntities.First());
|
||||
continue;
|
||||
@ -87,16 +87,16 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
// A batch insert can only contain 100 entities at a time
|
||||
var iterations = groupEntities.Count / 100;
|
||||
for(var i = 0; i <= iterations; i++)
|
||||
for (var i = 0; i <= iterations; i++)
|
||||
{
|
||||
var batch = new TableBatchOperation();
|
||||
var batchEntities = groupEntities.Skip(i * 100).Take(100);
|
||||
if(!batchEntities.Any())
|
||||
if (!batchEntities.Any())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
foreach(var entity in batchEntities)
|
||||
foreach (var entity in batchEntities)
|
||||
{
|
||||
batch.InsertOrReplace(entity);
|
||||
}
|
||||
@ -144,7 +144,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
private string SerializeContinuationToken(TableContinuationToken token)
|
||||
{
|
||||
if(token == null)
|
||||
if (token == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -155,13 +155,13 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
private TableContinuationToken DeserializeContinuationToken(string token)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(token))
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var tokenParts = token.Split(new string[] { "__" }, StringSplitOptions.None);
|
||||
if(tokenParts.Length < 4 || !Enum.TryParse(tokenParts[0], out StorageLocation tLoc))
|
||||
if (tokenParts.Length < 4 || !Enum.TryParse(tokenParts[0], out StorageLocation tLoc))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -29,22 +29,22 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
public async Task UpsertManyAsync(IList<InstallationDeviceEntity> entities)
|
||||
{
|
||||
if(!entities?.Any() ?? true)
|
||||
if (!entities?.Any() ?? true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(entities.Count == 1)
|
||||
if (entities.Count == 1)
|
||||
{
|
||||
await UpsertAsync(entities.First());
|
||||
return;
|
||||
}
|
||||
|
||||
var entityGroups = entities.GroupBy(ent => ent.PartitionKey);
|
||||
foreach(var group in entityGroups)
|
||||
foreach (var group in entityGroups)
|
||||
{
|
||||
var groupEntities = group.ToList();
|
||||
if(groupEntities.Count == 1)
|
||||
if (groupEntities.Count == 1)
|
||||
{
|
||||
await UpsertAsync(groupEntities.First());
|
||||
continue;
|
||||
@ -52,16 +52,16 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
|
||||
// A batch insert can only contain 100 entities at a time
|
||||
var iterations = groupEntities.Count / 100;
|
||||
for(var i = 0; i <= iterations; i++)
|
||||
for (var i = 0; i <= iterations; i++)
|
||||
{
|
||||
var batch = new TableBatchOperation();
|
||||
var batchEntities = groupEntities.Skip(i * 100).Take(100);
|
||||
if(!batchEntities.Any())
|
||||
if (!batchEntities.Any())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
foreach(var entity in batchEntities)
|
||||
foreach (var entity in batchEntities)
|
||||
{
|
||||
batch.InsertOrReplace(entity);
|
||||
}
|
||||
@ -78,9 +78,9 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
entity.ETag = "*";
|
||||
await _table.ExecuteAsync(TableOperation.Delete(entity));
|
||||
}
|
||||
catch(StorageException e)
|
||||
catch (StorageException e)
|
||||
{
|
||||
if(e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
|
||||
if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
public async Task<string> GetAsync(string objectName, string id, string prop)
|
||||
{
|
||||
var dict = await GetAsync(objectName, id);
|
||||
if(dict != null && dict.ContainsKey(prop))
|
||||
if (dict != null && dict.ContainsKey(prop))
|
||||
{
|
||||
return dict[prop];
|
||||
}
|
||||
@ -46,7 +46,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, $"{objectName}_{id}"));
|
||||
var queryResults = await _table.ExecuteQuerySegmentedAsync(query, null);
|
||||
var entity = queryResults.Results.FirstOrDefault();
|
||||
if(entity == null)
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new DictionaryEntity
|
||||
{
|
||||
@ -54,7 +54,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
RowKey = string.Empty
|
||||
};
|
||||
}
|
||||
if(entity.ContainsKey(keyValuePair.Key))
|
||||
if (entity.ContainsKey(keyValuePair.Key))
|
||||
{
|
||||
entity.Remove(keyValuePair.Key);
|
||||
}
|
||||
@ -69,7 +69,7 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
PartitionKey = $"{objectName}_{id}",
|
||||
RowKey = string.Empty
|
||||
};
|
||||
foreach(var item in dict)
|
||||
foreach (var item in dict)
|
||||
{
|
||||
entity.Add(item.Key, item.Value);
|
||||
}
|
||||
@ -87,9 +87,9 @@ namespace Bit.Core.Repositories.TableStorage
|
||||
ETag = "*"
|
||||
}));
|
||||
}
|
||||
catch(StorageException e)
|
||||
catch (StorageException e)
|
||||
{
|
||||
if(e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
|
||||
if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.NotFound)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user