Compare commits
	
		
			No commits in common. "37e56206d4b098d54145b1f92d451e254a36c7c1" and "10f2083590e547b1f6ee4cfdc2a78c0ac7b028ef" have entirely different histories.
		
	
	
		
			37e56206d4
			...
			10f2083590
		
	
		
| @ -10,7 +10,7 @@ | |||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" /> |     <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" /> | ||||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> |     <PackageReference Include="Blueprint.Logging" Version="0.0.2" /> | ||||||
|     <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" /> |     <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" /> | ||||||
|     <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.0.0" /> |     <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.0.0" /> | ||||||
|     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> |     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | ||||||
|  | |||||||
| @ -21,11 +21,7 @@ namespace Core.Blueprint.DAL.API.Extensions | |||||||
|             services.AddScoped<CollectionRepository<SampleCollection>>(); |             services.AddScoped<CollectionRepository<SampleCollection>>(); | ||||||
| 
 | 
 | ||||||
|             //SQL |             //SQL | ||||||
|             services.AddDbContext<SqlServerContext>(options => |             services.AddDbContext<SqlServerContext>(options => options.UseSqlServer(configuration.GetConnectionString("SQLServer"))); | ||||||
|                 options.UseSqlServer(configuration.GetConnectionString("SqlServer"), |  | ||||||
|                     sqlOptions => sqlOptions.EnableRetryOnFailure()) |  | ||||||
|             ); |  | ||||||
| 
 |  | ||||||
|             services.AddScoped<ISqlSampleService, SqlSampleService>(); |             services.AddScoped<ISqlSampleService, SqlSampleService>(); | ||||||
| 
 | 
 | ||||||
|             //Storage |             //Storage | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | using Azure.Identity; | ||||||
| using Core.Blueprint.DAL.API.Extensions; | using Core.Blueprint.DAL.API.Extensions; | ||||||
| using Core.Blueprint.DAL.Mongo.Configuration; | using Core.Blueprint.DAL.Mongo.Configuration; | ||||||
| using Core.Blueprint.KeyVault.Configuration; | using Core.Blueprint.KeyVault.Configuration; | ||||||
| @ -6,26 +7,27 @@ using Core.Blueprint.Redis.Configuration; | |||||||
| using Core.Blueprint.SQLServer.Configuration; | using Core.Blueprint.SQLServer.Configuration; | ||||||
| using Core.Blueprint.Storage.Configuration; | using Core.Blueprint.Storage.Configuration; | ||||||
| using Microsoft.AspNetCore.HttpLogging; | using Microsoft.AspNetCore.HttpLogging; | ||||||
|  | using Microsoft.Extensions.Configuration.AzureAppConfiguration; | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
| 
 | 
 | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
| 
 | 
 | ||||||
| //builder.Configuration.AddAzureAppConfiguration(options => | builder.Configuration.AddAzureAppConfiguration(options => | ||||||
| //{ | { | ||||||
| //    var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value; |     var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value; | ||||||
| 
 | 
 | ||||||
| //    if (string.IsNullOrEmpty(endpoint)) |     if (string.IsNullOrEmpty(endpoint)) | ||||||
| //        throw new ArgumentException("The app configuration is missing"); |         throw new ArgumentException("The app configuration is missing"); | ||||||
| 
 | 
 | ||||||
| //    options.Connect(new Uri(endpoint), new DefaultAzureCredential()) |     options.Connect(new Uri(endpoint), new DefaultAzureCredential()) | ||||||
| //    .Select(KeyFilter.Any, "blueprint_dal"); |     .Select(KeyFilter.Any, "blueprint_dal"); | ||||||
| 
 | 
 | ||||||
| //    options.ConfigureKeyVault(keyVaultOptions => |     options.ConfigureKeyVault(keyVaultOptions => | ||||||
| //    { |     { | ||||||
| //        keyVaultOptions.SetCredential(new DefaultAzureCredential()); |         keyVaultOptions.SetCredential(new DefaultAzureCredential()); | ||||||
| //    }); |     }); | ||||||
| //}); | }); | ||||||
| 
 | 
 | ||||||
