diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceAppService.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceAppService.cs index 11c66cf2..3f55c48a 100644 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceAppService.cs +++ b/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceAppService.cs @@ -32,11 +32,11 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp { try { - return await _compiler.CompileAndValidateAsync(request.Code, CurrentTenant.Id); + return await _compiler.CompileAndValidateAsync(request.Code); } catch (Exception ex) { - Logger.LogError(ex, "Failed to test compile dynamic service. Tenant: {TenantId}", CurrentTenant.Id); + Logger.LogError(ex, "Failed to test compile dynamic service"); throw; } } @@ -47,7 +47,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp try { // Önce kodu test compile et - var compileResult = await _compiler.CompileAndValidateAsync(request.Code, CurrentTenant.Id); + var compileResult = await _compiler.CompileAndValidateAsync(request.Code); if (!compileResult.Success) { return new PublishResultDto @@ -58,8 +58,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp } // Aynı isimde AppService var mı kontrol et - var existingService = await _dynamicAppServiceRepository - .FirstOrDefaultAsync(x => x.Name == request.Name && x.TenantId == CurrentTenant.Id); + var existingService = await _dynamicAppServiceRepository.FirstOrDefaultAsync(x => x.Name == request.Name); DynamicService appService; @@ -79,8 +78,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp appService = new DynamicService( GuidGenerator.Create(), request.Name, - request.Code, - CurrentTenant.Id) + request.Code) { DisplayName = request.DisplayName, Description = request.Description, @@ -97,9 +95,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp // Pasif olarak yayınlanıyorsa mevcut kaydı kaldır, assembly yükleme if (!request.IsActive) { - DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke( - CurrentTenant.Id ?? Guid.Empty, - appService.Name); + DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke(appService.Name); appService.MarkCompilationSuccess(); await _dynamicAppServiceRepository.UpdateAsync(appService); @@ -113,8 +109,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp }; } - var loadResult = await _compiler.CompileAndRegisterForTenantAsync( - CurrentTenant.Id ?? Guid.Empty, + var loadResult = await _compiler.CompileAndRegisterAsync( request.Code, assemblyName); @@ -152,8 +147,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp } catch (Exception ex) { - Logger.LogError(ex, "Failed to publish dynamic service. Name: {Name}, Tenant: {TenantId}", - request.Name, CurrentTenant.Id); + Logger.LogError(ex, "Failed to publish dynamic service. Name: {Name}", request.Name); return new PublishResultDto { @@ -166,11 +160,8 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp [Authorize(AppCodes.DeveloperKits.DynamicServices.DynamicService)] public virtual async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - Logger.LogDebug("AppService listesi istendi. Tenant: {TenantId}", CurrentTenant.Id); - var queryable = await _dynamicAppServiceRepository.GetQueryableAsync(); - // Tenant filtresi otomatik uygulanır (IMultiTenant) var query = queryable.WhereIf(!string.IsNullOrEmpty(input.Sorting), x => x.CreationTime.ToString().Contains(input.Sorting ?? "")); @@ -200,9 +191,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp var appService = await _dynamicAppServiceRepository.GetAsync(id); // Runtime'dan assembly ve Swagger endpoint'ini kaldır - DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke( - CurrentTenant.Id ?? Guid.Empty, - appService.Name); + DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke(appService.Name); await _dynamicAppServiceRepository.DeleteAsync(id); } @@ -217,16 +206,13 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp if (!isActive) { // Pasif yapılınca Swagger/MVC'den endpoint'i kaldır - DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke( - CurrentTenant.Id ?? Guid.Empty, - appService.Name); + DynamicServiceCompiler.NotifyAssemblyUnregistration?.Invoke(appService.Name); } else if (appService.CompilationStatus == CompilationStatus.Success) { // Aktif yapılınca yeniden derle ve yayınla var assemblyName = $"{appService.Name}_{appService.Version}"; - var result = await _compiler.CompileAndRegisterForTenantAsync( - CurrentTenant.Id ?? Guid.Empty, + var result = await _compiler.CompileAndRegisterAsync( appService.Code, assemblyName); @@ -255,8 +241,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp { // Service.Name üzerinden assembly adı oluştur var assemblyName = $"{service.Name}_{service.Version}"; - var result = await _compiler.CompileAndRegisterForTenantAsync( - CurrentTenant.Id ?? Guid.Empty, + var result = await _compiler.CompileAndRegisterAsync( service.Code, assemblyName); @@ -288,8 +273,7 @@ public class DynamicAppServiceAppService : PlatformAppService, IDynamicServiceAp var appService = await _dynamicAppServiceRepository.GetAsync(id); var assemblyName = $"{appService.Name}_{appService.Version + 1}"; - var result = await _compiler.CompileAndRegisterForTenantAsync( - CurrentTenant.Id ?? Guid.Empty, + var result = await _compiler.CompileAndRegisterAsync( appService.Code, assemblyName); diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceCompiler.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceCompiler.cs index a01cf277..2c991593 100644 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceCompiler.cs +++ b/api/src/Sozsoft.Platform.Application/DeveloperKit/DynamicServiceCompiler.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -22,23 +21,24 @@ public class DynamicServiceCompiler : ITransientDependency { private readonly ILogger _logger; - // Tenant bazlı yüklenmiş assembly'leri takip etmek için - private static readonly ConcurrentDictionary> _tenantAssemblies = new(); + // Yüklenmiş dinamik assembly'leri takip etmek için + private static readonly List _loadedAssemblies = new(); + private static readonly object _loadedAssembliesLock = new(); // Assembly kaydı için delegate - public static Action? NotifyAssemblyRegistration { get; set; } + public static Action? NotifyAssemblyRegistration { get; set; } // Assembly silinme bildirimi için delegate - public static Action? NotifyAssemblyUnregistration { get; set; } + public static Action? NotifyAssemblyUnregistration { get; set; } /// - /// Belirtilen tenant ve assembly adı prefix'ine ait assembly'leri tenant cache'inden kaldırır. + /// Belirtilen assembly adı prefix'ine ait assembly'leri cache'ten kaldırır. /// - public static void UnregisterTenantAssemblyByPrefix(Guid tenantId, string assemblyNamePrefix) + public static void UnregisterAssemblyByPrefix(string assemblyNamePrefix) { - if (_tenantAssemblies.TryGetValue(tenantId, out var assemblies)) + lock (_loadedAssembliesLock) { - assemblies.RemoveAll(a => a.GetName().Name?.StartsWith(assemblyNamePrefix) == true); + _loadedAssemblies.RemoveAll(a => a.GetName().Name?.StartsWith(assemblyNamePrefix) == true); } } @@ -81,7 +81,7 @@ public class DynamicServiceCompiler : ITransientDependency /// /// Kodu derler ve validate eder, ancak assembly yüklemez /// - public async Task CompileAndValidateAsync(string code, Guid? tenantId = null) + public async Task CompileAndValidateAsync(string code) { var stopwatch = Stopwatch.StartNew(); @@ -160,14 +160,14 @@ public class DynamicServiceCompiler : ITransientDependency } /// - /// Kodu derler ve belirtilen tenant için assembly yükler + /// Kodu derler ve assembly'yi yükler /// - public async Task CompileAndRegisterForTenantAsync(Guid tenantId, string code, string assemblyName) + public async Task CompileAndRegisterAsync(string code, string assemblyName) { try { // Önce validate et - var validateResult = await CompileAndValidateAsync(code, tenantId); + var validateResult = await CompileAndValidateAsync(code); if (!validateResult.Success) { return validateResult; @@ -186,21 +186,17 @@ public class DynamicServiceCompiler : ITransientDependency ms.Seek(0, SeekOrigin.Begin); - // Tenant'a özel assembly load context - var contextName = $"Tenant_{tenantId}_Context"; - var loadContext = new AssemblyLoadContext(contextName, isCollectible: true); + // Her dinamik assembly kendi collectible context'inde yüklenir + var loadContext = new AssemblyLoadContext($"Dynamic_{assemblyName}_Context", isCollectible: true); var assembly = loadContext.LoadFromStream(ms); - var appServiceTypes = assembly.GetTypes() - .Where(t => IsApplicationServiceType(t)) - .ToList(); + lock (_loadedAssembliesLock) + { + _loadedAssemblies.Add(assembly); + } - _tenantAssemblies.AddOrUpdate(tenantId, - new List { assembly }, - (key, existing) => { existing.Add(assembly); return existing; }); - - NotifyAssemblyRegistration?.Invoke(tenantId, assembly, assemblyName); + NotifyAssemblyRegistration?.Invoke(assembly, assemblyName); return new CompileResultDto { @@ -211,7 +207,7 @@ public class DynamicServiceCompiler : ITransientDependency } catch (Exception ex) { - _logger.LogError(ex, "Failed to load assembly. Tenant: {TenantId}", tenantId); + _logger.LogError(ex, "Failed to load assembly: {Assembly}", assemblyName); return new CompileResultDto { diff --git a/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Saas.cs b/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Saas.cs index 5ccee3c8..0350db2f 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Saas.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Saas.cs @@ -6862,7 +6862,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency Name = listFormName, Title = listFormName, DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = true, + IsTenant = false, IsBranch = false, IsOrganizationUnit = false, Description = $"{listFormName}.Description", diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CrudEndpoint.cs similarity index 76% rename from api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs rename to api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CrudEndpoint.cs index 54c7d20c..44a056fd 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CrudEndpoint.cs @@ -1,13 +1,10 @@ using System; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities; -public class CrudEndpoint : FullAuditedEntity, IMultiTenant +public class CrudEndpoint : FullAuditedEntity { - public virtual Guid? TenantId { get; protected set; } - public string EntityName { get; set; } = string.Empty; public string Method { get; set; } = string.Empty; public string Path { get; set; } = string.Empty; diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomComponent.cs b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomComponent.cs similarity index 89% rename from api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomComponent.cs rename to api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomComponent.cs index e91b1ae3..69cacf79 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomComponent.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomComponent.cs @@ -1,13 +1,10 @@ using System; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities; -public class CustomComponent : FullAuditedEntity, IMultiTenant +public class CustomComponent : FullAuditedEntity { - public virtual Guid? TenantId { get; protected set; } - public string Name { get; set; } = string.Empty; public string RoutePath { get; set; } = string.Empty; public string Code { get; set; } = string.Empty; diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEndpoint.cs b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomEndpoint.cs similarity index 93% rename from api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEndpoint.cs rename to api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomEndpoint.cs index 01f2d316..2da71003 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEndpoint.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/CustomEndpoint.cs @@ -3,14 +3,11 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities; -public class CustomEndpoint : FullAuditedEntity, IMultiTenant +public class CustomEndpoint : FullAuditedEntity { - public virtual Guid? TenantId { get; protected set; } - public string Name { get; set; } public string Description { get; set; } public string Url { get; set; } // GET, POST diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/DynamicService.cs b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/DynamicService.cs similarity index 92% rename from api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/DynamicService.cs rename to api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/DynamicService.cs index 00dcfa39..074e8edc 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/DynamicService.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Host/DeveloperKit/DynamicService.cs @@ -2,20 +2,14 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities; /// /// Tenant bazında dinamik olarak tanımlanmış AppService'lerin kod ve meta verilerini saklar /// -public class DynamicService : FullAuditedEntity, IMultiTenant +public class DynamicService : FullAuditedEntity { - /// - /// Tenant ID - IMultiTenant implementasyonu - /// - public Guid? TenantId { get; set; } - /// /// AppService'in benzersiz adı (örn: "DynamicCustomerService") /// @@ -92,12 +86,10 @@ public class DynamicService : FullAuditedEntity, IMultiTenant public DynamicService( Guid id, string name, - string code, - Guid? tenantId = null) : base(id) + string code) : base(id) { Name = Check.NotNullOrWhiteSpace(name, nameof(name), maxLength: 256); Code = Check.NotNullOrWhiteSpace(code, nameof(code)); - TenantId = tenantId; IsActive = true; CompilationStatus = CompilationStatus.Pending; Version = 1; diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index 312e970b..2a0cc77b 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -646,7 +646,7 @@ public class PlatformDbContext : b.Property(x => x.OperationType).IsRequired().HasMaxLength(64); b.Property(x => x.CsharpCode).IsRequired(); - b.HasIndex(x => new { x.TenantId, x.EntityName, x.Method, x.Path }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.EntityName, x.Method, x.Path }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -663,7 +663,7 @@ public class PlatformDbContext : b.Property(a => a.ParametersJson).HasColumnType("nvarchar(max)"); b.Property(a => a.PermissionsJson).HasColumnType("nvarchar(max)"); - b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -682,8 +682,8 @@ public class PlatformDbContext : // Data sekmesindeki endpoint listesi; adet ve url uzunlugu onceden bilinemez. b.Property(x => x.DataSources).HasColumnType("nvarchar(max)"); - b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); - b.HasIndex(x => new { x.TenantId, x.RoutePath }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.RoutePath }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1198,7 +1198,7 @@ public class PlatformDbContext : b.Property(x => x.PrimaryEntityType).HasMaxLength(256); b.Property(x => x.ControllerName).HasMaxLength(256); - b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.Designer.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.Designer.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.Designer.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.Designer.cs index c122b80b..242e6b9e 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.Designer.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Sozsoft.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20260831095952_Initial")] + [Migration("20260901075908_Initial")] partial class Initial { /// @@ -1825,13 +1825,9 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.HasKey("Id"); - b.HasIndex("TenantId", "EntityName", "Method", "Path") + b.HasIndex("EntityName", "Method", "Path") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -1970,17 +1966,13 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(512) .HasColumnType("nvarchar(512)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); - b.HasIndex("TenantId", "RoutePath") + b.HasIndex("RoutePath") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -2051,10 +2043,6 @@ namespace Sozsoft.Platform.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.Property("Url") .IsRequired() .HasMaxLength(256) @@ -2062,7 +2050,7 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -2601,10 +2589,6 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.Property("Version") .ValueGeneratedOnAdd() .HasColumnType("int") @@ -2612,7 +2596,7 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.cs index 224000d5..a822f367 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260831095952_Initial.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260901075908_Initial.cs @@ -1130,7 +1130,6 @@ namespace Sozsoft.Platform.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), EntityName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), Method = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: false), Path = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), @@ -1178,7 +1177,6 @@ namespace Sozsoft.Platform.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), RoutePath = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: false), Code = table.Column(type: "nvarchar(max)", nullable: false), @@ -1205,7 +1203,6 @@ namespace Sozsoft.Platform.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), Description = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), @@ -1339,7 +1336,6 @@ namespace Sozsoft.Platform.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), DisplayName = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), Description = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: true), @@ -4113,9 +4109,9 @@ namespace Sozsoft.Platform.Migrations filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_CrudEndpoint_TenantId_EntityName_Method_Path", + name: "IX_Sas_H_CrudEndpoint_EntityName_Method_Path", table: "Sas_H_CrudEndpoint", - columns: new[] { "TenantId", "EntityName", "Method", "Path" }, + columns: new[] { "EntityName", "Method", "Path" }, unique: true, filter: "[IsDeleted] = 0"); @@ -4127,23 +4123,23 @@ namespace Sozsoft.Platform.Migrations filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_CustomComponent_TenantId_Name", + name: "IX_Sas_H_CustomComponent_Name", table: "Sas_H_CustomComponent", - columns: new[] { "TenantId", "Name" }, + column: "Name", unique: true, filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_CustomComponent_TenantId_RoutePath", + name: "IX_Sas_H_CustomComponent_RoutePath", table: "Sas_H_CustomComponent", - columns: new[] { "TenantId", "RoutePath" }, + column: "RoutePath", unique: true, filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_CustomEndpoint_TenantId_Name", + name: "IX_Sas_H_CustomEndpoint_Name", table: "Sas_H_CustomEndpoint", - columns: new[] { "TenantId", "Name" }, + column: "Name", unique: true, filter: "[IsDeleted] = 0"); @@ -4167,9 +4163,9 @@ namespace Sozsoft.Platform.Migrations filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_DynamicService_TenantId_Name", + name: "IX_Sas_H_DynamicService_Name", table: "Sas_H_DynamicService", - columns: new[] { "TenantId", "Name" }, + column: "Name", unique: true, filter: "[IsDeleted] = 0"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index f1402162..edcefc7d 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -1822,13 +1822,9 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.HasKey("Id"); - b.HasIndex("TenantId", "EntityName", "Method", "Path") + b.HasIndex("EntityName", "Method", "Path") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -1967,17 +1963,13 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(512) .HasColumnType("nvarchar(512)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); - b.HasIndex("TenantId", "RoutePath") + b.HasIndex("RoutePath") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -2048,10 +2040,6 @@ namespace Sozsoft.Platform.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.Property("Url") .IsRequired() .HasMaxLength(256) @@ -2059,7 +2047,7 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); @@ -2598,10 +2586,6 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - b.Property("Version") .ValueGeneratedOnAdd() .HasColumnType("int") @@ -2609,7 +2593,7 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .IsUnique() .HasFilter("[IsDeleted] = 0"); diff --git a/api/src/Sozsoft.Platform.HttpApi.Host/DynamicServices/DynamicAssemblyRegistrationService.cs b/api/src/Sozsoft.Platform.HttpApi.Host/DynamicServices/DynamicAssemblyRegistrationService.cs index 1af111a3..8aecff2b 100644 --- a/api/src/Sozsoft.Platform.HttpApi.Host/DynamicServices/DynamicAssemblyRegistrationService.cs +++ b/api/src/Sozsoft.Platform.HttpApi.Host/DynamicServices/DynamicAssemblyRegistrationService.cs @@ -48,13 +48,12 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD /// /// Yeni assembly kaydı istemi /// - public static void RequestAssemblyRegistration(Guid tenantId, Assembly assembly, string assemblyName) + public static void RequestAssemblyRegistration(Assembly assembly, string assemblyName) { lock (_lock) { _pendingRegistrations.Enqueue(new AssemblyRegistrationRequest { - TenantId = tenantId, Assembly = assembly, AssemblyName = assemblyName, RequestTime = DateTime.Now @@ -65,13 +64,12 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD /// /// Bir servis adına ait assembly'nin Swagger/MVC'den kaldırılması istemi. /// - public static void RequestAssemblyUnregistration(Guid tenantId, string serviceName) + public static void RequestAssemblyUnregistration(string serviceName) { lock (_lock) { _pendingUnregistrations.Enqueue(new AssemblyUnregistrationRequest { - TenantId = tenantId, ServiceName = serviceName, RequestTime = DateTime.Now }); @@ -131,10 +129,7 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD try { var assemblyName = $"{service.Name}_{service.Version}"; - await compiler.CompileAndRegisterForTenantAsync( - service.TenantId ?? Guid.Empty, - service.Code, - assemblyName); + await compiler.CompileAndRegisterAsync(service.Code, assemblyName); } catch (Exception ex) { @@ -170,8 +165,7 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD } catch (Exception ex) { - _logger.LogError(ex, "Failed to unregister assembly. Tenant: {TenantId}, Service: {Service}", - request.TenantId, request.ServiceName); + _logger.LogError(ex, "Failed to unregister assembly. Service: {Service}", request.ServiceName); } } @@ -186,8 +180,7 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD } catch (Exception ex) { - _logger.LogError(ex, "Failed to register assembly. Tenant: {TenantId}, Assembly: {Assembly}", - request.TenantId, request.AssemblyName); + _logger.LogError(ex, "Failed to register assembly: {Assembly}", request.AssemblyName); } } } @@ -219,15 +212,13 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD // DynamicServiceTypeRegistry'den kaldır DynamicServiceTypeRegistry.UnregisterByAssemblyNamePrefix(servicePrefix); - // DynamicServiceCompiler tenant assembly cache'inden kaldır - DynamicServiceCompiler.UnregisterTenantAssemblyByPrefix(request.TenantId, servicePrefix); + // DynamicServiceCompiler assembly cache'inden kaldır + DynamicServiceCompiler.UnregisterAssemblyByPrefix(servicePrefix); // MVC/Swagger'ı yenile _changeProvider.NotifyChanges(); - _logger.LogInformation( - "Assembly unregistered: {ServiceName} (Tenant: {TenantId})", - request.ServiceName, request.TenantId); + _logger.LogInformation("Assembly unregistered: {ServiceName}", request.ServiceName); } private async Task RegisterAssembly(AssemblyRegistrationRequest request) @@ -347,7 +338,6 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD private class AssemblyRegistrationRequest { - public Guid TenantId { get; set; } public Assembly Assembly { get; set; } public string AssemblyName { get; set; } public DateTime RequestTime { get; set; } @@ -355,7 +345,6 @@ public class DynamicAssemblyRegistrationService : BackgroundService, ITransientD private class AssemblyUnregistrationRequest { - public Guid TenantId { get; set; } public string ServiceName { get; set; } public DateTime RequestTime { get; set; } } diff --git a/api/src/Sozsoft.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs b/api/src/Sozsoft.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs index 222e8f11..a6af7989 100644 --- a/api/src/Sozsoft.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs +++ b/api/src/Sozsoft.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs @@ -451,16 +451,10 @@ public class PlatformHttpApiHostModule : AbpModule var env = context.GetEnvironment(); // Setup delegate for dynamic service registration - DynamicServiceCompiler.NotifyAssemblyRegistration = (tenantId, assembly, assemblyName) => - { - DynamicAssemblyRegistrationService.RequestAssemblyRegistration(tenantId, assembly, assemblyName); - }; + DynamicServiceCompiler.NotifyAssemblyRegistration = DynamicAssemblyRegistrationService.RequestAssemblyRegistration; // Setup delegate for dynamic service unregistration - DynamicServiceCompiler.NotifyAssemblyUnregistration = (tenantId, serviceName) => - { - DynamicAssemblyRegistrationService.RequestAssemblyUnregistration(tenantId, serviceName); - }; + DynamicServiceCompiler.NotifyAssemblyUnregistration = DynamicAssemblyRegistrationService.RequestAssemblyUnregistration; if (env.IsDevelopment()) {