| builder.Services.AddEndpointsApiExplorer(); | builder.Services.AddEndpointsApiExplorer(); | ||||||
| builder.Services.AddSwaggerGen(); | builder.Services.AddSwaggerGen(); | ||||||
|  | |||||||
| @ -7,30 +7,5 @@ | |||||||
|   }, |   }, | ||||||
|   "CacheSettings": { |   "CacheSettings": { | ||||||
|     "DefaultCacheDurationInMinutes": 3 |     "DefaultCacheDurationInMinutes": 3 | ||||||
|   }, |  | ||||||
|   "Vault": { |  | ||||||
|     "Address": "http://100.123.31.103:8200", |  | ||||||
|     "Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm", |  | ||||||
|     "SecretMount": "secret" |  | ||||||
|   }, |  | ||||||
|   "ConnectionStrings": { |  | ||||||
|     "BlobStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFeqCnf2P==;BlobEndpoint=http://100.123.31.103:10000/devstoreaccount1;QueueEndpoint=http://100.123.31.103:10001/devstoreaccount1;TableEndpoint=http://100.123.31.103:10002/devstoreaccount1;", |  | ||||||
|     "MongoDB": "mongodb://admin_agile:Admin%40agileWebs@portainer.white-enciso.pro:27017/?authMechanism=SCRAM-SHA-256", |  | ||||||
|     "SqlServer": "Server=100.123.31.103,1433;Database=Blueprint;User Id=sa;Password=Alpha-Whisky-2025;TrustServerCertificate=True;", |  | ||||||
|     "Redis": "100.123.31.103:6379" |  | ||||||
|   }, |  | ||||||
|   "MongoDb": { |  | ||||||
|     "DatabaseName":  "Blueprint", |  | ||||||
|     "LocalAudience": "test", |  | ||||||
|     "Audience": "test", |  | ||||||
|   }, |  | ||||||
|   "BlobStorage": { |  | ||||||
|     "ContainerName": "blueprint", |  | ||||||
|     "AccountName": "devstoreaccount1", |  | ||||||
|     "AccountKey": "Eby8vdM02xNOcqFeqCnf2P==" |  | ||||||
|   }, |  | ||||||
|   "ServiceSettings": { |  | ||||||
|     "ApplicationName": "blueprint", |  | ||||||
|     "LayerName": "dal" |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -7,7 +7,7 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.0" /> |     <PackageReference Include="Blueprint.KeyVault" Version="0.0.1" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -7,9 +7,8 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> |     <PackageReference Include="Blueprint.Mongo" Version="0.0.2" /> | ||||||
|     <PackageReference Include="Core.Blueprint.Mongo" Version="1.0.0" /> |     <PackageReference Include="Blueprint.Redis" Version="0.0.1" /> | ||||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> |  | ||||||
|     <PackageReference Include="Mapster" Version="7.4.0" /> |     <PackageReference Include="Mapster" Version="7.4.0" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,21 +5,22 @@ using Core.Blueprint.Mongo; | |||||||
| using Core.Blueprint.Redis; | using Core.Blueprint.Redis; | ||||||
| using Core.Blueprint.Redis.Helpers; | using Core.Blueprint.Redis.Helpers; | ||||||
| using Mapster; | using Mapster; | ||||||
|  | using Microsoft.Extensions.Options; | ||||||
| 
 | 
 | ||||||
| namespace Core.Blueprint.DAL.Mongo.Service | namespace Core.Blueprint.DAL.Mongo.Service | ||||||
| { | { | ||||||
|     public class MongoSampleService : IMongoSampleService |     public class MongoSampleService : IMongoSampleService | ||||||
|     { |     { | ||||||
|         private readonly CollectionRepository<SampleCollection> repository; |         private readonly CollectionRepository<SampleCollection> repository; | ||||||
|         private readonly ICacheSettings cacheSettings; |         private readonly CacheSettings cacheSettings; | ||||||
|         private readonly IRedisCacheProvider cacheProvider; |         private readonly IRedisCacheProvider cacheProvider; | ||||||
| 
 | 
 | ||||||
|         public MongoSampleService(CollectionRepository<SampleCollection> repository, |         public MongoSampleService(CollectionRepository<SampleCollection> repository, | ||||||
|         IRedisCacheProvider cacheProvider, ICacheSettings cacheSettings) |         IRedisCacheProvider cacheProvider, IOptions<CacheSettings> cacheSettings) | ||||||
|         { |         { | ||||||
|             this.repository = repository; |             this.repository = repository; | ||||||
|             this.repository.CollectionInitialization(); |             this.repository.CollectionInitialization(); | ||||||
|             this.cacheSettings = cacheSettings; |             this.cacheSettings = cacheSettings.Value; | ||||||
|             this.cacheProvider = cacheProvider; |             this.cacheProvider = cacheProvider; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -29,8 +30,6 @@ namespace Core.Blueprint.DAL.Mongo.Service | |||||||
| 
 | 
 | ||||||
|             await this.repository.InsertOneAsync(sampleCollection); |             await this.repository.InsertOneAsync(sampleCollection); | ||||||
| 
 | 
 | ||||||
|             await ResetCollectionCache(); |  | ||||||
| 
 |  | ||||||
|             return sampleCollection; |             return sampleCollection; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -44,7 +43,7 @@ namespace Core.Blueprint.DAL.Mongo.Service | |||||||
| 
 | 
 | ||||||
|             var sample = await this.repository.FindByIdAsync(_id); |             var sample = await this.repository.FindByIdAsync(_id); | ||||||
| 
 | 
 | ||||||
|             await cacheProvider.SetAsync(cacheKey, sample, TimeSpan.FromMinutes(cacheSettings.DefaultCacheDurationInMinutes)); |             await cacheProvider.SetAsync(cacheKey, sample); | ||||||
| 
 | 
 | ||||||
|             return sample; |             return sample; | ||||||
|         } |         } | ||||||
| @ -59,7 +58,7 @@ namespace Core.Blueprint.DAL.Mongo.Service | |||||||
| 
 | 
 | ||||||
|             var samples = await this.repository.AsQueryable(); |             var samples = await this.repository.AsQueryable(); | ||||||
| 
 | 
 | ||||||
|             await cacheProvider.SetAsync(cacheKey, samples, TimeSpan.FromMinutes(cacheSettings.DefaultCacheDurationInMinutes)); |             await cacheProvider.SetAsync(cacheKey, samples); | ||||||
| 
 | 
 | ||||||
|             return samples; |             return samples; | ||||||
|         } |         } | ||||||
| @ -68,32 +67,14 @@ namespace Core.Blueprint.DAL.Mongo.Service | |||||||
|         { |         { | ||||||
|             await this.repository.ReplaceOneAsync(entity); |             await this.repository.ReplaceOneAsync(entity); | ||||||
| 
 | 
 | ||||||
|             await ResetCollectionCache(); |  | ||||||
| 
 |  | ||||||
|             return entity; |             return entity; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         |  | ||||||
|         public async ValueTask<SampleCollection> DeleteSample(string _id, CancellationToken cancellationToken) |         public async ValueTask<SampleCollection> DeleteSample(string _id, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             var entity = await this.repository.DeleteOneAsync(doc => doc._Id == _id); |             var entity = await this.repository.DeleteOneAsync(doc => doc._Id == _id); | ||||||
| 
 | 
 | ||||||
|             await ResetCollectionCache(); |  | ||||||
| 
 |  | ||||||
|             return entity; |             return entity; | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// Temporary method to "reset" collections cache |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         private async Task ResetCollectionCache() |  | ||||||
|         { |  | ||||||
|             //TODO: remoge this mehtod when necessary. |  | ||||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllSamples"); |  | ||||||
| 
 |  | ||||||
|             await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<SampleCollection>(), null); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> |     <PackageReference Include="Blueprint.Redis" Version="0.0.1" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ namespace Core.Blueprint.DAL.SQLServer.Context | |||||||
|     public sealed class SqlServerContext : DbContext |     public sealed class SqlServerContext : DbContext | ||||||
|     { |     { | ||||||
|         public SqlServerContext(DbContextOptions<SqlServerContext> options) : base(options) { } |         public SqlServerContext(DbContextOptions<SqlServerContext> options) : base(options) { } | ||||||
|         public DbSet<Sample> Samples { get; set; } |         public DbSet<Sample> UserProjects { get; set; } | ||||||
| 
 | 
 | ||||||
|         protected override void OnModelCreating(ModelBuilder modelBuilder) |         protected override void OnModelCreating(ModelBuilder modelBuilder) | ||||||
|         { |         { | ||||||
|  | |||||||
| @ -7,8 +7,8 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> |     <PackageReference Include="Blueprint.Redis" Version="0.0.1" /> | ||||||
|     <PackageReference Include="Core.Blueprint.SQLServer" Version="1.0.2" /> |     <PackageReference Include="Blueprint.SQLServer" Version="0.0.1" /> | ||||||
|     <PackageReference Include="Mapster" Version="7.4.1-pre01" /> |     <PackageReference Include="Mapster" Version="7.4.1-pre01" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,17 +6,18 @@ using Core.Blueprint.DAL.SQLServer.Entities.Request; | |||||||
| using Core.Blueprint.Redis; | using Core.Blueprint.Redis; | ||||||
| using Core.Blueprint.Redis.Helpers; | using Core.Blueprint.Redis.Helpers; | ||||||
| using Mapster; | using Mapster; | ||||||
|  | using Microsoft.Extensions.Options; | ||||||
| 
 | 
 | ||||||
| public class SqlSampleService : ISqlSampleService | public class SqlSampleService : ISqlSampleService | ||||||
| { | { | ||||||
|     private readonly IEntityRepository<Sample, SqlServerContext> _sqlSampleRepository; |     private readonly IEntityRepository<Sample, SqlServerContext> _sqlSampleRepository; | ||||||
|     private readonly ICacheSettings cacheSettings; |     private readonly CacheSettings cacheSettings; | ||||||
|     private readonly IRedisCacheProvider cacheProvider; |     private readonly IRedisCacheProvider cacheProvider; | ||||||
| 
 | 
 | ||||||
|     public SqlSampleService(IEntityRepository<Sample, SqlServerContext> sqlSampleRepository, IRedisCacheProvider cacheProvider, ICacheSettings cacheSettings) |     public SqlSampleService(IEntityRepository<Sample, SqlServerContext> sqlSampleRepository, IRedisCacheProvider cacheProvider, IOptions<CacheSettings> cacheSettings) | ||||||
|     { |     { | ||||||
|         _sqlSampleRepository = sqlSampleRepository; |         _sqlSampleRepository = sqlSampleRepository; | ||||||
|         this.cacheSettings = cacheSettings; |         this.cacheSettings = cacheSettings.Value; | ||||||
|         this.cacheProvider = cacheProvider; |         this.cacheProvider = cacheProvider; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -29,7 +30,7 @@ public class SqlSampleService : ISqlSampleService | |||||||
| 
 | 
 | ||||||
|         var samples = await _sqlSampleRepository.GetAllAsync(); |         var samples = await _sqlSampleRepository.GetAllAsync(); | ||||||
| 
 | 
 | ||||||
|         await cacheProvider.SetAsync(cacheKey, samples, TimeSpan.FromMinutes(cacheSettings.DefaultCacheDurationInMinutes)); |         await cacheProvider.SetAsync(cacheKey, samples); | ||||||
| 
 | 
 | ||||||
|         return samples; |         return samples; | ||||||
|     } |     } | ||||||
| @ -43,7 +44,7 @@ public class SqlSampleService : ISqlSampleService | |||||||
| 
 | 
 | ||||||
|         var sample = await _sqlSampleRepository.GetByIdAsync(id); |         var sample = await _sqlSampleRepository.GetByIdAsync(id); | ||||||
| 
 | 
 | ||||||
|         await cacheProvider.SetAsync(cacheKey, sample, TimeSpan.FromMinutes(cacheSettings.DefaultCacheDurationInMinutes)); |         await cacheProvider.SetAsync(cacheKey, sample); | ||||||
| 
 | 
 | ||||||
|         return sample; |         return sample; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ namespace Core.Blueprint.DAL.Storage.Contracts | |||||||
|         Task<IEnumerable<BlobFileAdapter>> GetBlobsListAsync(string? prefix); |         Task<IEnumerable<BlobFileAdapter>> GetBlobsListAsync(string? prefix); | ||||||
|         Task<Response<BlobContentInfo>> UploadBlobAsync(string blobName, Stream content); |         Task<Response<BlobContentInfo>> UploadBlobAsync(string blobName, Stream content); | ||||||
|         Task<BlobFileAdapter> UploadBlobAsync(BlobAddDto newBlob); |         Task<BlobFileAdapter> UploadBlobAsync(BlobAddDto newBlob); | ||||||
|         ValueTask<BlobDownloadUriAdapter> DownloadBlobAsync(string blobName); |         BlobDownloadUriAdapter DownloadBlobAsync(string blobName); | ||||||
|         Task<BlobFileAdapter?> DeleteBlobAsync(string fileName); |         Task<BlobFileAdapter?> DeleteBlobAsync(string fileName); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ | |||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" /> |     <PackageReference Include="Blueprint.Storage" Version="0.0.1" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -27,9 +27,9 @@ namespace Core.Blueprint.DAL.Storage.Service | |||||||
|             return await blobStorageProvider.ListBlobsAsync(prefix); |             return await blobStorageProvider.ListBlobsAsync(prefix); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public async ValueTask<BlobDownloadUriAdapter> DownloadBlobAsync(string blobName) |         public BlobDownloadUriAdapter DownloadBlobAsync(string blobName) | ||||||
|         { |         { | ||||||
|             var result = await blobStorageProvider.GenerateBlobDownloadUri(blobName); |             var result = blobStorageProvider.GenerateBlobDownloadUri(blobName); | ||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user