From 2664016c9d39b394ccfcfe847f2c488f43538dc2 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 14:10:39 +0800 Subject: [PATCH 01/26] upgrade abp framework to 7.0.0 --- aspnet-core/Directory.Build.props | 10 +- aspnet-core/LINGYUN.MicroService.All.sln | 123 +- aspnet-core/LINGYUN.MicroService.Workflow.sln | 127 +- aspnet-core/common.props | 2 +- .../AuthServerDbMigratorHostedService.cs | 51 + .../AuthServerDbMigratorModule.Configure.cs | 18 + .../AuthServerDbMigratorModule.cs | 23 + .../AuthServerDbMigrationService.cs | 216 ++ .../AuthServerMigrationsDbContext.cs | 25 + .../AuthServerMigrationsDbContextFactory.cs | 29 + ....MicroService.AuthServer.DbMigrator.csproj | 53 + ...0109085530_Initial-Auth-Server.Designer.cs | 1109 ++++++++++ .../20230109085530_Initial-Auth-Server.cs | 738 +++++++ ...hServerMigrationsDbContextModelSnapshot.cs | 1106 ++++++++++ .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + .../appsettings.json | 78 + .../BackendAdminDbMigratorHostedService.cs | 51 + .../BackendAdminDbMigratorModule.Configure.cs | 18 + .../BackendAdminDbMigratorModule.cs | 27 + .../BackendAdminDbMigrationService.cs | 216 ++ .../BackendAdminMigrationsDbContext.cs | 31 + .../BackendAdminMigrationsDbContextFactory.cs | 29 + ...icroService.BackendAdmin.DbMigrator.csproj | 51 + ...09083613_Initial-Backend-Admin.Designer.cs | 524 +++++ .../20230109083613_Initial-Backend-Admin.cs | 388 ++++ ...ndAdminMigrationsDbContextModelSnapshot.cs | 521 +++++ .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + .../appsettings.json | 80 + .../DataSeeder/IWeChatResourceDataSeeder.cs | 6 + .../IdentityServerDataSeedContributor.cs | 299 +++ .../DataSeeder/WeChatResourceDataSeeder.cs | 85 + .../IdentityServerDbMigrationService.cs | 216 ++ .../IdentityServerMigrationsDbContext.cs | 25 + ...dentityServerMigrationsDbContextFactory.cs | 29 + .../IdentityServerDbMigratorHostedService.cs | 51 + ...dentityServerDbMigratorModule.Configure.cs | 18 + .../IdentityServerDbMigratorModule.cs | 27 + ...roService.IdentityServer.DbMigrator.csproj | 55 + ...090609_Initial-Identity-Server.Designer.cs | 1777 +++++++++++++++++ .../20230109090609_Initial-Identity-Server.cs | 1224 ++++++++++++ ...yServerMigrationsDbContextModelSnapshot.cs | 1774 ++++++++++++++++ .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + .../appsettings.json | 93 + ...ocalizationManagementDbMigrationService.cs | 216 ++ ...calizationManagementMigrationsDbContext.cs | 23 + ...ionManagementMigrationsDbContextFactory.cs | 29 + ...e.LocalizationManagement.DbMigrator.csproj | 55 + ...zationManagementDbMigratorHostedService.cs | 51 + ...ionManagementDbMigratorModule.Configure.cs | 18 + .../LocalizationManagementDbMigratorModule.cs | 27 + ...nitial-Localization-Management.Designer.cs | 169 ++ ...9093938_Initial-Localization-Management.cs | 116 ++ ...agementMigrationsDbContextModelSnapshot.cs | 166 ++ .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + .../appsettings.json | 79 + .../PlatformDbMigrationService.cs | 216 ++ .../PlatformMigrationsDbContext.cs | 23 + .../PlatformMigrationsDbContextFactory.cs | 29 + ...LY.MicroService.Platform.DbMigrator.csproj | 56 + ...0230110015904_Initial-Platform.Designer.cs | 772 +++++++ .../20230110015904_Initial-Platform.cs | 399 ++++ ...latformMigrationsDbContextModelSnapshot.cs | 769 +++++++ .../PlatformDbMigratorHostedService.cs | 51 + .../PlatformDbMigratorModule.Configure.cs | 18 + .../PlatformDbMigratorModule.cs | 29 + .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + .../appsettings.json | 80 + .../RealtimeMessageDbMigrationService.cs | 216 ++ .../RealtimeMessageMigrationsDbContext.cs | 23 + ...altimeMessageMigrationsDbContextFactory.cs | 29 + ...oService.RealtimeMessage.DbMigrator.csproj | 55 + ...23420_Initial-Realtime-Message.Designer.cs | 736 +++++++ ...20230110023420_Initial-Realtime-Message.cs | 491 +++++ ...MessageMigrationsDbContextModelSnapshot.cs | 733 +++++++ .../Program.cs | 40 + .../Properties/launchSettings.json | 11 + .../RealtimeMessageDbMigratorHostedService.cs | 51 + ...altimeMessageDbMigratorModule.Configure.cs | 18 + .../RealtimeMessageDbMigratorModule.cs | 27 + .../Usings.cs | 7 + .../appsettings.json | 80 + .../LINGYUN.Abp.Account.Application.csproj | 2 +- .../LINGYUN.Abp.Account.HttpApi.csproj | 2 +- .../Elasticsearch/IndexInitializer.cs | 4 +- ...bp.AuditLogging.EntityFrameworkCore.csproj | 2 +- .../Auditing/Features/AuditingFeatureNames.cs | 4 +- .../AuditingPermissionDefinitionProvider.cs | 8 +- .../Permissions/AuditingPermissionNames.cs | 5 + .../LINGYUN.Abp.Auditing.Application.csproj | 2 +- .../Abp/Auditing/Logging/LogAppService.cs | 8 +- .../LINGYUN.Abp.Auditing.HttpApi.csproj | 2 +- .../Auditing/AuditLogs/AuditLogController.cs | 6 +- .../AuditLogs/EntityChangesController.cs | 5 +- .../Abp/Auditing/Logging/LogController.cs | 5 +- .../SecurityLogs/SecurityLogController.cs | 6 +- .../LINGYUN.Abp.Authentication.QQ.csproj | 2 +- .../LINGYUN.Abp.Authentication.WeChat.csproj | 2 +- ...ngManagemenPermissionDefinitionProvider.cs | 4 +- ...NGYUN.Abp.CachingManagement.HttpApi.csproj | 2 +- .../StackExchangeRedisCacheManager.cs | 1 - .../LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj | 2 +- ...INGYUN.Abp.Aliyun.SettingManagement.csproj | 2 +- ...NGYUN.Abp.Tencent.SettingManagement.csproj | 2 +- ...INGYUN.Abp.AspNetCore.HttpOverrides.csproj | 2 +- .../LINGYUN.Abp.AspNetCore.Mvc.Client.csproj | 2 +- ...MvcCachedApplicationConfigurationClient.cs | 12 +- ...NGYUN.Abp.AspNetCore.Mvc.Validation.csproj | 2 +- ...bp.AspNetCore.SignalR.Protocol.Json.csproj | 2 +- ...YUN.Abp.AspNetCore.SignalR.JwtToken.csproj | 2 +- .../LINGYUN.Abp.Data.DbMigrator.csproj | 2 +- .../DbMigrator/DefaultDbSchemaMigrator.cs | 25 +- .../LINGYUN.Abp.EventBus.CAP.csproj | 2 +- .../AbpEmailingExceptionHandlingModule.cs | 6 +- .../AbpEmailingExceptionSubscriber.cs | 6 +- .../Localization/ExceptionHandlingResource.cs | 9 - ...ptionHandlingTemplateDefinitionProvider.cs | 4 +- .../LINGYUN.Abp.ExceptionHandling.csproj | 2 +- .../AbpExceptionHandlingModule.cs | 15 +- .../Localization/ExceptionHandlingResource.cs | 9 - .../FeaturesLimitValidationInterceptor.cs | 8 +- .../LINGYUN.Abp.IM.SignalR.csproj | 2 +- .../LINGYUN.Abp.Location.Baidu.csproj | 8 +- .../Location/Baidu/AbpBaiduLocationModule.cs | 4 +- .../LINGYUN.Abp.Location.Tencent.csproj | 8 +- .../Tencent/AbpTencentLocationModule.cs | 4 +- .../Notifications/AbpNotificationsOptions.cs | 10 +- .../NotificationGroupDefinition.cs | 8 +- .../EmailingNotificationPublishProvider.cs | 8 +- .../LINGYUN.Abp.Notifications.SignalR.csproj | 2 +- .../LINGYUN.Abp.Notifications.csproj | 2 +- .../Notifications/AbpNotificationsModule.cs | 8 - .../Newtonsoft/Json/HexLongConverter.cs | 30 - .../LINGYUN.Abp.Encryption.Console.csproj | 2 +- ....Abp.Dapr.Actors.AspNetCore.Wrapper.csproj | 2 +- .../LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj | 2 +- .../LINGYUN.Abp.Dapr.Actors.csproj | 2 +- .../LINGYUN.Abp.Dapr.Client.Wrapper.csproj | 2 +- .../LINGYUN.Abp.Dapr.Client.csproj | 2 +- .../LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj | 2 +- ...LINGYUN.Abp.DistributedLocking.Dapr.csproj | 2 +- ....DataProtection.EntityFrameworkCore.csproj | 4 +- ...NGYUN.Abp.Dynamic.Queryable.HttpApi.csproj | 2 +- .../BlobStoring/Activities/BlobActivity.cs | 9 +- .../BlobStoring/Activities/BlobExists.cs | 5 +- .../BlobStoring/Activities/DeleteBlob.cs | 5 +- .../BlobStoring/Activities/ReadBlob.cs | 5 +- .../BlobStoring/Activities/WriteBlob.cs | 12 +- .../BlobActivityBuilderExtensions.cs | 35 + .../Extensions/BlobActivityExtensions.cs | 25 + .../Extensions/WriteBlobExtensions.cs | 40 + .../Emailing/Activities/SendEmailing.cs | 4 +- .../SendEmailingBuilderExtensions.cs | 14 + .../Extensions/SendEmailingExtensions.cs | 106 + .../Activities/IM/Activities/SendMessage.cs | 12 +- .../SendMessageBuilderExtensions.cs | 14 + .../IM/Extensions/SendMessageExtensions.cs | 88 + .../Activities/SendNotification.cs | 11 +- .../SendNotificationBuilderExtensions.cs | 14 + .../Extensions/SendNotificationExtensions.cs | 74 + .../Extensions/SendSmsBuilderExtensions.cs | 14 + .../Sms/Extensions/SendSmsExtensions.cs | 57 + .../PublishWebhookBuilderExtensions.cs | 14 + .../Extensions/PublishWebhookExtensions.cs | 89 + ....Abp.Elsa.EntityFrameworkCore.MySql.csproj | 2 +- ...INGYUN.Abp.Elsa.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.Elsa.Server.csproj | 2 +- .../LINGYUN/Abp/Elsa/AbpActivity.cs | 43 + .../LINGYUN/Abp/Elsa/AbpActivityExtensions.cs | 25 + .../LINGYUN/Abp/Elsa/AbpElsaModule.cs | 25 +- .../Abp/Elsa/IMultiTenantActivitySupport.cs | 13 + .../JavaScript/ConfigureJavaScriptEngine.cs | 2 +- .../LINGYUN.Abp.Identity.Application.csproj | 2 +- ...UN.Abp.Identity.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.Identity.HttpApi.csproj | 2 +- ...ntityServerPermissionDefinitionProvider.cs | 3 +- ...GYUN.Abp.IdentityServer.Application.csproj | 2 +- .../LINGYUN.Abp.IdentityServer.Domain.csproj | 2 +- ....IdentityServer.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.IdentityServer.HttpApi.csproj | 2 +- ...LINGYUN.Abp.IdentityServer.LinkUser.csproj | 2 +- ...YUN.Abp.IdentityServer.SmsValidator.csproj | 2 +- ...YUN.Abp.AspNetCore.Mvc.Localization.csproj | 2 +- .../Mvc/Localization/ResourceAppService.cs | 20 +- .../Mvc/Localization/TextAppService.cs | 29 +- ...LINGYUN.Abp.Localization.CultureMap.csproj | 2 +- ...FileLocalizationResourceContributorBase.cs | 21 +- ...nManagementPermissionDefinitionProvider.cs | 3 +- ...N.Abp.LocalizationManagement.Domain.csproj | 1 - .../AbpLocalizationManagementDomainModule.cs | 15 +- .../LocalizationStore.cs | 52 +- .../LocalizationSynchronizer.cs | 53 - ...ationManagement.EntityFrameworkCore.csproj | 2 +- ....Abp.LocalizationManagement.HttpApi.csproj | 2 +- ...essageService.Application.Contracts.csproj | 10 +- .../Dto/UserNotificationChangeReadStateDto.cs | 17 - .../Dto/UserNotificationGetByNameDto.cs | 13 - .../Dto/UserNotificationGetByPagedDto.cs | 14 - .../IMyNotificationAppService.cs | 17 - .../Notifications/INotificationAppService.cs | 14 - .../Dto/SubscriptionsGetByNameDto.cs | 14 - .../Dto/SubscriptionsGetByPagedDto.cs | 8 - .../Dto/UserSubscreNotificationDto.cs | 7 - .../Dto/UserSubscriptionsResult.cs | 22 - .../IMySubscriptionAppService.cs | 39 - ...sageServiceApplicationAutoMapperProfile.cs | 17 - .../Notifications/MyNotificationAppService.cs | 77 - .../Notifications/NotificationAppService.cs | 153 -- .../Subscriptions/MySubscriptionAppService.cs | 76 - ...UN.Abp.MessageService.Domain.Shared.csproj | 9 +- .../AbpMessageServiceDomainModule.cs | 5 +- .../MessageServiceDomainAutoMapperProfile.cs | 46 - ....MessageService.EntityFrameworkCore.csproj | 2 +- ...MessageServiceEntityFrameworkCoreModule.cs | 11 +- ...ServiceDbContextModelCreatingExtensions.cs | 94 - .../EfCoreNotificationRepository.cs | 42 - .../EfCoreUserNotificationRepository.cs | 182 -- .../EfCoreUserSubscribeRepository.cs | 164 -- .../LINGYUN.Abp.MessageService.HttpApi.csproj | 2 +- .../Notifications/MyNotificationController.cs | 49 - .../Notifications/NotificationController.cs | 43 - .../Subscriptions/MySubscriptionController.cs | 53 - .../LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj | 8 +- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + ...Notifications.Application.Contracts.csproj | 20 + ...NotificationsApplicationContractsModule.cs | 14 + .../AbpNotificationsRemoteServiceConsts.cs | 9 + .../Abp}/Notifications/Dto/NotificationDto.cs | 4 +- .../Dto/NotificationGetByIdDto.cs | 2 +- .../Notifications/Dto/NotificationGroupDto.cs | 2 +- .../Dto/NotificationMarkReadStateInput.cs | 5 +- .../Notifications/Dto/NotificationSendDto.cs | 5 +- .../Dto/NotificationTemplateDto.cs | 2 +- .../Dto/SubscriptionsGetByNameDto.cs | 12 + .../Dto/SubscriptionsGetByPagedDto.cs | 7 + .../Dto/UserNotificationChangeReadStateDto.cs | 15 + .../Notifications/Dto/UserNotificationDto.cs | 5 +- .../Dto/UserNotificationGetByNameDto.cs | 12 + .../Dto/UserNotificationGetByPagedDto.cs | 12 + .../Dto/UserSubscreNotificationDto.cs | 6 + .../Dto/UserSubscriptionsResult.cs | 21 + .../IMyNotificationAppService.cs | 15 + .../IMySubscriptionAppService.cs | 38 + .../Notifications/INotificationAppService.cs | 13 + .../Permissions/NotificationsPermissions.cs | 14 + ...ificationsPermissionsDefinitionProvider.cs | 22 + .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + ...NGYUN.Abp.Notifications.Application.csproj | 20 + ...tificationsApplicationAutoMapperProfile.cs | 26 + .../AbpNotificationsApplicationModule.cs | 20 + .../AbpNotificationsApplicationServiceBase.cs | 14 + .../Notifications/MyNotificationAppService.cs | 75 + .../Notifications/MySubscriptionAppService.cs | 74 + .../Notifications/NotificationAppService.cs | 151 ++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + ...YUN.Abp.Notifications.Domain.Shared.csproj | 24 + .../AbpNotificationsDomainSharedModule.cs | 28 + .../Localization/DomainShared/en.json | 6 + .../Localization/DomainShared/zh-Hans.json | 6 + .../Abp}/Notifications/NotificationConsts.cs | 2 +- ...NotificationDefinitionGroupRecordConsts.cs | 2 +- .../NotificationDefinitionRecordConsts.cs | 2 +- .../NotificationTemplateConsts.cs | 2 +- .../Notifications/NotificationsErrorCodes.cs | 35 + .../Abp/Notifications}/SubscribeConsts.cs | 2 +- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + .../LINGYUN.Abp.Notifications.Domain.csproj | 25 + .../Abp/Notifications/AbpNotificationNames.cs | 7 + .../AbpNotificationsDbProperties.cs | 11 + ...AbpNotificationsDomainAutoMapperProfile.cs | 53 + .../AbpNotificationsDomainModule.cs | 163 ++ .../AbpNotificationsManagementOptions.cs | 2 +- .../DynamicNotificationDefinitionCache.cs | 8 +- .../DynamicNotificationDefinitionStore.cs | 5 +- .../IDynamicNotificationDefinitionCache.cs | 5 +- ...ficationDefinitionGroupRecordRepository.cs | 2 +- ...INotificationDefinitionRecordRepository.cs | 2 +- .../INotificationDefinitionSerializer.cs | 18 + .../Notifications/INotificationRepository.cs | 2 +- .../Notifications/IStaticNotificationSaver.cs | 7 + .../IUserNotificationRepository.cs | 5 +- .../IUserSubscribeRepository.cs | 2 +- .../Abp}/Notifications/Notification.cs | 5 +- .../NotificationDefinitionGroupRecord.cs | 45 +- .../NotificationDefinitionGroupsCacheItem.cs | 2 +- .../NotificationDefinitionRecord.cs | 68 +- .../NotificationDefinitionSerializer.cs | 101 + .../NotificationDefinitionsCacheItem.cs | 5 +- .../Abp}/Notifications/NotificationStore.cs | 6 +- .../NotificationTypeConverter.cs | 4 +- .../NotificationsManagementOptions.cs | 18 + .../Notifications/StaticNotificationSaver.cs | 296 +++ .../LINGYUN/Abp/Notifications}/Subscribe.cs | 2 +- .../Abp}/Notifications/UserNotification.cs | 5 +- .../Notifications/UserNotificationInfo.cs | 5 +- .../Abp/Notifications}/UserSubscribe.cs | 2 +- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + ...p.Notifications.EntityFrameworkCore.csproj | 19 + ...pNotificationsEntityFrameworkCoreModule.cs | 36 + ...cationsModelBuilderConfigurationOptions.cs | 18 + ...ficationDefinitionGroupRecordRepository.cs | 9 +- ...eNotificationDefinitionRecordRepository.cs | 9 +- .../EfCoreNotificationRepository.cs | 40 + .../EfCoreUserNotificationRepository.cs | 179 ++ .../EfCoreUserSubscribeRepository.cs | 162 ++ .../INotificationsDbContext.cs | 9 + .../NotificationsDbContext.cs | 25 + ...cationsDbContextModelCreatingExtensions.cs | 112 ++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + .../LINGYUN.Abp.Notifications.HttpApi.csproj | 19 + .../AbpNotificationsHttpApiModule.cs | 28 + .../Notifications/MyNotificationController.cs | 52 + .../Notifications/MySubscriptionController.cs | 56 + .../Notifications/NotificationController.cs | 44 + .../LINGYUN.Abp.OpenApi.Authorization.csproj | 2 +- .../LINGYUN.Abp.OpenApi.csproj | 6 +- ...pOpenIddictPermissionDefinitionProvider.cs | 3 +- .../LINGYUN.Abp.OpenIddict.Dapr.Client.csproj | 2 +- .../LINGYUN.Abp.OpenIddict.HttpApi.csproj | 2 +- .../LINGYUN.Abp.OpenIddict.LinkUser.csproj | 2 +- .../Controllers/TokenController.LinkUser.cs | 2 +- .../LINGYUN.Abp.OpenIddict.Sms.csproj | 2 +- .../LINGYUN.Abp.OpenIddict.WeChat.csproj | 2 +- ...NGYUN.Abp.OssManagement.Application.csproj | 2 +- ...YUN.Abp.OssManagement.Domain.Shared.csproj | 6 +- ...INGYUN.Abp.OssManagement.FileSystem.csproj | 2 +- .../LINGYUN.Abp.OssManagement.HttpApi.csproj | 2 +- ...Abp.OssManagement.SettingManagement.csproj | 2 +- ...GYUN.Platform.Application.Contracts.csproj | 6 +- .../PlatformApplicationContractModule.cs | 10 - .../LINGYUN.Platform.Domain.Shared.csproj | 6 +- .../LINGYUN.Platform.Domain.csproj | 1 + ...INGYUN.Platform.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Platform.HttpApi.csproj | 2 +- ...LINGYUN.Platform.Theme.VueVbenAdmin.csproj | 2 +- .../PushPlusNotificationPublishProvider.cs | 8 +- ...GYUN.Abp.PushPlus.SettingManagement.csproj | 2 +- .../LINGYUN.Abp.PushPlus.csproj | 2 +- .../LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs | 49 +- .../LINGYUN.Abp.Saas.Application.csproj | 2 +- ...INGYUN.Abp.Saas.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.Saas.HttpApi.csproj | 2 +- ...ingManagement.Application.Contracts.csproj | 6 +- ...NGYUN.Abp.SettingManagement.HttpApi.csproj | 2 +- ...p.BackgroundTasks.ExceptionHandling.csproj | 2 +- .../JobExecutedFailedProvider.cs | 9 +- .../LINGYUN.Abp.BackgroundTasks.Jobs.csproj | 2 +- .../Jobs/HttpRequestJobBase.cs | 8 +- .../Abp/BackgroundTasks/Jobs/SendEmailJob.cs | 9 +- .../Abp/BackgroundTasks/Jobs/SendSmsJob.cs | 7 +- .../Jobs/ServiceInvocationJob.cs | 8 +- .../AbpBackgroundTasksModule.cs | 2 + .../BackgroundTasks/BackgroundJobAdapter.cs | 8 +- .../BackgroundTasks/BackgroundJobManager.cs | 7 +- ....TaskManagement.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.TaskManagement.HttpApi.csproj | 2 +- ...INGYUN.Abp.TenantManagement.HttpApi.csproj | 2 +- ....TextTemplating.EntityFrameworkCore.csproj | 2 +- .../LINGYUN.Abp.TextTemplating.HttpApi.csproj | 2 +- ...NGYUN.Abp.TuiJuhe.SettingManagement.csproj | 2 +- .../EventBus/AbpWebhooksEventBusModule.cs | 8 +- .../LINGYUN.Abp.Webhooks.csproj | 1 + .../LINGYUN/Abp/Webhooks/WebhookManager.cs | 12 +- ....Abp.WebhooksManagement.Dapr.Client.csproj | 2 +- ...hooksManagement.EntityFrameworkCore.csproj | 2 +- ...GYUN.Abp.WebhooksManagement.HttpApi.csproj | 2 +- .../LINGYUN.Abp.WeChat.MiniProgram.csproj | 6 +- .../FodyWeavers.xsd | 30 + ...LINGYUN.Abp.WeChat.Official.Senparc.csproj | 2 +- .../LINGYUN.Abp.WeChat.Official.csproj | 6 +- ...INGYUN.Abp.WeChat.SettingManagement.csproj | 8 +- .../LINGYUN.Abp.WeChat.csproj | 8 +- .../LINGYUN/Abp/WeChat/AbpWeChatModule.cs | 4 +- .../AbpWorkflowCoreLifeCycleEventModule.cs | 16 - .../PersistenceIndexInitializer.cs | 4 +- ...ore.Persistence.EntityFrameworkCore.csproj | 2 +- ....Abp.WorkflowManagement.Application.csproj | 2 +- ...kflowManagement.EntityFrameworkCore.csproj | 2 +- ...GYUN.Abp.WorkflowManagement.HttpApi.csproj | 2 +- .../WxPusherNotificationPublishProvider.cs | 8 +- ...GYUN.Abp.WxPusher.SettingManagement.csproj | 2 +- .../LINGYUN.Abp.WxPusher.csproj | 2 +- .../LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs | 18 +- .../AuthServerHttpApiHostModule.Configure.cs | 3 - ...icroService.AuthServer.HttpApi.Host.csproj | 2 +- .../LY.MicroService.AuthServer.csproj | 2 +- ...BackendAdminHttpApiHostModule.Configure.cs | 2 - .../BackendAdminMigrationsDbContext.cs | 2 + .../EventBus/Handlers/TenantSynchronizer.cs | 2 +- ...roService.BackendAdmin.HttpApi.Host.csproj | 3 +- ...Upgrade-Abp-Framework-To-7.0.0.Designer.cs | 524 +++++ ...06023648_Upgrade-Abp-Framework-To-7.0.0.cs | 161 ++ ...minHostMigrationsDbContextModelSnapshot.cs | 172 +- .../appsettings.Development.json | 2 +- ...LocalizationManagement.HttpApi.Host.csproj | 2 +- ...onManagementHttpApiHostModule.Configure.cs | 2 - ...ice.PlatformManagement.HttpApi.Host.csproj | 2 +- ...rmManagementHttpApiHostModule.Configure.cs | 2 - ...ervice.RealtimeMessage.HttpApi.Host.csproj | 2 +- ...ltimeMessageHttpApiHostModule.Configure.cs | 2 - ...Service.TaskManagement.HttpApi.Host.csproj | 2 +- ...skManagementHttpApiHostModule.Configure.cs | 2 - ...ice.WebhooksManagement.HttpApi.Host.csproj | 2 +- ...ice.WorkflowManagement.HttpApi.Host.csproj | 2 +- ...owManagementHttpApiHostModule.Configure.cs | 4 - ...entityServerHttpApiHostModule.Configure.cs | 2 - ...Service.identityServer.HttpApi.Host.csproj | 2 +- .../LY.MicroService.IdentityServer.csproj | 2 +- .../LINGYUN.Abp.Aliyun.Tests.csproj | 2 +- .../LINGYUN.Abp.AspNetCore.Mvc.Tests.csproj | 2 +- .../LINGYUN.Abp.AspNetCore.Tests.csproj | 2 +- ...bp.AuditLogging.Elasticsearch.Tests.csproj | 2 +- ...INGYUN.Abp.BlobStoring.Aliyun.Tests.csproj | 2 +- .../LINGYUN.Abp.Dapr.Actors.Tests.csproj | 2 +- ...INGYUN.Abp.Dapr.AspNetCore.TestHost.csproj | 2 +- .../LINGYUN.Abp.Dapr.Client.Tests.csproj | 2 +- .../LINGYUN.Abp.Dapr.Tests.csproj | 2 +- .../LINGYUN.Abp.DataProtection.Tests.csproj | 2 +- ...Queryable.EntityFrameworkCore.Tests.csproj | 2 +- ...NGYUN.Abp.EntityFrameworkCore.Tests.csproj | 2 +- ...bp.ExceptionHandling.Emailing.Tests.csproj | 2 +- ...eatures.LimitValidation.Redis.Tests.csproj | 2 +- ....Abp.Features.LimitValidation.Tests.csproj | 2 +- .../LINGYUN.Abp.IdGenerator.Tests.csproj | 2 +- .../LINGYUN.Abp.Localization.Xml.Tests.csproj | 2 +- .../LINGYUN.Abp.Location.Baidu.Tests.csproj | 2 +- .../LINGYUN.Abp.Location.Tencent.Tests.csproj | 2 +- ...YUN.Abp.MessageService.Domain.Tests.csproj | 2 +- ...geService.EntityFrameworkCore.Tests.csproj | 2 +- ...LINGYUN.Abp.Notifications.Sms.Tests.csproj | 2 +- .../LINGYUN.Abp.Notifications.Tests.csproj | 2 +- ...YUN.Abp.Notifications.TuiJuhe.Tests.csproj | 2 +- ...ifications.WeChat.MiniProgram.Tests.csproj | 2 +- ...UN.Abp.Notifications.WxPusher.Tests.csproj | 2 +- .../LINGYUN.Abp.OpenApi.Tests.csproj | 2 +- .../LINGYUN.Abp.PushPlus.Tests.csproj | 2 +- .../LINGYUN.Abp.Rules.NRules.Tests.csproj | 2 +- ...LINGYUN.Abp.Rules.RulesEngine.Tests.csproj | 2 +- .../LINGYUN.Abp.Sms.Aliyun.Tests.csproj | 2 +- .../LINGYUN.Abp.TestsBase.csproj | 2 +- .../Abp/Tests/Features/FakeFeatureStore.cs | 8 +- .../LINGYUN.Abp.TuiJuhe.Tests.csproj | 2 +- .../LINGYUN.Abp.WorkflowCore.Tests.csproj | 2 +- .../LINGYUN.Abp.Wrapper.Tests.csproj | 2 +- .../LINGYUN.Abp.WxPusher.Tests.csproj | 2 +- ...INGYUN.Linq.Dynamic.Queryable.Tests.csproj | 2 +- .../LINGYUN.Platform.Domain.Tests.csproj | 2 +- ....Platform.EntityFrameworkCore.Tests.csproj | 2 +- build/modules.dependencies.json | 10 +- common.props | 2 +- ...UN.MicroService.Internal.ApiGateway.csproj | 2 +- .../LY.MicroService.ApiGateway.csproj | 2 +- 467 files changed, 22023 insertions(+), 2005 deletions(-) create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/AuthServerMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IWeChatResourceDataSeeder.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IdentityServerDataSeedContributor.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/WeChatResourceDataSeeder.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/LY.MicroService.IdentityServer.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/PlatformMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Localization/ExceptionHandlingResource.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/Localization/ExceptionHandlingResource.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Notifications/Newtonsoft/Json/HexLongConverter.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/WriteBlobExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookBuilderExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivity.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivityExtensions.cs create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/IMultiTenantActivitySupport.cs delete mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationSynchronizer.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationChangeReadStateDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByNameDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/IMyNotificationAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByNameDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByPagedDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscreNotificationDto.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscriptionsResult.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/IMySubscriptionAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionAppService.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/MyNotificationController.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs delete mode 100644 aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionController.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN.Abp.Notifications.Application.Contracts.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsApplicationContractsModule.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsRemoteServiceConsts.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationDto.cs (89%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationGetByIdDto.cs (82%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationGroupDto.cs (84%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationMarkReadStateInput.cs (68%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationSendDto.cs (90%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/NotificationTemplateDto.cs (78%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByNameDto.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByPagedDto.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationChangeReadStateDto.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp}/Notifications/Dto/UserNotificationDto.cs (77%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByNameDto.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByPagedDto.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscreNotificationDto.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscriptionsResult.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMyNotificationAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMySubscriptionAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/INotificationAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissions.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissionsDefinitionProvider.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN.Abp.Notifications.Application.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationAutoMapperProfile.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationModule.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationServiceBase.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MyNotificationAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MySubscriptionAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/NotificationAppService.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN.Abp.Notifications.Domain.Shared.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/AbpNotificationsDomainSharedModule.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp}/Notifications/NotificationConsts.cs (82%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp}/Notifications/NotificationDefinitionGroupRecordConsts.cs (85%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp}/Notifications/NotificationDefinitionRecordConsts.cs (86%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp}/Notifications/NotificationTemplateConsts.cs (83%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Subscriptions => notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications}/SubscribeConsts.cs (74%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationNames.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDbProperties.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainAutoMapperProfile.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/AbpNotificationsManagementOptions.cs (77%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/DynamicNotificationDefinitionCache.cs (95%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/DynamicNotificationDefinitionStore.cs (91%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/IDynamicNotificationDefinitionCache.cs (68%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/INotificationDefinitionGroupRecordRepository.cs (75%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/INotificationDefinitionRecordRepository.cs (74%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionSerializer.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/INotificationRepository.cs (90%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IStaticNotificationSaver.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/IUserNotificationRepository.cs (91%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications}/IUserSubscribeRepository.cs (97%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/Notification.cs (92%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/NotificationDefinitionGroupRecord.cs (72%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/NotificationDefinitionGroupsCacheItem.cs (92%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/NotificationDefinitionRecord.cs (74%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/NotificationDefinitionsCacheItem.cs (92%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/NotificationStore.cs (96%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications}/NotificationTypeConverter.cs (89%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/StaticNotificationSaver.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications}/Subscribe.cs (92%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/UserNotification.cs (89%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp}/Notifications/UserNotificationInfo.cs (82%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions => notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications}/UserSubscribe.cs (90%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsModelBuilderConfigurationOptions.cs rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications => notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore}/EfCoreNotificationDefinitionGroupRecordRepository.cs (55%) rename aspnet-core/modules/{message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications => notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore}/EfCoreNotificationDefinitionRecordRepository.cs (55%) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationRepository.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xml create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xsd create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN.Abp.Notifications.HttpApi.csproj create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MyNotificationController.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MySubscriptionController.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/NotificationController.cs create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xsd create mode 100644 aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.cs diff --git a/aspnet-core/Directory.Build.props b/aspnet-core/Directory.Build.props index eb08075eb..6f785d6ed 100644 --- a/aspnet-core/Directory.Build.props +++ b/aspnet-core/Directory.Build.props @@ -1,11 +1,11 @@  - 6.0.2 - 6.0.2 + 7.0.0 + 7.0.0 1.9.0 1.0.2 7.0.0 - 2.9.0 + 2.10.0-rc2 1.5.10 2.13.0 3.0.434 @@ -13,6 +13,7 @@ 2.0.3 1.7.29 7.15.1 + 13.0.1 1.0.0-rc8 1.3.1 1.0.0-rc8 @@ -32,7 +33,8 @@ 8.4.1 5.0.0 6.1.5 - 6.0.* + 7.2.3 + 7.0.* 2.4.1 3.0.2 4.2.1 diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 6b5c73b1e..834a0c4bb 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -232,8 +232,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xm EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xml.Tests", "tests\LINGYUN.Abp.Localization.Xml.Tests\LINGYUN.Abp.Localization.Xml.Tests.csproj", "{A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Dynamic", "modules\common\LINGYUN.Abp.Localization.Dynamic\LINGYUN.Abp.Localization.Dynamic.csproj", "{4A9043FD-24A3-4A4A-956B-9CB71876F415}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "localization-management", "localization-management", "{D3BAA44E-8395-4E8A-AA96-6B463356C537}" ProjectSection(SolutionItems) = preProject modules\lt\README.md = modules\lt\README.md @@ -505,7 +503,49 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OpenIddict.WeCh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IdGenerator.Tests", "tests\LINGYUN.Abp.IdGenerator.Tests\LINGYUN.Abp.IdGenerator.Tests.csproj", "{2BFFE9C3-E022-4B57-9E4D-0A0408424B1A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WeChat.Official.Senparc", "modules\wechat\LINGYUN.Abp.WeChat.Official.Senparc\LINGYUN.Abp.WeChat.Official.Senparc.csproj", "{CA8D7141-9520-46AC-83FD-6E034AD6EBDD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.Official.Senparc", "modules\wechat\LINGYUN.Abp.WeChat.Official.Senparc\LINGYUN.Abp.WeChat.Official.Senparc.csproj", "{CA8D7141-9520-46AC-83FD-6E034AD6EBDD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.Core", "modules\webhooks\LINGYUN.Abp.Webhooks.Core\LINGYUN.Abp.Webhooks.Core.csproj", "{42FD76A3-803A-4E07-8A90-4269204B7B87}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{C90A505F-000E-4AE4-8CCD-AB5FE5092B5C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin", "admin", "{E12DFE37-3F4D-435D-97AE-903259AE2DF4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "auth-server", "auth-server", "{D724FDCC-375A-4D61-A444-4264A00A6AC9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "identity-server", "identity-server", "{B2493730-4DDC-4DA7-BF19-CACD75450270}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "localization", "localization", "{B18CF0D3-3D01-4A64-A9C4-DC0C214BEE42}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "platform", "platform", "{F260FB5F-C6C7-4948-B638-E4D6986D07ED}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "realtime-message", "realtime-message", "{B1AC656F-8F4C-43D5-B5A0-CCF5F119EA44}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LY.MicroService.BackendAdmin.DbMigrator", "migrations\LY.MicroService.BackendAdmin.DbMigrator\LY.MicroService.BackendAdmin.DbMigrator.csproj", "{EA144C64-CE14-40DF-A876-5D302A4FC208}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.AuthServer.DbMigrator", "migrations\LY.MicroService.AuthServer.DbMigrator\LY.MicroService.AuthServer.DbMigrator.csproj", "{D25156E6-532F-4BCC-8EE0-8A3F1986E10E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.IdentityServer.DbMigrator", "migrations\LY.MicroService.IdentityServer.DbMigrator\LY.MicroService.IdentityServer.DbMigrator.csproj", "{F5CCC079-8A6C-45E2-BA9D-09B31E072A57}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.LocalizationManagement.DbMigrator", "migrations\LY.MicroService.LocalizationManagement.DbMigrator\LY.MicroService.LocalizationManagement.DbMigrator.csproj", "{869C267D-D659-4DC6-AD64-6B466611FA61}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.Platform.DbMigrator", "migrations\LY.MicroService.Platform.DbMigrator\LY.MicroService.Platform.DbMigrator.csproj", "{DB417421-B5E7-499B-A19A-C04830BFF75F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.RealtimeMessage.DbMigrator", "migrations\LY.MicroService.RealtimeMessage.DbMigrator\LY.MicroService.RealtimeMessage.DbMigrator.csproj", "{F51EFCF5-812A-4BBC-AC88-82372B3CF78D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notifications", "notifications", "{1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Domain.Shared", "modules\notifications\LINGYUN.Abp.Notifications.Domain.Shared\LINGYUN.Abp.Notifications.Domain.Shared.csproj", "{4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Domain", "modules\notifications\LINGYUN.Abp.Notifications.Domain\LINGYUN.Abp.Notifications.Domain.csproj", "{CDD4CC0F-5493-40C2-B889-3670263888D8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.EntityFrameworkCore", "modules\notifications\LINGYUN.Abp.Notifications.EntityFrameworkCore\LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj", "{F74AAE01-7B87-44CA-85ED-9A6307D51504}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Application.Contracts", "modules\notifications\LINGYUN.Abp.Notifications.Application.Contracts\LINGYUN.Abp.Notifications.Application.Contracts.csproj", "{E3F010C7-6C96-4EEA-B5FA-BF80515E195F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Application", "modules\notifications\LINGYUN.Abp.Notifications.Application\LINGYUN.Abp.Notifications.Application.csproj", "{B153F98A-7DA9-4A12-A1D7-105BE9408FA1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.HttpApi", "modules\notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj", "{EFC5C34F-81A1-4EFC-966F-50B646C54FA6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -869,10 +909,6 @@ Global {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Release|Any CPU.Build.0 = Release|Any CPU - {4A9043FD-24A3-4A4A-956B-9CB71876F415}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A9043FD-24A3-4A4A-956B-9CB71876F415}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A9043FD-24A3-4A4A-956B-9CB71876F415}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A9043FD-24A3-4A4A-956B-9CB71876F415}.Release|Any CPU.Build.0 = Release|Any CPU {5BE18D72-0D02-4854-966E-745CE5DAF77F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5BE18D72-0D02-4854-966E-745CE5DAF77F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5BE18D72-0D02-4854-966E-745CE5DAF77F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1309,6 +1345,58 @@ Global {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Release|Any CPU.Build.0 = Release|Any CPU + {42FD76A3-803A-4E07-8A90-4269204B7B87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42FD76A3-803A-4E07-8A90-4269204B7B87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42FD76A3-803A-4E07-8A90-4269204B7B87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42FD76A3-803A-4E07-8A90-4269204B7B87}.Release|Any CPU.Build.0 = Release|Any CPU + {EA144C64-CE14-40DF-A876-5D302A4FC208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA144C64-CE14-40DF-A876-5D302A4FC208}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA144C64-CE14-40DF-A876-5D302A4FC208}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA144C64-CE14-40DF-A876-5D302A4FC208}.Release|Any CPU.Build.0 = Release|Any CPU + {D25156E6-532F-4BCC-8EE0-8A3F1986E10E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D25156E6-532F-4BCC-8EE0-8A3F1986E10E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D25156E6-532F-4BCC-8EE0-8A3F1986E10E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D25156E6-532F-4BCC-8EE0-8A3F1986E10E}.Release|Any CPU.Build.0 = Release|Any CPU + {F5CCC079-8A6C-45E2-BA9D-09B31E072A57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5CCC079-8A6C-45E2-BA9D-09B31E072A57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5CCC079-8A6C-45E2-BA9D-09B31E072A57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5CCC079-8A6C-45E2-BA9D-09B31E072A57}.Release|Any CPU.Build.0 = Release|Any CPU + {869C267D-D659-4DC6-AD64-6B466611FA61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {869C267D-D659-4DC6-AD64-6B466611FA61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {869C267D-D659-4DC6-AD64-6B466611FA61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {869C267D-D659-4DC6-AD64-6B466611FA61}.Release|Any CPU.Build.0 = Release|Any CPU + {DB417421-B5E7-499B-A19A-C04830BFF75F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB417421-B5E7-499B-A19A-C04830BFF75F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB417421-B5E7-499B-A19A-C04830BFF75F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB417421-B5E7-499B-A19A-C04830BFF75F}.Release|Any CPU.Build.0 = Release|Any CPU + {F51EFCF5-812A-4BBC-AC88-82372B3CF78D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F51EFCF5-812A-4BBC-AC88-82372B3CF78D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F51EFCF5-812A-4BBC-AC88-82372B3CF78D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F51EFCF5-812A-4BBC-AC88-82372B3CF78D}.Release|Any CPU.Build.0 = Release|Any CPU + {4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}.Release|Any CPU.Build.0 = Release|Any CPU + {CDD4CC0F-5493-40C2-B889-3670263888D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDD4CC0F-5493-40C2-B889-3670263888D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDD4CC0F-5493-40C2-B889-3670263888D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDD4CC0F-5493-40C2-B889-3670263888D8}.Release|Any CPU.Build.0 = Release|Any CPU + {F74AAE01-7B87-44CA-85ED-9A6307D51504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F74AAE01-7B87-44CA-85ED-9A6307D51504}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F74AAE01-7B87-44CA-85ED-9A6307D51504}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F74AAE01-7B87-44CA-85ED-9A6307D51504}.Release|Any CPU.Build.0 = Release|Any CPU + {E3F010C7-6C96-4EEA-B5FA-BF80515E195F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3F010C7-6C96-4EEA-B5FA-BF80515E195F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3F010C7-6C96-4EEA-B5FA-BF80515E195F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3F010C7-6C96-4EEA-B5FA-BF80515E195F}.Release|Any CPU.Build.0 = Release|Any CPU + {B153F98A-7DA9-4A12-A1D7-105BE9408FA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B153F98A-7DA9-4A12-A1D7-105BE9408FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B153F98A-7DA9-4A12-A1D7-105BE9408FA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B153F98A-7DA9-4A12-A1D7-105BE9408FA1}.Release|Any CPU.Build.0 = Release|Any CPU + {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1424,7 +1512,6 @@ Global {90E88EAC-4291-4406-8D88-EFDF61B11292} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} {84868710-ECBB-4025-900A-EEB99EC49534} = {90E88EAC-4291-4406-8D88-EFDF61B11292} {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} - {4A9043FD-24A3-4A4A-956B-9CB71876F415} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {D3BAA44E-8395-4E8A-AA96-6B463356C537} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} {5BE18D72-0D02-4854-966E-745CE5DAF77F} = {D3BAA44E-8395-4E8A-AA96-6B463356C537} {73EAD4FE-B44F-44A7-904E-FFA5096D91BD} = {D3BAA44E-8395-4E8A-AA96-6B463356C537} @@ -1556,6 +1643,26 @@ Global {427382F6-3153-47A2-BBC4-88F6EA116A8F} = {83E698F6-F8CD-4604-AB80-01A203389501} {2BFFE9C3-E022-4B57-9E4D-0A0408424B1A} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {CA8D7141-9520-46AC-83FD-6E034AD6EBDD} = {DD9BE9E7-F6BF-4869-BCD2-82F5072BDA21} + {42FD76A3-803A-4E07-8A90-4269204B7B87} = {13ACF670-F109-404E-B252-2FA34A4EA061} + {E12DFE37-3F4D-435D-97AE-903259AE2DF4} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {D724FDCC-375A-4D61-A444-4264A00A6AC9} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {B2493730-4DDC-4DA7-BF19-CACD75450270} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {B18CF0D3-3D01-4A64-A9C4-DC0C214BEE42} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {F260FB5F-C6C7-4948-B638-E4D6986D07ED} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {B1AC656F-8F4C-43D5-B5A0-CCF5F119EA44} = {C90A505F-000E-4AE4-8CCD-AB5FE5092B5C} + {EA144C64-CE14-40DF-A876-5D302A4FC208} = {E12DFE37-3F4D-435D-97AE-903259AE2DF4} + {D25156E6-532F-4BCC-8EE0-8A3F1986E10E} = {D724FDCC-375A-4D61-A444-4264A00A6AC9} + {F5CCC079-8A6C-45E2-BA9D-09B31E072A57} = {B2493730-4DDC-4DA7-BF19-CACD75450270} + {869C267D-D659-4DC6-AD64-6B466611FA61} = {B18CF0D3-3D01-4A64-A9C4-DC0C214BEE42} + {DB417421-B5E7-499B-A19A-C04830BFF75F} = {F260FB5F-C6C7-4948-B638-E4D6986D07ED} + {F51EFCF5-812A-4BBC-AC88-82372B3CF78D} = {B1AC656F-8F4C-43D5-B5A0-CCF5F119EA44} + {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} + {4CF6F78C-22BE-46C4-BC9B-824E8FEEF719} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {CDD4CC0F-5493-40C2-B889-3670263888D8} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {F74AAE01-7B87-44CA-85ED-9A6307D51504} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {E3F010C7-6C96-4EEA-B5FA-BF80515E195F} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {B153F98A-7DA9-4A12-A1D7-105BE9408FA1} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {EFC5C34F-81A1-4EFC-966F-50B646C54FA6} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/LINGYUN.MicroService.Workflow.sln b/aspnet-core/LINGYUN.MicroService.Workflow.sln index 22781a14e..87889e316 100644 --- a/aspnet-core/LINGYUN.MicroService.Workflow.sln +++ b/aspnet-core/LINGYUN.MicroService.Workflow.sln @@ -3,52 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework", "framework", "{A2963E0D-D290-40B2-9B36-75F4A5922ABF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore", "modules\workflow\LINGYUN.Abp.WorkflowCore\LINGYUN.Abp.WorkflowCore.csproj", "{F7152D31-9292-43A8-A018-4137A6F1BD92}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Elasticsearch", "modules\workflow\LINGYUN.Abp.WorkflowCore.Elasticsearch\LINGYUN.Abp.WorkflowCore.Elasticsearch.csproj", "{3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.LifeCycleEvent", "modules\workflow\LINGYUN.Abp.WorkflowCore.LifeCycleEvent\LINGYUN.Abp.WorkflowCore.LifeCycleEvent.csproj", "{C82A0FD1-53F3-47A2-99A4-748998B93499}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Persistence", "modules\workflow\LINGYUN.Abp.WorkflowCore.Persistence\LINGYUN.Abp.WorkflowCore.Persistence.csproj", "{A1DBB050-CA03-40FE-A097-F3AFE32C4E6D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore", "modules\workflow\LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore\LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj", "{9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.RabbitMQ", "modules\workflow\LINGYUN.Abp.WorkflowCore.RabbitMQ\LINGYUN.Abp.WorkflowCore.RabbitMQ.csproj", "{8F904E49-E6DA-499D-8127-DB60DA6B2EE9}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-components", "workflow-components", "{15F788FB-C7D0-4EE2-B1D9-EB9F3CCB7F33}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Components", "modules\workflow\LINGYUN.Abp.WorkflowCore.Components\LINGYUN.Abp.WorkflowCore.Components.csproj", "{13D116F7-C158-48D3-A78A-6F2BFAED1CDF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.DistributedLock", "modules\workflow\LINGYUN.Abp.WorkflowCore.DistributedLock\LINGYUN.Abp.WorkflowCore.DistributedLock.csproj", "{F8C68D4C-297D-42E0-84FB-D271CD13FAD0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "management", "management", "{C4496993-41F5-4821-829E-B80A8B3BC260}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.Domain.Shared", "modules\workflow\LINGYUN.Abp.WorkflowManagement.Domain.Shared\LINGYUN.Abp.WorkflowManagement.Domain.Shared.csproj", "{30C99D6C-29CA-4E13-A009-484A34258643}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.Domain", "modules\workflow\LINGYUN.Abp.WorkflowManagement.Domain\LINGYUN.Abp.WorkflowManagement.Domain.csproj", "{5C70152E-8848-46A1-93D7-7CBF6FCAE1BA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.Application.Contracts", "modules\workflow\LINGYUN.Abp.WorkflowManagement.Application.Contracts\LINGYUN.Abp.WorkflowManagement.Application.Contracts.csproj", "{EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.Application", "modules\workflow\LINGYUN.Abp.WorkflowManagement.Application\LINGYUN.Abp.WorkflowManagement.Application.csproj", "{AD48915D-70AF-4E11-8F92-76423DCCE653}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.HttpApi", "modules\workflow\LINGYUN.Abp.WorkflowManagement.HttpApi\LINGYUN.Abp.WorkflowManagement.HttpApi.csproj", "{99BDFED5-907F-44C9-8BA0-90E1725BE211}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore", "modules\workflow\LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore\LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj", "{C4B1160A-BF25-4868-B962-342ABA4A96EF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch", "modules\workflow\LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch\LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch.csproj", "{9F9453F3-7124-4C22-91E3-0DC41A4FD8AB}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "host", "host", "{6CB521FC-AC40-49A6-B9A5-91399CAA59AB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.WorkflowManagement.HttpApi.Host", "services\LY.MicroService.WorkflowManagement.HttpApi.Host\LY.MicroService.WorkflowManagement.HttpApi.Host.csproj", "{D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-tests", "workflow-tests", "{57CB3446-B825-4C55-A24A-E15EB2CAA80D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Tests", "tests\LINGYUN.Abp.WorkflowCore.Tests\LINGYUN.Abp.WorkflowCore.Tests.csproj", "{0A21C843-4175-42F2-A95D-A75ED1DC1E05}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-core", "workflow-core", "{DFE3435C-DD59-496F-BB77-6F7D62D2EA88}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "elsa", "elsa", "{F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa", "modules\elsa\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj", "{17EA5194-BBE8-4CE1-B6F9-DF6829622F38}" @@ -87,7 +45,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks", "mod EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.EventBus", "modules\webhooks\LINGYUN.Abp.Webhooks.EventBus\LINGYUN.Abp.Webhooks.EventBus.csproj", "{B6246B7A-4095-433A-B981-5D1E43CDF712}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql", "modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj", "{4B20572A-10E7-4414-943A-974F275677B4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql", "modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj", "{4B20572A-10E7-4414-943A-974F275677B4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -95,74 +53,10 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F7152D31-9292-43A8-A018-4137A6F1BD92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7152D31-9292-43A8-A018-4137A6F1BD92}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7152D31-9292-43A8-A018-4137A6F1BD92}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7152D31-9292-43A8-A018-4137A6F1BD92}.Release|Any CPU.Build.0 = Release|Any CPU - {3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17}.Release|Any CPU.Build.0 = Release|Any CPU - {C82A0FD1-53F3-47A2-99A4-748998B93499}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C82A0FD1-53F3-47A2-99A4-748998B93499}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C82A0FD1-53F3-47A2-99A4-748998B93499}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C82A0FD1-53F3-47A2-99A4-748998B93499}.Release|Any CPU.Build.0 = Release|Any CPU - {A1DBB050-CA03-40FE-A097-F3AFE32C4E6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A1DBB050-CA03-40FE-A097-F3AFE32C4E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A1DBB050-CA03-40FE-A097-F3AFE32C4E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A1DBB050-CA03-40FE-A097-F3AFE32C4E6D}.Release|Any CPU.Build.0 = Release|Any CPU - {9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD}.Release|Any CPU.Build.0 = Release|Any CPU - {8F904E49-E6DA-499D-8127-DB60DA6B2EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F904E49-E6DA-499D-8127-DB60DA6B2EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F904E49-E6DA-499D-8127-DB60DA6B2EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F904E49-E6DA-499D-8127-DB60DA6B2EE9}.Release|Any CPU.Build.0 = Release|Any CPU - {13D116F7-C158-48D3-A78A-6F2BFAED1CDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13D116F7-C158-48D3-A78A-6F2BFAED1CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13D116F7-C158-48D3-A78A-6F2BFAED1CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13D116F7-C158-48D3-A78A-6F2BFAED1CDF}.Release|Any CPU.Build.0 = Release|Any CPU - {F8C68D4C-297D-42E0-84FB-D271CD13FAD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8C68D4C-297D-42E0-84FB-D271CD13FAD0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8C68D4C-297D-42E0-84FB-D271CD13FAD0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8C68D4C-297D-42E0-84FB-D271CD13FAD0}.Release|Any CPU.Build.0 = Release|Any CPU - {30C99D6C-29CA-4E13-A009-484A34258643}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30C99D6C-29CA-4E13-A009-484A34258643}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30C99D6C-29CA-4E13-A009-484A34258643}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30C99D6C-29CA-4E13-A009-484A34258643}.Release|Any CPU.Build.0 = Release|Any CPU - {5C70152E-8848-46A1-93D7-7CBF6FCAE1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C70152E-8848-46A1-93D7-7CBF6FCAE1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5C70152E-8848-46A1-93D7-7CBF6FCAE1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5C70152E-8848-46A1-93D7-7CBF6FCAE1BA}.Release|Any CPU.Build.0 = Release|Any CPU - {EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41}.Release|Any CPU.Build.0 = Release|Any CPU - {AD48915D-70AF-4E11-8F92-76423DCCE653}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD48915D-70AF-4E11-8F92-76423DCCE653}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD48915D-70AF-4E11-8F92-76423DCCE653}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD48915D-70AF-4E11-8F92-76423DCCE653}.Release|Any CPU.Build.0 = Release|Any CPU - {99BDFED5-907F-44C9-8BA0-90E1725BE211}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {99BDFED5-907F-44C9-8BA0-90E1725BE211}.Debug|Any CPU.Build.0 = Debug|Any CPU - {99BDFED5-907F-44C9-8BA0-90E1725BE211}.Release|Any CPU.ActiveCfg = Release|Any CPU - {99BDFED5-907F-44C9-8BA0-90E1725BE211}.Release|Any CPU.Build.0 = Release|Any CPU - {C4B1160A-BF25-4868-B962-342ABA4A96EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4B1160A-BF25-4868-B962-342ABA4A96EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4B1160A-BF25-4868-B962-342ABA4A96EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4B1160A-BF25-4868-B962-342ABA4A96EF}.Release|Any CPU.Build.0 = Release|Any CPU - {9F9453F3-7124-4C22-91E3-0DC41A4FD8AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F9453F3-7124-4C22-91E3-0DC41A4FD8AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F9453F3-7124-4C22-91E3-0DC41A4FD8AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F9453F3-7124-4C22-91E3-0DC41A4FD8AB}.Release|Any CPU.Build.0 = Release|Any CPU {D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B}.Release|Any CPU.Build.0 = Release|Any CPU - {0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Release|Any CPU.Build.0 = Release|Any CPU {17EA5194-BBE8-4CE1-B6F9-DF6829622F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {17EA5194-BBE8-4CE1-B6F9-DF6829622F38}.Debug|Any CPU.Build.0 = Debug|Any CPU {17EA5194-BBE8-4CE1-B6F9-DF6829622F38}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -240,26 +134,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {A2963E0D-D290-40B2-9B36-75F4A5922ABF} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88} - {F7152D31-9292-43A8-A018-4137A6F1BD92} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {C82A0FD1-53F3-47A2-99A4-748998B93499} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {A1DBB050-CA03-40FE-A097-F3AFE32C4E6D} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {8F904E49-E6DA-499D-8127-DB60DA6B2EE9} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {15F788FB-C7D0-4EE2-B1D9-EB9F3CCB7F33} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88} - {13D116F7-C158-48D3-A78A-6F2BFAED1CDF} = {15F788FB-C7D0-4EE2-B1D9-EB9F3CCB7F33} - {F8C68D4C-297D-42E0-84FB-D271CD13FAD0} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} - {30C99D6C-29CA-4E13-A009-484A34258643} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {5C70152E-8848-46A1-93D7-7CBF6FCAE1BA} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {EC4D6195-617C-4D6B-A6B2-8C5FE9CC4B41} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {AD48915D-70AF-4E11-8F92-76423DCCE653} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {99BDFED5-907F-44C9-8BA0-90E1725BE211} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {C4B1160A-BF25-4868-B962-342ABA4A96EF} = {C4496993-41F5-4821-829E-B80A8B3BC260} - {9F9453F3-7124-4C22-91E3-0DC41A4FD8AB} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF} {D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B} = {6CB521FC-AC40-49A6-B9A5-91399CAA59AB} - {57CB3446-B825-4C55-A24A-E15EB2CAA80D} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88} - {0A21C843-4175-42F2-A95D-A75ED1DC1E05} = {57CB3446-B825-4C55-A24A-E15EB2CAA80D} {17EA5194-BBE8-4CE1-B6F9-DF6829622F38} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {88AA0D46-597E-4969-8382-A3F8054B9409} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} diff --git a/aspnet-core/common.props b/aspnet-core/common.props index 879ddc1fc..2fb95982f 100644 --- a/aspnet-core/common.props +++ b/aspnet-core/common.props @@ -1,7 +1,7 @@ latest - 6.0.2 + 7.0.0 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorHostedService.cs new file mode 100644 index 000000000..aca4bbe15 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.AuthServer.DbMigrator; + +public class AuthServerDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public AuthServerDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.Configure.cs new file mode 100644 index 000000000..790b72a55 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.AuthServer.DbMigrator; +public partial class AuthServerDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.cs new file mode 100644 index 000000000..c431d1fbd --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/AuthServerDbMigratorModule.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Identity.EntityFrameworkCore; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; +using Volo.Abp.OpenIddict.EntityFrameworkCore; + +namespace LY.MicroService.AuthServer.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpOpenIddictEntityFrameworkCoreModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class AuthServerDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerDbMigrationService.cs new file mode 100644 index 000000000..cd37ed7f7 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; + +public class AuthServerDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public AuthServerDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new AuthServerMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContext.cs new file mode 100644 index 000000000..905d6e151 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.OpenIddict.EntityFrameworkCore; + +namespace LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("AuthServerDbMigrator")] +public class AuthServerMigrationsDbContext : AbpDbContext +{ + public AuthServerMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureOpenIddict(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs new file mode 100644 index 000000000..b02a70e6f --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; + +public class AuthServerMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public AuthServerMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new AuthServerMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj new file mode 100644 index 000000000..d41e58a72 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj @@ -0,0 +1,53 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.Designer.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.Designer.cs new file mode 100644 index 000000000..892179dfc --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.Designer.cs @@ -0,0 +1,1109 @@ +// +using System; +using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.AuthServer.DbMigrator.Migrations +{ + [DbContext(typeof(AuthServerMigrationsDbContext))] + [Migration("20230109085530_Initial-Auth-Server")] + partial class InitialAuthServer + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Regex") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("RegexDescription") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityLinkUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("SourceTenantId") + .HasColumnType("char(36)"); + + b.Property("SourceUserId") + .HasColumnType("char(36)"); + + b.Property("TargetTenantId") + .HasColumnType("char(36)"); + + b.Property("TargetUserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId") + .IsUnique(); + + b.ToTable("AbpLinkUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySecurityLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Action") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Identity") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Action"); + + b.HasIndex("TenantId", "ApplicationName"); + + b.HasIndex("TenantId", "Identity"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSecurityLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0) + .HasColumnName("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("Email"); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("EmailConfirmed"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnName("IsActive"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsExternal") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsExternal"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("LockoutEnabled"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedEmail"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedUserName"); + + b.Property("PasswordHash") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("PasswordHash"); + + b.Property("PhoneNumber") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("PhoneNumber"); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("PhoneNumberConfirmed"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SecurityStamp"); + + b.Property("Surname") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Surname"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("TwoFactorEnabled"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196) + .HasColumnType("varchar(196)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "UserId"); + + b.HasIndex("UserId", "OrganizationUnitId"); + + b.ToTable("AbpUserOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(95) + .HasColumnType("varchar(95)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AbpOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "RoleId"); + + b.HasIndex("RoleId", "OrganizationUnitId"); + + b.ToTable("AbpOrganizationUnitRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ClientSecret") + .HasColumnType("longtext"); + + b.Property("ClientUri") + .HasColumnType("longtext"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("DisplayNames") + .HasColumnType("longtext"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasColumnType("longtext"); + + b.Property("Permissions") + .HasColumnType("longtext"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("longtext"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("RedirectUris") + .HasColumnType("longtext"); + + b.Property("Requirements") + .HasColumnType("longtext"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("OpenIddictApplications", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicationId") + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("Scopes") + .HasColumnType("longtext"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("varchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Scopes.OpenIddictScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Descriptions") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("DisplayNames") + .HasColumnType("longtext"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("Resources") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("OpenIddictScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicationId") + .HasColumnType("char(36)"); + + b.Property("AuthorizationId") + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Payload") + .HasColumnType("longtext"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("RedemptionDate") + .HasColumnType("datetime(6)"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("varchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("OrganizationUnits") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany("Roles") + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + + b.HasOne("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", null) + .WithMany() + .HasForeignKey("AuthorizationId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Navigation("Claims"); + + b.Navigation("Logins"); + + b.Navigation("OrganizationUnits"); + + b.Navigation("Roles"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Navigation("Roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.cs new file mode 100644 index 000000000..a14ec5ed5 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/20230109085530_Initial-Auth-Server.cs @@ -0,0 +1,738 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.AuthServer.DbMigrator.Migrations +{ + /// + public partial class InitialAuthServer : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Required = table.Column(type: "tinyint(1)", nullable: false), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + Regex = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RegexDescription = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SourceUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SourceTenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + TargetUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TargetTenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Code = table.Column(type: "varchar(95)", maxLength: 95, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsDefault = table.Column(type: "tinyint(1)", nullable: false), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + IsPublic = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ApplicationName = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Identity = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Action = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientId = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CorrelationId = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientIpAddress = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + BrowserInfo = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Surname = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SecurityStamp = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsExternal = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "varchar(16)", maxLength: 16, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetime(6)", nullable: true), + LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "OpenIddictApplications", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ClientId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientSecret = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConsentType = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayNames = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Permissions = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PostLogoutRedirectUris = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Properties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RedirectUris = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Requirements = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientUri = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LogoUri = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "OpenIddictScopes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Descriptions = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayNames = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Properties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Resources = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new + { + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OrganizationUnitId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUn~", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LoginProvider = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ProviderKey = table.Column(type: "varchar(196)", maxLength: 196, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderDisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserOrganizationUnits", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OrganizationUnitId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUn~", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LoginProvider = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Value = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "OpenIddictAuthorizations", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ApplicationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationDate = table.Column(type: "datetime(6)", nullable: true), + Properties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Scopes = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Subject = table.Column(type: "varchar(400)", maxLength: 400, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); + table.ForeignKey( + name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", + column: x => x.ApplicationId, + principalTable: "OpenIddictApplications", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "OpenIddictTokens", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ApplicationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + AuthorizationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationDate = table.Column(type: "datetime(6)", nullable: true), + ExpirationDate = table.Column(type: "datetime(6)", nullable: true), + Payload = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Properties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RedemptionDate = table.Column(type: "datetime(6)", nullable: true), + ReferenceId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Subject = table.Column(type: "varchar(400)", maxLength: 400, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); + table.ForeignKey( + name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", + column: x => x.ApplicationId, + principalTable: "OpenIddictApplications", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", + column: x => x.AuthorizationId, + principalTable: "OpenIddictAuthorizations", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_Target~", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictApplications_ClientId", + table: "OpenIddictApplications", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", + table: "OpenIddictAuthorizations", + columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictScopes_Name", + table: "OpenIddictScopes", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", + table: "OpenIddictTokens", + columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictTokens_AuthorizationId", + table: "OpenIddictTokens", + column: "AuthorizationId"); + + migrationBuilder.CreateIndex( + name: "IX_OpenIddictTokens_ReferenceId", + table: "OpenIddictTokens", + column: "ReferenceId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + + migrationBuilder.DropTable( + name: "AbpLinkUsers"); + + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); + + migrationBuilder.DropTable( + name: "AbpRoleClaims"); + + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); + + migrationBuilder.DropTable( + name: "AbpUserClaims"); + + migrationBuilder.DropTable( + name: "AbpUserLogins"); + + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); + + migrationBuilder.DropTable( + name: "AbpUserRoles"); + + migrationBuilder.DropTable( + name: "AbpUserTokens"); + + migrationBuilder.DropTable( + name: "OpenIddictScopes"); + + migrationBuilder.DropTable( + name: "OpenIddictTokens"); + + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); + + migrationBuilder.DropTable( + name: "AbpRoles"); + + migrationBuilder.DropTable( + name: "AbpUsers"); + + migrationBuilder.DropTable( + name: "OpenIddictAuthorizations"); + + migrationBuilder.DropTable( + name: "OpenIddictApplications"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/AuthServerMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/AuthServerMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..26a918cfd --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Migrations/AuthServerMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,1106 @@ +// +using System; +using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.AuthServer.DbMigrator.Migrations +{ + [DbContext(typeof(AuthServerMigrationsDbContext))] + partial class AuthServerMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Regex") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("RegexDescription") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityLinkUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("SourceTenantId") + .HasColumnType("char(36)"); + + b.Property("SourceUserId") + .HasColumnType("char(36)"); + + b.Property("TargetTenantId") + .HasColumnType("char(36)"); + + b.Property("TargetUserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId") + .IsUnique(); + + b.ToTable("AbpLinkUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySecurityLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Action") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Identity") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Action"); + + b.HasIndex("TenantId", "ApplicationName"); + + b.HasIndex("TenantId", "Identity"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSecurityLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0) + .HasColumnName("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("Email"); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("EmailConfirmed"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnName("IsActive"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsExternal") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsExternal"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("LockoutEnabled"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedEmail"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedUserName"); + + b.Property("PasswordHash") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("PasswordHash"); + + b.Property("PhoneNumber") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("PhoneNumber"); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("PhoneNumberConfirmed"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SecurityStamp"); + + b.Property("Surname") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Surname"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("TwoFactorEnabled"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196) + .HasColumnType("varchar(196)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "UserId"); + + b.HasIndex("UserId", "OrganizationUnitId"); + + b.ToTable("AbpUserOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(95) + .HasColumnType("varchar(95)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AbpOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "RoleId"); + + b.HasIndex("RoleId", "OrganizationUnitId"); + + b.ToTable("AbpOrganizationUnitRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ClientSecret") + .HasColumnType("longtext"); + + b.Property("ClientUri") + .HasColumnType("longtext"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("DisplayNames") + .HasColumnType("longtext"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasColumnType("longtext"); + + b.Property("Permissions") + .HasColumnType("longtext"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("longtext"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("RedirectUris") + .HasColumnType("longtext"); + + b.Property("Requirements") + .HasColumnType("longtext"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("OpenIddictApplications", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicationId") + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("Scopes") + .HasColumnType("longtext"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("varchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Scopes.OpenIddictScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Descriptions") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("DisplayNames") + .HasColumnType("longtext"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("Resources") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("OpenIddictScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicationId") + .HasColumnType("char(36)"); + + b.Property("AuthorizationId") + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Payload") + .HasColumnType("longtext"); + + b.Property("Properties") + .HasColumnType("longtext"); + + b.Property("RedemptionDate") + .HasColumnType("datetime(6)"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("varchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("OrganizationUnits") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany("Roles") + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + + b.HasOne("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", null) + .WithMany() + .HasForeignKey("AuthorizationId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Navigation("Claims"); + + b.Navigation("Logins"); + + b.Navigation("OrganizationUnits"); + + b.Navigation("Roles"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Navigation("Roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Program.cs new file mode 100644 index 000000000..4860b953c --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.AuthServer.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.AuthServer.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.AuthServer.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..210486f38 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.AuthServer.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json new file mode 100644 index 000000000..db79c340d --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json @@ -0,0 +1,78 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", + "AbpIdentity": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", + "OpenIddict": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorHostedService.cs new file mode 100644 index 000000000..e03469a3c --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.BackendAdmin.DbMigrator; + +public class BackendAdminDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public BackendAdminDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.Configure.cs new file mode 100644 index 000000000..ff0c0ddf4 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.BackendAdmin.DbMigrator; +public partial class BackendAdminDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs new file mode 100644 index 000000000..4dba235b6 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs @@ -0,0 +1,27 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.BackendAdmin.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpTextTemplatingEntityFrameworkCoreModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class BackendAdminDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminDbMigrationService.cs new file mode 100644 index 000000000..a7b2c0311 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; + +public class BackendAdminDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public BackendAdminDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new BackendAdminMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs new file mode 100644 index 000000000..e830ae934 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs @@ -0,0 +1,31 @@ +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("BackendAdminDbMigrator")] +public class BackendAdminMigrationsDbContext : AbpDbContext +{ + public BackendAdminMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureSaas(); + modelBuilder.ConfigureTextTemplating(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigurePermissionManagement(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs new file mode 100644 index 000000000..373b8bd83 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; + +public class BackendAdminMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public BackendAdminMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new BackendAdminMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj new file mode 100644 index 000000000..dc64a16d9 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj @@ -0,0 +1,51 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.Designer.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.Designer.cs new file mode 100644 index 000000000..3c056137b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.Designer.cs @@ -0,0 +1,524 @@ +// +using System; +using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations +{ + [DbContext(typeof(BackendAdminMigrationsDbContext))] + [Migration("20230109083613_Initial-Backend-Admin")] + partial class InitialBackendAdmin + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.ToTable("AbpEditions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisableTime") + .HasColumnType("datetime(6)"); + + b.Property("EditionId") + .HasColumnType("char(36)"); + + b.Property("EnableTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EditionId"); + + b.HasIndex("Name"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Culture") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint unsigned"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId"); + + b.Navigation("Edition"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.cs new file mode 100644 index 000000000..7986c100d --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/20230109083613_Initial-Backend-Admin.cs @@ -0,0 +1,388 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations +{ + /// + public partial class InitialBackendAdmin : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpEditions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + DisplayName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEditions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpFeatureGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpFeatures", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DefaultValue = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsVisibleToClients = table.Column(type: "tinyint(1)", nullable: false), + IsAvailableToHost = table.Column(type: "tinyint(1)", nullable: false), + AllowedProviders = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueType = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatures", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpPermissionGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpPermissions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + MultiTenancySide = table.Column(type: "tinyint unsigned", nullable: false), + Providers = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + StateCheckers = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpTextTemplates", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", maxLength: 1048576, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Culture = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTextTemplates", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + EnableTime = table.Column(type: "datetime(6)", nullable: true), + DisableTime = table.Column(type: "datetime(6)", nullable: true), + EditionId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + table.ForeignKey( + name: "FK_AbpTenants_AbpEditions_EditionId", + column: x => x.EditionId, + principalTable: "AbpEditions", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpTenantConnectionStrings", + columns: table => new + { + TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); + table.ForeignKey( + name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", + column: x => x.TenantId, + principalTable: "AbpTenants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEditions_DisplayName", + table: "AbpEditions", + column: "DisplayName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureGroups_Name", + table: "AbpFeatureGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatures_GroupName", + table: "AbpFeatures", + column: "GroupName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatures_Name", + table: "AbpFeatures", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGroups_Name", + table: "AbpPermissionGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissions_GroupName", + table: "AbpPermissions", + column: "GroupName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissions_Name", + table: "AbpPermissions", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_EditionId", + table: "AbpTenants", + column: "EditionId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates", + columns: new[] { "TenantId", "Name" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpFeatureGroups"); + + migrationBuilder.DropTable( + name: "AbpFeatures"); + + migrationBuilder.DropTable( + name: "AbpFeatureValues"); + + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); + + migrationBuilder.DropTable( + name: "AbpPermissionGroups"); + + migrationBuilder.DropTable( + name: "AbpPermissions"); + + migrationBuilder.DropTable( + name: "AbpSettings"); + + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); + + migrationBuilder.DropTable( + name: "AbpTextTemplates"); + + migrationBuilder.DropTable( + name: "AbpTenants"); + + migrationBuilder.DropTable( + name: "AbpEditions"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..b62269730 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,521 @@ +// +using System; +using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations +{ + [DbContext(typeof(BackendAdminMigrationsDbContext))] + partial class BackendAdminMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.ToTable("AbpEditions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisableTime") + .HasColumnType("datetime(6)"); + + b.Property("EditionId") + .HasColumnType("char(36)"); + + b.Property("EnableTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EditionId"); + + b.HasIndex("Name"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Culture") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint unsigned"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId"); + + b.Navigation("Edition"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Program.cs new file mode 100644 index 000000000..1a93600f5 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.BackendAdmin.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.BackendAdmin.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.BackendAdmin.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..4e71ebf53 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.BackendAdmin.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json new file mode 100644 index 000000000..3ddf5bb51 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json @@ -0,0 +1,80 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpTextTemplating": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IWeChatResourceDataSeeder.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IWeChatResourceDataSeeder.cs new file mode 100644 index 000000000..7c15ae4c6 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IWeChatResourceDataSeeder.cs @@ -0,0 +1,6 @@ +namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; + +public interface IWeChatResourceDataSeeder +{ + Task CreateStandardResourcesAsync(); +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IdentityServerDataSeedContributor.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IdentityServerDataSeedContributor.cs new file mode 100644 index 000000000..ae15d8404 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/IdentityServerDataSeedContributor.cs @@ -0,0 +1,299 @@ +using LINGYUN.Abp.IdentityServer.IdentityResources; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.IdentityServer.ApiResources; +using Volo.Abp.IdentityServer.ApiScopes; +using Volo.Abp.IdentityServer.Clients; +using Volo.Abp.IdentityServer.IdentityResources; +using Volo.Abp.MultiTenancy; +using Volo.Abp.PermissionManagement; +using Volo.Abp.Uow; + +namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; + +public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency +{ + private readonly IApiResourceRepository _apiResourceRepository; + private readonly IApiScopeRepository _apiScopeRepository; + private readonly IClientRepository _clientRepository; + private readonly ICustomIdentityResourceDataSeeder _customIdentityResourceDataSeeder; + private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; + private readonly IWeChatResourceDataSeeder _weChatResourceDataSeeder; + private readonly IGuidGenerator _guidGenerator; + private readonly IPermissionDataSeeder _permissionDataSeeder; + private readonly IConfiguration _configuration; + private readonly ICurrentTenant _currentTenant; + + public IdentityServerDataSeedContributor( + IClientRepository clientRepository, + IApiScopeRepository apiScopeRepository, + IPermissionDataSeeder permissionDataSeeder, + IApiResourceRepository apiResourceRepository, + IWeChatResourceDataSeeder weChatResourceDataSeeder, + IIdentityResourceDataSeeder identityResourceDataSeeder, + ICustomIdentityResourceDataSeeder customIdentityResourceDataSeeder, + IGuidGenerator guidGenerator, + ICurrentTenant currentTenant, + IConfiguration configuration) + { + _currentTenant = currentTenant; + _clientRepository = clientRepository; + _permissionDataSeeder = permissionDataSeeder; + _apiScopeRepository = apiScopeRepository; + _apiResourceRepository = apiResourceRepository; + _weChatResourceDataSeeder = weChatResourceDataSeeder; + _identityResourceDataSeeder = identityResourceDataSeeder; + _customIdentityResourceDataSeeder = customIdentityResourceDataSeeder; + _guidGenerator = guidGenerator; + _configuration = configuration; + } + + [UnitOfWork] + public async virtual Task SeedAsync(DataSeedContext context) + { + using (_currentTenant.Change(context?.TenantId)) + { + await _identityResourceDataSeeder.CreateStandardResourcesAsync(); + await _customIdentityResourceDataSeeder.CreateCustomResourcesAsync(); + await CreateWeChatClaimTypeAsync(); + await CreateApiResourcesAsync(); + await CreateApiScopesAsync(); + await CreateClientsAsync(); + } + } + + private async Task CreateWeChatClaimTypeAsync() + { + await _weChatResourceDataSeeder.CreateStandardResourcesAsync(); + } + + private async Task CreateApiScopesAsync() + { + await CreateApiScopeAsync("lingyun-abp-application"); + } + + private async Task CreateApiResourcesAsync() + { + var commonApiUserClaims = new[] + { + "email", + "email_verified", + "name", + "phone_number", + "phone_number_verified", + "role" + }; + + await CreateApiResourceAsync("lingyun-abp-application", commonApiUserClaims); + } + + private async Task CreateApiResourceAsync(string name, IEnumerable claims, IEnumerable secrets = null) + { + var apiResource = await _apiResourceRepository.FindByNameAsync(name); + if (apiResource == null) + { + apiResource = await _apiResourceRepository.InsertAsync( + new ApiResource( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); + } + + foreach (var claim in claims) + { + if (apiResource.FindClaim(claim) == null) + { + apiResource.AddUserClaim(claim); + } + } + if (secrets != null) + { + foreach (var secret in secrets) + { + if (apiResource.FindSecret(secret) == null) + { + apiResource.AddSecret(secret); + } + } + } + + return await _apiResourceRepository.UpdateAsync(apiResource); + } + + private async Task CreateApiScopeAsync(string name) + { + var apiScope = await _apiScopeRepository.FindByNameAsync(name); + if (apiScope == null) + { + apiScope = await _apiScopeRepository.InsertAsync( + new ApiScope( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); + } + + return apiScope; + } + + private async Task CreateClientsAsync() + { + + string commonSecret = IdentityServer4.Models.HashExtensions.Sha256("1q2w3e*"); + + var commonScopes = new[] + { + "email", + "openid", + "profile", + "role", + "phone", + "address", + "offline_access" // 加上刷新, + + }; + + var configurationSection = _configuration.GetSection("IdentityServer:Clients"); + + var vueClientId = configurationSection["AuthVueAdmin:ClientId"]; + if (!vueClientId.IsNullOrWhiteSpace()) + { + var vueClientPermissions = new string[1] + { + "AbpIdentity.UserLookup" + }; + var vueClientRootUrl = configurationSection["AuthVueAdmin:RootUrl"].EnsureEndsWith('/'); + await CreateClientAsync( + vueClientId, + commonScopes.Union(new[] { "lingyun-abp-application" }), + new[] { "password", "client_credentials", "implicit", "phone_verify", "wx-mp" }, + commonSecret, + redirectUri: $"{vueClientRootUrl}signin-oidc", + postLogoutRedirectUri: $"{vueClientRootUrl}signout-callback-oidc", + corsOrigins: configurationSection["CorsOrigins"], + permissions: vueClientPermissions + ); + } + + // InternalService 内部服务间通讯客户端,必要的话需要在前端指定它拥有所有权限,当前项目仅预置用户查询权限 + var internalServiceClientId = configurationSection["InternalService:ClientId"]; + if (!internalServiceClientId.IsNullOrWhiteSpace()) + { + var internalServicePermissions = new string[2] + { + "AbpIdentity.UserLookup","AbpIdentity.Users" + }; + await CreateClientAsync( + internalServiceClientId, + commonScopes.Union(new[] { "lingyun-abp-application" }), + new[] { "client_credentials" }, + commonSecret, + permissions: internalServicePermissions + ); + } + } + + private async Task CreateClientAsync( + string name, + IEnumerable scopes, + IEnumerable grantTypes, + string secret, + string redirectUri = null, + string postLogoutRedirectUri = null, + IEnumerable permissions = null, + string corsOrigins = null) + { + var client = await _clientRepository.FindByClientIdAsync(name); + if (client == null) + { + client = await _clientRepository.InsertAsync( + new Client( + _guidGenerator.Create(), + name + ) + { + ClientName = name, + ProtocolType = "oidc", + Description = name, + AlwaysIncludeUserClaimsInIdToken = true, + AllowOfflineAccess = true, + AbsoluteRefreshTokenLifetime = 10800, //3 hours + AccessTokenLifetime = 7200, //2 hours + AuthorizationCodeLifetime = 300, + IdentityTokenLifetime = 300, + RequireConsent = false + }, + autoSave: true + ); + } + + foreach (var scope in scopes) + { + if (client.FindScope(scope) == null) + { + client.AddScope(scope); + } + } + + foreach (var grantType in grantTypes) + { + if (client.FindGrantType(grantType) == null) + { + client.AddGrantType(grantType); + } + } + + if (client.FindSecret(secret) == null) + { + client.AddSecret(secret); + } + + if (redirectUri != null) + { + if (client.FindRedirectUri(redirectUri) == null) + { + client.AddRedirectUri(redirectUri); + } + } + + if (postLogoutRedirectUri != null) + { + if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) + { + client.AddPostLogoutRedirectUri(postLogoutRedirectUri); + } + } + + if (corsOrigins != null) + { + var corsOriginsSplit = corsOrigins.Split(";"); + foreach (var corsOrigin in corsOriginsSplit) + { + if (client.FindCorsOrigin(corsOrigin) == null) + { + client.AddCorsOrigin(corsOrigin); + } + } + } + + if (permissions != null) + { + await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, name, permissions); + } + + return await _clientRepository.UpdateAsync(client); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/WeChatResourceDataSeeder.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/WeChatResourceDataSeeder.cs new file mode 100644 index 000000000..7eab87459 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/DataSeeder/WeChatResourceDataSeeder.cs @@ -0,0 +1,85 @@ +using LINGYUN.Abp.WeChat; +using LINGYUN.Abp.WeChat.Security.Claims; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.Identity; +using Volo.Abp.IdentityServer.IdentityResources; + +namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; + +public class WeChatResourceDataSeeder : IWeChatResourceDataSeeder, ITransientDependency +{ + protected IIdentityClaimTypeRepository ClaimTypeRepository { get; } + protected IIdentityResourceRepository IdentityResourceRepository { get; } + protected IGuidGenerator GuidGenerator { get; } + + public WeChatResourceDataSeeder( + IIdentityResourceRepository identityResourceRepository, + IGuidGenerator guidGenerator, + IIdentityClaimTypeRepository claimTypeRepository) + { + IdentityResourceRepository = identityResourceRepository; + GuidGenerator = guidGenerator; + ClaimTypeRepository = claimTypeRepository; + } + + public async virtual Task CreateStandardResourcesAsync() + { + var wechatClaimTypes = new string[] + { + AbpWeChatClaimTypes.AvatarUrl, + AbpWeChatClaimTypes.City, + AbpWeChatClaimTypes.Country, + AbpWeChatClaimTypes.NickName, + AbpWeChatClaimTypes.OpenId, + AbpWeChatClaimTypes.Privilege, + AbpWeChatClaimTypes.Province, + AbpWeChatClaimTypes.Sex, + AbpWeChatClaimTypes.UnionId + }; + + var wechatResource = new IdentityServer4.Models.IdentityResource( + AbpWeChatGlobalConsts.ProfileKey, + AbpWeChatGlobalConsts.DisplayName, + wechatClaimTypes); + + foreach (var claimType in wechatClaimTypes) + { + await AddClaimTypeIfNotExistsAsync(claimType); + } + + await AddIdentityResourceIfNotExistsAsync(wechatResource); + } + + protected async virtual Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource) + { + if (await IdentityResourceRepository.CheckNameExistAsync(resource.Name)) + { + return; + } + + await IdentityResourceRepository.InsertAsync( + new IdentityResource( + GuidGenerator.Create(), + resource + ) + ); + } + + protected async virtual Task AddClaimTypeIfNotExistsAsync(string claimType) + { + if (await ClaimTypeRepository.AnyAsync(claimType)) + { + return; + } + + await ClaimTypeRepository.InsertAsync( + new IdentityClaimType( + GuidGenerator.Create(), + claimType, + isStatic: true + ) + ); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerDbMigrationService.cs new file mode 100644 index 000000000..16f7d23d7 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; + +public class IdentityServerDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public IdentityServerDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new IdentityServerMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContext.cs new file mode 100644 index 000000000..dc56642f4 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.IdentityServer.EntityFrameworkCore; + +namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("IdentityServerDbMigrator")] +public class IdentityServerMigrationsDbContext : AbpDbContext +{ + public IdentityServerMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureIdentityServer(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContextFactory.cs new file mode 100644 index 000000000..92f2e2649 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/EntityFrameworkCore/IdentityServerMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; + +public class IdentityServerMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public IdentityServerMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new IdentityServerMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorHostedService.cs new file mode 100644 index 000000000..0f7b0c25b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.IdentityServer.DbMigrator; + +public class IdentityServerDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public IdentityServerDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.Configure.cs new file mode 100644 index 000000000..e8887d2f6 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.IdentityServer.DbMigrator; +public partial class IdentityServerDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.cs new file mode 100644 index 000000000..a0f7c2a8e --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/IdentityServerDbMigratorModule.cs @@ -0,0 +1,27 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Identity.EntityFrameworkCore; +using LINGYUN.Abp.IdentityServer.EntityFrameworkCore; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.WeChat; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; + +namespace LY.MicroService.IdentityServer.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpWeChatModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class IdentityServerDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/LY.MicroService.IdentityServer.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/LY.MicroService.IdentityServer.DbMigrator.csproj new file mode 100644 index 000000000..236d69b04 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/LY.MicroService.IdentityServer.DbMigrator.csproj @@ -0,0 +1,55 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.Designer.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.Designer.cs new file mode 100644 index 000000000..e80281fb2 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.Designer.cs @@ -0,0 +1,1777 @@ +// +using System; +using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.IdentityServer.DbMigrator.Migrations +{ + [DbContext(typeof(IdentityServerMigrationsDbContext))] + [Migration("20230109090609_Initial-Identity-Server")] + partial class InitialIdentityServer + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Regex") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("RegexDescription") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityLinkUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("SourceTenantId") + .HasColumnType("char(36)"); + + b.Property("SourceUserId") + .HasColumnType("char(36)"); + + b.Property("TargetTenantId") + .HasColumnType("char(36)"); + + b.Property("TargetUserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId") + .IsUnique(); + + b.ToTable("AbpLinkUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySecurityLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Action") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Identity") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Action"); + + b.HasIndex("TenantId", "ApplicationName"); + + b.HasIndex("TenantId", "Identity"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSecurityLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0) + .HasColumnName("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("Email"); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("EmailConfirmed"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnName("IsActive"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsExternal") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsExternal"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("LockoutEnabled"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedEmail"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedUserName"); + + b.Property("PasswordHash") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("PasswordHash"); + + b.Property("PhoneNumber") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("PhoneNumber"); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("PhoneNumberConfirmed"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SecurityStamp"); + + b.Property("Surname") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Surname"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("TwoFactorEnabled"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196) + .HasColumnType("varchar(196)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "UserId"); + + b.HasIndex("UserId", "OrganizationUnitId"); + + b.ToTable("AbpUserOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(95) + .HasColumnType("varchar(95)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AbpOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "RoleId"); + + b.HasIndex("RoleId", "OrganizationUnitId"); + + b.ToTable("AbpOrganizationUnitRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedAccessTokenSigningAlgorithms") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerApiResources", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiResourceId", "Type"); + + b.ToTable("IdentityServerApiResourceClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceProperty", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ApiResourceId", "Key", "Value"); + + b.ToTable("IdentityServerApiResourceProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceScope", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Scope") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiResourceId", "Scope"); + + b.ToTable("IdentityServerApiResourceScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceSecret", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.HasKey("ApiResourceId", "Type", "Value"); + + b.ToTable("IdentityServerApiResourceSecrets", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Emphasize") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerApiScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeClaim", b => + { + b.Property("ApiScopeId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiScopeId", "Type"); + + b.ToTable("IdentityServerApiScopeClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeProperty", b => + { + b.Property("ApiScopeId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ApiScopeId", "Key", "Value"); + + b.ToTable("IdentityServerApiScopeProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AbsoluteRefreshTokenLifetime") + .HasColumnType("int"); + + b.Property("AccessTokenLifetime") + .HasColumnType("int"); + + b.Property("AccessTokenType") + .HasColumnType("int"); + + b.Property("AllowAccessTokensViaBrowser") + .HasColumnType("tinyint(1)"); + + b.Property("AllowOfflineAccess") + .HasColumnType("tinyint(1)"); + + b.Property("AllowPlainTextPkce") + .HasColumnType("tinyint(1)"); + + b.Property("AllowRememberConsent") + .HasColumnType("tinyint(1)"); + + b.Property("AllowedIdentityTokenSigningAlgorithms") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("AlwaysIncludeUserClaimsInIdToken") + .HasColumnType("tinyint(1)"); + + b.Property("AlwaysSendClientClaims") + .HasColumnType("tinyint(1)"); + + b.Property("AuthorizationCodeLifetime") + .HasColumnType("int"); + + b.Property("BackChannelLogoutSessionRequired") + .HasColumnType("tinyint(1)"); + + b.Property("BackChannelLogoutUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("ClientClaimsPrefix") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsentLifetime") + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DeviceCodeLifetime") + .HasColumnType("int"); + + b.Property("EnableLocalLogin") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrontChannelLogoutSessionRequired") + .HasColumnType("tinyint(1)"); + + b.Property("FrontChannelLogoutUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("IdentityTokenLifetime") + .HasColumnType("int"); + + b.Property("IncludeJwtId") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("PairWiseSubjectSalt") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ProtocolType") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RefreshTokenExpiration") + .HasColumnType("int"); + + b.Property("RefreshTokenUsage") + .HasColumnType("int"); + + b.Property("RequireClientSecret") + .HasColumnType("tinyint(1)"); + + b.Property("RequireConsent") + .HasColumnType("tinyint(1)"); + + b.Property("RequirePkce") + .HasColumnType("tinyint(1)"); + + b.Property("RequireRequestObject") + .HasColumnType("tinyint(1)"); + + b.Property("SlidingRefreshTokenLifetime") + .HasColumnType("int"); + + b.Property("UpdateAccessTokenClaimsOnRefresh") + .HasColumnType("tinyint(1)"); + + b.Property("UserCodeType") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UserSsoLifetime") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("IdentityServerClients", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Origin") + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("ClientId", "Origin"); + + b.ToTable("IdentityServerClientCorsOrigins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("GrantType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("ClientId", "GrantType"); + + b.ToTable("IdentityServerClientGrantTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Provider") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ClientId", "Provider"); + + b.ToTable("IdentityServerClientIdPRestrictions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("PostLogoutRedirectUri") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "PostLogoutRedirectUri"); + + b.ToTable("IdentityServerClientPostLogoutRedirectUris", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "Key", "Value"); + + b.ToTable("IdentityServerClientProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("RedirectUri") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "RedirectUri"); + + b.ToTable("IdentityServerClientRedirectUris", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Scope") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ClientId", "Scope"); + + b.ToTable("IdentityServerClientScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientSecrets", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Devices.DeviceFlowCodes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Data") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("varchar(10000)"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("DeviceCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Expiration") + .IsRequired() + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UserCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DeviceCode") + .IsUnique(); + + b.HasIndex("Expiration"); + + b.HasIndex("UserCode"); + + b.ToTable("IdentityServerDeviceFlowCodes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => + { + b.Property("Key") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsumedTime") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("varchar(10000)"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Key"); + + b.HasIndex("Expiration"); + + b.HasIndex("SubjectId", "ClientId", "Type"); + + b.HasIndex("SubjectId", "SessionId", "Type"); + + b.ToTable("IdentityServerPersistedGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Emphasize") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerIdentityResources", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceClaim", b => + { + b.Property("IdentityResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("IdentityResourceId", "Type"); + + b.ToTable("IdentityServerIdentityResourceClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceProperty", b => + { + b.Property("IdentityResourceId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("IdentityResourceId", "Key", "Value"); + + b.ToTable("IdentityServerIdentityResourceProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("OrganizationUnits") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany("Roles") + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Properties") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Scopes") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Secrets") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiScopes.ApiScope", null) + .WithMany("UserClaims") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiScopes.ApiScope", null) + .WithMany("Properties") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("Claims") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedCorsOrigins") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedGrantTypes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("IdentityProviderRestrictions") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("PostLogoutRedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("Properties") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("RedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedScopes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("ClientSecrets") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null) + .WithMany("UserClaims") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null) + .WithMany("Properties") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Navigation("Claims"); + + b.Navigation("Logins"); + + b.Navigation("OrganizationUnits"); + + b.Navigation("Roles"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Navigation("Properties"); + + b.Navigation("Scopes"); + + b.Navigation("Secrets"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScope", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Navigation("AllowedCorsOrigins"); + + b.Navigation("AllowedGrantTypes"); + + b.Navigation("AllowedScopes"); + + b.Navigation("Claims"); + + b.Navigation("ClientSecrets"); + + b.Navigation("IdentityProviderRestrictions"); + + b.Navigation("PostLogoutRedirectUris"); + + b.Navigation("Properties"); + + b.Navigation("RedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.cs new file mode 100644 index 000000000..f2834fa7b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/20230109090609_Initial-Identity-Server.cs @@ -0,0 +1,1224 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.IdentityServer.DbMigrator.Migrations +{ + /// + public partial class InitialIdentityServer : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Required = table.Column(type: "tinyint(1)", nullable: false), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + Regex = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RegexDescription = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SourceUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SourceTenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + TargetUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TargetTenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Code = table.Column(type: "varchar(95)", maxLength: 95, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsDefault = table.Column(type: "tinyint(1)", nullable: false), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + IsPublic = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ApplicationName = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Identity = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Action = table.Column(type: "varchar(96)", maxLength: 96, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientId = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CorrelationId = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientIpAddress = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + BrowserInfo = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Surname = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SecurityStamp = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsExternal = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "varchar(16)", maxLength: 16, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetime(6)", nullable: true), + LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResources", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Enabled = table.Column(type: "tinyint(1)", nullable: false), + AllowedAccessTokenSigningAlgorithms = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ShowInDiscoveryDocument = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Enabled = table.Column(type: "tinyint(1)", nullable: false), + Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Required = table.Column(type: "tinyint(1)", nullable: false), + Emphasize = table.Column(type: "tinyint(1)", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClients", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ClientId = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientUri = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LogoUri = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Enabled = table.Column(type: "tinyint(1)", nullable: false), + ProtocolType = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RequireClientSecret = table.Column(type: "tinyint(1)", nullable: false), + RequireConsent = table.Column(type: "tinyint(1)", nullable: false), + AllowRememberConsent = table.Column(type: "tinyint(1)", nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(type: "tinyint(1)", nullable: false), + RequirePkce = table.Column(type: "tinyint(1)", nullable: false), + AllowPlainTextPkce = table.Column(type: "tinyint(1)", nullable: false), + RequireRequestObject = table.Column(type: "tinyint(1)", nullable: false), + AllowAccessTokensViaBrowser = table.Column(type: "tinyint(1)", nullable: false), + FrontChannelLogoutUri = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + FrontChannelLogoutSessionRequired = table.Column(type: "tinyint(1)", nullable: false), + BackChannelLogoutUri = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + BackChannelLogoutSessionRequired = table.Column(type: "tinyint(1)", nullable: false), + AllowOfflineAccess = table.Column(type: "tinyint(1)", nullable: false), + IdentityTokenLifetime = table.Column(type: "int", nullable: false), + AllowedIdentityTokenSigningAlgorithms = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AccessTokenLifetime = table.Column(type: "int", nullable: false), + AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), + ConsentLifetime = table.Column(type: "int", nullable: true), + AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), + SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), + RefreshTokenUsage = table.Column(type: "int", nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(type: "tinyint(1)", nullable: false), + RefreshTokenExpiration = table.Column(type: "int", nullable: false), + AccessTokenType = table.Column(type: "int", nullable: false), + EnableLocalLogin = table.Column(type: "tinyint(1)", nullable: false), + IncludeJwtId = table.Column(type: "tinyint(1)", nullable: false), + AlwaysSendClientClaims = table.Column(type: "tinyint(1)", nullable: false), + ClientClaimsPrefix = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PairWiseSubjectSalt = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserSsoLifetime = table.Column(type: "int", nullable: true), + UserCodeType = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DeviceCodeLifetime = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClients", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerDeviceFlowCodes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + DeviceCode = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserCode = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SubjectId = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SessionId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientId = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Expiration = table.Column(type: "datetime(6)", nullable: false), + Data = table.Column(type: "varchar(10000)", maxLength: 10000, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResources", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Enabled = table.Column(type: "tinyint(1)", nullable: false), + Required = table.Column(type: "tinyint(1)", nullable: false), + Emphasize = table.Column(type: "tinyint(1)", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerPersistedGrants", + columns: table => new + { + Key = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SubjectId = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SessionId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientId = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + Expiration = table.Column(type: "datetime(6)", nullable: true), + ConsumedTime = table.Column(type: "datetime(6)", nullable: true), + Data = table.Column(type: "varchar(10000)", maxLength: 10000, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new + { + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OrganizationUnitId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUn~", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LoginProvider = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + ProviderKey = table.Column(type: "varchar(196)", maxLength: 196, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderDisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserOrganizationUnits", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OrganizationUnitId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUn~", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LoginProvider = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Value = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceClaims", + columns: table => new + { + Type = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ApiResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_A~", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceProperties", + columns: table => new + { + ApiResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Key = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResourc~", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceScopes", + columns: table => new + { + ApiResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Scope = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_A~", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceSecrets", + columns: table => new + { + Type = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ApiResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Description = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Expiration = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_~", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeClaims", + columns: table => new + { + Type = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ApiScopeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScop~", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeProperties", + columns: table => new + { + ApiScopeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Key = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_Api~", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientClaims", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Type = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientCorsOrigins", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Origin = table.Column(type: "varchar(150)", maxLength: 150, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); + table.ForeignKey( + name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_Client~", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientGrantTypes", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GrantType = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); + table.ForeignKey( + name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientIdPRestrictions", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Provider = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); + table.ForeignKey( + name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_Cl~", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientPostLogoutRedirectUris", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + PostLogoutRedirectUri = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerCli~", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientProperties", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Key = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientRedirectUris", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RedirectUri = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_Clien~", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientScopes", + columns: table => new + { + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Scope = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerClientSecrets", + columns: table => new + { + Type = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Description = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Expiration = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceClaims", + columns: table => new + { + Type = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IdentityResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityR~", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceProperties", + columns: table => new + { + IdentityResourceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Key = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(300)", maxLength: 300, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdent~", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_Target~", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerClients_ClientId", + table: "IdentityServerClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", + table: "IdentityServerDeviceFlowCodes", + column: "DeviceCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_Expiration", + table: "IdentityServerDeviceFlowCodes", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_UserCode", + table: "IdentityServerDeviceFlowCodes", + column: "UserCode"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_Expiration", + table: "IdentityServerPersistedGrants", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "SessionId", "Type" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpClaimTypes"); + + migrationBuilder.DropTable( + name: "AbpLinkUsers"); + + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); + + migrationBuilder.DropTable( + name: "AbpRoleClaims"); + + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); + + migrationBuilder.DropTable( + name: "AbpUserClaims"); + + migrationBuilder.DropTable( + name: "AbpUserLogins"); + + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); + + migrationBuilder.DropTable( + name: "AbpUserRoles"); + + migrationBuilder.DropTable( + name: "AbpUserTokens"); + + migrationBuilder.DropTable( + name: "IdentityServerApiResourceClaims"); + + migrationBuilder.DropTable( + name: "IdentityServerApiResourceProperties"); + + migrationBuilder.DropTable( + name: "IdentityServerApiResourceScopes"); + + migrationBuilder.DropTable( + name: "IdentityServerApiResourceSecrets"); + + migrationBuilder.DropTable( + name: "IdentityServerApiScopeClaims"); + + migrationBuilder.DropTable( + name: "IdentityServerApiScopeProperties"); + + migrationBuilder.DropTable( + name: "IdentityServerClientClaims"); + + migrationBuilder.DropTable( + name: "IdentityServerClientCorsOrigins"); + + migrationBuilder.DropTable( + name: "IdentityServerClientGrantTypes"); + + migrationBuilder.DropTable( + name: "IdentityServerClientIdPRestrictions"); + + migrationBuilder.DropTable( + name: "IdentityServerClientPostLogoutRedirectUris"); + + migrationBuilder.DropTable( + name: "IdentityServerClientProperties"); + + migrationBuilder.DropTable( + name: "IdentityServerClientRedirectUris"); + + migrationBuilder.DropTable( + name: "IdentityServerClientScopes"); + + migrationBuilder.DropTable( + name: "IdentityServerClientSecrets"); + + migrationBuilder.DropTable( + name: "IdentityServerDeviceFlowCodes"); + + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceClaims"); + + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceProperties"); + + migrationBuilder.DropTable( + name: "IdentityServerPersistedGrants"); + + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); + + migrationBuilder.DropTable( + name: "AbpRoles"); + + migrationBuilder.DropTable( + name: "AbpUsers"); + + migrationBuilder.DropTable( + name: "IdentityServerApiResources"); + + migrationBuilder.DropTable( + name: "IdentityServerApiScopes"); + + migrationBuilder.DropTable( + name: "IdentityServerClients"); + + migrationBuilder.DropTable( + name: "IdentityServerIdentityResources"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..a284929bf --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,1774 @@ +// +using System; +using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.IdentityServer.DbMigrator.Migrations +{ + [DbContext(typeof(IdentityServerMigrationsDbContext))] + partial class IdentityServerMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Regex") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("RegexDescription") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityLinkUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("SourceTenantId") + .HasColumnType("char(36)"); + + b.Property("SourceUserId") + .HasColumnType("char(36)"); + + b.Property("TargetTenantId") + .HasColumnType("char(36)"); + + b.Property("TargetUserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId") + .IsUnique(); + + b.ToTable("AbpLinkUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySecurityLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Action") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Identity") + .HasMaxLength(96) + .HasColumnType("varchar(96)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Action"); + + b.HasIndex("TenantId", "ApplicationName"); + + b.HasIndex("TenantId", "Identity"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSecurityLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0) + .HasColumnName("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("Email"); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("EmailConfirmed"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnName("IsActive"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsExternal") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsExternal"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("LockoutEnabled"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedEmail"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("NormalizedUserName"); + + b.Property("PasswordHash") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("PasswordHash"); + + b.Property("PhoneNumber") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("PhoneNumber"); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("PhoneNumberConfirmed"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SecurityStamp"); + + b.Property("Surname") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Surname"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("TwoFactorEnabled"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196) + .HasColumnType("varchar(196)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "UserId"); + + b.HasIndex("UserId", "OrganizationUnitId"); + + b.ToTable("AbpUserOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(95) + .HasColumnType("varchar(95)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AbpOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "RoleId"); + + b.HasIndex("RoleId", "OrganizationUnitId"); + + b.ToTable("AbpOrganizationUnitRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedAccessTokenSigningAlgorithms") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerApiResources", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiResourceId", "Type"); + + b.ToTable("IdentityServerApiResourceClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceProperty", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ApiResourceId", "Key", "Value"); + + b.ToTable("IdentityServerApiResourceProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceScope", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Scope") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiResourceId", "Scope"); + + b.ToTable("IdentityServerApiResourceScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceSecret", b => + { + b.Property("ApiResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.HasKey("ApiResourceId", "Type", "Value"); + + b.ToTable("IdentityServerApiResourceSecrets", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Emphasize") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerApiScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeClaim", b => + { + b.Property("ApiScopeId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ApiScopeId", "Type"); + + b.ToTable("IdentityServerApiScopeClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeProperty", b => + { + b.Property("ApiScopeId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ApiScopeId", "Key", "Value"); + + b.ToTable("IdentityServerApiScopeProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AbsoluteRefreshTokenLifetime") + .HasColumnType("int"); + + b.Property("AccessTokenLifetime") + .HasColumnType("int"); + + b.Property("AccessTokenType") + .HasColumnType("int"); + + b.Property("AllowAccessTokensViaBrowser") + .HasColumnType("tinyint(1)"); + + b.Property("AllowOfflineAccess") + .HasColumnType("tinyint(1)"); + + b.Property("AllowPlainTextPkce") + .HasColumnType("tinyint(1)"); + + b.Property("AllowRememberConsent") + .HasColumnType("tinyint(1)"); + + b.Property("AllowedIdentityTokenSigningAlgorithms") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("AlwaysIncludeUserClaimsInIdToken") + .HasColumnType("tinyint(1)"); + + b.Property("AlwaysSendClientClaims") + .HasColumnType("tinyint(1)"); + + b.Property("AuthorizationCodeLifetime") + .HasColumnType("int"); + + b.Property("BackChannelLogoutSessionRequired") + .HasColumnType("tinyint(1)"); + + b.Property("BackChannelLogoutUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("ClientClaimsPrefix") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsentLifetime") + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DeviceCodeLifetime") + .HasColumnType("int"); + + b.Property("EnableLocalLogin") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrontChannelLogoutSessionRequired") + .HasColumnType("tinyint(1)"); + + b.Property("FrontChannelLogoutUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("IdentityTokenLifetime") + .HasColumnType("int"); + + b.Property("IncludeJwtId") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("PairWiseSubjectSalt") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ProtocolType") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RefreshTokenExpiration") + .HasColumnType("int"); + + b.Property("RefreshTokenUsage") + .HasColumnType("int"); + + b.Property("RequireClientSecret") + .HasColumnType("tinyint(1)"); + + b.Property("RequireConsent") + .HasColumnType("tinyint(1)"); + + b.Property("RequirePkce") + .HasColumnType("tinyint(1)"); + + b.Property("RequireRequestObject") + .HasColumnType("tinyint(1)"); + + b.Property("SlidingRefreshTokenLifetime") + .HasColumnType("int"); + + b.Property("UpdateAccessTokenClaimsOnRefresh") + .HasColumnType("tinyint(1)"); + + b.Property("UserCodeType") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UserSsoLifetime") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("IdentityServerClients", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Origin") + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("ClientId", "Origin"); + + b.ToTable("IdentityServerClientCorsOrigins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("GrantType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("ClientId", "GrantType"); + + b.ToTable("IdentityServerClientGrantTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Provider") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ClientId", "Provider"); + + b.ToTable("IdentityServerClientIdPRestrictions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("PostLogoutRedirectUri") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "PostLogoutRedirectUri"); + + b.ToTable("IdentityServerClientPostLogoutRedirectUris", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "Key", "Value"); + + b.ToTable("IdentityServerClientProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("RedirectUri") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("ClientId", "RedirectUri"); + + b.ToTable("IdentityServerClientRedirectUris", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Scope") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("ClientId", "Scope"); + + b.ToTable("IdentityServerClientScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.Property("ClientId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientSecrets", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Devices.DeviceFlowCodes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Data") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("varchar(10000)"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("DeviceCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Expiration") + .IsRequired() + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UserCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DeviceCode") + .IsUnique(); + + b.HasIndex("Expiration"); + + b.HasIndex("UserCode"); + + b.ToTable("IdentityServerDeviceFlowCodes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => + { + b.Property("Key") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsumedTime") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("varchar(10000)"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Expiration") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Key"); + + b.HasIndex("Expiration"); + + b.HasIndex("SubjectId", "ClientId", "Type"); + + b.HasIndex("SubjectId", "SessionId", "Type"); + + b.ToTable("IdentityServerPersistedGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Emphasize") + .HasColumnType("tinyint(1)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Required") + .HasColumnType("tinyint(1)"); + + b.Property("ShowInDiscoveryDocument") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerIdentityResources", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceClaim", b => + { + b.Property("IdentityResourceId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("IdentityResourceId", "Type"); + + b.ToTable("IdentityServerIdentityResourceClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceProperty", b => + { + b.Property("IdentityResourceId") + .HasColumnType("char(36)"); + + b.Property("Key") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Value") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.HasKey("IdentityResourceId", "Key", "Value"); + + b.ToTable("IdentityServerIdentityResourceProperties", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("OrganizationUnits") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany("Roles") + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Properties") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Scopes") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null) + .WithMany("Secrets") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiScopes.ApiScope", null) + .WithMany("UserClaims") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScopeProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiScopes.ApiScope", null) + .WithMany("Properties") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("Claims") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedCorsOrigins") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedGrantTypes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("IdentityProviderRestrictions") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("PostLogoutRedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("Properties") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("RedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("AllowedScopes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null) + .WithMany("ClientSecrets") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null) + .WithMany("UserClaims") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResourceProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null) + .WithMany("Properties") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Navigation("Claims"); + + b.Navigation("Logins"); + + b.Navigation("OrganizationUnits"); + + b.Navigation("Roles"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Navigation("Properties"); + + b.Navigation("Scopes"); + + b.Navigation("Secrets"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiScopes.ApiScope", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Navigation("AllowedCorsOrigins"); + + b.Navigation("AllowedGrantTypes"); + + b.Navigation("AllowedScopes"); + + b.Navigation("Claims"); + + b.Navigation("ClientSecrets"); + + b.Navigation("IdentityProviderRestrictions"); + + b.Navigation("PostLogoutRedirectUris"); + + b.Navigation("Properties"); + + b.Navigation("RedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Program.cs new file mode 100644 index 000000000..68f6cf29e --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.IdentityServer.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.IdentityServer.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.IdentityServer.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..9f85cebeb --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.IdentityServer.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json new file mode 100644 index 000000000..755b73d22 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json @@ -0,0 +1,93 @@ +{ + "App": { + "CorsOrigins": "http://127.0.0.1:3100" + }, + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "IdentityServer": { + "Clients": { + "AuthVueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + }, + "InternalService": { + "ClientId": "InternalServiceClient" + } + } + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementDbMigrationService.cs new file mode 100644 index 000000000..d9b21bb14 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; + +public class LocalizationManagementDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public LocalizationManagementDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new LocalizationManagementMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.LocalizationManagement.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContext.cs new file mode 100644 index 000000000..8089bdd10 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContext.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("LocalizationManagementDbMigrator")] +public class LocalizationManagementMigrationsDbContext : AbpDbContext +{ + public LocalizationManagementMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureLocalization(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs new file mode 100644 index 000000000..75d9732ba --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; + +public class LocalizationManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public LocalizationManagementMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new LocalizationManagementMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj new file mode 100644 index 000000000..d862e1929 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj @@ -0,0 +1,55 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorHostedService.cs new file mode 100644 index 000000000..d10a301a7 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.LocalizationManagement.DbMigrator; + +public class LocalizationManagementDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public LocalizationManagementDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.Configure.cs new file mode 100644 index 000000000..ab833bee8 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.LocalizationManagement.DbMigrator; +public partial class LocalizationManagementDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.cs new file mode 100644 index 000000000..4f8975003 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LocalizationManagementDbMigratorModule.cs @@ -0,0 +1,27 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.LocalizationManagement.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpLocalizationManagementEntityFrameworkCoreModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class LocalizationManagementDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.Designer.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.Designer.cs new file mode 100644 index 000000000..42d3667a6 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.Designer.cs @@ -0,0 +1,169 @@ +// +using System; +using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations +{ + [DbContext(typeof(LocalizationManagementMigrationsDbContext))] + [Migration("20230109093938_Initial-Localization-Management")] + partial class InitialLocalizationManagement + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("FlagIcon") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("FlagIcon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("UiCultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("UiCultureName"); + + b.HasKey("Id"); + + b.HasIndex("CultureName"); + + b.ToTable("AbpLocalizationLanguages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AbpLocalizationResources", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Key"); + + b.Property("ResourceName") + .HasColumnType("longtext"); + + b.Property("Value") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)") + .HasColumnName("Value"); + + b.HasKey("Id"); + + b.HasIndex("Key"); + + b.ToTable("AbpLocalizationTexts", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.cs new file mode 100644 index 000000000..1d832ffe3 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230109093938_Initial-Localization-Management.cs @@ -0,0 +1,116 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations +{ + /// + public partial class InitialLocalizationManagement : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpLocalizationLanguages", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Enable = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), + CultureName = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UiCultureName = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + FlagIcon = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLocalizationLanguages", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpLocalizationResources", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Enable = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), + Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLocalizationResources", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpLocalizationTexts", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CultureName = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Key = table.Column(type: "varchar(512)", maxLength: 512, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResourceName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLocalizationTexts", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLocalizationLanguages_CultureName", + table: "AbpLocalizationLanguages", + column: "CultureName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLocalizationResources_Name", + table: "AbpLocalizationResources", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLocalizationTexts_Key", + table: "AbpLocalizationTexts", + column: "Key"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpLocalizationLanguages"); + + migrationBuilder.DropTable( + name: "AbpLocalizationResources"); + + migrationBuilder.DropTable( + name: "AbpLocalizationTexts"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..18a431aff --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,166 @@ +// +using System; +using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations +{ + [DbContext(typeof(LocalizationManagementMigrationsDbContext))] + partial class LocalizationManagementMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("FlagIcon") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("FlagIcon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("UiCultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("UiCultureName"); + + b.HasKey("Id"); + + b.HasIndex("CultureName"); + + b.ToTable("AbpLocalizationLanguages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AbpLocalizationResources", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Key"); + + b.Property("ResourceName") + .HasColumnType("longtext"); + + b.Property("Value") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)") + .HasColumnName("Value"); + + b.HasKey("Id"); + + b.HasIndex("Key"); + + b.ToTable("AbpLocalizationTexts", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Program.cs new file mode 100644 index 000000000..3bcb16c66 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.LocalizationManagement.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.LocalizationManagement.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.LocalizationManagement.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..145ee8cb9 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.LocalizationManagement.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json new file mode 100644 index 000000000..98487a606 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json @@ -0,0 +1,79 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformDbMigrationService.cs new file mode 100644 index 000000000..79dc80114 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; + +public class PlatformDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public PlatformDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new PlatformMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.Platform.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContext.cs new file mode 100644 index 000000000..72f20e950 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContext.cs @@ -0,0 +1,23 @@ +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("PlatformDbMigrator")] +public class PlatformMigrationsDbContext : AbpDbContext +{ + public PlatformMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigurePlatform(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContextFactory.cs new file mode 100644 index 000000000..f335baecf --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/EntityFrameworkCore/PlatformMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; + +public class PlatformMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public PlatformMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new PlatformMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj new file mode 100644 index 000000000..7c004bc29 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj @@ -0,0 +1,56 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.Designer.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.Designer.cs new file mode 100644 index 000000000..822a6bc41 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.Designer.cs @@ -0,0 +1,772 @@ +// +using System; +using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.Platform.DbMigrator.Migrations +{ + [DbContext(typeof(PlatformMigrationsDbContext))] + [Migration("20230110015904_Initial-Platform")] + partial class InitialPlatform + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.cs new file mode 100644 index 000000000..47a0bc4d5 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/20230110015904_Initial-Platform.cs @@ -0,0 +1,399 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.Platform.DbMigrator.Migrations +{ + /// + public partial class InitialPlatform : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformDatas", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Code = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformDatas", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformLayouts", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Framework = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DataId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Path = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Redirect = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformLayouts", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformMenus", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Framework = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Code = table.Column(type: "varchar(23)", maxLength: 23, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Component = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LayoutId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsPublic = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Path = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Redirect = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformMenus", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformPackages", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Version = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ForceUpdate = table.Column(type: "tinyint(1)", nullable: false), + Authors = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Level = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformPackages", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformRoleMenus", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + MenuId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Startup = table.Column(type: "tinyint(1)", nullable: false), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformRoleMenus", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformUserFavoriteMenus", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + MenuId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + AliasName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Color = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Framework = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Path = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Icon = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformUserFavoriteMenus", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformUserMenus", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + MenuId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Startup = table.Column(type: "tinyint(1)", nullable: false), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformUserMenus", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformDataItems", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DefaultValue = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AllowBeNull = table.Column(type: "tinyint(1)", nullable: false, defaultValue: true), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + ValueType = table.Column(type: "int", nullable: false), + DataId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformDataItems", x => x.Id); + table.ForeignKey( + name: "FK_AppPlatformDataItems_AppPlatformDatas_DataId", + column: x => x.DataId, + principalTable: "AppPlatformDatas", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformPackageBlobs", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + PackageId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Url = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Size = table.Column(type: "bigint", nullable: true), + Summary = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: true), + License = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Authors = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ContentType = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SHA256 = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DownloadCount = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformPackageBlobs", x => x.Id); + table.ForeignKey( + name: "FK_AppPlatformPackageBlobs_AppPlatformPackages_PackageId", + column: x => x.PackageId, + principalTable: "AppPlatformPackages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformDataItems_DataId", + table: "AppPlatformDataItems", + column: "DataId"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformDataItems_Name", + table: "AppPlatformDataItems", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformDatas_Name", + table: "AppPlatformDatas", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformPackageBlobs_PackageId_Name", + table: "AppPlatformPackageBlobs", + columns: new[] { "PackageId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformPackages_Name_Version", + table: "AppPlatformPackages", + columns: new[] { "Name", "Version" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformRoleMenus_RoleName_MenuId", + table: "AppPlatformRoleMenus", + columns: new[] { "RoleName", "MenuId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformUserFavoriteMenus_UserId_MenuId", + table: "AppPlatformUserFavoriteMenus", + columns: new[] { "UserId", "MenuId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformUserMenus_UserId_MenuId", + table: "AppPlatformUserMenus", + columns: new[] { "UserId", "MenuId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppPlatformDataItems"); + + migrationBuilder.DropTable( + name: "AppPlatformLayouts"); + + migrationBuilder.DropTable( + name: "AppPlatformMenus"); + + migrationBuilder.DropTable( + name: "AppPlatformPackageBlobs"); + + migrationBuilder.DropTable( + name: "AppPlatformRoleMenus"); + + migrationBuilder.DropTable( + name: "AppPlatformUserFavoriteMenus"); + + migrationBuilder.DropTable( + name: "AppPlatformUserMenus"); + + migrationBuilder.DropTable( + name: "AppPlatformDatas"); + + migrationBuilder.DropTable( + name: "AppPlatformPackages"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/PlatformMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/PlatformMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..0e2d05916 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Migrations/PlatformMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,769 @@ +// +using System; +using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.Platform.DbMigrator.Migrations +{ + [DbContext(typeof(PlatformMigrationsDbContext))] + partial class PlatformMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorHostedService.cs new file mode 100644 index 000000000..3e75627e7 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.Platform.DbMigrator; + +public class PlatformDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public PlatformDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.Configure.cs new file mode 100644 index 000000000..ee39e7c28 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.Platform.DbMigrator; +public partial class PlatformDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.cs new file mode 100644 index 000000000..c43ee1274 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/PlatformDbMigratorModule.cs @@ -0,0 +1,29 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; +using LINGYUN.Platform.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.Platform.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(PlatformEntityFrameworkCoreModule), + typeof(AbpUINavigationVueVbenAdminModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class PlatformDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Program.cs new file mode 100644 index 000000000..55503bdb2 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.Platform.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.Platform.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.Platform.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..f8be836d8 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.Platform.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json new file mode 100644 index 000000000..e12143b82 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json @@ -0,0 +1,80 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageDbMigrationService.cs new file mode 100644 index 000000000..6beefd2d3 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; + +public class RealtimeMessageDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public RealtimeMessageDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new RealtimeMessageMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.RealtimeMessage.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs new file mode 100644 index 000000000..cc6f3ddff --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("RealtimeMessageDbMigrator")] +public class RealtimeMessageMigrationsDbContext : AbpDbContext +{ + public RealtimeMessageMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureMessageService(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs new file mode 100644 index 000000000..93744ecf1 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; + +public class RealtimeMessageMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public RealtimeMessageMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new RealtimeMessageMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj new file mode 100644 index 000000000..5d84ea8d8 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj @@ -0,0 +1,55 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs new file mode 100644 index 000000000..732f48480 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs @@ -0,0 +1,736 @@ +// +using System; +using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations +{ + [DbContext(typeof(RealtimeMessageMigrationsDbContext))] + [Migration("20230110023420_Initial-Realtime-Message")] + partial class InitialRealtimeMessage + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Age") + .HasColumnType("int"); + + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Birthday") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastOnlineTime") + .HasColumnType("datetime(6)"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Sex") + .HasColumnType("int"); + + b.Property("Sign") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Black") + .HasColumnType("tinyint(1)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("DontDisturb") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrientId") + .HasColumnType("char(36)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("RemarkName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SpecialFocus") + .HasColumnType("tinyint(1)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "FrientId"); + + b.ToTable("AppUserChatFriends", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AllowAddFriend") + .HasColumnType("tinyint(1)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowReceiveMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("RequireAddFriendValition") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("ReceiveUserId") + .HasColumnType("char(36)"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReceiveUserId"); + + b.ToTable("AppUserMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("AdminUserId") + .HasColumnType("char(36)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AvatarUrl") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MaxUserCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Notice") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Tag") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("AppChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("ShieldUserId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupChatBlacks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId", "UserId"); + + b.ToTable("AppUserChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsAdmin") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SilenceEnd") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserGroupCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Severity") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "NotificationName"); + + b.ToTable("AppNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionGroupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitionGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("NotificationLifetime") + .HasColumnType("int"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Providers") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("ReadStatus") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationId") + .HasDatabaseName("IX_Tenant_User_Notification_Id"); + + b.ToTable("AppUserNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasDefaultValue("/"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationName") + .IsUnique() + .HasDatabaseName("IX_Tenant_User_Notification_Name"); + + b.ToTable("AppUserSubscribes", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs new file mode 100644 index 000000000..7571152fb --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs @@ -0,0 +1,491 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations +{ + /// + public partial class InitialRealtimeMessage : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppChatGroups", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + AdminUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Tag = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Address = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Notice = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + MaxUserCount = table.Column(type: "int", nullable: false), + AllowAnonymous = table.Column(type: "tinyint(1)", nullable: false), + AllowSendMessage = table.Column(type: "tinyint(1)", nullable: false), + Description = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AvatarUrl = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppChatGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppGroupChatBlacks", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + GroupId = table.Column(type: "bigint", nullable: false), + ShieldUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppGroupChatBlacks", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppGroupMessages", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GroupId = table.Column(type: "bigint", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + MessageId = table.Column(type: "bigint", nullable: false), + SendUserName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", maxLength: 1048576, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "int", nullable: false), + Source = table.Column(type: "int", nullable: false), + State = table.Column(type: "tinyint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppGroupMessages", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppNotificationDefinitionGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResourceName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Localization = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AllowSubscriptionToClients = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppNotificationDefinitionGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppNotificationDefinitions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + GroupName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResourceName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Localization = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + NotificationLifetime = table.Column(type: "int", nullable: false), + NotificationType = table.Column(type: "int", nullable: false), + ContentType = table.Column(type: "int", nullable: false, defaultValue: 0), + Providers = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AllowSubscriptionToClients = table.Column(type: "tinyint(1)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppNotificationDefinitions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppNotifications", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Severity = table.Column(type: "tinyint", nullable: false), + Type = table.Column(type: "int", nullable: false), + ContentType = table.Column(type: "int", nullable: false, defaultValue: 0), + NotificationId = table.Column(type: "bigint", nullable: false), + NotificationName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + NotificationTypeName = table.Column(type: "varchar(512)", maxLength: 512, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExpirationTime = table.Column(type: "datetime(6)", nullable: true), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppNotifications", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserChatCards", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Sex = table.Column(type: "int", nullable: false), + Sign = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + NickName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AvatarUrl = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Birthday = table.Column(type: "datetime(6)", nullable: true), + Age = table.Column(type: "int", nullable: false), + LastOnlineTime = table.Column(type: "datetime(6)", nullable: true), + State = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserChatCards", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserChatFriends", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FrientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsStatic = table.Column(type: "tinyint(1)", nullable: false), + Black = table.Column(type: "tinyint(1)", nullable: false), + DontDisturb = table.Column(type: "tinyint(1)", nullable: false), + SpecialFocus = table.Column(type: "tinyint(1)", nullable: false), + RemarkName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "tinyint unsigned", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserChatFriends", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserChatGroups", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupId = table.Column(type: "bigint", nullable: false), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserChatGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserChatSettings", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + AllowAnonymous = table.Column(type: "tinyint(1)", nullable: false), + AllowAddFriend = table.Column(type: "tinyint(1)", nullable: false), + RequireAddFriendValition = table.Column(type: "tinyint(1)", nullable: false), + AllowReceiveMessage = table.Column(type: "tinyint(1)", nullable: false), + AllowSendMessage = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserChatSettings", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserGroupCards", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + NickName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsAdmin = table.Column(type: "tinyint(1)", nullable: false), + SilenceEnd = table.Column(type: "datetime(6)", nullable: true), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserGroupCards", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserMessages", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ReceiveUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + MessageId = table.Column(type: "bigint", nullable: false), + SendUserName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", maxLength: 1048576, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "int", nullable: false), + Source = table.Column(type: "int", nullable: false), + State = table.Column(type: "tinyint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserMessages", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserNotifications", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + NotificationId = table.Column(type: "bigint", nullable: false), + ReadStatus = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserNotifications", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppUserSubscribes", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, defaultValue: "/") + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + NotificationName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserSubscribes", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AppChatGroups_TenantId_Name", + table: "AppChatGroups", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AppGroupChatBlacks_TenantId_GroupId", + table: "AppGroupChatBlacks", + columns: new[] { "TenantId", "GroupId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppGroupMessages_TenantId_GroupId", + table: "AppGroupMessages", + columns: new[] { "TenantId", "GroupId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppNotifications_TenantId_NotificationName", + table: "AppNotifications", + columns: new[] { "TenantId", "NotificationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserChatCards_TenantId_UserId", + table: "AppUserChatCards", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserChatFriends_TenantId_UserId_FrientId", + table: "AppUserChatFriends", + columns: new[] { "TenantId", "UserId", "FrientId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserChatGroups_TenantId_GroupId_UserId", + table: "AppUserChatGroups", + columns: new[] { "TenantId", "GroupId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserChatSettings_TenantId_UserId", + table: "AppUserChatSettings", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserGroupCards_TenantId_UserId", + table: "AppUserGroupCards", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserMessages_TenantId_ReceiveUserId", + table: "AppUserMessages", + columns: new[] { "TenantId", "ReceiveUserId" }); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_User_Notification_Id", + table: "AppUserNotifications", + columns: new[] { "TenantId", "UserId", "NotificationId" }); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_User_Notification_Name", + table: "AppUserSubscribes", + columns: new[] { "TenantId", "UserId", "NotificationName" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppChatGroups"); + + migrationBuilder.DropTable( + name: "AppGroupChatBlacks"); + + migrationBuilder.DropTable( + name: "AppGroupMessages"); + + migrationBuilder.DropTable( + name: "AppNotificationDefinitionGroups"); + + migrationBuilder.DropTable( + name: "AppNotificationDefinitions"); + + migrationBuilder.DropTable( + name: "AppNotifications"); + + migrationBuilder.DropTable( + name: "AppUserChatCards"); + + migrationBuilder.DropTable( + name: "AppUserChatFriends"); + + migrationBuilder.DropTable( + name: "AppUserChatGroups"); + + migrationBuilder.DropTable( + name: "AppUserChatSettings"); + + migrationBuilder.DropTable( + name: "AppUserGroupCards"); + + migrationBuilder.DropTable( + name: "AppUserMessages"); + + migrationBuilder.DropTable( + name: "AppUserNotifications"); + + migrationBuilder.DropTable( + name: "AppUserSubscribes"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..2c3d93160 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,733 @@ +// +using System; +using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations +{ + [DbContext(typeof(RealtimeMessageMigrationsDbContext))] + partial class RealtimeMessageMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Age") + .HasColumnType("int"); + + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Birthday") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastOnlineTime") + .HasColumnType("datetime(6)"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Sex") + .HasColumnType("int"); + + b.Property("Sign") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Black") + .HasColumnType("tinyint(1)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("DontDisturb") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrientId") + .HasColumnType("char(36)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("RemarkName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SpecialFocus") + .HasColumnType("tinyint(1)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "FrientId"); + + b.ToTable("AppUserChatFriends", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AllowAddFriend") + .HasColumnType("tinyint(1)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowReceiveMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("RequireAddFriendValition") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("ReceiveUserId") + .HasColumnType("char(36)"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReceiveUserId"); + + b.ToTable("AppUserMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("AdminUserId") + .HasColumnType("char(36)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AvatarUrl") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MaxUserCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Notice") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Tag") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("AppChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("ShieldUserId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupChatBlacks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId", "UserId"); + + b.ToTable("AppUserChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsAdmin") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SilenceEnd") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserGroupCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Severity") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "NotificationName"); + + b.ToTable("AppNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionGroupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitionGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("NotificationLifetime") + .HasColumnType("int"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Providers") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("ReadStatus") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationId") + .HasDatabaseName("IX_Tenant_User_Notification_Id"); + + b.ToTable("AppUserNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasDefaultValue("/"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationName") + .IsUnique() + .HasDatabaseName("IX_Tenant_User_Notification_Name"); + + b.ToTable("AppUserSubscribes", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Program.cs new file mode 100644 index 000000000..0f34ac55f --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.RealtimeMessage.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..e1dc32b0b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.RealtimeMessage.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorHostedService.cs new file mode 100644 index 000000000..0200baae3 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.RealtimeMessage.DbMigrator; + +public class RealtimeMessageDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public RealtimeMessageDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.Configure.cs new file mode 100644 index 000000000..7e9875d32 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.RealtimeMessage.DbMigrator; +public partial class RealtimeMessageDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs new file mode 100644 index 000000000..9aecbb142 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs @@ -0,0 +1,27 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.RealtimeMessage.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpMessageServiceEntityFrameworkCoreModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class RealtimeMessageDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json new file mode 100644 index 000000000..e12143b82 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json @@ -0,0 +1,80 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj index ab8949116..0abfd0a7b 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj index 07f9fad38..aa3d12483 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/IndexInitializer.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/IndexInitializer.cs index fb59eee97..845a9fb54 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/IndexInitializer.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/IndexInitializer.cs @@ -37,8 +37,8 @@ namespace LINGYUN.Abp.AuditLogging.Elasticsearch public async virtual Task InitializeAsync() { var client = _clientFactory.Create(); - var dateTimeFormat = !_jsonOptions.DefaultDateTimeFormat.IsNullOrWhiteSpace() - ? $"{_jsonOptions.DefaultDateTimeFormat}||strict_date_optional_time||epoch_millis" + var dateTimeFormat = !_jsonOptions.OutputDateTimeFormat.IsNullOrWhiteSpace() + ? $"{_jsonOptions.OutputDateTimeFormat}||strict_date_optional_time||epoch_millis" : "strict_date_optional_time||epoch_millis"; var indexState = new IndexState { diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN.Abp.AuditLogging.EntityFrameworkCore.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN.Abp.AuditLogging.EntityFrameworkCore.csproj index 613b67f37..9bd1bd9e8 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN.Abp.AuditLogging.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN.Abp.AuditLogging.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Features/AuditingFeatureNames.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Features/AuditingFeatureNames.cs index 4685db1fc..8dd83769d 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Features/AuditingFeatureNames.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Features/AuditingFeatureNames.cs @@ -9,7 +9,9 @@ public const string AuditLog = Default + ".AuditLog"; - public const string SecurityLog = Default + ".SecurityLog"; + public const string SecurityLog = Default + ".SecurityLog"; + + public const string SystemLog = Default + ".SystemLog"; } } } diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionDefinitionProvider.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionDefinitionProvider.cs index 5ba5a7345..550ae8b04 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionDefinitionProvider.cs @@ -1,7 +1,8 @@ using Volo.Abp.AuditLogging.Localization; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Localization; - +using Volo.Abp.MultiTenancy; + namespace LINGYUN.Abp.Auditing.Permissions { public class AuditingPermissionDefinitionProvider : PermissionDefinitionProvider @@ -19,6 +20,11 @@ namespace LINGYUN.Abp.Auditing.Permissions name: AuditingPermissionNames.AuditLog.Delete, displayName: L("Permissions:DeleteLog")); + var sysLogPermission = auditingGroup.AddPermission( + name: AuditingPermissionNames.SystemLog.Default, + displayName: L("Permissions:SystemLog"), + multiTenancySide: MultiTenancySides.Host); + var securityLogPermission = auditingGroup.AddPermission( name: AuditingPermissionNames.SecurityLog.Default, displayName: L("Permissions:SecurityLog")); diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionNames.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionNames.cs index 2b0e148e6..b4f7724f7 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionNames.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/Permissions/AuditingPermissionNames.cs @@ -14,5 +14,10 @@ public const string Default = GroupName + ".SecurityLog"; public const string Delete = Default + ".Delete"; } + + public class SystemLog + { + public const string Default = GroupName + ".SystemLog"; + } } } diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj index 4b0a6a451..af429068d 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/Logging/LogAppService.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/Logging/LogAppService.cs index 9eb7f5af0..0959b4cb1 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/Logging/LogAppService.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/Logging/LogAppService.cs @@ -1,10 +1,16 @@ -using LINGYUN.Abp.Logging; +using LINGYUN.Abp.Auditing.Features; +using LINGYUN.Abp.Auditing.Permissions; +using LINGYUN.Abp.Logging; +using Microsoft.AspNetCore.Authorization; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; +using Volo.Abp.Features; namespace LINGYUN.Abp.Auditing.Logging { + [Authorize(AuditingPermissionNames.SystemLog.Default)] + [RequiresFeature(AuditingFeatureNames.Logging.SystemLog)] public class LogAppService : AuditingApplicationServiceBase, ILogAppService { private readonly ILoggingManager _manager; diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj index 87a9c957a..1c8fc3c92 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/AuditLogController.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/AuditLogController.cs index bd08ac7c3..9411cefe0 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/AuditLogController.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/AuditLogController.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using LINGYUN.Abp.Auditing.Permissions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; using Volo.Abp; @@ -11,6 +13,7 @@ namespace LINGYUN.Abp.Auditing.AuditLogs [Area("auditing")] [ControllerName("audit-log")] [Route("api/auditing/audit-log")] + [Authorize(AuditingPermissionNames.AuditLog.Default)] public class AuditLogController : AbpController, IAuditLogAppService { protected IAuditLogAppService AuditLogAppService { get; } @@ -22,6 +25,7 @@ namespace LINGYUN.Abp.Auditing.AuditLogs [HttpDelete] [Route("{id}")] + [Authorize(AuditingPermissionNames.AuditLog.Delete)] public async virtual Task DeleteAsync(Guid id) { await AuditLogAppService.DeleteAsync(id); diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/EntityChangesController.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/EntityChangesController.cs index 8d4369e97..fffea9658 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/EntityChangesController.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/EntityChangesController.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using LINGYUN.Abp.Auditing.Permissions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; using Volo.Abp; @@ -11,6 +13,7 @@ namespace LINGYUN.Abp.Auditing.AuditLogs; [Area("auditing")] [ControllerName("entity-changes")] [Route("api/auditing/entity-changes")] +[Authorize(AuditingPermissionNames.AuditLog.Default)] public class EntityChangesController : AbpControllerBase, IEntityChangesAppService { protected IEntityChangesAppService EntityChangeAppService { get; } diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/Logging/LogController.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/Logging/LogController.cs index aeaebf8ef..52ead46b0 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/Logging/LogController.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/Logging/LogController.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using LINGYUN.Abp.Auditing.Permissions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; @@ -10,6 +12,7 @@ namespace LINGYUN.Abp.Auditing.Logging [Area("auditing")] [ControllerName("logging")] [Route("api/auditing/logging")] + [Authorize(AuditingPermissionNames.SystemLog.Default)] public class LogController : AbpController, ILogAppService { private readonly ILogAppService _service; diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogController.cs b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogController.cs index 3d74d5618..35178057c 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogController.cs +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogController.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using LINGYUN.Abp.Auditing.Permissions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; using Volo.Abp; @@ -11,6 +13,7 @@ namespace LINGYUN.Abp.Auditing.SecurityLogs [Area("auditing")] [ControllerName("security-log")] [Route("api/auditing/security-log")] + [Authorize(AuditingPermissionNames.SecurityLog.Default)] public class SecurityLogController : AbpController, ISecurityLogAppService { protected ISecurityLogAppService SecurityLogAppService { get; } @@ -22,6 +25,7 @@ namespace LINGYUN.Abp.Auditing.SecurityLogs [HttpDelete] [Route("{id}")] + [Authorize(AuditingPermissionNames.SecurityLog.Delete)] public async virtual Task DeleteAsync(Guid id) { await SecurityLogAppService.DeleteAsync(id); diff --git a/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.QQ/LINGYUN.Abp.Authentication.QQ.csproj b/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.QQ/LINGYUN.Abp.Authentication.QQ.csproj index 1722a2e0a..34e4b737d 100644 --- a/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.QQ/LINGYUN.Abp.Authentication.QQ.csproj +++ b/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.QQ/LINGYUN.Abp.Authentication.QQ.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.WeChat/LINGYUN.Abp.Authentication.WeChat.csproj b/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.WeChat/LINGYUN.Abp.Authentication.WeChat.csproj index e112be904..22c00b9fb 100644 --- a/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.WeChat/LINGYUN.Abp.Authentication.WeChat.csproj +++ b/aspnet-core/modules/authentication/LINGYUN.Abp.Authentication.WeChat/LINGYUN.Abp.Authentication.WeChat.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.Application.Contracts/LINGYUN/Abp/CachingManagement/Permissions/CachingManagemenPermissionDefinitionProvider.cs b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.Application.Contracts/LINGYUN/Abp/CachingManagement/Permissions/CachingManagemenPermissionDefinitionProvider.cs index a9c901f54..1d45381f2 100644 --- a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.Application.Contracts/LINGYUN/Abp/CachingManagement/Permissions/CachingManagemenPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.Application.Contracts/LINGYUN/Abp/CachingManagement/Permissions/CachingManagemenPermissionDefinitionProvider.cs @@ -8,7 +8,9 @@ public class CachingManagemenPermissionDefinitionProvider : PermissionDefinition { public override void Define(IPermissionDefinitionContext context) { - var cachingManagerGroup = context.AddGroup(CachingManagementPermissionNames.GroupName, L("Permission:CachingManagement")); + var cachingManagerGroup = context.AddGroup( + CachingManagementPermissionNames.GroupName, + L("Permission:CachingManagement")); var cacheGroup = cachingManagerGroup.AddPermission(CachingManagementPermissionNames.Cache.Default, L("Permission:Caches")); cacheGroup.AddChild(CachingManagementPermissionNames.Cache.ManageValue, L("Permission:ManageValue")); diff --git a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj index f481b084b..29403a971 100644 --- a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj +++ b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.StackExchangeRedis/LINGYUN/Abp/CachingManagement/StackExchangeRedis/StackExchangeRedisCacheManager.cs b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.StackExchangeRedis/LINGYUN/Abp/CachingManagement/StackExchangeRedis/StackExchangeRedisCacheManager.cs index c29d8898a..dffea984d 100644 --- a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.StackExchangeRedis/LINGYUN/Abp/CachingManagement/StackExchangeRedis/StackExchangeRedisCacheManager.cs +++ b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.StackExchangeRedis/LINGYUN/Abp/CachingManagement/StackExchangeRedis/StackExchangeRedisCacheManager.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.StackExchangeRedis; using Microsoft.Extensions.Options; -using Newtonsoft.Json.Linq; using StackExchange.Redis; using System; using System.Collections.Generic; diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj index ddb1652d1..671afeaa8 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj @@ -4,7 +4,7 @@ Exe - net6.0 + net7.0 6.0.2 colin Use LINGYUN.MicroService.Templates command line diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN.Abp.Aliyun.SettingManagement.csproj b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN.Abp.Aliyun.SettingManagement.csproj index 13e098f2b..fe98d0827 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN.Abp.Aliyun.SettingManagement.csproj +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN.Abp.Aliyun.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj index bec2dcf28..4b6934b7c 100644 --- a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj +++ b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN.Abp.AspNetCore.HttpOverrides.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN.Abp.AspNetCore.HttpOverrides.csproj index 25c09976f..a9da9dcbd 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN.Abp.AspNetCore.HttpOverrides.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN.Abp.AspNetCore.HttpOverrides.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN.Abp.AspNetCore.Mvc.Client.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN.Abp.AspNetCore.Mvc.Client.csproj index fd82b5f86..a936933b5 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN.Abp.AspNetCore.Mvc.Client.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN.Abp.AspNetCore.Mvc.Client.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 Library false diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs index 5f1c77c24..e89dd6060 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/LINGYUN/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs @@ -24,20 +24,20 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Client protected IHttpClientProxy Proxy { get; } protected ICurrentUser CurrentUser { get; } protected IDistributedCache Cache { get; } - protected AbpAspNetCoreMvcClientCacheOptions Options { get; } + protected AbpAspNetCoreMvcClientCacheOptions MvcClientCacheOptions { get; } public MvcCachedApplicationConfigurationClient( IDistributedCache cache, IHttpClientProxy proxy, ICurrentUser currentUser, IHttpContextAccessor httpContextAccessor, - IOptions options) + IOptions mvcClientCacheOptions) { Proxy = proxy; CurrentUser = currentUser; HttpContextAccessor = httpContextAccessor; Cache = cache; - Options = options.Value; + MvcClientCacheOptions = mvcClientCacheOptions.Value; } public async Task GetAsync() @@ -52,12 +52,12 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Client configuration = await Cache.GetOrAddAsync( cacheKey, - async () => await Proxy.Service.GetAsync(), + async () => await Proxy.Service.GetAsync(new ApplicationConfigurationRequestOptions()), () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(CurrentUser.IsAuthenticated - ? Options.UserCacheExpirationSeconds - : Options.AnonymousCacheExpirationSeconds) + ? MvcClientCacheOptions.UserCacheExpirationSeconds + : MvcClientCacheOptions.AnonymousCacheExpirationSeconds) } ); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj index 019f6b8b2..ed6d3ec42 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj index 5443f06cc..4a80e7054 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj index 1cea1ce36..1d432ec82 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj index 314f386ec..8789a77c8 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN/Abp/Data/DbMigrator/DefaultDbSchemaMigrator.cs b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN/Abp/Data/DbMigrator/DefaultDbSchemaMigrator.cs index 2814099a8..07302a1f7 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN/Abp/Data/DbMigrator/DefaultDbSchemaMigrator.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN/Abp/Data/DbMigrator/DefaultDbSchemaMigrator.cs @@ -5,20 +5,24 @@ using Microsoft.Extensions.Options; using System; using System.Threading.Tasks; using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; using Volo.Abp.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Data.DbMigrator { public class DefaultDbSchemaMigrator : IDbSchemaMigrator, ITransientDependency { private readonly IServiceProvider _serviceProvider; + private readonly ICurrentTenant _currentTenant; private readonly AbpDbConnectionOptions _dbConnectionOptions; public DefaultDbSchemaMigrator( + ICurrentTenant currentTenant, IServiceProvider serviceProvider, IOptions dbConnectionOptions) { + _currentTenant = currentTenant; _serviceProvider = serviceProvider; _dbConnectionOptions = dbConnectionOptions.Value; } @@ -28,10 +32,21 @@ namespace LINGYUN.Abp.Data.DbMigrator where TDbContext : AbpDbContext { var connectionStringName = ConnectionStringNameAttribute.GetConnStringName(); - var connectionStringResolver = _serviceProvider - .GetRequiredService(); - var connectionString = await connectionStringResolver.ResolveAsync(connectionStringName); + string connectionString = null; + if (_currentTenant.IsAvailable) + { + var connectionStringResolver = _serviceProvider.GetRequiredService(); + connectionString = await connectionStringResolver.ResolveAsync(connectionStringName); + } + else + { + connectionString = _dbConnectionOptions.GetConnectionStringOrNull( + connectionStringName, + fallbackToDatabaseMappings: false, + fallbackToDefault: false); + } + var defaultConnectionString = _dbConnectionOptions.GetConnectionStringOrNull(connectionStringName); // 租户连接字符串与默认连接字符串相同,则不执行迁移脚本 if (string.Equals( @@ -42,6 +57,8 @@ namespace LINGYUN.Abp.Data.DbMigrator return; } + connectionString??= defaultConnectionString; + var dbContextBuilder = new DbContextOptionsBuilder(); using var dbContext = configureDbContext(connectionString, dbContextBuilder); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj index 014be2cb4..9d541763a 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 Cap分布式事件总线 true diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionHandlingModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionHandlingModule.cs index 401d60cd2..2bf8d81f9 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionHandlingModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionHandlingModule.cs @@ -1,6 +1,6 @@ -using LINGYUN.Abp.ExceptionHandling.Emailing.Localization; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Emailing; +using Volo.Abp.ExceptionHandling.Localization; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -26,7 +26,7 @@ namespace LINGYUN.Abp.ExceptionHandling.Emailing Configure(options => { options.Resources - .Add("en") + .Get() .AddVirtualJson("/LINGYUN/Abp/ExceptionHandling/Emailing/Localization/Resources"); }); } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionSubscriber.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionSubscriber.cs index 163a7f605..d2213048b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionSubscriber.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/AbpEmailingExceptionSubscriber.cs @@ -1,11 +1,11 @@ -using LINGYUN.Abp.ExceptionHandling.Emailing.Localization; -using LINGYUN.Abp.ExceptionHandling.Emailing.Templates; +using LINGYUN.Abp.ExceptionHandling.Emailing.Templates; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using System; using System.Threading.Tasks; using Volo.Abp.Emailing; +using Volo.Abp.ExceptionHandling.Localization; using Volo.Abp.TextTemplating; namespace LINGYUN.Abp.ExceptionHandling.Emailing @@ -22,7 +22,7 @@ namespace LINGYUN.Abp.ExceptionHandling.Emailing IServiceScopeFactory serviceScopeFactory, IOptions options, IOptions emailOptions, - IStringLocalizer stringLocalizer) + IStringLocalizer stringLocalizer) : base(serviceScopeFactory, options) { EmailSender = emailSender; diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Localization/ExceptionHandlingResource.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Localization/ExceptionHandlingResource.cs deleted file mode 100644 index a6100a7f3..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Localization/ExceptionHandlingResource.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Volo.Abp.Localization; - -namespace LINGYUN.Abp.ExceptionHandling.Emailing.Localization -{ - [LocalizationResourceName("AbpExceptionHandlingEmailing")] - public class ExceptionHandlingResource - { - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Templates/ExceptionHandlingTemplateDefinitionProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Templates/ExceptionHandlingTemplateDefinitionProvider.cs index 60738bbde..3079cfaf6 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Templates/ExceptionHandlingTemplateDefinitionProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN/Abp/ExceptionHandling/Emailing/Templates/ExceptionHandlingTemplateDefinitionProvider.cs @@ -1,4 +1,4 @@ -using LINGYUN.Abp.ExceptionHandling.Emailing.Localization; +using Volo.Abp.ExceptionHandling.Localization; using Volo.Abp.Localization; using Volo.Abp.TextTemplating; @@ -11,7 +11,7 @@ namespace LINGYUN.Abp.ExceptionHandling.Emailing.Templates context.Add( new TemplateDefinition( ExceptionHandlingTemplates.SendEmail, - displayName: LocalizableString.Create("TextTemplate:ExceptionHandlingTemplates.SendEmail"), + displayName: LocalizableString.Create("TextTemplate:ExceptionHandlingTemplates.SendEmail"), defaultCultureName: "en" ).WithVirtualFilePath("/LINGYUN/Abp/ExceptionHandling/Emailing/Templates/SendEmail", false) ); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj index c137f1b1b..7666654f6 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/AbpExceptionHandlingModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/AbpExceptionHandlingModule.cs index 17823f27a..6352a4e46 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/AbpExceptionHandlingModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/AbpExceptionHandlingModule.cs @@ -1,18 +1,11 @@ -using LINGYUN.Abp.ExceptionHandling.Localization; -using Volo.Abp.Localization; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; +using VoloAbpExceptionHandlingModule = Volo.Abp.ExceptionHandling.AbpExceptionHandlingModule +; namespace LINGYUN.Abp.ExceptionHandling { - [DependsOn(typeof(AbpLocalizationModule))] + [DependsOn(typeof(VoloAbpExceptionHandlingModule))] public class AbpExceptionHandlingModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.Resources.Add("en"); - }); - } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/Localization/ExceptionHandlingResource.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/Localization/ExceptionHandlingResource.cs deleted file mode 100644 index 4eba5b5fa..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN/Abp/ExceptionHandling/Localization/ExceptionHandlingResource.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Volo.Abp.Localization; - -namespace LINGYUN.Abp.ExceptionHandling.Localization -{ - [LocalizationResourceName("AbpExceptionHandling")] - public class ExceptionHandlingResource - { - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN/Abp/Features/LimitValidation/FeaturesLimitValidationInterceptor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN/Abp/Features/LimitValidation/FeaturesLimitValidationInterceptor.cs index 1f1e1786d..d041e561d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN/Abp/Features/LimitValidation/FeaturesLimitValidationInterceptor.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN/Abp/Features/LimitValidation/FeaturesLimitValidationInterceptor.cs @@ -37,7 +37,7 @@ namespace LINGYUN.Abp.Features.LimitValidation return; } - var limitFeature = GetRequiresLimitFeature(invocation.Method); + var limitFeature = await GetRequiresLimitFeature(invocation.Method); if (limitFeature == null) { @@ -74,20 +74,20 @@ namespace LINGYUN.Abp.Features.LimitValidation await _limitFeatureChecker.ProcessAsync(context); } - protected virtual RequiresLimitFeatureAttribute GetRequiresLimitFeature(MethodInfo methodInfo) + protected async virtual Task GetRequiresLimitFeature(MethodInfo methodInfo) { var limitFeature = methodInfo.GetCustomAttribute(false); if (limitFeature != null) { // 限制次数定义的不是范围参数,则不参与限制功能 - var featureLimitDefinition = _featureDefinitionManager.GetOrNull(limitFeature.LimitFeature); + var featureLimitDefinition = await _featureDefinitionManager.GetOrNullAsync(limitFeature.LimitFeature); if (featureLimitDefinition == null || !typeof(NumericValueValidator).IsAssignableFrom(featureLimitDefinition.ValueType.Validator.GetType())) { return null; } // 时长刻度定义的不是范围参数,则不参与限制功能 - var featureIntervalDefinition = _featureDefinitionManager.GetOrNull(limitFeature.IntervalFeature); + var featureIntervalDefinition = await _featureDefinitionManager.GetOrNullAsync(limitFeature.IntervalFeature); if (featureIntervalDefinition == null || !typeof(NumericValueValidator).IsAssignableFrom(featureIntervalDefinition.ValueType.Validator.GetType())) { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj index 2e5e3af2f..80c1924e8 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj index 918d7a557..872228d9a 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj @@ -10,19 +10,17 @@ - - + - - + - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs index cc2dc5991..2979d0bfa 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Polly; using System; -using Volo.Abp.Json; +using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -12,7 +12,7 @@ namespace LINGYUN.Abp.Location.Baidu { [DependsOn( typeof(AbpLocationModule), - typeof(AbpJsonModule), + typeof(AbpJsonNewtonsoftModule), typeof(AbpThreadingModule))] public class AbpBaiduLocationModule : AbpModule { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj index fffa982bf..99fe956e9 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj @@ -10,19 +10,17 @@ - - + - - + - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs index 8e918b6c8..6e121cc39 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Polly; using System; -using Volo.Abp.Json; +using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -12,7 +12,7 @@ namespace LINGYUN.Abp.Location.Tencent { [DependsOn( typeof(AbpLocationModule), - typeof(AbpJsonModule), + typeof(AbpJsonNewtonsoftModule), typeof(AbpThreadingModule))] public class AbpTencentLocationModule : AbpModule { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/AbpNotificationsOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/AbpNotificationsOptions.cs index 2cb0cd92b..1cc4209e7 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/AbpNotificationsOptions.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/AbpNotificationsOptions.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Collections; +using System.Collections.Generic; +using Volo.Abp.Collections; namespace LINGYUN.Abp.Notifications { @@ -9,9 +10,16 @@ namespace LINGYUN.Abp.Notifications /// public ITypeList DefinitionProviders { get; } + public HashSet DeletedNotifications { get; } + + public HashSet DeletedNotificationGroups { get; } + public AbpNotificationsOptions() { DefinitionProviders = new TypeList(); + + DeletedNotifications = new HashSet(); + DeletedNotificationGroups = new HashSet(); } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs index a50394c19..031557e1a 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs @@ -30,7 +30,9 @@ namespace LINGYUN.Abp.Notifications public ILocalizableString Description { get; set; } public bool AllowSubscriptionToClients { get; set; } public IReadOnlyList Notifications => _notifications.ToImmutableList(); - private readonly List _notifications; + private readonly List _notifications; + + public Dictionary Properties { get; } public static NotificationGroupDefinition Create( string name, @@ -49,7 +51,9 @@ namespace LINGYUN.Abp.Notifications DisplayName = displayName ?? new FixedLocalizableString(Name); AllowSubscriptionToClients = allowSubscriptionToClients; - _notifications = new List(); + _notifications = new List(); + + Properties = new Dictionary(); } public virtual NotificationDefinition AddNotification( diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs index 8e6306932..178f5505f 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs @@ -68,17 +68,19 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider { var titleInfo = notification.Data.TryGetData("title").As(); var titleResource = GetResource(titleInfo.ResourceName); - var title = LocalizerFactory.Create(titleResource.ResourceType)[titleInfo.Name, titleInfo.Values].Value; + var titleLocalizer = await LocalizerFactory.CreateByResourceNameAsync(titleResource.ResourceName); + var title = titleLocalizer[titleInfo.Name, titleInfo.Values].Value; var messageInfo = notification.Data.TryGetData("message").As(); var messageResource = GetResource(messageInfo.ResourceName); - var message = LocalizerFactory.Create(messageResource.ResourceType)[messageInfo.Name, messageInfo.Values].Value; + var messageLocalizer = await LocalizerFactory.CreateByResourceNameAsync(messageResource.ResourceName); + var message = messageLocalizer[messageInfo.Name, messageInfo.Values].Value; await EmailSender.SendAsync(emailAddress, title, message); } } - private LocalizationResource GetResource(string resourceName) + private LocalizationResourceBase GetResource(string resourceName) { return LocalizationOptions.Resources.Values .First(x => x.ResourceName.Equals(resourceName)); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj index c74ae9328..1b0109d20 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj index 0d406ce01..e7a40c2f2 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj @@ -17,8 +17,8 @@ + - diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationsModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationsModule.cs index c724ed22d..2e7db907f 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationsModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationsModule.cs @@ -4,8 +4,6 @@ using LINGYUN.Abp.RealTime; using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundWorkers; using Volo.Abp.EventBus; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.TextTemplating; @@ -19,7 +17,6 @@ namespace LINGYUN.Abp.Notifications typeof(AbpBackgroundWorkersModule), typeof(AbpBackgroundJobsAbstractionsModule), typeof(AbpIdGeneratorModule), - typeof(AbpJsonModule), typeof(AbpLocalizationModule), typeof(AbpRealTimeModule), typeof(AbpEventBusModule), @@ -39,11 +36,6 @@ namespace LINGYUN.Abp.Notifications .Get() .AddVirtualJson("/LINGYUN/Abp/Notifications/Localization/Resources"); }); - - Configure(options => - { - options.UnsupportedTypes.Add(); - }); } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/Newtonsoft/Json/HexLongConverter.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/Newtonsoft/Json/HexLongConverter.cs deleted file mode 100644 index e28c43cda..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/Newtonsoft/Json/HexLongConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace Newtonsoft.Json -{ - public class HexLongConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - long v = value is ulong ? (long)(ulong)value : (long)value; - writer.WriteValue(v.ToString()); - } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - string value = reader.Value as string; - long lValue = long.Parse(value); - return typeof(ulong) == objectType ? (object)(ulong)lValue : lValue; - } - public override bool CanConvert(Type objectType) - { - switch (objectType.FullName) - { - case "System.Int64": - case "System.UInt64": - return true; - default: - return false; - } - } - } -} diff --git a/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj index 10d254e7b..35ae683fb 100644 --- a/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj +++ b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj index 658e83ed0..8bf38a334 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj index e3b5db94d..761479d64 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj index bf40da9e6..6b029c51b 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj index a1eaeaf19..a3057ba35 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj index d65383c68..66fa1d3c6 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj index 754b51ba4..2ebeb6d4f 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj index 6af99b359..c111e93aa 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj index 89c8c06d8..a436b72e3 100644 --- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj @@ -4,8 +4,8 @@ - net6.0 - 9.0 + net7.0 + latest diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj index 887eddbf2..ebdf68818 100644 --- a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobActivity.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobActivity.cs index 918831dde..bce3acfed 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobActivity.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobActivity.cs @@ -1,12 +1,13 @@ -using Elsa.Services; +using Elsa.Attributes; using Volo.Abp.BlobStoring; -using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; -public abstract class BlobActivity : Activity +public abstract class BlobActivity : AbpActivity { - protected ICurrentTenant CurrentTenant; + [ActivityInput(Hint = "Path of the blob.")] + public string Path { get; set; } + protected IBlobContainer BlobContainer; protected BlobActivity(IBlobContainer blobContainer) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs index 36276f3c8..551b3958a 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs @@ -13,15 +13,12 @@ namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; Outcomes = new[] { OutcomeNames.True, OutcomeNames.False })] public class BlobExists : BlobActivity { - [ActivityInput(Hint = "Path of the oss.")] - public string? Path { get; set; } - public BlobExists(IBlobContainer blobContainer) : base(blobContainer) { } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { var exists = await BlobContainer.ExistsAsync(Path, context.CancellationToken); if (exists) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs index 4c163d412..bec05b7fa 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs @@ -13,15 +13,12 @@ namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; Outcomes = new[] { OutcomeNames.Done })] public class DeleteBlob : BlobActivity { - [ActivityInput(Hint = "Path of the blob to be deleted.")] - public string? Path { get; set; } - public DeleteBlob(IBlobContainer blobContainer) : base(blobContainer) { } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { await BlobContainer.DeleteAsync(Path, context.CancellationToken); diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs index b3893bbe6..42d345c56 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs @@ -13,9 +13,6 @@ namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; Outcomes = new[] { OutcomeNames.Done })] public class ReadBlob : BlobActivity { - [ActivityInput(Hint = "Path of the blob.")] - public string? Path { get; set; } - [ActivityOutput] public byte[]? Output { get; set; } @@ -24,7 +21,7 @@ public class ReadBlob : BlobActivity { } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { Output = await BlobContainer.GetAllBytesAsync(Path, context.CancellationToken); diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs index 6c70f5531..21a99c7e5 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs @@ -14,21 +14,21 @@ namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; Outcomes = new[] { OutcomeNames.Done })] public class WriteBlob : BlobActivity { - [ActivityInput(Hint = "Path of the blob.")] - public string? Path { get; set; } - [ActivityInput(Hint = "Blob exists whether overwrite")] public bool Overwrite { get; set; } - [ActivityInput(Hint = "The bytes to write.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, DefaultSyntax = SyntaxNames.JavaScript)] - public byte[]? Bytes { get; set; } + [ActivityInput( + Hint = "The bytes to write.", + SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, + DefaultSyntax = SyntaxNames.JavaScript)] + public byte[] Bytes { get; set; } public WriteBlob(IBlobContainer blobContainer) : base(blobContainer) { } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { await BlobContainer.SaveAsync(Path, Bytes, Overwrite, context.CancellationToken); diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityBuilderExtensions.cs new file mode 100644 index 000000000..32f199794 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityBuilderExtensions.cs @@ -0,0 +1,35 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; +public static class BlobActivityBuilderExtensions +{ + public static IActivityBuilder BlobExists( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); + + public static IActivityBuilder DeleteBlob( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); + + public static IActivityBuilder ReadBlob( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); + + public static IActivityBuilder WriteBlob( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityExtensions.cs new file mode 100644 index 000000000..80d55f939 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/BlobActivityExtensions.cs @@ -0,0 +1,25 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +public static class BlobActivityExtensions +{ + public static ISetupActivity WithPath( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Path, value); + + public static ISetupActivity WithPath( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Path, value); + + public static ISetupActivity WithPath( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Path, value); + + public static ISetupActivity WithPath( + this ISetupActivity activity, + string? value) => activity.Set(x => x.Path, value); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/WriteBlobExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/WriteBlobExtensions.cs new file mode 100644 index 000000000..bbeda6026 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Extensions/WriteBlobExtensions.cs @@ -0,0 +1,40 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; +public static class WriteBlobExtensions +{ + public static ISetupActivity WithOverwrite( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Overwrite, value); + + public static ISetupActivity WithOverwrite( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Overwrite, value); + + public static ISetupActivity WithOverwrite( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Overwrite, value); + + public static ISetupActivity WithOverwrite( + this ISetupActivity activity, + bool value) => activity.Set(x => x.Overwrite, value); + + public static ISetupActivity WithBytes( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Bytes, value); + + public static ISetupActivity WithBytes( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Bytes, value); + + public static ISetupActivity WithBytes( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Bytes, value); + + public static ISetupActivity WithBytes( + this ISetupActivity activity, + byte[]? value) => activity.Set(x => x.Bytes, value); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Activities/SendEmailing.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Activities/SendEmailing.cs index 376326e6b..24f78161b 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Activities/SendEmailing.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Activities/SendEmailing.cs @@ -25,7 +25,7 @@ namespace LINGYUN.Abp.Elsa.Activities.Emailing; Category = "Emailing", Description = "Send an email message.", Outcomes = new[] { OutcomeNames.Done })] -public class SendEmailing : Activity +public class SendEmailing : AbpActivity { private readonly IEmailSender _emailSender; private readonly ITemplateRenderer _templateRenderer; @@ -61,7 +61,7 @@ public class SendEmailing : Activity )] public object? Model { get; set; } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { var to = To.JoinAsString(";"); var content = Body; diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingBuilderExtensions.cs new file mode 100644 index 000000000..f8fa0d876 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingBuilderExtensions.cs @@ -0,0 +1,14 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.Emailing; +public static class SendEmailingBuilderExtensions +{ + public static IActivityBuilder SendEmailing( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingExtensions.cs new file mode 100644 index 000000000..1e0dff361 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Emailing/LINGYUN/Abp/Elsa/Activities/Emailing/Extensions/SendEmailingExtensions.cs @@ -0,0 +1,106 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.Emailing; + +public static class SendEmailingExtensions +{ + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func>> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + ICollection value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithSubject( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Subject, value); + + public static ISetupActivity WithSubject( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Subject, value); + + public static ISetupActivity WithSubject( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Subject, value); + + public static ISetupActivity WithSubject( + this ISetupActivity activity, + string? value) => activity.Set(x => x.Subject, value); + + public static ISetupActivity WithBody( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Body, value); + + public static ISetupActivity WithBody( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Body, value); + + public static ISetupActivity WithBody( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Body, value); + + public static ISetupActivity WithBody( + this ISetupActivity activity, + string? value) => activity.Set(x => x.Body, value); + + public static ISetupActivity WithCulture( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Culture, value); + + public static ISetupActivity WithCulture( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Culture, value); + + public static ISetupActivity WithCulture( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Culture, value); + + public static ISetupActivity WithCulture( + this ISetupActivity activity, + string? value) => activity.Set(x => x.Culture, value); + + public static ISetupActivity WithTemplate( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Template, value); + + public static ISetupActivity WithTemplate( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Template, value); + + public static ISetupActivity WithTemplate( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Template, value); + + public static ISetupActivity WithTemplate( + this ISetupActivity activity, + string? value) => activity.Set(x => x.Template, value); + + public static ISetupActivity WithModel( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Model, value); + + public static ISetupActivity WithModel( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Model, value); + + public static ISetupActivity WithModel( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Model, value); + + public static ISetupActivity WithModel( + this ISetupActivity activity, + object? value) => activity.Set(x => x.Model, value); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Activities/SendMessage.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Activities/SendMessage.cs index f1393d0c5..870f42904 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Activities/SendMessage.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Activities/SendMessage.cs @@ -1,11 +1,11 @@ using Elsa; using Elsa.ActivityResults; using Elsa.Attributes; -using Elsa.Services; using Elsa.Services.Models; using LINGYUN.Abp.IM.Messages; using System; using System.Threading.Tasks; +using Volo.Abp.MultiTenancy; using Volo.Abp.Timing; namespace LINGYUN.Abp.Elsa.Activities.IM; @@ -14,7 +14,7 @@ namespace LINGYUN.Abp.Elsa.Activities.IM; Category = "Message", Description = "Send an message.", Outcomes = new[] { OutcomeNames.Done })] -public class SendMessage : Activity +public class SendMessage : AbpActivity { private readonly IClock _clock; private readonly IMessageSender _messageSender; @@ -50,10 +50,10 @@ public class SendMessage : Activity } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { ChatMessage? chatMessage = null; - var tenantId = context.GetTenantId(); + var currentTenant = context.GetService(); if (!GroupId.IsNullOrWhiteSpace()) { @@ -66,7 +66,7 @@ public class SendMessage : Activity false, MessageType.Text, MessageSourceType.User, - tenantId); + currentTenant.Id); } else if (To.HasValue) { @@ -79,7 +79,7 @@ public class SendMessage : Activity false, MessageType.Text, MessageSourceType.User, - tenantId); + currentTenant.Id); } if (chatMessage != null) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageBuilderExtensions.cs new file mode 100644 index 000000000..2783087fe --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageBuilderExtensions.cs @@ -0,0 +1,14 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.IM; +public static class SendEmailingBuilderExtensions +{ + public static IActivityBuilder SendMessage( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageExtensions.cs new file mode 100644 index 000000000..198acd6bd --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.IM/LINGYUN/Abp/Elsa/Activities/IM/Extensions/SendMessageExtensions.cs @@ -0,0 +1,88 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.IM; +public static class SendMessageExtensions +{ + public static ISetupActivity WithContent( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Content, value!); + + public static ISetupActivity WithContent( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Content, value!); + + public static ISetupActivity WithContent( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Content, value!); + + public static ISetupActivity WithContent( + this ISetupActivity activity, + string value) => activity.Set(x => x.Content, value!); + + public static ISetupActivity WithFormUser( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.FormUser, value!); + + public static ISetupActivity WithFormUser( + this ISetupActivity activity, + Func value) => activity.Set(x => x.FormUser, value!); + + public static ISetupActivity WithFormUser( + this ISetupActivity activity, + Func value) => activity.Set(x => x.FormUser, value!); + + public static ISetupActivity WithFormUser( + this ISetupActivity activity, + Guid value) => activity.Set(x => x.FormUser, value!); + + public static ISetupActivity WithFormUserName( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.FormUserName, value); + + public static ISetupActivity WithFormUserName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.FormUserName, value); + + public static ISetupActivity WithFormUserName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.FormUserName, value); + + public static ISetupActivity WithFormUserName( + this ISetupActivity activity, + string? value) => activity.Set(x => x.FormUserName, value); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func value) => activity.Set(x => x.To, value); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func value) => activity.Set(x => x.To, value); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Guid? value) => activity.Set(x => x.To, value); + + public static ISetupActivity WithGroupId( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.GroupId, value); + + public static ISetupActivity WithGroupId( + this ISetupActivity activity, + Func value) => activity.Set(x => x.GroupId, value); + + public static ISetupActivity WithGroupId( + this ISetupActivity activity, + Func value) => activity.Set(x => x.GroupId, value); + + public static ISetupActivity WithGroupId( + this ISetupActivity activity, + string? value) => activity.Set(x => x.GroupId, value); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Activities/SendNotification.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Activities/SendNotification.cs index a765ce0ca..1de561e7a 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Activities/SendNotification.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Activities/SendNotification.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Elsa.Activities.Notifications; @@ -18,7 +19,7 @@ namespace LINGYUN.Abp.Elsa.Activities.Notifications; Category = "Notification", Description = "Send an notification.", Outcomes = new[] { OutcomeNames.Done })] -public class SendNotification : Activity +public class SendNotification : AbpActivity { private readonly INotificationSender _notificationSender; @@ -53,9 +54,9 @@ public class SendNotification : Activity } - protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + protected async override ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) { - var tenantId = context.GetTenantId(); + var currentTenant = context.GetService(); switch (NotificationData) { case NotificationData data: @@ -63,7 +64,7 @@ public class SendNotification : Activity NotificationName, data, GetUserIdentifiers(), - tenantId, + currentTenant.Id, Severity); return Done(); case NotificationTemplate template: @@ -71,7 +72,7 @@ public class SendNotification : Activity NotificationName, template, GetUserIdentifiers(), - tenantId, + currentTenant.Id, Severity); return Done(); } diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationBuilderExtensions.cs new file mode 100644 index 000000000..3f319ca69 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationBuilderExtensions.cs @@ -0,0 +1,14 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.Notifications; +public static class SendNotificationBuilderExtensions +{ + public static IActivityBuilder SendNotification( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationExtensions.cs new file mode 100644 index 000000000..5abc412bc --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Notifications/LINGYUN/Abp/Elsa/Activities/Notifications/Extensions/SendNotificationExtensions.cs @@ -0,0 +1,74 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using LINGYUN.Abp.Notifications; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.Notifications; +public static class SendNotificationExtensions +{ + public static ISetupActivity WithNotificationName( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.NotificationName, value!); + + public static ISetupActivity WithNotificationName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.NotificationName, value!); + + public static ISetupActivity WithNotificationName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.NotificationName, value!); + + public static ISetupActivity WithNotificationName( + this ISetupActivity activity, + string value) => activity.Set(x => x.NotificationName, value!); + + public static ISetupActivity WithNotificationData( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.NotificationData, value!); + + public static ISetupActivity WithNotificationData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.NotificationData, value!); + + public static ISetupActivity WithNotificationData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.NotificationData, value!); + + public static ISetupActivity WithNotificationData( + this ISetupActivity activity, + object value) => activity.Set(x => x.NotificationData, value!); + + public static ISetupActivity WithSeverity( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Severity, value!); + + public static ISetupActivity WithSeverity( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Severity, value!); + + public static ISetupActivity WithSeverity( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Severity, value!); + + public static ISetupActivity WithSeverity( + this ISetupActivity activity, + NotificationSeverity value) => activity.Set(x => x.Severity, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func>> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + ICollection value) => activity.Set(x => x.To, value!); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsBuilderExtensions.cs new file mode 100644 index 000000000..82999f892 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsBuilderExtensions.cs @@ -0,0 +1,14 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.Sms; +public static class SendSmsBuilderExtensions +{ + public static IActivityBuilder SendSms( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsExtensions.cs new file mode 100644 index 000000000..1d35848bc --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Sms/LINGYUN/Abp/Elsa/Activities/Sms/Extensions/SendSmsExtensions.cs @@ -0,0 +1,57 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.Sms; +public static class SendSmsExtensions +{ + public static ISetupActivity WithMessage( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Message, value!); + + public static ISetupActivity WithMessage( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Message, value!); + + public static ISetupActivity WithMessage( + this ISetupActivity activity, + Func value) => activity.Set(x => x.Message, value!); + + public static ISetupActivity WithMessage( + this ISetupActivity activity, + string value) => activity.Set(x => x.Message, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func>> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithTo( + this ISetupActivity activity, + ICollection value) => activity.Set(x => x.To, value!); + + public static ISetupActivity WithProperties( + this ISetupActivity activity, + Func>> value) => activity.Set(x => x.Properties, value!); + + public static ISetupActivity WithProperties( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Properties, value!); + + public static ISetupActivity WithProperties( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Properties, value!); + + public static ISetupActivity WithProperties( + this ISetupActivity activity, + Dictionary value) => activity.Set(x => x.Properties, value!); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookBuilderExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookBuilderExtensions.cs new file mode 100644 index 000000000..a60d2efc3 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookBuilderExtensions.cs @@ -0,0 +1,14 @@ +using Elsa.Builders; +using System; +using System.Runtime.CompilerServices; + +namespace LINGYUN.Abp.Elsa.Activities.Webhooks; +public static class PublishWebhookBuilderExtensions +{ + public static IActivityBuilder PublishWebhook( + this IBuilder builder, + Action>? setup, + [CallerLineNumber] int lineNumber = default, + [CallerFilePath] string? sourceFile = default) => + builder.Then(setup, null, lineNumber, sourceFile); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookExtensions.cs new file mode 100644 index 000000000..c62bda087 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Extensions/PublishWebhookExtensions.cs @@ -0,0 +1,89 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa.Activities.Webhooks; +public static class PublishWebhookExtensions +{ + public static ISetupActivity WithWebhooName( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.WebhooName, value!); + + public static ISetupActivity WithWebhooName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.WebhooName, value!); + + public static ISetupActivity WithWebhooName( + this ISetupActivity activity, + Func value) => activity.Set(x => x.WebhooName, value!); + + public static ISetupActivity WithWebhooName( + this ISetupActivity activity, + string value) => activity.Set(x => x.WebhooName, value!); + + public static ISetupActivity WithWebhookData( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.WebhookData, value!); + + public static ISetupActivity WithWebhookData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.WebhookData, value!); + + public static ISetupActivity WithWebhookData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.WebhookData, value!); + + public static ISetupActivity WithWebhookData( + this ISetupActivity activity, + object value) => activity.Set(x => x.WebhookData, value!); + + public static ISetupActivity WithSendExactSameData( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.SendExactSameData, value!); + + public static ISetupActivity WithSendExactSameData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.SendExactSameData, value!); + + public static ISetupActivity WithSendExactSameData( + this ISetupActivity activity, + Func value) => activity.Set(x => x.SendExactSameData, value!); + + public static ISetupActivity WithSendExactSameData( + this ISetupActivity activity, + bool value) => activity.Set(x => x.SendExactSameData, value!); + + public static ISetupActivity WithUseOnlyGivenHeaders( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.UseOnlyGivenHeaders, value!); + + public static ISetupActivity WithUseOnlyGivenHeaders( + this ISetupActivity activity, + Func value) => activity.Set(x => x.UseOnlyGivenHeaders, value!); + + public static ISetupActivity WithUseOnlyGivenHeaders( + this ISetupActivity activity, + Func value) => activity.Set(x => x.UseOnlyGivenHeaders, value!); + + public static ISetupActivity WithUseOnlyGivenHeaders( + this ISetupActivity activity, + bool value) => activity.Set(x => x.UseOnlyGivenHeaders, value!); + + public static ISetupActivity WithHeaders( + this ISetupActivity activity, + Func>> value) => activity.Set(x => x.Headers, value!); + + public static ISetupActivity WithHeaders( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Headers, value!); + + public static ISetupActivity WithHeaders( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.Headers, value!); + + public static ISetupActivity WithHeaders( + this ISetupActivity activity, + IDictionary value) => activity.Set(x => x.Headers, value!); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj index d5eb83291..0120c8e82 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj index c3debf680..adc53c824 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Server/LINGYUN.Abp.Elsa.Server.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Server/LINGYUN.Abp.Elsa.Server.csproj index 40a9254b0..9498cf6c4 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Server/LINGYUN.Abp.Elsa.Server.csproj +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Server/LINGYUN.Abp.Elsa.Server.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivity.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivity.cs new file mode 100644 index 000000000..1427a91c4 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivity.cs @@ -0,0 +1,43 @@ +using Elsa.ActivityResults; +using Elsa.Attributes; +using Elsa.Services; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.Elsa; + +public abstract class AbpActivity : Activity, IMultiTenantActivitySupport +{ + [ActivityInput(Hint = "The tenant id.")] + public Guid? TenantId { get; set; } + + protected override ValueTask OnCanExecuteAsync(ActivityExecutionContext context) + { + var currentTenant = context.GetService(); + using (currentTenant.Change(TenantId ?? context.GetTenantId() ?? currentTenant.Id)) + { + return OnActivitCanExecuteAsync(context); + } + } + + protected override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + var currentTenant = context.GetService(); + using (currentTenant.Change(TenantId ?? context.GetTenantId() ?? currentTenant.Id)) + { + return OnActivitExecuteAsync(context); + } + } + + protected virtual ValueTask OnActivitCanExecuteAsync(ActivityExecutionContext context) + { + return new ValueTask(OnCanExecute(context)); + } + + protected virtual ValueTask OnActivitExecuteAsync(ActivityExecutionContext context) + { + return new ValueTask(OnExecute(context)); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivityExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivityExtensions.cs new file mode 100644 index 000000000..ab8cb5fa4 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpActivityExtensions.cs @@ -0,0 +1,25 @@ +using Elsa.Builders; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Elsa; + +public static class AbpActivityExtensions +{ + public static ISetupActivity WithTenantId( + this ISetupActivity activity, + Func> value) => activity.Set(x => x.TenantId, value); + + public static ISetupActivity WithTenantId( + this ISetupActivity activity, + Func value) => activity.Set(x => x.TenantId, value); + + public static ISetupActivity WithTenantId( + this ISetupActivity activity, + Func value) => activity.Set(x => x.TenantId, value); + + public static ISetupActivity WithTenantId( + this ISetupActivity activity, + Guid? value) => activity.Set(x => x.TenantId, value); +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpElsaModule.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpElsaModule.cs index 2ddeadf17..eb880bee3 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpElsaModule.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/AbpElsaModule.cs @@ -3,13 +3,8 @@ using Elsa.Services; using LINGYUN.Abp.Elsa.Localization; using LINGYUN.Abp.Elsa.Scripting.JavaScript; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Linq; using Volo.Abp.Features; using Volo.Abp.Json; -using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -33,17 +28,17 @@ public class AbpElsaModule : AbpModule options.AddCustomTenantAccessor(); options.AddConsoleActivities(); options.AddJavaScriptActivities(); - options.UseJsonSerializer((provider) => - { - var jsonOptions = provider.GetRequiredService>(); - var jsonConverters = jsonOptions.Value.Converters - .Select(c => (JsonConverter)provider.GetRequiredService(c)) - .ToList(); - var jsonSettings = new JsonSerializerSettings(); - jsonSettings.Converters.InsertRange(0, jsonConverters); + //options.UseJsonSerializer((provider) => + //{ + // var jsonOptions = provider.GetRequiredService>(); + // var jsonConverters = jsonOptions.Value.Converters + // .Select(c => (JsonConverter)provider.GetRequiredService(c)) + // .ToList(); + // var jsonSettings = new JsonSerializerSettings(); + // jsonSettings.Converters.InsertRange(0, jsonConverters); - return JsonSerializer.Create(jsonSettings); - }); + // return JsonSerializer.Create(jsonSettings); + //}); builder.Configure(options); }) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/IMultiTenantActivitySupport.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/IMultiTenantActivitySupport.cs new file mode 100644 index 000000000..c03104592 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/IMultiTenantActivitySupport.cs @@ -0,0 +1,13 @@ +using System; + +namespace LINGYUN.Abp.Elsa; +/// +/// 多租户支持 +/// +/// +/// elsa与abp的兼容,还是最好指定多租户字段 +/// +public interface IMultiTenantActivitySupport +{ + Guid? TenantId { get; set; } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Scripting/JavaScript/ConfigureJavaScriptEngine.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Scripting/JavaScript/ConfigureJavaScriptEngine.cs index 96b2dc082..dbc37e0f9 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Scripting/JavaScript/ConfigureJavaScriptEngine.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Scripting/JavaScript/ConfigureJavaScriptEngine.cs @@ -129,7 +129,7 @@ public class ConfigureJavaScriptEngine : INotificationHandler - net6.0 + net7.0 diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj index ac9926890..e47d0e4a3 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj index 566d48092..cef5c2c78 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/AbpIdentityServerPermissionDefinitionProvider.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/AbpIdentityServerPermissionDefinitionProvider.cs index a179d35f1..9bbc68503 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/AbpIdentityServerPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/AbpIdentityServerPermissionDefinitionProvider.cs @@ -20,8 +20,7 @@ namespace LINGYUN.Abp.IdentityServer identityServerGroup = context .AddGroup( name: AbpIdentityServerPermissions.GroupName, - displayName: L("Permissions:IdentityServer"), - multiTenancySide: MultiTenancySides.Host); + displayName: L("Permissions:IdentityServer")); } // 客户端权限 var clientPermissions = identityServerGroup.AddPermission(AbpIdentityServerPermissions.Clients.Default, L("Permissions:Clients"), MultiTenancySides.Host); diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj index a79ea30d2..87e1be4ff 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj index 8ddd0f474..4bd45847a 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj index 54e283a02..a587315e6 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj index 3a436bec4..d349f2f75 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj index 6d8982839..8d3fb18c3 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj index 886caf391..84895b186 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj index b253f4cec..3799678ca 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj +++ b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/ResourceAppService.cs b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/ResourceAppService.cs index 815b5e096..9e939d2fd 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/ResourceAppService.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/ResourceAppService.cs @@ -5,22 +5,28 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Localization; +using Volo.Abp.Localization.External; namespace LINGYUN.Abp.AspNetCore.Mvc.Localization { [Authorize] public class ResourceAppService : ApplicationService, IResourceAppService - { + { + private readonly IExternalLocalizationStore _externalLocalizationStore; private readonly AbpLocalizationOptions _localizationOptions; public ResourceAppService( - IOptions localizationOptions) + IOptions localizationOptions, + IExternalLocalizationStore externalLocalizationStore) { _localizationOptions = localizationOptions.Value; + _externalLocalizationStore = externalLocalizationStore; } - public virtual Task> GetListAsync() + public virtual async Task> GetListAsync() { + var externalResources = await _externalLocalizationStore.GetResourcesAsync(); + var resources = _localizationOptions .Resources .Select(x => new ResourceDto @@ -29,10 +35,16 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization DisplayName = x.Value.ResourceName, Description = x.Value.ResourceName, }) + .Union(externalResources.Select(resource => new ResourceDto + { + Name = resource.ResourceName, + DisplayName = resource.ResourceName, + Description = resource.ResourceName, + })) .OrderBy(l => l.Name) .DistinctBy(l => l.Name); - return Task.FromResult(new ListResultDto(resources.ToList())); + return new ListResultDto(resources.ToList()); } } } diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs index fea4c1d2e..cf05ed082 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs @@ -24,15 +24,12 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization _localizationOptions = localizationOptions.Value; } - public virtual Task GetByCultureKeyAsync(GetTextByKeyInput input) - { - var resource = _localizationOptions.Resources - .Where(l => l.Value.ResourceName.Equals(input.ResourceName)) - .Select(l => l.Value) - .FirstOrDefault(); + public async virtual Task GetByCultureKeyAsync(GetTextByKeyInput input) + { + var resource = _localizationOptions.Resources.GetOrDefault(input.ResourceName); IEnumerable localizedStrings = new List(); - var localizer = _localizerFactory.Create(resource.ResourceType); + var localizer = await _localizerFactory.CreateByResourceNameAsync(resource.ResourceName); using (CultureHelper.Use(input.CultureName)) { @@ -47,11 +44,11 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization Value = localizer[input.Key]?.Value }; - return Task.FromResult(result); + return result; } } - public virtual Task> GetListAsync(GetTextsInput input) + public async virtual Task> GetListAsync(GetTextsInput input) { var result = new List(); @@ -63,7 +60,8 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization foreach (var resource in filterResources) { - result.AddRange(GetTextDifferences(resource.Value, input.CultureName, input.TargetCultureName, input.Filter, input.OnlyNull)); + result.AddRange( + await GetTextDifferences(resource.Value, input.CultureName, input.TargetCultureName, input.Filter, input.OnlyNull)); } } else @@ -75,15 +73,16 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization .FirstOrDefault(); if (resource != null) { - result.AddRange(GetTextDifferences(resource, input.CultureName, input.TargetCultureName, input.Filter, input.OnlyNull)); + result.AddRange( + await GetTextDifferences(resource, input.CultureName, input.TargetCultureName, input.Filter, input.OnlyNull)); } } - return Task.FromResult(new ListResultDto(result)); + return new ListResultDto(result); } - protected virtual IEnumerable GetTextDifferences( - LocalizationResource resource, + protected async virtual Task> GetTextDifferences( + LocalizationResourceBase resource, string cultureName, string targetCultureName, string filter = null, @@ -93,7 +92,7 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization IEnumerable localizedStrings = new List(); IEnumerable targetLocalizedStrings = new List(); - var localizer = _localizerFactory.Create(resource.ResourceType); + var localizer = await _localizerFactory.CreateByResourceNameAsync(resource.ResourceName); using (CultureHelper.Use(cultureName)) { diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj index c21a3091e..49564cb57 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs index e49f42e4b..84e8a078b 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Localization; using Microsoft.Extensions.Primitives; using System; using System.Collections.Generic; +using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Internal; using Volo.Abp.Localization; @@ -16,8 +17,10 @@ namespace LINGYUN.Abp.Localization.Xml private IFileProvider _fileProvider; private Dictionary _dictionaries; private bool _subscribedForChanges; - private readonly object _syncObj = new object(); - + private readonly object _syncObj = new object(); + + public bool IsDynamic => throw new NotImplementedException(); + protected XmlFileLocalizationResourceContributorBase(string filePath) { _filePath = filePath; @@ -114,6 +117,18 @@ namespace LINGYUN.Abp.Localization.Xml return XmlLocalizationDictionaryBuilder.BuildFromXmlString(fileContent); } - protected abstract IFileProvider BuildFileProvider(LocalizationResourceInitializationContext context); + protected abstract IFileProvider BuildFileProvider(LocalizationResourceInitializationContext context); + + public virtual Task FillAsync(string cultureName, Dictionary dictionary) + { + Fill(cultureName, dictionary); + + return Task.CompletedTask; + } + + public virtual Task> GetSupportedCulturesAsync() + { + return Task.FromResult((IEnumerable)GetDictionaries().Keys); + } } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/Permissions/LocalizationManagementPermissionDefinitionProvider.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/Permissions/LocalizationManagementPermissionDefinitionProvider.cs index c470c04d3..e3666d37f 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/Permissions/LocalizationManagementPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/Permissions/LocalizationManagementPermissionDefinitionProvider.cs @@ -10,8 +10,7 @@ namespace LINGYUN.Abp.LocalizationManagement.Permissions { var permissionGroup = context.AddGroup( LocalizationManagementPermissions.GroupName, - L("Permissions:LocalizationManagement"), - Volo.Abp.MultiTenancy.MultiTenancySides.Host); + L("Permissions:LocalizationManagement")); var resourcePermission = permissionGroup.AddPermission( LocalizationManagementPermissions.Resource.Default, diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj index 49c3cc746..78c91b6ad 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj @@ -14,7 +14,6 @@ - diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs index 9e91df512..c5e1c30f1 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs @@ -1,19 +1,13 @@ -using LINGYUN.Abp.Localization.Dynamic; -using LINGYUN.Abp.LocalizationManagement.Localization; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; using Volo.Abp.Domain; -using Volo.Abp.Localization; using Volo.Abp.Modularity; -using Volo.Abp.EventBus.Distributed; -using Volo.Abp.Domain.Entities.Events.Distributed; -using Microsoft.Extensions.DependencyInjection; namespace LINGYUN.Abp.LocalizationManagement { [DependsOn( typeof(AbpAutoMapperModule), typeof(AbpDddDomainModule), - typeof(AbpLocalizationDynamicModule), typeof(AbpLocalizationManagementDomainSharedModule))] public class AbpLocalizationManagementDomainModule : AbpModule { @@ -21,13 +15,6 @@ namespace LINGYUN.Abp.LocalizationManagement { context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.Resources - .Get() - .AddDynamic(); - }); - Configure(options => { options.AddProfile(validate: true); diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs index 874dad3ea..4bd7ce6bc 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Localization.Dynamic; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; @@ -8,14 +7,16 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Localization; - +using Volo.Abp.Localization.External; +using Volo.Abp.Threading; + namespace LINGYUN.Abp.LocalizationManagement { - [Dependency(ServiceLifetime.Singleton, ReplaceServices = true)] + [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] [ExposeServices( - typeof(ILocalizationStore), + typeof(IExternalLocalizationStore), typeof(LocalizationStore))] - public class LocalizationStore : ILocalizationStore + public class LocalizationStore : IExternalLocalizationStore { protected ILanguageRepository LanguageRepository { get; } protected ITextRepository TextRepository { get; } @@ -31,6 +32,7 @@ namespace LINGYUN.Abp.LocalizationManagement ResourceRepository = resourceRepository; } + [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task> GetLanguageListAsync( CancellationToken cancellationToken = default) { @@ -41,6 +43,7 @@ namespace LINGYUN.Abp.LocalizationManagement .ToList(); } + [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task> GetLocalizationDictionaryAsync( string resourceName, CancellationToken cancellationToken = default) @@ -78,6 +81,7 @@ namespace LINGYUN.Abp.LocalizationManagement return dictionaries; } + [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task>> GetAllLocalizationDictionaryAsync(CancellationToken cancellationToken = default) { var result = new Dictionary>(); @@ -111,9 +115,43 @@ namespace LINGYUN.Abp.LocalizationManagement return result; } + [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task ResourceExistsAsync(string resourceName, CancellationToken cancellationToken = default) { return await ResourceRepository.ExistsAsync(resourceName, cancellationToken); - } + } + + public LocalizationResourceBase GetResourceOrNull(string resourceName) + { + return GetResourceOrNullAsync(resourceName) + .ConfigureAwait(continueOnCapturedContext: false) + .GetAwaiter() + .GetResult(); + } + + public async virtual Task GetResourceOrNullAsync(string resourceName) + { + var resource = await ResourceRepository.FindByNameAsync(resourceName); + if (resource == null) + { + return null; + } + + return new NonTypedLocalizationResource(resource.Name); + } + + public async virtual Task GetResourceNamesAsync() + { + var resources = await ResourceRepository.GetListAsync(); + + return resources.Select(r => r.Name).ToArray(); + } + + public async virtual Task GetResourcesAsync() + { + var resources = await ResourceRepository.GetListAsync(); + + return resources.Select(r => new NonTypedLocalizationResource(r.Name)).ToArray(); + } } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationSynchronizer.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationSynchronizer.cs deleted file mode 100644 index 833616167..000000000 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationSynchronizer.cs +++ /dev/null @@ -1,53 +0,0 @@ -using LINGYUN.Abp.Localization.Dynamic; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Entities.Events; -using Volo.Abp.EventBus; -using Volo.Abp.EventBus.Distributed; - -namespace LINGYUN.Abp.LocalizationManagement -{ - public class LocalizationSynchronizer : - ILocalEventHandler>, - ILocalEventHandler>, - ILocalEventHandler>, - ITransientDependency - { - private readonly IDistributedEventBus _eventBus; - - public LocalizationSynchronizer( - IDistributedEventBus eventBus) - { - _eventBus = eventBus; - } - - public async virtual Task HandleEventAsync(EntityCreatedEventData eventData) - { - await HandleEventAsync(BuildResetEventData(eventData.Entity)); - } - - public async virtual Task HandleEventAsync(EntityUpdatedEventData eventData) - { - await HandleEventAsync(BuildResetEventData(eventData.Entity)); - } - - public async virtual Task HandleEventAsync(EntityDeletedEventData eventData) - { - var data = BuildResetEventData(eventData.Entity); - data.IsDeleted = true; - - await HandleEventAsync(data); - } - - private LocalizedStringCacheResetEventData BuildResetEventData(Text text) - { - return new LocalizedStringCacheResetEventData( - text.ResourceName, text.CultureName, text.Key, text.Value); - } - - private async Task HandleEventAsync(LocalizedStringCacheResetEventData eventData) - { - await _eventBus.PublishAsync(eventData); - } - } -} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj index 1c34300a6..46df10b02 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj index 82453cf7f..2072a3c60 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj index 4ff326edb..f0aad2b54 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj @@ -14,18 +14,12 @@ - - - - - - - + + - diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationChangeReadStateDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationChangeReadStateDto.cs deleted file mode 100644 index e287a0c22..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationChangeReadStateDto.cs +++ /dev/null @@ -1,17 +0,0 @@ -using LINGYUN.Abp.Notifications; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public class UserNotificationChangeReadStateDto - { - [Required] - [DisplayName("Notifications:Id")] - public long NotificationId { get; set; } - - [Required] - [DisplayName("Notifications:State")] - public NotificationReadState ReadState { get; set; } = NotificationReadState.Read; - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByNameDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByNameDto.cs deleted file mode 100644 index d1e49a1e4..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByNameDto.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public class UserNotificationGetByNameDto - { - [Required] - [StringLength(NotificationConsts.MaxNameLength)] - [DisplayName("Notifications:Name")] - public string NotificationName { get; set; } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs deleted file mode 100644 index 11f7616d3..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs +++ /dev/null @@ -1,14 +0,0 @@ -using LINGYUN.Abp.Notifications; -using System.ComponentModel; -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public class UserNotificationGetByPagedDto : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - - [DisplayName("Notifications:State")] - public NotificationReadState? ReadState { get; set; } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/IMyNotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/IMyNotificationAppService.cs deleted file mode 100644 index 72e3c352f..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/IMyNotificationAppService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Application.Services; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public interface IMyNotificationAppService : - - IReadOnlyAppService< - UserNotificationDto, - long, - UserNotificationGetByPagedDto - >, - IDeleteAppService - { - Task MarkReadStateAsync(NotificationMarkReadStateInput input); - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs deleted file mode 100644 index 4b228f922..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public interface INotificationAppService - { - Task> GetAssignableNotifiersAsync(); - - Task> GetAssignableTemplatesAsync(); - - Task SendAsync(NotificationSendDto input); - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByNameDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByNameDto.cs deleted file mode 100644 index 7ce9faa91..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByNameDto.cs +++ /dev/null @@ -1,14 +0,0 @@ -using LINGYUN.Abp.MessageService.Notifications; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public class SubscriptionsGetByNameDto - { - [Required] - [StringLength(NotificationConsts.MaxNameLength)] - [DisplayName("Notifications:Name")] - public string Name { get; set; } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByPagedDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByPagedDto.cs deleted file mode 100644 index 0321ab0fa..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/SubscriptionsGetByPagedDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public class SubscriptionsGetByPagedDto : PagedAndSortedResultRequestDto - { - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscreNotificationDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscreNotificationDto.cs deleted file mode 100644 index 6e47e7823..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscreNotificationDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public class UserSubscreNotificationDto - { - public string Name { get; set; } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscriptionsResult.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscriptionsResult.cs deleted file mode 100644 index 495c2dd04..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/Dto/UserSubscriptionsResult.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public class UserSubscriptionsResult - { - public bool IsSubscribed { get; } - - public UserSubscriptionsResult(bool isSubscribed) - { - IsSubscribed = isSubscribed; - } - - public static UserSubscriptionsResult Subscribed() - { - return new UserSubscriptionsResult(true); - } - - public static UserSubscriptionsResult UnSubscribed() - { - return new UserSubscriptionsResult(false); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/IMySubscriptionAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/IMySubscriptionAppService.cs deleted file mode 100644 index c22d53b39..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Subscriptions/IMySubscriptionAppService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public interface IMySubscriptionAppService : IApplicationService - { - /// - /// 是否已订阅消息 - /// - /// - /// - Task IsSubscribedAsync(SubscriptionsGetByNameDto input); - /// - /// 订阅消息 - /// - /// - /// - Task SubscribeAsync(SubscriptionsGetByNameDto input); - /// - /// 退订消息 - /// - /// - /// - Task UnSubscribeAsync(SubscriptionsGetByNameDto input); - /// - /// 获取订阅列表 - /// - /// - /// - Task> GetListAsync(SubscriptionsGetByPagedDto input); - /// - /// 获取所有订阅列表 - /// - /// - Task> GetAllListAsync(); - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs index 363e6aa80..88fe8ff33 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs @@ -1,7 +1,4 @@ using AutoMapper; -using LINGYUN.Abp.MessageService.Notifications; -using LINGYUN.Abp.Notifications; -using System; namespace LINGYUN.Abp.MessageService { @@ -9,20 +6,6 @@ namespace LINGYUN.Abp.MessageService { public AbpMessageServiceApplicationAutoMapperProfile() { - CreateMap() - .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) - .ForMember(dto => dto.Lifetime, map => map.Ignore()) - .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => - { - var dataType = Type.GetType(src.NotificationTypeName); - var data = Activator.CreateInstance(dataType); - if (data is NotificationData notificationData) - { - notificationData.ExtraProperties = src.ExtraProperties; - return notificationData; - } - return new NotificationData(); - })); } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs deleted file mode 100644 index ff7e8fca5..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs +++ /dev/null @@ -1,77 +0,0 @@ -using LINGYUN.Abp.Notifications; -using Microsoft.AspNetCore.Authorization; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; -using Volo.Abp.Users; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - [Authorize] - public class MyNotificationAppService : ApplicationService, IMyNotificationAppService - { - protected INotificationSender NotificationSender { get; } - - protected INotificationStore NotificationStore { get; } - - protected IUserNotificationRepository UserNotificationRepository { get; } - - protected INotificationDefinitionManager NotificationDefinitionManager { get; } - - public MyNotificationAppService( - INotificationStore notificationStore, - INotificationSender notificationSender, - IUserNotificationRepository userNotificationRepository, - INotificationDefinitionManager notificationDefinitionManager) - { - NotificationStore = notificationStore; - NotificationSender = notificationSender; - UserNotificationRepository = userNotificationRepository; - NotificationDefinitionManager = notificationDefinitionManager; - } - - public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) - { - await NotificationStore.ChangeUserNotificationsReadStateAsync( - CurrentTenant.Id, - CurrentUser.GetId(), - input.IdList, - input.State); - } - - public async virtual Task DeleteAsync(long id) - { - await NotificationStore - .DeleteUserNotificationAsync( - CurrentTenant.Id, - CurrentUser.GetId(), - id); - } - - public async virtual Task GetAsync(long id) - { - var notification = await UserNotificationRepository.GetByIdAsync(CurrentUser.GetId(), id); - - return ObjectMapper.Map(notification); - } - - public async virtual Task> GetListAsync(UserNotificationGetByPagedDto input) - { - var totalCount = await UserNotificationRepository - .GetCountAsync( - CurrentUser.GetId(), - input.Filter, - input.ReadState); - - var notifications = await UserNotificationRepository - .GetListAsync( - CurrentUser.GetId(), - input.Filter, input.Sorting, - input.ReadState, input.SkipCount, input.MaxResultCount); - - return new PagedResultDto(totalCount, - ObjectMapper.Map, List>(notifications)); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs deleted file mode 100644 index 30fefcdd6..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs +++ /dev/null @@ -1,153 +0,0 @@ -using LINGYUN.Abp.Notifications; -using Microsoft.AspNetCore.Authorization; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; -using Volo.Abp.TextTemplating; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - [Authorize] - public class NotificationAppService : ApplicationService, INotificationAppService - { - protected ITemplateContentProvider TemplateContentProvider { get; } - protected INotificationSender NotificationSender { get; } - protected INotificationDefinitionManager NotificationDefinitionManager { get; } - - public NotificationAppService( - INotificationSender notificationSender, - ITemplateContentProvider templateContentProvider, - INotificationDefinitionManager notificationDefinitionManager) - { - NotificationSender = notificationSender; - TemplateContentProvider = templateContentProvider; - NotificationDefinitionManager = notificationDefinitionManager; - } - - public async virtual Task> GetAssignableNotifiersAsync() - { - var groups = new List(); - var defineGroups = await NotificationDefinitionManager.GetGroupsAsync(); - - foreach (var group in defineGroups) - { - if (!group.AllowSubscriptionToClients) - { - continue; - - } - var notificationGroup = new NotificationGroupDto - { - Name = group.Name, - DisplayName = group.DisplayName.Localize(StringLocalizerFactory) - }; - - foreach (var notification in group.Notifications) - { - if (!notification.AllowSubscriptionToClients) - { - continue; - } - - var notificationChildren = new NotificationDto - { - Name = notification.Name, - DisplayName = notification.DisplayName.Localize(StringLocalizerFactory), - Description = notification.Description?.Localize(StringLocalizerFactory) ?? notification.Name, - Lifetime = notification.NotificationLifetime, - Type = notification.NotificationType, - ContentType = notification.ContentType - }; - - notificationGroup.Notifications.Add(notificationChildren); - } - - groups.Add(notificationGroup); - } - - return new ListResultDto(groups); - } - - public async virtual Task> GetAssignableTemplatesAsync() - { - var templates = new List(); - var notifications = (await NotificationDefinitionManager - .GetNotificationsAsync()) - .Where(n => n.Template != null); - - foreach (var notification in notifications) - { - templates.Add( - new NotificationTemplateDto - { - Name = notification.Name, - Culture = CultureInfo.CurrentCulture.Name, - Title = notification.DisplayName.Localize(StringLocalizerFactory), - Description = notification.Description?.Localize(StringLocalizerFactory), - }); - } - - return new ListResultDto(templates); - } - - public async virtual Task SendAsync(NotificationSendDto input) - { - var notification = await GetNotificationDefinition(input.Name); - - UserIdentifier user = null; - if (input.ToUserId.HasValue) - { - user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); - } - - if (!input.TemplateName.IsNullOrWhiteSpace()) - { - if (notification.Template == null) - { - throw new BusinessException( - MessageServiceErrorCodes.NotificationTemplateNotFound, - $"The notification template {input.TemplateName} does not exist!") - .WithData("Name", input.TemplateName); - } - var notificationTemplate = new NotificationTemplate( - notification.Name, - culture: input.Culture ?? CultureInfo.CurrentCulture.Name, - formUser: CurrentUser.Name ?? CurrentUser.UserName, - data: input.Data); - - await NotificationSender - .SendNofiterAsync( - name: input.Name, - template: notificationTemplate, - user: user, - tenantId: CurrentTenant.Id, - severity: input.Severity); - } - else - { - var notificationData = new NotificationData(); - notificationData.ExtraProperties.AddIfNotContains(input.Data); - - notificationData = NotificationData.ToStandardData(notificationData); - - await NotificationSender - .SendNofiterAsync( - name: input.Name, - data: notificationData, - user: user, - tenantId: CurrentTenant.Id, - severity: input.Severity); - } - } - - protected async virtual Task GetNotificationDefinition(string name) - { - return await NotificationDefinitionManager.GetAsync(name); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionAppService.cs deleted file mode 100644 index 49b920ec0..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionAppService.cs +++ /dev/null @@ -1,76 +0,0 @@ -using LINGYUN.Abp.Notifications; -using Microsoft.AspNetCore.Authorization; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; -using Volo.Abp.Users; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - [Authorize] - public class MySubscriptionAppService : ApplicationService, IMySubscriptionAppService - { - protected IUserSubscribeRepository UserSubscribeRepository { get; } - protected INotificationSubscriptionManager NotificationSubscriptionManager { get; } - - public MySubscriptionAppService( - IUserSubscribeRepository userSubscribeRepository, - INotificationSubscriptionManager notificationSubscriptionManager) - { - UserSubscribeRepository = userSubscribeRepository; - NotificationSubscriptionManager = notificationSubscriptionManager; - } - - public async virtual Task> GetListAsync(SubscriptionsGetByPagedDto input) - { - var userSubscribedCount = await UserSubscribeRepository.GetCountAsync(CurrentUser.GetId()); - - var userSubscribes = await UserSubscribeRepository - .GetUserSubscribesAsync(CurrentUser.GetId(), input.Sorting, - input.SkipCount, input.MaxResultCount); - - return new PagedResultDto(userSubscribedCount, - userSubscribes.Select(us => new UserSubscreNotificationDto { Name = us.NotificationName }).ToList()); - } - - public async virtual Task> GetAllListAsync() - { - var userSubscribes = await NotificationSubscriptionManager - .GetUserSubscriptionsAsync( - CurrentTenant.Id, - CurrentUser.GetId()); - - return new ListResultDto( - userSubscribes.Select(msn => new UserSubscreNotificationDto { Name = msn.NotificationName }).ToList()); - } - - public async virtual Task IsSubscribedAsync(SubscriptionsGetByNameDto input) - { - var isSubscribed = await NotificationSubscriptionManager - .IsSubscribedAsync(CurrentTenant.Id, CurrentUser.GetId(), input.Name); - - return isSubscribed - ? UserSubscriptionsResult.Subscribed() - : UserSubscriptionsResult.UnSubscribed(); - } - - public async virtual Task SubscribeAsync(SubscriptionsGetByNameDto input) - { - await NotificationSubscriptionManager - .SubscribeAsync( - CurrentTenant.Id, - new UserIdentifier(CurrentUser.GetId(), CurrentUser.UserName), - input.Name); - } - - public async virtual Task UnSubscribeAsync(SubscriptionsGetByNameDto input) - { - await NotificationSubscriptionManager - .UnsubscribeAsync( - CurrentTenant.Id, - new UserIdentifier(CurrentUser.GetId(), CurrentUser.UserName), - input.Name); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj index 88d0b846a..a0c13dd72 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj @@ -9,13 +9,8 @@ - - - - - - - + + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs index e40d773b4..f447bfb49 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs @@ -3,7 +3,7 @@ using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Localization; using LINGYUN.Abp.MessageService.Mapper; using LINGYUN.Abp.MessageService.ObjectExtending; -using LINGYUN.Abp.Notifications.Localization; +using LINGYUN.Abp.Notifications; using Volo.Abp.AutoMapper; using Volo.Abp.Caching; using Volo.Abp.Localization; @@ -15,6 +15,7 @@ namespace LINGYUN.Abp.MessageService [DependsOn( typeof(AbpAutoMapperModule), typeof(AbpCachingModule), + typeof(AbpNotificationsModule), typeof(AbpMessageServiceDomainSharedModule))] public class AbpMessageServiceDomainModule : AbpModule { @@ -29,7 +30,7 @@ namespace LINGYUN.Abp.MessageService { options.Resources .Get() - .AddBaseTypes(typeof(NotificationsResource), typeof(AbpIMResource)); + .AddBaseTypes(typeof(AbpIMResource)); }); } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs index 72932813f..96dfb6d56 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs @@ -3,10 +3,6 @@ using LINGYUN.Abp.IM.Groups; using LINGYUN.Abp.IM.Messages; using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Groups; -using LINGYUN.Abp.MessageService.Notifications; -using LINGYUN.Abp.MessageService.Subscriptions; -using LINGYUN.Abp.Notifications; -using System; using Volo.Abp.AutoMapper; using Volo.Abp.Data; using Volo.Abp.ObjectExtending; @@ -17,48 +13,6 @@ namespace LINGYUN.Abp.MessageService.Mapper { public MessageServiceDomainAutoMapperProfile() { - CreateMap() - .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId.ToString())) - .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName)) - .ForMember(dto => dto.Lifetime, map => map.Ignore()) - .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) - .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) - .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) - .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) - .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => - { - var dataType = Type.GetType(src.NotificationTypeName); - var data = Activator.CreateInstance(dataType); - if (data is NotificationData notificationData) - { - notificationData.ExtraProperties = src.ExtraProperties; - return notificationData; - } - return new NotificationData(); - })); - - CreateMap() - .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) - .ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name)) - .ForMember(dto => dto.Lifetime, map => map.Ignore()) - .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) - .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) - .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) - .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) - .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => - { - var dataType = Type.GetType(src.NotificationTypeName); - var data = Activator.CreateInstance(dataType); - if (data is NotificationData notificationData) - { - notificationData.ExtraProperties = src.ExtraProperties; - return notificationData; - } - return new NotificationData(); - })); - - CreateMap(); - CreateMessageMap() .ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content)) .ForMember(dto => dto.GroupId, map => map.MapFrom(src => src.GroupId.ToString())) diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj index a14bb1d0b..b06cc24d3 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs index cd34fd4cc..41e005dc8 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs @@ -1,7 +1,5 @@ using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Groups; -using LINGYUN.Abp.MessageService.Notifications; -using LINGYUN.Abp.MessageService.Subscriptions; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; @@ -17,12 +15,7 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore { context.Services.AddAbpDbContext(options => { - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - - options.AddRepository(); - options.AddRepository(); + options.AddDefaultRepositories(); options.AddRepository(); options.AddRepository(); @@ -30,8 +23,6 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore options.AddRepository(); options.AddRepository(); - - options.AddDefaultRepositories(includeAllEntities: true); }); } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs index 0bd29569d..f09a12099 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs @@ -1,8 +1,5 @@ using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Groups; -using LINGYUN.Abp.MessageService.Notifications; -using LINGYUN.Abp.MessageService.Subscriptions; -using LINGYUN.Abp.Notifications; using Microsoft.EntityFrameworkCore; using System; using Volo.Abp; @@ -22,49 +19,6 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore optionsAction?.Invoke(options); - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "Notifications", options.Schema); - - b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired(); - b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired(); - //b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired(); - - b.Property(p => p.ContentType) - .HasDefaultValue(NotificationContentType.Text); - - b.ConfigureByConvention(); - - b.HasIndex(p => new { p.TenantId, p.NotificationName }); - }); - - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); - - b.ConfigureByConvention(); - - b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId }) - .HasDatabaseName("IX_Tenant_User_Notification_Id"); - }); - - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema); - - b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired(); - b.Property(p => p.UserName) - .HasMaxLength(SubscribeConsts.MaxUserNameLength) - .HasDefaultValue("/")// 不是必须的 - .IsRequired(); - - b.ConfigureByConvention(); - - b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName }) - .HasDatabaseName("IX_Tenant_User_Notification_Name") - .IsUnique(); - }); - builder.Entity(b => { b.ToTable(options.TablePrefix + "UserMessages", options.Schema); @@ -190,54 +144,6 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore b.HasIndex(p => new { p.TenantId, p.GroupId, p.UserId }); }); - - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "NotificationDefinitionGroups", options.Schema); - - b.Property(p => p.Name) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxNameLength) - .IsRequired(); - - b.Property(p => p.DisplayName) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDisplayNameLength); - b.Property(p => p.Description) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDescriptionLength); - b.Property(p => p.ResourceName) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); - b.Property(p => p.Localization) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); - - b.ConfigureByConvention(); - }); - - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "NotificationDefinitions", options.Schema); - - b.Property(p => p.Name) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxNameLength) - .IsRequired(); - b.Property(p => p.GroupName) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxNameLength) - .IsRequired(); - - b.Property(p => p.DisplayName) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxDisplayNameLength); - b.Property(p => p.Description) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxDescriptionLength); - b.Property(p => p.ResourceName) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxResourceNameLength); - b.Property(p => p.Localization) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxLocalizationLength); - b.Property(p => p.Providers) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxProvidersLength); - - b.Property(p => p.ContentType) - .HasDefaultValue(NotificationContentType.Text); - - b.ConfigureByConvention(); - }); } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs deleted file mode 100644 index a40ba8f31..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs +++ /dev/null @@ -1,42 +0,0 @@ -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public class EfCoreNotificationRepository : EfCoreRepository, - INotificationRepository, ITransientDependency - { - public EfCoreNotificationRepository( - IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public async Task> GetExpritionAsync( - int batchCount, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Where(x => x.ExpirationTime < DateTime.Now) - .OrderBy(x => x.ExpirationTime) - .Take(batchCount) - .ToListAsync(GetCancellationToken(cancellationToken)); - } - - public async Task GetByIdAsync( - long notificationId, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()).Where(x => x.NotificationId.Equals(notificationId)) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs deleted file mode 100644 index e51b9abe4..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs +++ /dev/null @@ -1,182 +0,0 @@ -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using LINGYUN.Abp.Notifications; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Dynamic.Core; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - public class EfCoreUserNotificationRepository : EfCoreRepository, - IUserNotificationRepository, ITransientDependency - { - public EfCoreUserNotificationRepository( - IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public async virtual Task AnyAsync( - Guid userId, - long notificationId, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .AnyAsync(x => x.NotificationId.Equals(notificationId) && x.UserId.Equals(userId), - GetCancellationToken(cancellationToken)); - } - - public async virtual Task GetByIdAsync( - Guid userId, - long notificationId, - CancellationToken cancellationToken = default) - { - var dbContext = await GetDbContextAsync(); - var userNotifilerQuery = dbContext.Set() - .Where(x => x.UserId == userId); - - var notificationQuery = dbContext.Set(); - - var notifilerQuery = from un in userNotifilerQuery - join n in dbContext.Set() - on un.NotificationId equals n.NotificationId - where n.NotificationId.Equals(notificationId) - select new UserNotificationInfo - { - Id = n.NotificationId, - TenantId = n.TenantId, - Name = n.NotificationName, - ExtraProperties = n.ExtraProperties, - CreationTime = n.CreationTime, - NotificationTypeName = n.NotificationTypeName, - Severity = n.Severity, - State = un.ReadStatus, - Type = n.Type, - ContentType = n.ContentType - }; - - return await notifilerQuery - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task> GetListAsync( - Guid userId, - IEnumerable notificationIds, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Where(x => x.UserId.Equals(userId) && notificationIds.Contains(x.NotificationId)) - .ToListAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task> GetNotificationsAsync( - Guid userId, - NotificationReadState? readState = null, - int maxResultCount = 10, - CancellationToken cancellationToken = default) - { - var dbContext = await GetDbContextAsync(); - var userNotifilerQuery = dbContext.Set() - .Where(x => x.UserId == userId) - .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); - - var notifilerQuery = from un in userNotifilerQuery - join n in dbContext.Set() - on un.NotificationId equals n.NotificationId - select new UserNotificationInfo - { - Id = n.NotificationId, - TenantId = n.TenantId, - Name = n.NotificationName, - ExtraProperties = n.ExtraProperties, - CreationTime = n.CreationTime, - NotificationTypeName = n.NotificationTypeName, - Severity = n.Severity, - State = un.ReadStatus, - Type = n.Type, - ContentType = n.ContentType - }; - - return await notifilerQuery - .OrderBy(nameof(Notification.CreationTime) + " DESC") - .Take(maxResultCount) - .AsNoTracking() - .ToListAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task GetCountAsync( - Guid userId, - string filter = "", - NotificationReadState? readState = null, - CancellationToken cancellationToken = default) - { - var dbContext = await GetDbContextAsync(); - var userNotifilerQuery = dbContext.Set() - .Where(x => x.UserId == userId) - .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); - - var notificationQuery = dbContext.Set() - .WhereIf(!filter.IsNullOrWhiteSpace(), nf => - nf.NotificationName.Contains(filter) || - nf.NotificationTypeName.Contains(filter)); - - var notifilerQuery = from un in userNotifilerQuery - join n in notificationQuery - on un.NotificationId equals n.NotificationId - select n; - - return await notifilerQuery - .CountAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task> GetListAsync( - Guid userId, - string filter = "", - string sorting = nameof(Notification.CreationTime), - NotificationReadState? readState = null, - int skipCount = 1, - int maxResultCount = 10, - CancellationToken cancellationToken = default) - { - sorting ??= $"{nameof(Notification.CreationTime)} DESC"; - var dbContext = await GetDbContextAsync(); - var userNotifilerQuery = dbContext.Set() - .Where(x => x.UserId == userId) - .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); - - var notificationQuery = dbContext.Set() - .WhereIf(!filter.IsNullOrWhiteSpace(), nf => - nf.NotificationName.Contains(filter) || - nf.NotificationTypeName.Contains(filter)); - - var notifilerQuery = from un in userNotifilerQuery - join n in notificationQuery - on un.NotificationId equals n.NotificationId - select new UserNotificationInfo - { - Id = n.NotificationId, - TenantId = n.TenantId, - Name = n.NotificationName, - ExtraProperties = n.ExtraProperties, - CreationTime = n.CreationTime, - NotificationTypeName = n.NotificationTypeName, - Severity = n.Severity, - State = un.ReadStatus, - Type = n.Type, - ContentType = n.ContentType - }; - - return await notifilerQuery - .OrderBy(sorting) - .PageBy(skipCount, maxResultCount) - .AsNoTracking() - .ToListAsync(GetCancellationToken(cancellationToken)); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs deleted file mode 100644 index 828803cd4..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs +++ /dev/null @@ -1,164 +0,0 @@ -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Dynamic.Core; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - public class EfCoreUserSubscribeRepository : EfCoreRepository, - IUserSubscribeRepository, ITransientDependency - { - public EfCoreUserSubscribeRepository( - IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public async virtual Task> GetUserSubscribesAsync( - string notificationName, - IEnumerable userIds = null, - CancellationToken cancellationToken = default) - { - var userSubscribes = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.NotificationName.Equals(notificationName)) - .WhereIf(userIds?.Any() == true, x => userIds.Contains(x.UserId)) - .AsNoTracking() - .ToListAsync(GetCancellationToken(cancellationToken)); - - return userSubscribes; - } - - public async virtual Task GetUserSubscribeAsync( - string notificationName, - Guid userId, - CancellationToken cancellationToken = default) - { - var userSubscribe = await (await GetDbSetAsync()) - .Where(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName)) - .AsNoTracking() - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - - return userSubscribe; - } - - public async virtual Task> GetUserSubscribesAsync( - Guid userId, - CancellationToken cancellationToken = default) - { - var userSubscribeNames = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.UserId.Equals(userId)) - .Select(x => x.NotificationName) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return userSubscribeNames; - } - - public async virtual Task> GetUserSubscribesByNameAsync( - string userName, - CancellationToken cancellationToken = default) - { - var userSubscribeNames = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.UserName.Equals(userName)) - .AsNoTracking() - .ToListAsync(GetCancellationToken(cancellationToken)); - - return userSubscribeNames; - } - - public async virtual Task> GetUserSubscribesAsync( - string notificationName, - CancellationToken cancellationToken = default) - { - var subscribeUsers = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.NotificationName.Equals(notificationName)) - .Select(x => x.UserId) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return subscribeUsers; - } - - public async virtual Task InsertUserSubscriptionAsync( - IEnumerable userSubscribes, - CancellationToken cancellationToken = default) - { - await (await GetDbSetAsync()).AddRangeAsync(userSubscribes, GetCancellationToken(cancellationToken)); - } - - public async virtual Task DeleteUserSubscriptionAsync( - string notificationName, - CancellationToken cancellationToken = default) - { - var userSubscribes = await (await GetDbSetAsync()).Where(x => x.NotificationName.Equals(notificationName)) - .ToListAsync(GetCancellationToken(cancellationToken)); - (await GetDbSetAsync()).RemoveRange(userSubscribes); - } - - public async virtual Task DeleteUserSubscriptionAsync( - IEnumerable userSubscribes, - CancellationToken cancellationToken = default) - { - await DeleteManyAsync(userSubscribes); - } - - public async virtual Task DeleteUserSubscriptionAsync( - string notificationName, - IEnumerable userIds, - CancellationToken cancellationToken = default) - { - await DeleteAsync(usr => usr.NotificationName == notificationName && userIds.Contains(usr.UserId), - false, - GetCancellationToken(cancellationToken)); - } - - public async virtual Task UserSubscribeExistsAysnc( - string notificationName, - Guid userId, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .AnyAsync(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName), - GetCancellationToken(cancellationToken)); - } - - public async virtual Task> GetUserSubscribesAsync( - Guid userId, - string sorting = "Id", - int skipCount = 1, - int maxResultCount = 10, - CancellationToken cancellationToken = default) - { - var userSubscribes = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.UserId.Equals(userId)) - .OrderBy(sorting ?? nameof(UserSubscribe.Id)) - .Page(skipCount, maxResultCount) - .AsNoTracking() - .ToListAsync(GetCancellationToken(cancellationToken)); - - return userSubscribes; - } - - public async virtual Task GetCountAsync( - Guid userId, - CancellationToken cancellationToken = default) - { - var userSubscribedCount = await (await GetDbSetAsync()) - .Distinct() - .Where(x => x.UserId.Equals(userId)) - .LongCountAsync(GetCancellationToken(cancellationToken)); - - return userSubscribedCount; - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj index 3d10df747..cb83ff965 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/MyNotificationController.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/MyNotificationController.cs deleted file mode 100644 index 875ab9b95..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/MyNotificationController.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; -using Volo.Abp.AspNetCore.Mvc; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - [RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] - [Route("api/my-notifilers")] - public class MyNotificationController : AbpController, IMyNotificationAppService - { - protected IMyNotificationAppService MyNotificationAppService { get; } - - public MyNotificationController( - IMyNotificationAppService myNotificationAppService) - { - MyNotificationAppService = myNotificationAppService; - } - - [HttpPut] - [Route("mark-read-state")] - public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) - { - await MyNotificationAppService.MarkReadStateAsync(input); - } - - [HttpDelete] - [Route("{id}")] - public async virtual Task DeleteAsync(long id) - { - await MyNotificationAppService.DeleteAsync(id); - } - - - [HttpGet] - [Route("{id}")] - public async virtual Task GetAsync(long id) - { - return await MyNotificationAppService.GetAsync(id); - } - - [HttpGet] - public async virtual Task> GetListAsync(UserNotificationGetByPagedDto input) - { - return await MyNotificationAppService.GetListAsync(input); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs deleted file mode 100644 index 533d7a20d..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; -using Volo.Abp.AspNetCore.Mvc; - -namespace LINGYUN.Abp.MessageService.Notifications -{ - [Authorize] - [RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] - [Route("api/notifilers")] - public class NotificationController : AbpController, INotificationAppService - { - protected INotificationAppService NotificationAppService { get; } - - public NotificationController( - INotificationAppService notificationAppService) - { - NotificationAppService = notificationAppService; - } - - [HttpPost] - public async virtual Task SendAsync(NotificationSendDto input) - { - await NotificationAppService.SendAsync(input); - } - - [HttpGet] - [Route("assignables")] - public async virtual Task> GetAssignableNotifiersAsync() - { - return await NotificationAppService.GetAssignableNotifiersAsync(); - } - - [HttpGet] - [Route("assignable-templates")] - public async virtual Task> GetAssignableTemplatesAsync() - { - return await NotificationAppService.GetAssignableTemplatesAsync(); - } - } -} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionController.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionController.cs deleted file mode 100644 index 855477648..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Subscriptions/MySubscriptionController.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; -using Volo.Abp.AspNetCore.Mvc; - -namespace LINGYUN.Abp.MessageService.Subscriptions -{ - [RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] - [Route("api/my-subscribes")] - public class MySubscriptionController : AbpController, IMySubscriptionAppService - { - private readonly IMySubscriptionAppService _subscriptionAppService; - - public MySubscriptionController( - IMySubscriptionAppService subscriptionAppService) - { - _subscriptionAppService = subscriptionAppService; - } - - [HttpGet] - [Route("all")] - public async virtual Task> GetAllListAsync() - { - return await _subscriptionAppService.GetAllListAsync(); - } - - [HttpGet] - public async virtual Task> GetListAsync(SubscriptionsGetByPagedDto input) - { - return await _subscriptionAppService.GetListAsync(input); - } - - [HttpGet] - [Route("is-subscribed/{Name}")] - public async virtual Task IsSubscribedAsync(SubscriptionsGetByNameDto input) - { - return await _subscriptionAppService.IsSubscribedAsync(input); - } - - [HttpPost] - public async virtual Task SubscribeAsync(SubscriptionsGetByNameDto input) - { - await _subscriptionAppService.SubscribeAsync(input); - } - - [HttpDelete] - public async virtual Task UnSubscribeAsync(SubscriptionsGetByNameDto input) - { - await _subscriptionAppService.UnSubscribeAsync(input); - } - } -} diff --git a/aspnet-core/modules/mvc/LINGYUN.Abp.AspNetCore.Mvc.Wrapper/LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj b/aspnet-core/modules/mvc/LINGYUN.Abp.AspNetCore.Mvc.Wrapper/LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj index 58e359c65..83ff032f9 100644 --- a/aspnet-core/modules/mvc/LINGYUN.Abp.AspNetCore.Mvc.Wrapper/LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj +++ b/aspnet-core/modules/mvc/LINGYUN.Abp.AspNetCore.Mvc.Wrapper/LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj @@ -4,18 +4,16 @@ - net6.0 + net7.0 - - + - - + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN.Abp.Notifications.Application.Contracts.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN.Abp.Notifications.Application.Contracts.csproj new file mode 100644 index 000000000..60b3e02c9 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN.Abp.Notifications.Application.Contracts.csproj @@ -0,0 +1,20 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsApplicationContractsModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsApplicationContractsModule.cs new file mode 100644 index 000000000..26e4c4261 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsApplicationContractsModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Application; +using Volo.Abp.Authorization; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Notifications; + +[DependsOn( + typeof(AbpNotificationsDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationAbstractionsModule))] +public class AbpNotificationsApplicationContractsModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsRemoteServiceConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsRemoteServiceConsts.cs new file mode 100644 index 000000000..93f2d92e5 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/AbpNotificationsRemoteServiceConsts.cs @@ -0,0 +1,9 @@ +namespace LINGYUN.Abp.Notifications +{ + public class AbpNotificationsRemoteServiceConsts + { + public const string RemoteServiceName = "Notifications"; + + public const string ModuleName = "notifications"; + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationDto.cs similarity index 89% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationDto.cs index d3288364a..9b8bddae4 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationDto.cs @@ -1,6 +1,4 @@ -using LINGYUN.Abp.Notifications; - -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class NotificationDto { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGetByIdDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGetByIdDto.cs similarity index 82% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGetByIdDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGetByIdDto.cs index 1820eb7b0..f67bd01d1 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGetByIdDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGetByIdDto.cs @@ -1,7 +1,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class NotificationGetByIdDto { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGroupDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGroupDto.cs similarity index 84% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGroupDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGroupDto.cs index 32cf4587e..0908004f5 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationGroupDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationGroupDto.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class NotificationGroupDto { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationMarkReadStateInput.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationMarkReadStateInput.cs similarity index 68% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationMarkReadStateInput.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationMarkReadStateInput.cs index 1f2bf6675..400574df3 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationMarkReadStateInput.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationMarkReadStateInput.cs @@ -1,8 +1,7 @@ -using LINGYUN.Abp.Notifications; -using System.ComponentModel; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class NotificationMarkReadStateInput { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationSendDto.cs similarity index 90% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationSendDto.cs index 174acd640..bc2edffeb 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationSendDto.cs @@ -1,10 +1,9 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class NotificationSendDto { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationTemplateDto.cs similarity index 78% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationTemplateDto.cs index 31ad034ff..9e3362709 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/NotificationTemplateDto.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class NotificationTemplateDto { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByNameDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByNameDto.cs new file mode 100644 index 000000000..f252163cd --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByNameDto.cs @@ -0,0 +1,12 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Abp.Notifications; + +public class SubscriptionsGetByNameDto +{ + [Required] + [StringLength(NotificationConsts.MaxNameLength)] + [DisplayName("Notifications:Name")] + public string Name { get; set; } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByPagedDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByPagedDto.cs new file mode 100644 index 000000000..aef5525bb --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/SubscriptionsGetByPagedDto.cs @@ -0,0 +1,7 @@ +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.Notifications; + +public class SubscriptionsGetByPagedDto : PagedAndSortedResultRequestDto +{ +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationChangeReadStateDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationChangeReadStateDto.cs new file mode 100644 index 000000000..4e6747573 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationChangeReadStateDto.cs @@ -0,0 +1,15 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Abp.Notifications; + +public class UserNotificationChangeReadStateDto +{ + [Required] + [DisplayName("Notifications:Id")] + public long NotificationId { get; set; } + + [Required] + [DisplayName("Notifications:State")] + public NotificationReadState ReadState { get; set; } = NotificationReadState.Read; +} \ No newline at end of file diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationDto.cs similarity index 77% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationDto.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationDto.cs index 972117926..9eb5b651a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationDto.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationDto.cs @@ -1,7 +1,6 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class UserNotificationDto { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByNameDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByNameDto.cs new file mode 100644 index 000000000..a422fa3af --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByNameDto.cs @@ -0,0 +1,12 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Abp.Notifications; + +public class UserNotificationGetByNameDto +{ + [Required] + [StringLength(NotificationConsts.MaxNameLength)] + [DisplayName("Notifications:Name")] + public string NotificationName { get; set; } +} \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByPagedDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByPagedDto.cs new file mode 100644 index 000000000..6bcaaaa17 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserNotificationGetByPagedDto.cs @@ -0,0 +1,12 @@ +using System.ComponentModel; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.Notifications; + +public class UserNotificationGetByPagedDto : PagedAndSortedResultRequestDto +{ + public string Filter { get; set; } + + [DisplayName("Notifications:State")] + public NotificationReadState? ReadState { get; set; } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscreNotificationDto.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscreNotificationDto.cs new file mode 100644 index 000000000..2653317a2 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscreNotificationDto.cs @@ -0,0 +1,6 @@ +namespace LINGYUN.Abp.Notifications; + +public class UserSubscreNotificationDto +{ + public string Name { get; set; } +} \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscriptionsResult.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscriptionsResult.cs new file mode 100644 index 000000000..4bbad0b48 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Dto/UserSubscriptionsResult.cs @@ -0,0 +1,21 @@ +namespace LINGYUN.Abp.Notifications; + +public class UserSubscriptionsResult +{ + public bool IsSubscribed { get; } + + public UserSubscriptionsResult(bool isSubscribed) + { + IsSubscribed = isSubscribed; + } + + public static UserSubscriptionsResult Subscribed() + { + return new UserSubscriptionsResult(true); + } + + public static UserSubscriptionsResult UnSubscribed() + { + return new UserSubscriptionsResult(false); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMyNotificationAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMyNotificationAppService.cs new file mode 100644 index 000000000..7e26bb27a --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMyNotificationAppService.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.Notifications; + +public interface IMyNotificationAppService : + IReadOnlyAppService< + UserNotificationDto, + long, + UserNotificationGetByPagedDto + >, + IDeleteAppService +{ + Task MarkReadStateAsync(NotificationMarkReadStateInput input); +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMySubscriptionAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMySubscriptionAppService.cs new file mode 100644 index 000000000..0ffc61a1e --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/IMySubscriptionAppService.cs @@ -0,0 +1,38 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.Notifications; + +public interface IMySubscriptionAppService : IApplicationService +{ + /// + /// 是否已订阅消息 + /// + /// + /// + Task IsSubscribedAsync(SubscriptionsGetByNameDto input); + /// + /// 订阅消息 + /// + /// + /// + Task SubscribeAsync(SubscriptionsGetByNameDto input); + /// + /// 退订消息 + /// + /// + /// + Task UnSubscribeAsync(SubscriptionsGetByNameDto input); + /// + /// 获取订阅列表 + /// + /// + /// + Task> GetListAsync(SubscriptionsGetByPagedDto input); + /// + /// 获取所有订阅列表 + /// + /// + Task> GetAllListAsync(); +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/INotificationAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/INotificationAppService.cs new file mode 100644 index 000000000..f67e8775a --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/INotificationAppService.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.Notifications; + +public interface INotificationAppService +{ + Task> GetAssignableNotifiersAsync(); + + Task> GetAssignableTemplatesAsync(); + + Task SendAsync(NotificationSendDto input); +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissions.cs new file mode 100644 index 000000000..bd271df7d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissions.cs @@ -0,0 +1,14 @@ +namespace LINGYUN.Abp.Notifications.Permissions +{ + public class NotificationsPermissions + { + public const string GroupName = "Notifications"; + + public class Notification + { + public const string Default = GroupName + ".Notification"; + + public const string Delete = Default + ".Delete"; + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissionsDefinitionProvider.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissionsDefinitionProvider.cs new file mode 100644 index 000000000..d5374777d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application.Contracts/LINGYUN/Abp/Notifications/Permissions/NotificationsPermissionsDefinitionProvider.cs @@ -0,0 +1,22 @@ +using LINGYUN.Abp.Notifications.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.Notifications.Permissions +{ + public class NotificationsPermissionsDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var group = context.AddGroup(NotificationsPermissions.GroupName, L("Permission:Notifications")); + + var noticeGroup = group.AddPermission(NotificationsPermissions.Notification.Default, L("Permission:Notification")); + noticeGroup.AddChild(NotificationsPermissions.Notification.Delete, L("Permission:Delete")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN.Abp.Notifications.Application.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN.Abp.Notifications.Application.csproj new file mode 100644 index 000000000..370a42946 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN.Abp.Notifications.Application.csproj @@ -0,0 +1,20 @@ + + + + + + + netstandard2.1 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationAutoMapperProfile.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationAutoMapperProfile.cs new file mode 100644 index 000000000..8957d7dea --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationAutoMapperProfile.cs @@ -0,0 +1,26 @@ +using AutoMapper; +using System; + +namespace LINGYUN.Abp.Notifications +{ + public class AbpNotificationsApplicationAutoMapperProfile : Profile + { + public AbpNotificationsApplicationAutoMapperProfile() + { + CreateMap() + .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) + .ForMember(dto => dto.Lifetime, map => map.Ignore()) + .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => + { + var dataType = Type.GetType(src.NotificationTypeName); + var data = Activator.CreateInstance(dataType); + if (data is NotificationData notificationData) + { + notificationData.ExtraProperties = src.ExtraProperties; + return notificationData; + } + return new NotificationData(); + })); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationModule.cs new file mode 100644 index 000000000..7bece657d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationModule.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Application; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Notifications; + +[DependsOn( + typeof(AbpNotificationsDomainModule), + typeof(AbpNotificationsApplicationContractsModule), + typeof(AbpDddApplicationModule))] +public class AbpNotificationsApplicationModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.AddProfile(validate: true); + }); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationServiceBase.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationServiceBase.cs new file mode 100644 index 000000000..66dc52022 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationServiceBase.cs @@ -0,0 +1,14 @@ +using LINGYUN.Abp.Notifications.Localization; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.Notifications +{ + public abstract class AbpMessageServiceApplicationServiceBase : ApplicationService + { + protected AbpMessageServiceApplicationServiceBase() + { + LocalizationResource = typeof(NotificationsResource); + ObjectMapperContext = typeof(AbpNotificationsApplicationModule); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MyNotificationAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MyNotificationAppService.cs new file mode 100644 index 000000000..9965b65b0 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MyNotificationAppService.cs @@ -0,0 +1,75 @@ +using Microsoft.AspNetCore.Authorization; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Users; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +public class MyNotificationAppService : ApplicationService, IMyNotificationAppService +{ + protected INotificationSender NotificationSender { get; } + + protected INotificationStore NotificationStore { get; } + + protected IUserNotificationRepository UserNotificationRepository { get; } + + protected INotificationDefinitionManager NotificationDefinitionManager { get; } + + public MyNotificationAppService( + INotificationStore notificationStore, + INotificationSender notificationSender, + IUserNotificationRepository userNotificationRepository, + INotificationDefinitionManager notificationDefinitionManager) + { + NotificationStore = notificationStore; + NotificationSender = notificationSender; + UserNotificationRepository = userNotificationRepository; + NotificationDefinitionManager = notificationDefinitionManager; + } + + public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) + { + await NotificationStore.ChangeUserNotificationsReadStateAsync( + CurrentTenant.Id, + CurrentUser.GetId(), + input.IdList, + input.State); + } + + public async virtual Task DeleteAsync(long id) + { + await NotificationStore + .DeleteUserNotificationAsync( + CurrentTenant.Id, + CurrentUser.GetId(), + id); + } + + public async virtual Task GetAsync(long id) + { + var notification = await UserNotificationRepository.GetByIdAsync(CurrentUser.GetId(), id); + + return ObjectMapper.Map(notification); + } + + public async virtual Task> GetListAsync(UserNotificationGetByPagedDto input) + { + var totalCount = await UserNotificationRepository + .GetCountAsync( + CurrentUser.GetId(), + input.Filter, + input.ReadState); + + var notifications = await UserNotificationRepository + .GetListAsync( + CurrentUser.GetId(), + input.Filter, input.Sorting, + input.ReadState, input.SkipCount, input.MaxResultCount); + + return new PagedResultDto(totalCount, + ObjectMapper.Map, List>(notifications)); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MySubscriptionAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MySubscriptionAppService.cs new file mode 100644 index 000000000..28caee1d1 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/MySubscriptionAppService.cs @@ -0,0 +1,74 @@ +using Microsoft.AspNetCore.Authorization; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Users; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +public class MySubscriptionAppService : ApplicationService, IMySubscriptionAppService +{ + protected IUserSubscribeRepository UserSubscribeRepository { get; } + protected INotificationSubscriptionManager NotificationSubscriptionManager { get; } + + public MySubscriptionAppService( + IUserSubscribeRepository userSubscribeRepository, + INotificationSubscriptionManager notificationSubscriptionManager) + { + UserSubscribeRepository = userSubscribeRepository; + NotificationSubscriptionManager = notificationSubscriptionManager; + } + + public async virtual Task> GetListAsync(SubscriptionsGetByPagedDto input) + { + var userSubscribedCount = await UserSubscribeRepository.GetCountAsync(CurrentUser.GetId()); + + var userSubscribes = await UserSubscribeRepository + .GetUserSubscribesAsync(CurrentUser.GetId(), input.Sorting, + input.SkipCount, input.MaxResultCount); + + return new PagedResultDto(userSubscribedCount, + userSubscribes.Select(us => new UserSubscreNotificationDto { Name = us.NotificationName }).ToList()); + } + + public async virtual Task> GetAllListAsync() + { + var userSubscribes = await NotificationSubscriptionManager + .GetUserSubscriptionsAsync( + CurrentTenant.Id, + CurrentUser.GetId()); + + return new ListResultDto( + userSubscribes.Select(msn => new UserSubscreNotificationDto { Name = msn.NotificationName }).ToList()); + } + + public async virtual Task IsSubscribedAsync(SubscriptionsGetByNameDto input) + { + var isSubscribed = await NotificationSubscriptionManager + .IsSubscribedAsync(CurrentTenant.Id, CurrentUser.GetId(), input.Name); + + return isSubscribed + ? UserSubscriptionsResult.Subscribed() + : UserSubscriptionsResult.UnSubscribed(); + } + + public async virtual Task SubscribeAsync(SubscriptionsGetByNameDto input) + { + await NotificationSubscriptionManager + .SubscribeAsync( + CurrentTenant.Id, + new UserIdentifier(CurrentUser.GetId(), CurrentUser.UserName), + input.Name); + } + + public async virtual Task UnSubscribeAsync(SubscriptionsGetByNameDto input) + { + await NotificationSubscriptionManager + .UnsubscribeAsync( + CurrentTenant.Id, + new UserIdentifier(CurrentUser.GetId(), CurrentUser.UserName), + input.Name); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/NotificationAppService.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/NotificationAppService.cs new file mode 100644 index 000000000..367db47b9 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/NotificationAppService.cs @@ -0,0 +1,151 @@ +using Microsoft.AspNetCore.Authorization; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +public class NotificationAppService : ApplicationService, INotificationAppService +{ + protected ITemplateContentProvider TemplateContentProvider { get; } + protected INotificationSender NotificationSender { get; } + protected INotificationDefinitionManager NotificationDefinitionManager { get; } + + public NotificationAppService( + INotificationSender notificationSender, + ITemplateContentProvider templateContentProvider, + INotificationDefinitionManager notificationDefinitionManager) + { + NotificationSender = notificationSender; + TemplateContentProvider = templateContentProvider; + NotificationDefinitionManager = notificationDefinitionManager; + } + + public async virtual Task> GetAssignableNotifiersAsync() + { + var groups = new List(); + var defineGroups = await NotificationDefinitionManager.GetGroupsAsync(); + + foreach (var group in defineGroups) + { + if (!group.AllowSubscriptionToClients) + { + continue; + + } + var notificationGroup = new NotificationGroupDto + { + Name = group.Name, + DisplayName = group.DisplayName.Localize(StringLocalizerFactory) + }; + + foreach (var notification in group.Notifications) + { + if (!notification.AllowSubscriptionToClients) + { + continue; + } + + var notificationChildren = new NotificationDto + { + Name = notification.Name, + DisplayName = notification.DisplayName.Localize(StringLocalizerFactory), + Description = notification.Description?.Localize(StringLocalizerFactory) ?? notification.Name, + Lifetime = notification.NotificationLifetime, + Type = notification.NotificationType, + ContentType = notification.ContentType + }; + + notificationGroup.Notifications.Add(notificationChildren); + } + + groups.Add(notificationGroup); + } + + return new ListResultDto(groups); + } + + public async virtual Task> GetAssignableTemplatesAsync() + { + var templates = new List(); + var notifications = (await NotificationDefinitionManager + .GetNotificationsAsync()) + .Where(n => n.Template != null); + + foreach (var notification in notifications) + { + templates.Add( + new NotificationTemplateDto + { + Name = notification.Name, + Culture = CultureInfo.CurrentCulture.Name, + Title = notification.DisplayName.Localize(StringLocalizerFactory), + Description = notification.Description?.Localize(StringLocalizerFactory), + }); + } + + return new ListResultDto(templates); + } + + public async virtual Task SendAsync(NotificationSendDto input) + { + var notification = await GetNotificationDefinition(input.Name); + + UserIdentifier user = null; + if (input.ToUserId.HasValue) + { + user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); + } + + if (!input.TemplateName.IsNullOrWhiteSpace()) + { + if (notification.Template == null) + { + throw new BusinessException( + NotificationsErrorCodes.NotificationTemplateNotFound, + $"The notification template {input.TemplateName} does not exist!") + .WithData("Name", input.TemplateName); + } + var notificationTemplate = new NotificationTemplate( + notification.Name, + culture: input.Culture ?? CultureInfo.CurrentCulture.Name, + formUser: CurrentUser.Name ?? CurrentUser.UserName, + data: input.Data); + + await NotificationSender + .SendNofiterAsync( + name: input.Name, + template: notificationTemplate, + user: user, + tenantId: CurrentTenant.Id, + severity: input.Severity); + } + else + { + var notificationData = new NotificationData(); + notificationData.ExtraProperties.AddIfNotContains(input.Data); + + notificationData = NotificationData.ToStandardData(notificationData); + + await NotificationSender + .SendNofiterAsync( + name: input.Name, + data: notificationData, + user: user, + tenantId: CurrentTenant.Id, + severity: input.Severity); + } + } + + protected async virtual Task GetNotificationDefinition(string name) + { + return await NotificationDefinitionManager.GetAsync(name); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN.Abp.Notifications.Domain.Shared.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN.Abp.Notifications.Domain.Shared.csproj new file mode 100644 index 000000000..0d7136018 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN.Abp.Notifications.Domain.Shared.csproj @@ -0,0 +1,24 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/AbpNotificationsDomainSharedModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/AbpNotificationsDomainSharedModule.cs new file mode 100644 index 000000000..255d7802f --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/AbpNotificationsDomainSharedModule.cs @@ -0,0 +1,28 @@ +using LINGYUN.Abp.Notifications.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.Users; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.Notifications; + +[DependsOn( + typeof(AbpNotificationsCoreModule), + typeof(AbpUsersDomainSharedModule))] +public class AbpNotificationsDomainSharedModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/Notifications/Localization/DomainShared"); + }); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json new file mode 100644 index 000000000..153609b48 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json @@ -0,0 +1,6 @@ +{ + "culture": "en", + "texts": { + + } +} \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json new file mode 100644 index 000000000..50324cb8c --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hans", + "texts": { + + } +} \ No newline at end of file diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationConsts.cs similarity index 82% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationConsts.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationConsts.cs index 4e4d39cd6..f8429c5d2 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationConsts.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class NotificationConsts { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecordConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs similarity index 85% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecordConsts.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs index 5a1353517..b3e19b50a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecordConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public static class NotificationDefinitionGroupRecordConsts { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecordConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs similarity index 86% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecordConsts.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs index d84894f4b..d103ffeae 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecordConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public static class NotificationDefinitionRecordConsts { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationTemplateConsts.cs similarity index 83% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationTemplateConsts.cs index 27c74e900..2fda304be 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationTemplateConsts.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public static class NotificationTemplateConsts { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs new file mode 100644 index 000000000..23630baea --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs @@ -0,0 +1,35 @@ +namespace LINGYUN.Abp.Notifications +{ + /// + /// 消息系统错误码设计 + /// 状态码分为两部分 前2位领域 后3位状态 + /// + /// + /// 领域部分: + /// 01 输入 + /// 02 群组 + /// 03 用户 + /// 04 应用 + /// 05 内部 + /// 10 输出 + /// + /// + /// + /// 状态部分: + /// 200-299 成功 + /// 300-399 成功但有后续操作 + /// 400-499 业务异常 + /// 500-599 内部异常 + /// 900-999 输入输出异常 + /// + /// + /// + public class NotificationsErrorCodes + { + public const string Namespace = "LINGYUN.Abp.Notifications"; + /// + /// 通知模板不存在! + /// + public const string NotificationTemplateNotFound = Namespace + ":05404"; + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Subscriptions/SubscribeConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/SubscribeConsts.cs similarity index 74% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Subscriptions/SubscribeConsts.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/SubscribeConsts.cs index 3a70048aa..29a2e9f40 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Subscriptions/SubscribeConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/SubscribeConsts.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Subscriptions +namespace LINGYUN.Abp.Notifications { public class SubscribeConsts { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj new file mode 100644 index 000000000..d957d22ac --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj @@ -0,0 +1,25 @@ + + + + + + + netstandard2.1 + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationNames.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationNames.cs new file mode 100644 index 000000000..e18313861 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationNames.cs @@ -0,0 +1,7 @@ +namespace LINGYUN.Abp.Notifications +{ + public static class AbpNotificationNames + { + public const string GroupName = "LINGYUN.Abp.Notifications"; + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDbProperties.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDbProperties.cs new file mode 100644 index 000000000..0fee22aea --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDbProperties.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Abp.Notifications +{ + public class AbpNotificationsDbProperties + { + public const string DefaultTablePrefix = "App"; + + public const string DefaultSchema = null; + + public const string ConnectionStringName = "Notifications"; + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainAutoMapperProfile.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainAutoMapperProfile.cs new file mode 100644 index 000000000..0f6ac53ff --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainAutoMapperProfile.cs @@ -0,0 +1,53 @@ +using AutoMapper; +using System; + +namespace LINGYUN.Abp.Notifications +{ + public class AbpNotificationsDomainAutoMapperProfile : Profile + { + public AbpNotificationsDomainAutoMapperProfile() + { + CreateMap() + .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId.ToString())) + .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName)) + .ForMember(dto => dto.Lifetime, map => map.Ignore()) + .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) + .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) + .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) + .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) + .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => + { + var dataType = Type.GetType(src.NotificationTypeName); + var data = Activator.CreateInstance(dataType); + if (data is NotificationData notificationData) + { + notificationData.ExtraProperties = src.ExtraProperties; + return notificationData; + } + return new NotificationData(); + })); + + CreateMap() + .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) + .ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name)) + .ForMember(dto => dto.Lifetime, map => map.Ignore()) + .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) + .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) + .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) + .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) + .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => + { + var dataType = Type.GetType(src.NotificationTypeName); + var data = Activator.CreateInstance(dataType); + if (data is NotificationData notificationData) + { + notificationData.ExtraProperties = src.ExtraProperties; + return notificationData; + } + return new NotificationData(); + })); + + CreateMap(); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs new file mode 100644 index 000000000..a44cd376d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs @@ -0,0 +1,163 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Polly; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.AutoMapper; +using Volo.Abp.Caching; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace LINGYUN.Abp.Notifications; + +[DependsOn( + typeof(AbpCachingModule), + typeof(AbpAutoMapperModule), + typeof(AbpNotificationsModule), + typeof(AbpNotificationsDomainSharedModule))] +public class AbpNotificationsDomainModule : AbpModule +{ + private readonly CancellationTokenSource _cancellationTokenSource = new(); + + public override void ConfigureServices(ServiceConfigurationContext context) + { + if (context.Services.IsDataMigrationEnvironment()) + { + Configure(options => + { + options.SaveStaticNotificationsToDatabase = false; + options.IsDynamicNotificationsStoreEnabled = false; + }); + } + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); + } + + public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + InitializeDynamicNotifications(context); + return Task.CompletedTask; + } + + public override Task OnApplicationShutdownAsync(ApplicationShutdownContext context) + { + _cancellationTokenSource.Cancel(); + return Task.CompletedTask; + } + + private void InitializeDynamicNotifications(ApplicationInitializationContext context) + { + var options = context + .ServiceProvider + .GetRequiredService>() + .Value; + + if (!options.SaveStaticNotificationsToDatabase && !options.IsDynamicNotificationsStoreEnabled) + { + return; + } + + var rootServiceProvider = context.ServiceProvider.GetRequiredService(); + + Task.Run(async () => + { + using var scope = rootServiceProvider.CreateScope(); + var applicationLifetime = scope.ServiceProvider.GetService(); + var cancellationTokenProvider = scope.ServiceProvider.GetRequiredService(); + var cancellationToken = applicationLifetime?.ApplicationStopping ?? _cancellationTokenSource.Token; + + try + { + using (cancellationTokenProvider.Use(cancellationToken)) + { + if (cancellationTokenProvider.Token.IsCancellationRequested) + { + return; + } + + await SaveStaticNotificationsToDatabaseAsync(options, scope, cancellationTokenProvider); + + if (cancellationTokenProvider.Token.IsCancellationRequested) + { + return; + } + + await PreCacheDynamicNotificationsAsync(options, scope); + } + } + // ReSharper disable once EmptyGeneralCatchClause (No need to log since it is logged above) + catch { } + }); + } + + private async static Task SaveStaticNotificationsToDatabaseAsync( + NotificationsManagementOptions options, + IServiceScope scope, + ICancellationTokenProvider cancellationTokenProvider) + { + if (!options.SaveStaticNotificationsToDatabase) + { + return; + } + + await Policy + .Handle() + .WaitAndRetryAsync(8, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt) * 10)) + .ExecuteAsync(async _ => + { + try + { + // ReSharper disable once AccessToDisposedClosure + await scope + .ServiceProvider + .GetRequiredService() + .SaveAsync(); + } + catch (Exception ex) + { + // ReSharper disable once AccessToDisposedClosure + scope.ServiceProvider + .GetService>()? + .LogException(ex); + + throw; // Polly will catch it + } + }, cancellationTokenProvider.Token); + } + + private async static Task PreCacheDynamicNotificationsAsync(NotificationsManagementOptions options, IServiceScope scope) + { + if (!options.IsDynamicNotificationsStoreEnabled) + { + return; + } + + try + { + // Pre-cache Notifications, so first request doesn't wait + await scope + .ServiceProvider + .GetRequiredService() + .GetGroupsAsync(); + } + catch (Exception ex) + { + // ReSharper disable once AccessToDisposedClosure + scope + .ServiceProvider + .GetService>()? + .LogException(ex); + + throw; // It will be cached in InitializeDynamicNotifications + } + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpNotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs similarity index 77% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpNotificationsManagementOptions.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs index b3fa0f90c..7db82663b 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpNotificationsManagementOptions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs @@ -1,4 +1,4 @@ -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class AbpNotificationsManagementOptions { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs similarity index 95% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs index 64b8e9ba4..b12e23da1 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs @@ -16,7 +16,7 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Localization; using Volo.Abp.Threading; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinitionCache, ISingletonDependency { @@ -188,7 +188,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition var resource = GetResourceOrNull(record.ResourceName); if (resource != null) { - var localizer = StringLocalizerFactory.Create(resource.ResourceType); + var localizer = await StringLocalizerFactory.CreateByResourceNameAsync(resource.ResourceName); displayName = localizer[$"DisplayName:{record.Localization}"]; description = localizer[$"Description:{record.Localization}"]; @@ -276,7 +276,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition var resource = GetResourceOrNull(record.ResourceName); if (resource != null) { - var localizer = StringLocalizerFactory.Create(resource.ResourceType); + var localizer = await StringLocalizerFactory.CreateByResourceNameAsync(resource.ResourceName); displayName = localizer[$"DisplayName:{record.Localization}"]; description = localizer[$"Description:{record.Localization}"]; @@ -320,7 +320,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition return records; } - protected virtual LocalizationResource GetResourceOrNull(string resourceName) + protected virtual LocalizationResourceBase GetResourceOrNull(string resourceName) { return LocalizationOptions.Resources.Values .FirstOrDefault(x => x.ResourceName.Equals(resourceName)); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionStore.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs similarity index 91% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionStore.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs index 74190cd4d..fdc3bc190 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionStore.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs @@ -1,11 +1,10 @@ -using LINGYUN.Abp.Notifications; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; [Dependency(ReplaceServices = true)] public class DynamicNotificationDefinitionStore : IDynamicNotificationDefinitionStore, ITransientDependency diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IDynamicNotificationDefinitionCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs similarity index 68% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IDynamicNotificationDefinitionCache.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs index cd6056cda..fcebc3e87 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IDynamicNotificationDefinitionCache.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs @@ -1,8 +1,7 @@ -using LINGYUN.Abp.Notifications; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public interface IDynamicNotificationDefinitionCache { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionGroupRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionGroupRecordRepository.cs similarity index 75% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionGroupRecordRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionGroupRecordRepository.cs index 0983e18c5..28fcefda0 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionGroupRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionGroupRecordRepository.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Domain.Repositories; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public interface INotificationDefinitionGroupRecordRepository : IBasicRepository { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionRecordRepository.cs similarity index 74% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionRecordRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionRecordRepository.cs index caa1bddde..b071795e4 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationDefinitionRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionRecordRepository.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Domain.Repositories; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public interface INotificationDefinitionRecordRepository : IBasicRepository { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionSerializer.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionSerializer.cs new file mode 100644 index 000000000..3e044d8b9 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationDefinitionSerializer.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Notifications; + +public interface INotificationDefinitionSerializer +{ + Task<(NotificationDefinitionGroupRecord[], NotificationDefinitionRecord[])> + SerializeAsync(IEnumerable NotificationGroups); + + Task SerializeAsync( + NotificationGroupDefinition NotificationGroup); + + Task SerializeAsync( + NotificationDefinition Notification, + [CanBeNull] NotificationGroupDefinition NotificationGroup); +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationRepository.cs similarity index 90% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationRepository.cs index 162a20906..90cb20904 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/INotificationRepository.cs @@ -3,7 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public interface INotificationRepository : IBasicRepository { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IStaticNotificationSaver.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IStaticNotificationSaver.cs new file mode 100644 index 000000000..9b1b97670 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IStaticNotificationSaver.cs @@ -0,0 +1,7 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Notifications; +public interface IStaticNotificationSaver +{ + Task SaveAsync(); +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IUserNotificationRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserNotificationRepository.cs similarity index 91% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IUserNotificationRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserNotificationRepository.cs index 9dcfd7b68..567f62084 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IUserNotificationRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserNotificationRepository.cs @@ -1,11 +1,10 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public interface IUserNotificationRepository : IBasicRepository { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/IUserSubscribeRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserSubscribeRepository.cs similarity index 97% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/IUserSubscribeRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserSubscribeRepository.cs index c30014730..570abf531 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/IUserSubscribeRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IUserSubscribeRepository.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace LINGYUN.Abp.MessageService.Subscriptions +namespace LINGYUN.Abp.Notifications { public interface IUserSubscribeRepository : IBasicRepository { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Notification.cs similarity index 92% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Notification.cs index f6d5e0b45..ba55c01cf 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Notification.cs @@ -1,11 +1,10 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using Volo.Abp.Auditing; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class Notification : Entity, IMultiTenant, IHasCreationTime, IHasExtraProperties { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecord.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs similarity index 72% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecord.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs index 7dac326ac..e5241a7b3 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupRecord.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs @@ -3,7 +3,7 @@ using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class NotificationDefinitionGroupRecord : BasicAggregateRoot, IHasExtraProperties { @@ -86,4 +86,47 @@ public class NotificationDefinitionGroupRecord : BasicAggregateRoot, IHasE ResourceName = Check.Length(resourceName, nameof(resourceName), NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); Localization = Check.Length(localization, nameof(localization), NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); } + + public bool HasSameData(NotificationDefinitionGroupRecord otherRecord) + { + if (Name != otherRecord.Name) + { + return false; + } + + if (DisplayName != otherRecord.DisplayName) + { + return false; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + return false; + } + + return true; + } + + public void Patch(NotificationDefinitionGroupRecord otherRecord) + { + if (Name != otherRecord.Name) + { + Name = otherRecord.Name; + } + + if (DisplayName != otherRecord.DisplayName) + { + DisplayName = otherRecord.DisplayName; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + ExtraProperties.Clear(); + + foreach (var property in otherRecord.ExtraProperties) + { + ExtraProperties.Add(property.Key, property.Value); + } + } + } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupsCacheItem.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupsCacheItem.cs similarity index 92% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupsCacheItem.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupsCacheItem.cs index c23d3d1c9..7ecf55b95 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionGroupsCacheItem.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupsCacheItem.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.MultiTenancy; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; [Serializable] [IgnoreMultiTenancy] diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs similarity index 74% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs index 66419c92e..d6a0ad633 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs @@ -1,12 +1,11 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using System.Collections.Generic; using System.Linq; using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraProperties { @@ -136,4 +135,67 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP Providers = currentProviders.JoinAsString(";"); } } + + public bool HasSameData(NotificationDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + return false; + } + + if (GroupName != otherRecord.GroupName) + { + return false; + } + + if (DisplayName != otherRecord.DisplayName) + { + return false; + } + + if (Providers != otherRecord.Providers) + { + return false; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + return false; + } + + return true; + } + + public void Patch(NotificationDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + Name = otherRecord.Name; + } + + if (GroupName != otherRecord.GroupName) + { + GroupName = otherRecord.GroupName; + } + + if (DisplayName != otherRecord.DisplayName) + { + DisplayName = otherRecord.DisplayName; + } + + if (Providers != otherRecord.Providers) + { + Providers = otherRecord.Providers; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + ExtraProperties.Clear(); + + foreach (var property in otherRecord.ExtraProperties) + { + ExtraProperties.Add(property.Key, property.Value); + } + } + } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs new file mode 100644 index 000000000..a0cab7267 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs @@ -0,0 +1,101 @@ +using JetBrains.Annotations; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.Localization; +using Volo.Abp.SimpleStateChecking; + +namespace LINGYUN.Abp.Notifications; +public class NotificationDefinitionSerializer : INotificationDefinitionSerializer, ITransientDependency +{ + protected ISimpleStateCheckerSerializer StateCheckerSerializer { get; } + protected IGuidGenerator GuidGenerator { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } + + public NotificationDefinitionSerializer( + IGuidGenerator guidGenerator, + ISimpleStateCheckerSerializer stateCheckerSerializer, + ILocalizableStringSerializer localizableStringSerializer) + { + StateCheckerSerializer = stateCheckerSerializer; + LocalizableStringSerializer = localizableStringSerializer; + GuidGenerator = guidGenerator; + } + + public async virtual Task<(NotificationDefinitionGroupRecord[], NotificationDefinitionRecord[])> + SerializeAsync(IEnumerable notificationGroups) + { + var notificationGroupRecords = new List(); + var notificationRecords = new List(); + + foreach (var notificationGroup in notificationGroups) + { + notificationGroupRecords.Add(await SerializeAsync(notificationGroup)); + + foreach (var notification in notificationGroup.Notifications) + { + notificationRecords.Add(await SerializeAsync(notification, notificationGroup)); + } + } + + return (notificationGroupRecords.ToArray(), notificationRecords.ToArray()); + } + + public virtual Task SerializeAsync(NotificationGroupDefinition notificationGroup) + { + using (CultureHelper.Use(CultureInfo.InvariantCulture)) + { + var permissionGroupRecord = new NotificationDefinitionGroupRecord( + GuidGenerator.Create(), + notificationGroup.Name, + LocalizableStringSerializer.Serialize(notificationGroup.DisplayName) + ); + + foreach (var property in notificationGroup.Properties) + { + permissionGroupRecord.SetProperty(property.Key, property.Value); + } + + return Task.FromResult(permissionGroupRecord); + } + } + + public virtual Task SerializeAsync( + NotificationDefinition notification, + [CanBeNull] NotificationGroupDefinition notificationGroup) + { + using (CultureHelper.Use(CultureInfo.InvariantCulture)) + { + var notificationRecord = new NotificationDefinitionRecord( + GuidGenerator.Create(), + notification.Name, + notificationGroup?.Name, + LocalizableStringSerializer.Serialize(notification.DisplayName), + LocalizableStringSerializer.Serialize(notification.Description), + null, + null, + notification.NotificationLifetime, + notification.NotificationType, + notification.ContentType + ); + + foreach (var property in notification.Properties) + { + notificationRecord.SetProperty(property.Key, property.Value); + } + + return Task.FromResult(notificationRecord); + } + } + + protected virtual string SerializeProviders(ICollection providers) + { + return providers.Any() + ? providers.JoinAsString(",") + : null; + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionsCacheItem.cs similarity index 92% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionsCacheItem.cs index 34b941f56..91521585f 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionsCacheItem.cs @@ -1,9 +1,8 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using System.Collections.Generic; using Volo.Abp.MultiTenancy; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; [Serializable] [IgnoreMultiTenancy] diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationStore.cs similarity index 96% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationStore.cs index eb9529c27..7f25b2a41 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationStore.cs @@ -1,6 +1,4 @@ -using LINGYUN.Abp.MessageService.Subscriptions; -using LINGYUN.Abp.Notifications; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; @@ -13,7 +11,7 @@ using Volo.Abp.ObjectMapping; using Volo.Abp.Timing; using Volo.Abp.Uow; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] [ExposeServices(typeof(INotificationStore))] diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationTypeConverter.cs similarity index 89% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationTypeConverter.cs index 87b4c21c0..d401bfc05 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationTypeConverter.cs @@ -1,11 +1,9 @@ using AutoMapper; -using LINGYUN.Abp.MessageService.Notifications; -using LINGYUN.Abp.Notifications; using System; using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace LINGYUN.Abp.MessageService.Mapper +namespace LINGYUN.Abp.Notifications { public class NotificationTypeConverter : ITypeConverter, ISingletonDependency { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs new file mode 100644 index 000000000..2d18a4d7a --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs @@ -0,0 +1,18 @@ +namespace LINGYUN.Abp.Notifications; + +public class NotificationsManagementOptions +{ + /// + /// Default: true. + /// + public bool SaveStaticNotificationsToDatabase { get; set; } = true; + + /// + /// Default: false. + /// + public bool IsDynamicNotificationsStoreEnabled { get; set; } + + public NotificationsManagementOptions() + { + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/StaticNotificationSaver.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/StaticNotificationSaver.cs new file mode 100644 index 000000000..e4c716fae --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/StaticNotificationSaver.cs @@ -0,0 +1,296 @@ +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Threading; +using Volo.Abp.Uow; + +namespace LINGYUN.Abp.Notifications; + +public class StaticNotificationSaver : IStaticNotificationSaver, ITransientDependency +{ + protected IStaticNotificationDefinitionStore StaticStore { get; } + protected INotificationDefinitionGroupRecordRepository NotificationGroupRepository { get; } + protected INotificationDefinitionRecordRepository NotificationRepository { get; } + protected INotificationDefinitionSerializer NotificationSerializer { get; } + protected IDistributedCache Cache { get; } + protected IApplicationInfoAccessor ApplicationInfoAccessor { get; } + protected IAbpDistributedLock DistributedLock { get; } + protected AbpNotificationsOptions NotificationsOptions { get; } + protected ICancellationTokenProvider CancellationTokenProvider { get; } + protected AbpDistributedCacheOptions CacheOptions { get; } + + public StaticNotificationSaver( + IStaticNotificationDefinitionStore staticStore, + INotificationDefinitionGroupRecordRepository notificationGroupRepository, + INotificationDefinitionRecordRepository notificationRepository, + INotificationDefinitionSerializer notificationSerializer, + IDistributedCache cache, + IOptions cacheOptions, + IApplicationInfoAccessor applicationInfoAccessor, + IAbpDistributedLock distributedLock, + IOptions notificationsOptions, + ICancellationTokenProvider cancellationTokenProvider) + { + StaticStore = staticStore; + NotificationGroupRepository = notificationGroupRepository; + NotificationRepository = notificationRepository; + NotificationSerializer = notificationSerializer; + Cache = cache; + ApplicationInfoAccessor = applicationInfoAccessor; + DistributedLock = distributedLock; + CancellationTokenProvider = cancellationTokenProvider; + NotificationsOptions = notificationsOptions.Value; + CacheOptions = cacheOptions.Value; + } + + [UnitOfWork] + public async virtual Task SaveAsync() + { + await using var applicationLockHandle = await DistributedLock.TryAcquireAsync( + GetApplicationDistributedLockKey() + ); + + if (applicationLockHandle == null) + { + /* Another application instance is already doing it */ + return; + } + + /* NOTE: This can be further optimized by using 4 cache values for: + * Groups, notifications, deleted groups and deleted notifications. + * But the code would be more complex. This is enough for now. + */ + + var cacheKey = GetApplicationHashCacheKey(); + var cachedHash = await Cache.GetStringAsync(cacheKey, CancellationTokenProvider.Token); + + var (notificationGroupRecords, notificationRecords) = await NotificationSerializer.SerializeAsync( + await StaticStore.GetGroupsAsync() + ); + + var currentHash = CalculateHash( + notificationGroupRecords, + notificationRecords, + NotificationsOptions.DeletedNotificationGroups, + NotificationsOptions.DeletedNotifications + ); + + if (cachedHash == currentHash) + { + return; + } + + await using (var commonLockHandle = await DistributedLock.TryAcquireAsync( + GetCommonDistributedLockKey(), + TimeSpan.FromMinutes(5))) + { + if (commonLockHandle == null) + { + /* It will re-try */ + throw new AbpException("Could not acquire distributed lock for saving static notifications!"); + } + + var hasChangesInGroups = await UpdateChangednotificationGroupsAsync(notificationGroupRecords); + var hasChangesInnotifications = await UpdateChangednotificationsAsync(notificationRecords); + + if (hasChangesInGroups || hasChangesInnotifications) + { + await Cache.SetStringAsync( + GetCommonStampCacheKey(), + Guid.NewGuid().ToString(), + new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + }, + CancellationTokenProvider.Token + ); + } + } + + await Cache.SetStringAsync( + cacheKey, + currentHash, + new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + }, + CancellationTokenProvider.Token + ); + } + + private async Task UpdateChangednotificationGroupsAsync( + IEnumerable notificationGroupRecords) + { + var newRecords = new List(); + var changedRecords = new List(); + + var notificationGroupRecordsInDatabase = (await NotificationGroupRepository.GetListAsync()) + .ToDictionary(x => x.Name); + + foreach (var notificationGroupRecord in notificationGroupRecords) + { + var notificationGroupRecordInDatabase = notificationGroupRecordsInDatabase.GetOrDefault(notificationGroupRecord.Name); + if (notificationGroupRecordInDatabase == null) + { + /* New group */ + newRecords.Add(notificationGroupRecord); + continue; + } + + if (notificationGroupRecord.HasSameData(notificationGroupRecordInDatabase)) + { + /* Not changed */ + continue; + } + + /* Changed */ + notificationGroupRecordInDatabase.Patch(notificationGroupRecord); + changedRecords.Add(notificationGroupRecordInDatabase); + } + + /* Deleted */ + var deletedRecords = NotificationsOptions.DeletedNotificationGroups.Any() + ? notificationGroupRecordsInDatabase.Values + .Where(x => NotificationsOptions.DeletedNotificationGroups.Contains(x.Name)) + .ToArray() + : Array.Empty(); + + if (newRecords.Any()) + { + await NotificationGroupRepository.InsertManyAsync(newRecords); + } + + if (changedRecords.Any()) + { + await NotificationGroupRepository.UpdateManyAsync(changedRecords); + } + + if (deletedRecords.Any()) + { + await NotificationGroupRepository.DeleteManyAsync(deletedRecords); + } + + return newRecords.Any() || changedRecords.Any() || deletedRecords.Any(); + } + + private async Task UpdateChangednotificationsAsync( + IEnumerable notificationRecords) + { + var newRecords = new List(); + var changedRecords = new List(); + + var notificationRecordsInDatabase = (await NotificationRepository.GetListAsync()) + .ToDictionary(x => x.Name); + + foreach (var notificationRecord in notificationRecords) + { + var notificationRecordInDatabase = notificationRecordsInDatabase.GetOrDefault(notificationRecord.Name); + if (notificationRecordInDatabase == null) + { + /* New group */ + newRecords.Add(notificationRecord); + continue; + } + + if (notificationRecord.HasSameData(notificationRecordInDatabase)) + { + /* Not changed */ + continue; + } + + /* Changed */ + notificationRecordInDatabase.Patch(notificationRecord); + changedRecords.Add(notificationRecordInDatabase); + } + + /* Deleted */ + var deletedRecords = new List(); + + if (NotificationsOptions.DeletedNotifications.Any()) + { + deletedRecords.AddRange( + notificationRecordsInDatabase.Values + .Where(x => NotificationsOptions.DeletedNotifications.Contains(x.Name)) + ); + } + + if (NotificationsOptions.DeletedNotificationGroups.Any()) + { + deletedRecords.AddIfNotContains( + notificationRecordsInDatabase.Values + .Where(x => NotificationsOptions.DeletedNotificationGroups.Contains(x.GroupName)) + ); + } + + if (newRecords.Any()) + { + await NotificationRepository.InsertManyAsync(newRecords); + } + + if (changedRecords.Any()) + { + await NotificationRepository.UpdateManyAsync(changedRecords); + } + + if (deletedRecords.Any()) + { + await NotificationRepository.DeleteManyAsync(deletedRecords); + } + + return newRecords.Any() || changedRecords.Any() || deletedRecords.Any(); + } + + private string GetApplicationDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_{ApplicationInfoAccessor.ApplicationName}_AbpNotificationUpdateLock"; + } + + private string GetCommonDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_Common_AbpNotificationUpdateLock"; + } + + private string GetApplicationHashCacheKey() + { + return $"{CacheOptions.KeyPrefix}_{ApplicationInfoAccessor.ApplicationName}_AbpNotificationsHash"; + } + + private string GetCommonStampCacheKey() + { + return $"{CacheOptions.KeyPrefix}_AbpInMemoryNotificationCacheStamp"; + } + + private static string CalculateHash( + NotificationDefinitionGroupRecord[] notificationGroupRecords, + NotificationDefinitionRecord[] notificationRecords, + IEnumerable deletednotificationGroups, + IEnumerable deletednotifications) + { + var stringBuilder = new StringBuilder(); + + stringBuilder.Append("NotificationGroupRecords:"); + stringBuilder.AppendLine(JsonSerializer.Serialize(notificationGroupRecords)); + + stringBuilder.Append("NotificationRecords:"); + stringBuilder.AppendLine(JsonSerializer.Serialize(notificationRecords)); + + stringBuilder.Append("DeletedNotificationGroups:"); + stringBuilder.AppendLine(deletednotificationGroups.JoinAsString(",")); + + stringBuilder.Append("DeletedNotification:"); + stringBuilder.Append(deletednotifications.JoinAsString(",")); + + return stringBuilder + .ToString() + .ToMd5(); + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/Subscribe.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Subscribe.cs similarity index 92% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/Subscribe.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Subscribe.cs index e3fd97d74..3499e0937 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/Subscribe.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/Subscribe.cs @@ -3,7 +3,7 @@ using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace LINGYUN.Abp.MessageService.Subscriptions +namespace LINGYUN.Abp.Notifications { public abstract class Subscribe : Entity, IMultiTenant, IHasCreationTime { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotification.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotification.cs similarity index 89% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotification.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotification.cs index 871866eff..80f5c5027 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotification.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotification.cs @@ -1,9 +1,8 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace LINGYUN.Abp.MessageService.Notifications +namespace LINGYUN.Abp.Notifications { public class UserNotification : Entity, IMultiTenant { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotificationInfo.cs similarity index 82% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotificationInfo.cs index 1c36f1d4a..adc4099ec 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserNotificationInfo.cs @@ -1,8 +1,7 @@ -using LINGYUN.Abp.Notifications; -using System; +using System; using Volo.Abp.Data; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications; public class UserNotificationInfo { diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/UserSubscribe.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserSubscribe.cs similarity index 90% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/UserSubscribe.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserSubscribe.cs index b6726644e..5b2efd784 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/UserSubscribe.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/UserSubscribe.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Auditing; -namespace LINGYUN.Abp.MessageService.Subscriptions +namespace LINGYUN.Abp.Notifications { public class UserSubscribe : Subscribe, IHasCreationTime { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj new file mode 100644 index 000000000..203477b49 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj @@ -0,0 +1,19 @@ + + + + + + + net7.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs new file mode 100644 index 000000000..d87f093e3 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs @@ -0,0 +1,36 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Caching; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +[DependsOn( + typeof(AbpCachingModule), + typeof(AbpAutoMapperModule), + typeof(AbpNotificationsModule), + typeof(AbpNotificationsDomainSharedModule))] +public class AbpNotificationsEntityFrameworkCoreModule : AbpModule +{ + [DependsOn( + typeof(AbpNotificationsDomainModule), + typeof(AbpEntityFrameworkCoreModule))] + public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + options.AddDefaultRepositories(); + + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + + options.AddRepository(); + options.AddRepository(); + }); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsModelBuilderConfigurationOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsModelBuilderConfigurationOptions.cs new file mode 100644 index 000000000..d05a07bce --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsModelBuilderConfigurationOptions.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore +{ + public class AbpNotificationsModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions + { + public AbpNotificationsModelBuilderConfigurationOptions( + [NotNull] string tablePrefix = AbpNotificationsDbProperties.DefaultTablePrefix, + [CanBeNull] string schema = AbpNotificationsDbProperties.DefaultSchema) + : base( + tablePrefix, + schema) + { + + } + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionGroupRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs similarity index 55% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionGroupRecordRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs index df48ab133..fc08242a0 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionGroupRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs @@ -1,18 +1,17 @@ -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using System; +using System; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; public class EfCoreNotificationDefinitionGroupRecordRepository : - EfCoreRepository, + EfCoreRepository, INotificationDefinitionGroupRecordRepository, ITransientDependency { public EfCoreNotificationDefinitionGroupRecordRepository( - IDbContextProvider dbContextProvider) + IDbContextProvider dbContextProvider) : base(dbContextProvider) { } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs similarity index 55% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionRecordRepository.cs rename to aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs index 410c9561b..65ed69c5c 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationDefinitionRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs @@ -1,18 +1,17 @@ -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using System; +using System; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -namespace LINGYUN.Abp.MessageService.Notifications; +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; public class EfCoreNotificationDefinitionRecordRepository : - EfCoreRepository, + EfCoreRepository, INotificationDefinitionRecordRepository, ITransientDependency { public EfCoreNotificationDefinitionRecordRepository( - IDbContextProvider dbContextProvider) + IDbContextProvider dbContextProvider) : base(dbContextProvider) { } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationRepository.cs new file mode 100644 index 000000000..98409e549 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationRepository.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +public class EfCoreNotificationRepository : EfCoreRepository, + INotificationRepository, ITransientDependency +{ + public EfCoreNotificationRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async Task> GetExpritionAsync( + int batchCount, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.ExpirationTime < DateTime.Now) + .OrderBy(x => x.ExpirationTime) + .Take(batchCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async Task GetByIdAsync( + long notificationId, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()).Where(x => x.NotificationId.Equals(notificationId)) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs new file mode 100644 index 000000000..c458cb2de --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs @@ -0,0 +1,179 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +public class EfCoreUserNotificationRepository : EfCoreRepository, + IUserNotificationRepository, ITransientDependency +{ + public EfCoreUserNotificationRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task AnyAsync( + Guid userId, + long notificationId, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .AnyAsync(x => x.NotificationId.Equals(notificationId) && x.UserId.Equals(userId), + GetCancellationToken(cancellationToken)); + } + + public async virtual Task GetByIdAsync( + Guid userId, + long notificationId, + CancellationToken cancellationToken = default) + { + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() + .Where(x => x.UserId == userId); + + var notificationQuery = dbContext.Set(); + + var notifilerQuery = from un in userNotifilerQuery + join n in dbContext.Set() + on un.NotificationId equals n.NotificationId + where n.NotificationId.Equals(notificationId) + select new UserNotificationInfo + { + Id = n.NotificationId, + TenantId = n.TenantId, + Name = n.NotificationName, + ExtraProperties = n.ExtraProperties, + CreationTime = n.CreationTime, + NotificationTypeName = n.NotificationTypeName, + Severity = n.Severity, + State = un.ReadStatus, + Type = n.Type, + ContentType = n.ContentType + }; + + return await notifilerQuery + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetListAsync( + Guid userId, + IEnumerable notificationIds, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.UserId.Equals(userId) && notificationIds.Contains(x.NotificationId)) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetNotificationsAsync( + Guid userId, + NotificationReadState? readState = null, + int maxResultCount = 10, + CancellationToken cancellationToken = default) + { + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() + .Where(x => x.UserId == userId) + .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); + + var notifilerQuery = from un in userNotifilerQuery + join n in dbContext.Set() + on un.NotificationId equals n.NotificationId + select new UserNotificationInfo + { + Id = n.NotificationId, + TenantId = n.TenantId, + Name = n.NotificationName, + ExtraProperties = n.ExtraProperties, + CreationTime = n.CreationTime, + NotificationTypeName = n.NotificationTypeName, + Severity = n.Severity, + State = un.ReadStatus, + Type = n.Type, + ContentType = n.ContentType + }; + + return await notifilerQuery + .OrderBy(nameof(Notification.CreationTime) + " DESC") + .Take(maxResultCount) + .AsNoTracking() + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task GetCountAsync( + Guid userId, + string filter = "", + NotificationReadState? readState = null, + CancellationToken cancellationToken = default) + { + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() + .Where(x => x.UserId == userId) + .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); + + var notificationQuery = dbContext.Set() + .WhereIf(!filter.IsNullOrWhiteSpace(), nf => + nf.NotificationName.Contains(filter) || + nf.NotificationTypeName.Contains(filter)); + + var notifilerQuery = from un in userNotifilerQuery + join n in notificationQuery + on un.NotificationId equals n.NotificationId + select n; + + return await notifilerQuery + .CountAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetListAsync( + Guid userId, + string filter = "", + string sorting = nameof(Notification.CreationTime), + NotificationReadState? readState = null, + int skipCount = 1, + int maxResultCount = 10, + CancellationToken cancellationToken = default) + { + sorting ??= $"{nameof(Notification.CreationTime)} DESC"; + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() + .Where(x => x.UserId == userId) + .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); + + var notificationQuery = dbContext.Set() + .WhereIf(!filter.IsNullOrWhiteSpace(), nf => + nf.NotificationName.Contains(filter) || + nf.NotificationTypeName.Contains(filter)); + + var notifilerQuery = from un in userNotifilerQuery + join n in notificationQuery + on un.NotificationId equals n.NotificationId + select new UserNotificationInfo + { + Id = n.NotificationId, + TenantId = n.TenantId, + Name = n.NotificationName, + ExtraProperties = n.ExtraProperties, + CreationTime = n.CreationTime, + NotificationTypeName = n.NotificationTypeName, + Severity = n.Severity, + State = un.ReadStatus, + Type = n.Type, + ContentType = n.ContentType + }; + + return await notifilerQuery + .OrderBy(sorting) + .PageBy(skipCount, maxResultCount) + .AsNoTracking() + .ToListAsync(GetCancellationToken(cancellationToken)); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs new file mode 100644 index 000000000..8f375bc83 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs @@ -0,0 +1,162 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +public class EfCoreUserSubscribeRepository : EfCoreRepository, + IUserSubscribeRepository, ITransientDependency +{ + public EfCoreUserSubscribeRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task> GetUserSubscribesAsync( + string notificationName, + IEnumerable userIds = null, + CancellationToken cancellationToken = default) + { + var userSubscribes = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.NotificationName.Equals(notificationName)) + .WhereIf(userIds?.Any() == true, x => userIds.Contains(x.UserId)) + .AsNoTracking() + .ToListAsync(GetCancellationToken(cancellationToken)); + + return userSubscribes; + } + + public async virtual Task GetUserSubscribeAsync( + string notificationName, + Guid userId, + CancellationToken cancellationToken = default) + { + var userSubscribe = await (await GetDbSetAsync()) + .Where(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName)) + .AsNoTracking() + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + + return userSubscribe; + } + + public async virtual Task> GetUserSubscribesAsync( + Guid userId, + CancellationToken cancellationToken = default) + { + var userSubscribeNames = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.UserId.Equals(userId)) + .Select(x => x.NotificationName) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return userSubscribeNames; + } + + public async virtual Task> GetUserSubscribesByNameAsync( + string userName, + CancellationToken cancellationToken = default) + { + var userSubscribeNames = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.UserName.Equals(userName)) + .AsNoTracking() + .ToListAsync(GetCancellationToken(cancellationToken)); + + return userSubscribeNames; + } + + public async virtual Task> GetUserSubscribesAsync( + string notificationName, + CancellationToken cancellationToken = default) + { + var subscribeUsers = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.NotificationName.Equals(notificationName)) + .Select(x => x.UserId) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return subscribeUsers; + } + + public async virtual Task InsertUserSubscriptionAsync( + IEnumerable userSubscribes, + CancellationToken cancellationToken = default) + { + await (await GetDbSetAsync()).AddRangeAsync(userSubscribes, GetCancellationToken(cancellationToken)); + } + + public async virtual Task DeleteUserSubscriptionAsync( + string notificationName, + CancellationToken cancellationToken = default) + { + var userSubscribes = await (await GetDbSetAsync()).Where(x => x.NotificationName.Equals(notificationName)) + .ToListAsync(GetCancellationToken(cancellationToken)); + (await GetDbSetAsync()).RemoveRange(userSubscribes); + } + + public async virtual Task DeleteUserSubscriptionAsync( + IEnumerable userSubscribes, + CancellationToken cancellationToken = default) + { + await DeleteManyAsync(userSubscribes); + } + + public async virtual Task DeleteUserSubscriptionAsync( + string notificationName, + IEnumerable userIds, + CancellationToken cancellationToken = default) + { + await DeleteAsync(usr => usr.NotificationName == notificationName && userIds.Contains(usr.UserId), + false, + GetCancellationToken(cancellationToken)); + } + + public async virtual Task UserSubscribeExistsAysnc( + string notificationName, + Guid userId, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .AnyAsync(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName), + GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetUserSubscribesAsync( + Guid userId, + string sorting = "Id", + int skipCount = 1, + int maxResultCount = 10, + CancellationToken cancellationToken = default) + { + var userSubscribes = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.UserId.Equals(userId)) + .OrderBy(sorting ?? nameof(UserSubscribe.Id)) + .Page(skipCount, maxResultCount) + .AsNoTracking() + .ToListAsync(GetCancellationToken(cancellationToken)); + + return userSubscribes; + } + + public async virtual Task GetCountAsync( + Guid userId, + CancellationToken cancellationToken = default) + { + var userSubscribedCount = await (await GetDbSetAsync()) + .Distinct() + .Where(x => x.UserId.Equals(userId)) + .LongCountAsync(GetCancellationToken(cancellationToken)); + + return userSubscribedCount; + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs new file mode 100644 index 000000000..d20b6ff7d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] +public interface INotificationsDbContext : IEfCoreDbContext +{ +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs new file mode 100644 index 000000000..5ae9b78a7 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] +public class NotificationsDbContext : AbpDbContext, INotificationsDbContext +{ + public NotificationsDbContext(DbContextOptions options) + : base(options) + { + } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureNotifications(); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..9fa15f6c3 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs @@ -0,0 +1,112 @@ +using Microsoft.EntityFrameworkCore; +using System; +using Volo.Abp; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore +{ + public static class NotificationsDbContextModelCreatingExtensions + { + public static void ConfigureNotifications( + this ModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + var options = new AbpNotificationsModelBuilderConfigurationOptions(); + + optionsAction?.Invoke(options); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Notifications", options.Schema); + + b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired(); + b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired(); + //b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired(); + + b.Property(p => p.ContentType) + .HasDefaultValue(NotificationContentType.Text); + + b.ConfigureByConvention(); + + b.HasIndex(p => new { p.TenantId, p.NotificationName }); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); + + b.ConfigureByConvention(); + + b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId }) + .HasDatabaseName("IX_Tenant_User_Notification_Id"); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema); + + b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired(); + b.Property(p => p.UserName) + .HasMaxLength(SubscribeConsts.MaxUserNameLength) + .HasDefaultValue("/")// 不是必须的 + .IsRequired(); + + b.ConfigureByConvention(); + + b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName }) + .HasDatabaseName("IX_Tenant_User_Notification_Name") + .IsUnique(); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "NotificationDefinitionGroups", options.Schema); + + b.Property(p => p.Name) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxNameLength) + .IsRequired(); + + b.Property(p => p.DisplayName) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDisplayNameLength); + b.Property(p => p.Description) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDescriptionLength); + b.Property(p => p.ResourceName) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); + b.Property(p => p.Localization) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); + + b.ConfigureByConvention(); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "NotificationDefinitions", options.Schema); + + b.Property(p => p.Name) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxNameLength) + .IsRequired(); + b.Property(p => p.GroupName) + .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxNameLength) + .IsRequired(); + + b.Property(p => p.DisplayName) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxDisplayNameLength); + b.Property(p => p.Description) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxDescriptionLength); + b.Property(p => p.ResourceName) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxResourceNameLength); + b.Property(p => p.Localization) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxLocalizationLength); + b.Property(p => p.Providers) + .HasMaxLength(NotificationDefinitionRecordConsts.MaxProvidersLength); + + b.Property(p => p.ContentType) + .HasDefaultValue(NotificationContentType.Text); + + b.ConfigureByConvention(); + }); + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xml b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xsd b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN.Abp.Notifications.HttpApi.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN.Abp.Notifications.HttpApi.csproj new file mode 100644 index 000000000..53ee33d3a --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN.Abp.Notifications.HttpApi.csproj @@ -0,0 +1,19 @@ + + + + + + + net7.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs new file mode 100644 index 000000000..c19e4e64e --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs @@ -0,0 +1,28 @@ +using LINGYUN.Abp.Notifications.Localization; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.Localization; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Notifications.HttpApi; + +[DependsOn( + typeof(AbpAspNetCoreMvcModule), + typeof(AbpNotificationsApplicationContractsModule))] +public class AbpNotificationsHttpApiModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpNotificationsHttpApiModule).Assembly); + }); + + PreConfigure(options => + { + options.AddAssemblyResource( + typeof(NotificationsResource), + typeof(AbpNotificationsApplicationContractsModule).Assembly); // Dto所在程序集 + }); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MyNotificationController.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MyNotificationController.cs new file mode 100644 index 000000000..eb1a55963 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MyNotificationController.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +[Controller] +[RemoteService(Name = AbpNotificationsRemoteServiceConsts.RemoteServiceName)] +[Area(AbpNotificationsRemoteServiceConsts.ModuleName)] +[Route("api/notifications/my-notifilers")] +public class MyNotificationController : AbpController, IMyNotificationAppService +{ + protected IMyNotificationAppService MyNotificationAppService { get; } + + public MyNotificationController( + IMyNotificationAppService myNotificationAppService) + { + MyNotificationAppService = myNotificationAppService; + } + + [HttpPut] + [Route("mark-read-state")] + public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) + { + await MyNotificationAppService.MarkReadStateAsync(input); + } + + [HttpDelete] + [Route("{id}")] + public async virtual Task DeleteAsync(long id) + { + await MyNotificationAppService.DeleteAsync(id); + } + + + [HttpGet] + [Route("{id}")] + public async virtual Task GetAsync(long id) + { + return await MyNotificationAppService.GetAsync(id); + } + + [HttpGet] + public async virtual Task> GetListAsync(UserNotificationGetByPagedDto input) + { + return await MyNotificationAppService.GetListAsync(input); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MySubscriptionController.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MySubscriptionController.cs new file mode 100644 index 000000000..f848bdf39 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/MySubscriptionController.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +[Controller] +[RemoteService(Name = AbpNotificationsRemoteServiceConsts.RemoteServiceName)] +[Area(AbpNotificationsRemoteServiceConsts.ModuleName)] +[Route("api/notifications/my-subscribes")] +public class MySubscriptionController : AbpController, IMySubscriptionAppService +{ + private readonly IMySubscriptionAppService _subscriptionAppService; + + public MySubscriptionController( + IMySubscriptionAppService subscriptionAppService) + { + _subscriptionAppService = subscriptionAppService; + } + + [HttpGet] + [Route("all")] + public async virtual Task> GetAllListAsync() + { + return await _subscriptionAppService.GetAllListAsync(); + } + + [HttpGet] + public async virtual Task> GetListAsync(SubscriptionsGetByPagedDto input) + { + return await _subscriptionAppService.GetListAsync(input); + } + + [HttpGet] + [Route("is-subscribed/{Name}")] + public async virtual Task IsSubscribedAsync(SubscriptionsGetByNameDto input) + { + return await _subscriptionAppService.IsSubscribedAsync(input); + } + + [HttpPost] + public async virtual Task SubscribeAsync(SubscriptionsGetByNameDto input) + { + await _subscriptionAppService.SubscribeAsync(input); + } + + [HttpDelete] + public async virtual Task UnSubscribeAsync(SubscriptionsGetByNameDto input) + { + await _subscriptionAppService.UnSubscribeAsync(input); + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/NotificationController.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/NotificationController.cs new file mode 100644 index 000000000..2c4849d92 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/NotificationController.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.Notifications; + +[Authorize] +[Controller] +[RemoteService(Name = AbpNotificationsRemoteServiceConsts.RemoteServiceName)] +[Area(AbpNotificationsRemoteServiceConsts.ModuleName)] +[Route("api/notifications")] +public class NotificationController : AbpController, INotificationAppService +{ + protected INotificationAppService NotificationAppService { get; } + + public NotificationController( + INotificationAppService notificationAppService) + { + NotificationAppService = notificationAppService; + } + + [HttpPost] + public async virtual Task SendAsync(NotificationSendDto input) + { + await NotificationAppService.SendAsync(input); + } + + [HttpGet] + [Route("assignables")] + public async virtual Task> GetAssignableNotifiersAsync() + { + return await NotificationAppService.GetAssignableNotifiersAsync(); + } + + [HttpGet] + [Route("assignable-templates")] + public async virtual Task> GetAssignableTemplatesAsync() + { + return await NotificationAppService.GetAssignableTemplatesAsync(); + } +} diff --git a/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN.Abp.OpenApi.Authorization.csproj b/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN.Abp.OpenApi.Authorization.csproj index 16a55c435..ccdedfef0 100644 --- a/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN.Abp.OpenApi.Authorization.csproj +++ b/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN.Abp.OpenApi.Authorization.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi/LINGYUN.Abp.OpenApi.csproj b/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi/LINGYUN.Abp.OpenApi.csproj index 8451b8bce..43cdb69b3 100644 --- a/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi/LINGYUN.Abp.OpenApi.csproj +++ b/aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi/LINGYUN.Abp.OpenApi.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Permissions/AbpOpenIddictPermissionDefinitionProvider.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Permissions/AbpOpenIddictPermissionDefinitionProvider.cs index 289e4f8a6..50a21d867 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Permissions/AbpOpenIddictPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Permissions/AbpOpenIddictPermissionDefinitionProvider.cs @@ -15,8 +15,7 @@ namespace LINGYUN.Abp.OpenIddict.Permissions openIddictGroup = context .AddGroup( name: AbpOpenIddictPermissions.GroupName, - displayName: L("Permissions:OpenIddict"), - multiTenancySide: MultiTenancySides.Host); + displayName: L("Permissions:OpenIddict")); } var applications = openIddictGroup.AddPermission( diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Dapr.Client/LINGYUN.Abp.OpenIddict.Dapr.Client.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Dapr.Client/LINGYUN.Abp.OpenIddict.Dapr.Client.csproj index 1aaa08526..3d309ad54 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Dapr.Client/LINGYUN.Abp.OpenIddict.Dapr.Client.csproj +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Dapr.Client/LINGYUN.Abp.OpenIddict.Dapr.Client.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.HttpApi/LINGYUN.Abp.OpenIddict.HttpApi.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.HttpApi/LINGYUN.Abp.OpenIddict.HttpApi.csproj index c5d5696f1..d7a75f148 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.HttpApi/LINGYUN.Abp.OpenIddict.HttpApi.csproj +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.HttpApi/LINGYUN.Abp.OpenIddict.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN.Abp.OpenIddict.LinkUser.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN.Abp.OpenIddict.LinkUser.csproj index 75b81c6d6..9fbffe121 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN.Abp.OpenIddict.LinkUser.csproj +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN.Abp.OpenIddict.LinkUser.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN/Abp/OpenIddict/LinkUser/Controllers/TokenController.LinkUser.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN/Abp/OpenIddict/LinkUser/Controllers/TokenController.LinkUser.cs index 3f0b51dba..b68917082 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN/Abp/OpenIddict/LinkUser/Controllers/TokenController.LinkUser.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.LinkUser/LINGYUN/Abp/OpenIddict/LinkUser/Controllers/TokenController.LinkUser.cs @@ -72,7 +72,7 @@ public class LinkUserTokenController : AbpOpenIdDictControllerBase, ITokenExtens OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); } - var principal = notification.Principal; + var principal = notification.AccessTokenPrincipal; if (principal == null) { return Forbid( diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Sms/LINGYUN.Abp.OpenIddict.Sms.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Sms/LINGYUN.Abp.OpenIddict.Sms.csproj index 9d3d2a64e..cebd42847 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Sms/LINGYUN.Abp.OpenIddict.Sms.csproj +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Sms/LINGYUN.Abp.OpenIddict.Sms.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat/LINGYUN.Abp.OpenIddict.WeChat.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat/LINGYUN.Abp.OpenIddict.WeChat.csproj index 83f989dc9..bb67315a1 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat/LINGYUN.Abp.OpenIddict.WeChat.csproj +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat/LINGYUN.Abp.OpenIddict.WeChat.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN.Abp.OssManagement.Application.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN.Abp.OssManagement.Application.csproj index 18df5dec1..70a574141 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN.Abp.OssManagement.Application.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN.Abp.OssManagement.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN.Abp.OssManagement.Domain.Shared.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN.Abp.OssManagement.Domain.Shared.csproj index e14015a80..c6b9df02e 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN.Abp.OssManagement.Domain.Shared.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN.Abp.OssManagement.Domain.Shared.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN.Abp.OssManagement.FileSystem.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN.Abp.OssManagement.FileSystem.csproj index 2e683d8c7..ee3311da7 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN.Abp.OssManagement.FileSystem.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN.Abp.OssManagement.FileSystem.csproj @@ -5,7 +5,7 @@ netstandard2.1 - 8.0 + latest diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN.Abp.OssManagement.HttpApi.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN.Abp.OssManagement.HttpApi.csproj index c2c3bc751..a42c56cad 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN.Abp.OssManagement.HttpApi.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN.Abp.OssManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN.Abp.OssManagement.SettingManagement.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN.Abp.OssManagement.SettingManagement.csproj index 242af5a4b..b2ec0114a 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN.Abp.OssManagement.SettingManagement.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN.Abp.OssManagement.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj index 442884dda..f093937dd 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs index e028e619c..d6bfd65ca 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs @@ -1,7 +1,4 @@ using LINGYUN.Platform.Localization; -using LINGYUN.Platform.Menus; -using System.Collections.Generic; -using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -13,13 +10,6 @@ namespace LINGYUN.Platform { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - // 2020-12-26 对于结构中的 Meta 字段,需要使用 Newtonsoft.Json 来序列化 - options.UnsupportedTypes.AddIfNotContains(typeof(MenuCreateDto)); - options.UnsupportedTypes.AddIfNotContains(typeof(MenuUpdateDto)); - }); - Configure(options => { options.FileSets.AddEmbedded(); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj index 13efc2f73..f60ef768a 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj index 6200bb511..60a5ecba1 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj @@ -13,6 +13,7 @@ + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj index 3fcf0961b..5353d1dbe 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj index 8080b8251..833de28d1 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Theme.VueVbenAdmin/LINGYUN.Platform.Theme.VueVbenAdmin.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Theme.VueVbenAdmin/LINGYUN.Platform.Theme.VueVbenAdmin.csproj index d4977ecf0..7217456aa 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Theme.VueVbenAdmin/LINGYUN.Platform.Theme.VueVbenAdmin.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Theme.VueVbenAdmin/LINGYUN.Platform.Theme.VueVbenAdmin.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs index aed531e4f..60b8e60af 100644 --- a/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/PushPlus/PushPlusNotificationPublishProvider.cs @@ -97,11 +97,13 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider { var titleInfo = notification.Data.TryGetData("title").As(); var titleResource = GetResource(titleInfo.ResourceName); - var title = LocalizerFactory.Create(titleResource.ResourceType)[titleInfo.Name, titleInfo.Values].Value; + var titleLocalizer = await LocalizerFactory.CreateByResourceNameAsync(titleResource.ResourceName); + var title = titleLocalizer[titleInfo.Name, titleInfo.Values].Value; var messageInfo = notification.Data.TryGetData("message").As(); var messageResource = GetResource(messageInfo.ResourceName); - var message = LocalizerFactory.Create(messageResource.ResourceType)[messageInfo.Name, messageInfo.Values].Value; + var messageLocalizer = await LocalizerFactory.CreateByResourceNameAsync(messageResource.ResourceName); + var message = messageLocalizer[messageInfo.Name, messageInfo.Values].Value; await PushPlusMessageSender.SendWithChannelAsync( title, @@ -115,7 +117,7 @@ public class PushPlusNotificationPublishProvider : NotificationPublishProvider } } - private LocalizationResource GetResource(string resourceName) + private LocalizationResourceBase GetResource(string resourceName) { return LocalizationOptions.Resources.Values .First(x => x.ResourceName.Equals(resourceName)); diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj index 304159eae..cfd7f283f 100644 --- a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj index 93331c526..6de1f3879 100644 --- a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs index 8de9e44f1..02272f61e 100644 --- a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs @@ -1,15 +1,8 @@ using LINGYUN.Abp.Features.LimitValidation; -using LINGYUN.Abp.PushPlus.Channel.Webhook; using LINGYUN.Abp.PushPlus.Localization; -using LINGYUN.Abp.PushPlus.Message; -using LINGYUN.Abp.PushPlus.Setting; -using LINGYUN.Abp.PushPlus.Token; -using LINGYUN.Abp.PushPlus.Topic; -using LINGYUN.Abp.PushPlus.User; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Caching; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Settings; @@ -18,7 +11,7 @@ using Volo.Abp.VirtualFileSystem; namespace LINGYUN.Abp.PushPlus; [DependsOn( - typeof(AbpJsonModule), + typeof(AbpJsonNewtonsoftModule), typeof(AbpSettingsModule), typeof(AbpCachingModule), typeof(AbpFeaturesLimitValidationModule))] @@ -28,30 +21,30 @@ public class AbpPushPlusModule : AbpModule { context.Services.AddPushPlusClient(); - Configure(options => - { - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); + //Configure(options => + //{ + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>>(); - options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>>(); - options.UnsupportedTypes.TryAdd>>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>>(); + // options.UnsupportedTypes.TryAdd>>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - }); + // options.UnsupportedTypes.TryAdd>(); + // options.UnsupportedTypes.TryAdd>(); + //}); Configure(options => { diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN.Abp.Saas.Application.csproj b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN.Abp.Saas.Application.csproj index 559a74862..0b533d863 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN.Abp.Saas.Application.csproj +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN.Abp.Saas.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN.Abp.Saas.EntityFrameworkCore.csproj b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN.Abp.Saas.EntityFrameworkCore.csproj index ebe702e68..896f88d2f 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN.Abp.Saas.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN.Abp.Saas.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.HttpApi/LINGYUN.Abp.Saas.HttpApi.csproj b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.HttpApi/LINGYUN.Abp.Saas.HttpApi.csproj index 3768d3c1a..edbb51654 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.HttpApi/LINGYUN.Abp.Saas.HttpApi.csproj +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.HttpApi/LINGYUN.Abp.Saas.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj index 95bed304a..70f03f7d2 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj index 4cdb1b6bf..49544c861 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj index 95bdbb147..4b2e0e99f 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs index 9573be853..c2bb43e09 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs @@ -4,13 +4,13 @@ using LINGYUN.Abp.BackgroundTasks.ExceptionHandling.Templates; using LINGYUN.Abp.BackgroundTasks.Localization; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Emailing; +using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; using Volo.Abp.TextTemplating; @@ -64,14 +64,17 @@ public class JobExecutedFailedProvider : JobExecutedProvider, ITransientDependen protected IEmailSender EmailSender { get; } protected ITemplateRenderer TemplateRenderer { get; } + protected IJsonSerializer JsonSerializer { get; } public JobExecutedFailedProvider( IEmailSender emailSender, - ITemplateRenderer templateRenderer) + ITemplateRenderer templateRenderer, + IJsonSerializer jsonSerializer) { EmailSender = emailSender; TemplateRenderer = templateRenderer; Logger = NullLogger.Instance; + JsonSerializer = jsonSerializer; } public override async Task NotifyErrorAsync([NotNull] JobActionExecuteContext context) @@ -113,7 +116,7 @@ public class JobExecutedFailedProvider : JobExecutedProvider, ITransientDependen { try { - globalContext = JsonConvert.DeserializeObject>(ctxStr); + globalContext = JsonSerializer.Deserialize>(ctxStr); } catch { } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN.Abp.BackgroundTasks.Jobs.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN.Abp.BackgroundTasks.Jobs.csproj index 26e2ad9a0..3c80f47b8 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN.Abp.BackgroundTasks.Jobs.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN.Abp.BackgroundTasks.Jobs.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/HttpRequestJobBase.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/HttpRequestJobBase.cs index 57c8eb01d..a7ab7eba3 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/HttpRequestJobBase.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/HttpRequestJobBase.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.Primitives; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; @@ -10,6 +9,7 @@ using System.Threading.Tasks; using Volo.Abp.Content; using Volo.Abp.Http; using Volo.Abp.Http.Client; +using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; @@ -21,10 +21,12 @@ public abstract class HttpRequestJobBase public const string PropertyCulture = "culture"; protected ICurrentTenant CurrentTenant { get; set; } + protected IJsonSerializer JsonSerializer { get; set; } protected virtual void InitJob(JobRunnableContext context) { CurrentTenant = context.GetRequiredService(); + JsonSerializer = context.GetRequiredService(); } protected async virtual Task RequestAsync( @@ -195,12 +197,12 @@ public abstract class HttpRequestJobBase protected virtual T Deserialize(string value) { - return JsonConvert.DeserializeObject(value); + return JsonSerializer.Deserialize(value); } protected virtual string Serialize(object value) { - return JsonConvert.SerializeObject(value); + return JsonSerializer.Serialize(value); } protected virtual StringSegment RemoveQuotes(StringSegment input) diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs index 20016c134..3a77f82c3 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Emailing; +using Volo.Abp.Json; using Volo.Abp.TextTemplating; namespace LINGYUN.Abp.BackgroundTasks.Jobs; @@ -69,13 +69,14 @@ public class SendEmailJob : IJobRunnable if (context.TryGetString(PropertyTemplate, out var template) && !template.IsNullOrWhiteSpace()) { + var jsonSerializer = context.GetRequiredService(); var globalContext = new Dictionary(); context.TryGetString(PropertyCulture, out var culture); if (context.TryGetString(PropertyContext, out var globalCtx)) { try { - globalContext = JsonConvert.DeserializeObject>(globalCtx); + globalContext = jsonSerializer.Deserialize>(globalCtx); } catch { } } @@ -85,7 +86,7 @@ public class SendEmailJob : IJobRunnable { try { - model = JsonConvert.DeserializeObject(modelString); + model = jsonSerializer.Deserialize>(modelString); } catch { } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs index c3ba1a943..05c200b73 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.Json; using Volo.Abp.Sms; namespace LINGYUN.Abp.BackgroundTasks.Jobs; @@ -36,7 +36,8 @@ public class SendSmsJob : IJobRunnable try { - properties = JsonConvert.DeserializeObject>(data); + var jsonSerializer = context.GetRequiredService(); + properties = jsonSerializer.Deserialize>(data); } catch { } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs index 8de4ce001..a27a9d0cf 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs @@ -1,6 +1,5 @@ using LINGYUN.Abp.Dapr.Client.DynamicProxying; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; @@ -13,6 +12,7 @@ using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.Http.Client.DynamicProxying; using Volo.Abp.Http.Client.Proxying; using Volo.Abp.Http.Modeling; +using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; @@ -119,7 +119,8 @@ public class ServiceInvocationJob : IJobRunnable var invokeParameters = new Dictionary(); if (context.TryGetString(PropertyData, out var data)) { - invokeParameters = JsonConvert.DeserializeObject>(data); + var jsonSerializer = context.GetRequiredService(); + invokeParameters = jsonSerializer.Deserialize>(data); } // 构造服务代理上下文 @@ -212,7 +213,8 @@ public class ServiceInvocationJob : IJobRunnable var invokeParameters = new Dictionary(); if (context.TryGetString(PropertyData, out var data)) { - invokeParameters = JsonConvert.DeserializeObject>(data); + var jsonSerializer = context.GetRequiredService(); + invokeParameters = jsonSerializer.Deserialize>(data); } // 构造服务代理上下文 diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs index ee743fa15..b29892385 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs @@ -6,6 +6,7 @@ using Volo.Abp.Auditing; using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Guids; +using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -17,6 +18,7 @@ namespace LINGYUN.Abp.BackgroundTasks; [DependsOn(typeof(AbpBackgroundJobsAbstractionsModule))] [DependsOn(typeof(AbpBackgroundWorkersModule))] [DependsOn(typeof(AbpGuidsModule))] +[DependsOn(typeof(AbpJsonModule))] public class AbpBackgroundTasksModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs index 26f05d255..be72c3341 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs @@ -2,9 +2,9 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using System.Threading.Tasks; using Volo.Abp.BackgroundJobs; +using Volo.Abp.Json; namespace LINGYUN.Abp.BackgroundTasks; @@ -34,9 +34,9 @@ public class BackgroundJobAdapter : IJobRunnable object args = null; if (context.TryGetString(nameof(TArgs), out var argsJson)) { - //var jsonSerializer = context.GetRequiredService(); - //args = jsonSerializer.Deserialize(argsJson); - args = JsonConvert.DeserializeObject(argsJson); + var jsonSerializer = context.GetRequiredService(); + args = jsonSerializer.Deserialize(argsJson); + // args = JsonConvert.DeserializeObject(argsJson); } var jobType = Options.GetJob(typeof(TArgs)).JobType; diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs index 789fd0971..8c79f3eac 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs @@ -1,11 +1,11 @@ using Microsoft.Extensions.Options; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.BackgroundJobs; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; +using Volo.Abp.Json; using Volo.Abp.MultiTenancy; using Volo.Abp.Timing; @@ -19,6 +19,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency protected IJobPublisher JobPublisher { get; } protected ICurrentTenant CurrentTenant { get; } protected IGuidGenerator GuidGenerator { get; } + protected IJsonSerializer JsonSerializer { get; } protected AbpBackgroundTasksOptions TasksOptions { get; } protected AbpBackgroundJobOptions Options { get; } public BackgroundJobManager( @@ -27,6 +28,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency IJobPublisher jobPublisher, ICurrentTenant currentTenant, IGuidGenerator guidGenerator, + IJsonSerializer jsonSerializer, IOptions options, IOptions taskOptions) { @@ -35,6 +37,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency JobPublisher = jobPublisher; CurrentTenant = currentTenant; GuidGenerator = guidGenerator; + JsonSerializer = jsonSerializer; Options = options.Value; TasksOptions = taskOptions.Value; } @@ -53,7 +56,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency var jobId = GuidGenerator.Create(); var jobArgs = new Dictionary { - { nameof(TArgs), JsonConvert.SerializeObject(args) }, + { nameof(TArgs), JsonSerializer.Serialize(args) }, { "ArgsType", jobConfiguration.ArgsType.AssemblyQualifiedName }, { "JobType", jobConfiguration.JobType.AssemblyQualifiedName }, { "JobName", jobConfiguration.JobName }, diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj index 60375de9f..6550d4452 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj index 32c4a92bb..b7a32bade 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj index ddb659ad1..de4c51cc1 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj index 025f36a6d..08cad3ef0 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj index 8e0fea148..acbf6d963 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/tui-juhe/LINGYUN.Abp.TuiJuhe.SettingManagement/LINGYUN.Abp.TuiJuhe.SettingManagement.csproj b/aspnet-core/modules/tui-juhe/LINGYUN.Abp.TuiJuhe.SettingManagement/LINGYUN.Abp.TuiJuhe.SettingManagement.csproj index 352b43507..42d770a4e 100644 --- a/aspnet-core/modules/tui-juhe/LINGYUN.Abp.TuiJuhe.SettingManagement/LINGYUN.Abp.TuiJuhe.SettingManagement.csproj +++ b/aspnet-core/modules/tui-juhe/LINGYUN.Abp.TuiJuhe.SettingManagement/LINGYUN.Abp.TuiJuhe.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.EventBus/LINGYUN/Abp/Webhooks/EventBus/AbpWebhooksEventBusModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.EventBus/LINGYUN/Abp/Webhooks/EventBus/AbpWebhooksEventBusModule.cs index cdc1f9b31..d8652d910 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.EventBus/LINGYUN/Abp/Webhooks/EventBus/AbpWebhooksEventBusModule.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.EventBus/LINGYUN/Abp/Webhooks/EventBus/AbpWebhooksEventBusModule.cs @@ -11,9 +11,9 @@ public class AbpWebhooksEventBusModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - options.UnsupportedTypes.TryAdd(); - }); + //Configure(options => + //{ + // options.UnsupportedTypes.TryAdd(); + //}); } } \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN.Abp.Webhooks.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN.Abp.Webhooks.csproj index 5a53bbb1f..c984760d4 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN.Abp.Webhooks.csproj +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN.Abp.Webhooks.csproj @@ -9,6 +9,7 @@ + diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN/Abp/Webhooks/WebhookManager.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN/Abp/Webhooks/WebhookManager.cs index f761230c3..5026b866c 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN/Abp/Webhooks/WebhookManager.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks/LINGYUN/Abp/Webhooks/WebhookManager.cs @@ -6,6 +6,7 @@ using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Http; namespace LINGYUN.Abp.Webhooks @@ -43,15 +44,8 @@ namespace LINGYUN.Abp.Webhooks public virtual void SignWebhookRequest(HttpRequestMessage request, string serializedBody, string secret) { - if (request == null) - { - throw new ArgumentNullException(nameof(request)); - } - - if (string.IsNullOrWhiteSpace(serializedBody)) - { - throw new ArgumentNullException(nameof(serializedBody)); - } + Check.NotNull(request, nameof(request)); + Check.NotNullOrWhiteSpace(serializedBody, nameof(serializedBody)); request.Content = new StringContent(serializedBody, Encoding.UTF8, MimeTypes.Application.Json); diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Dapr.Client/LINGYUN.Abp.WebhooksManagement.Dapr.Client.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Dapr.Client/LINGYUN.Abp.WebhooksManagement.Dapr.Client.csproj index e07d4c79d..969450d7b 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Dapr.Client/LINGYUN.Abp.WebhooksManagement.Dapr.Client.csproj +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Dapr.Client/LINGYUN.Abp.WebhooksManagement.Dapr.Client.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore.csproj index 6eb433ff2..9d9886e60 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN.Abp.WebhooksManagement.HttpApi.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN.Abp.WebhooksManagement.HttpApi.csproj index e2556eb0b..debfcb8a9 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN.Abp.WebhooksManagement.HttpApi.csproj +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN.Abp.WebhooksManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN.Abp.WeChat.MiniProgram.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN.Abp.WeChat.MiniProgram.csproj index 2b3c7fb98..ae0002f46 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN.Abp.WeChat.MiniProgram.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN.Abp.WeChat.MiniProgram.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xsd b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj index 0c4e72aba..6a34430ad 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official/LINGYUN.Abp.WeChat.Official.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official/LINGYUN.Abp.WeChat.Official.csproj index bd51ebc08..817553b9b 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official/LINGYUN.Abp.WeChat.Official.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official/LINGYUN.Abp.WeChat.Official.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj index fa23fc1f1..24d8d0710 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj @@ -4,18 +4,16 @@ - net6.0 + net7.0 - - + - - + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj index 7bcf7c81b..0c38e32af 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj @@ -9,19 +9,17 @@ - - + - - + - + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs index cf692fda7..5d1ea6f6f 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using Volo.Abp.Caching; using Volo.Abp.Features; -using Volo.Abp.Json; +using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Settings; @@ -14,7 +14,7 @@ namespace LINGYUN.Abp.WeChat [DependsOn( typeof(AbpCachingModule), typeof(AbpFeaturesModule), - typeof(AbpJsonModule), + typeof(AbpJsonNewtonsoftModule), typeof(AbpSettingsModule))] public class AbpWeChatModule : AbpModule { diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs index 6612a21b8..2febcca91 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs @@ -1,11 +1,8 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.EventBus; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Modularity; using WorkflowCore.Interface; using WorkflowCore.Models; -using EventData = WorkflowCore.Models.LifeCycleEvents.LifeCycleEvent; namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent { @@ -23,18 +20,5 @@ namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent options.UseEventHub(provider => provider.GetRequiredService()); }); } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.UseHybridSerializer = true; - }); - - Configure(options => - { - options.UnsupportedTypes.TryAdd(); - }); - } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch/LINGYUN/Abp/WorkflowCore/Persistence/Elasticsearch/PersistenceIndexInitializer.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch/LINGYUN/Abp/WorkflowCore/Persistence/Elasticsearch/PersistenceIndexInitializer.cs index ae8a21b3f..2aba4b276 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch/LINGYUN/Abp/WorkflowCore/Persistence/Elasticsearch/PersistenceIndexInitializer.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch/LINGYUN/Abp/WorkflowCore/Persistence/Elasticsearch/PersistenceIndexInitializer.cs @@ -38,8 +38,8 @@ namespace LINGYUN.Abp.WorkflowCore.Persistence.Elasticsearch public async virtual Task InitializeAsync() { var client = _clientFactory.Create(); - var dateTimeFormat = !_jsonOptions.DefaultDateTimeFormat.IsNullOrWhiteSpace() - ? $"{_jsonOptions.DefaultDateTimeFormat}||strict_date_optional_time||epoch_millis" + var dateTimeFormat = !_jsonOptions.OutputDateTimeFormat.IsNullOrWhiteSpace() + ? $"{_jsonOptions.OutputDateTimeFormat}||strict_date_optional_time||epoch_millis" : "strict_date_optional_time||epoch_millis"; var indexState = new IndexState { diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj index f600d0ffb..a6efb3b79 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore/LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN.Abp.WorkflowManagement.Application.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN.Abp.WorkflowManagement.Application.csproj index b608d551f..82231f8ef 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN.Abp.WorkflowManagement.Application.csproj +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN.Abp.WorkflowManagement.Application.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj index 7f1addccf..cfa26d262 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore/LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.HttpApi/LINGYUN.Abp.WorkflowManagement.HttpApi.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.HttpApi/LINGYUN.Abp.WorkflowManagement.HttpApi.csproj index 74350395b..b705b390b 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.HttpApi/LINGYUN.Abp.WorkflowManagement.HttpApi.csproj +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.HttpApi/LINGYUN.Abp.WorkflowManagement.HttpApi.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs index b644b445e..e3c729179 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/WxPusher/WxPusherNotificationPublishProvider.cs @@ -100,11 +100,13 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider { var titleInfo = notification.Data.TryGetData("title").As(); var titleResource = GetResource(titleInfo.ResourceName); - var title = LocalizerFactory.Create(titleResource.ResourceType)[titleInfo.Name, titleInfo.Values].Value; + var titleLocalizer = await LocalizerFactory.CreateByResourceNameAsync(titleResource.ResourceName); + var title = titleLocalizer[titleInfo.Name, titleInfo.Values].Value; var messageInfo = notification.Data.TryGetData("message").As(); var messageResource = GetResource(messageInfo.ResourceName); - var message = LocalizerFactory.Create(messageResource.ResourceType)[messageInfo.Name, messageInfo.Values].Value; + var messageLocalizer = await LocalizerFactory.CreateByResourceNameAsync(messageResource.ResourceName); + var message = messageLocalizer[messageInfo.Name, messageInfo.Values].Value; await WxPusherMessageSender.SendAsync( content: message, @@ -117,7 +119,7 @@ public class WxPusherNotificationPublishProvider : NotificationPublishProvider } } - private LocalizationResource GetResource(string resourceName) + private LocalizationResourceBase GetResource(string resourceName) { return LocalizationOptions.Resources.Values .First(x => x.ResourceName.Equals(resourceName)); diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj index 2c43def64..7ab148287 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj @@ -4,7 +4,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj index 206c5d785..aa35fe450 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs index 01ab71b81..918dd87fc 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs @@ -1,14 +1,10 @@ using LINGYUN.Abp.Features.LimitValidation; using LINGYUN.Abp.WxPusher.Localization; -using LINGYUN.Abp.WxPusher.Messages; -using LINGYUN.Abp.WxPusher.QrCode; using LINGYUN.Abp.WxPusher.User; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using System.Collections.Generic; using Volo.Abp.Caching; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Settings; @@ -17,7 +13,7 @@ using Volo.Abp.VirtualFileSystem; namespace LINGYUN.Abp.WxPusher; [DependsOn( - typeof(AbpJsonModule), + typeof(AbpJsonNewtonsoftModule), typeof(AbpSettingsModule), typeof(AbpCachingModule), typeof(AbpFeaturesLimitValidationModule))] @@ -28,16 +24,6 @@ public class AbpWxPusherModule : AbpModule context.Services.AddWxPusherClient(); context.Services.TryAddSingleton(NullWxPusherUserStore.Instance); - Configure(options => - { - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>(); - options.UnsupportedTypes.TryAdd>>(); - options.UnsupportedTypes.TryAdd>>(); - }); - Configure(options => { options.FileSets.AddEmbedded(); diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs index 1ca03c94e..a9bf5ca33 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs @@ -25,7 +25,6 @@ using Volo.Abp.Caching; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.GlobalFeatures; -using Volo.Abp.Identity.Localization; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Localization; @@ -260,8 +259,6 @@ public partial class AuthServerHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - - options.Resources.AddDynamic(typeof(IdentityResource)); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj index e57119d03..a547aff4f 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.AuthServer diff --git a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj index c448e0cef..775483dde 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 InProcess LY.MicroService.AuthServer diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs index c168529e0..ef9943f4d 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs @@ -269,8 +269,6 @@ public partial class BackendAdminHttpApiHostModule .AddLanguagesMapOrUpdate( "vben-admin-ui", new NameValue("zh_CN", "zh-Hans")); - - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs index edec673ff..b8dc25d8f 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs @@ -5,9 +5,11 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using Volo.Abp.Data; namespace LY.MicroService.BackendAdmin.EntityFrameworkCore; +[ConnectionStringName("BackendAdminDbMigrator")] public class BackendAdminMigrationsDbContext : AbpDbContext { public BackendAdminMigrationsDbContext(DbContextOptions options) diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs index 4c0e2c64c..425cf0b0a 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs @@ -115,7 +115,7 @@ public class TenantSynchronizer : Logger.LogInformation("Migrated the new tenant database with platform."); Logger.LogInformation("Seeding the new tenant admin role permissions..."); - var definitionPermissions = PermissionDefinitionManager.GetPermissions(); + var definitionPermissions = await PermissionDefinitionManager.GetPermissionsAsync(); var grantPermissions = definitionPermissions .Where(p => p.MultiTenancySide.HasFlag(MultiTenancySides.Tenant)) .Select(p => p.Name).ToArray(); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj index 039c98ef3..b661f31cb 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.BackendAdmin @@ -58,7 +58,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.Designer.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.Designer.cs new file mode 100644 index 000000000..c79e0bdff --- /dev/null +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.Designer.cs @@ -0,0 +1,524 @@ +// +using System; +using LY.MicroService.BackendAdmin.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.Migrations +{ + [DbContext(typeof(BackendAdminMigrationsDbContext))] + [Migration("20230106023648_Upgrade-Abp-Framework-To-7.0.0")] + partial class UpgradeAbpFrameworkTo700 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.ToTable("AbpEditions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisableTime") + .HasColumnType("datetime(6)"); + + b.Property("EditionId") + .HasColumnType("char(36)"); + + b.Property("EnableTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EditionId"); + + b.HasIndex("Name"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Culture") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint unsigned"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId"); + + b.Navigation("Edition"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.cs new file mode 100644 index 000000000..4472779ab --- /dev/null +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20230106023648_Upgrade-Abp-Framework-To-7.0.0.cs @@ -0,0 +1,161 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.Migrations +{ + /// + public partial class UpgradeAbpFrameworkTo700 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpFeatureGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpFeatures", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DefaultValue = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsVisibleToClients = table.Column(type: "tinyint(1)", nullable: false), + IsAvailableToHost = table.Column(type: "tinyint(1)", nullable: false), + AllowedProviders = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ValueType = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatures", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpPermissionGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpPermissions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ParentName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + MultiTenancySide = table.Column(type: "tinyint unsigned", nullable: false), + Providers = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + StateCheckers = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureGroups_Name", + table: "AbpFeatureGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatures_GroupName", + table: "AbpFeatures", + column: "GroupName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatures_Name", + table: "AbpFeatures", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGroups_Name", + table: "AbpPermissionGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissions_GroupName", + table: "AbpPermissions", + column: "GroupName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissions_Name", + table: "AbpPermissions", + column: "Name", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpFeatureGroups"); + + migrationBuilder.DropTable( + name: "AbpFeatures"); + + migrationBuilder.DropTable( + name: "AbpPermissionGroups"); + + migrationBuilder.DropTable( + name: "AbpPermissions"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs index 5c1daa123..22525cb09 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace LY.MicroService.BackendAdmin.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("ProductVersion", "7.0.1") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => @@ -226,6 +226,95 @@ namespace LY.MicroService.BackendAdmin.Migrations b.ToTable("AbpTextTemplates", (string)null); }); + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => { b.Property("Id") @@ -258,6 +347,59 @@ namespace LY.MicroService.BackendAdmin.Migrations b.ToTable("AbpFeatureValues", (string)null); }); + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint unsigned"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => { b.Property("Id") @@ -291,6 +433,34 @@ namespace LY.MicroService.BackendAdmin.Migrations b.ToTable("AbpPermissionGrants", (string)null); }); + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => { b.Property("Id") diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json index afec21890..a917bdb7e 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.Backend.Admin", "secret": "1q2w3E*", diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj index 276911013..e6b386858 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.LocalizationManagement diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index cb06e2140..9a68a4698 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -207,8 +207,6 @@ public partial class LocalizationManagementHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj index d0aa518d2..e1ee24ec4 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.PlatformManagement diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs index 2eef82f37..ce2ef05f6 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs @@ -253,8 +253,6 @@ public partial class PlatformManagementHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index 01dc9c084..ba3e0495d 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.RealtimeMessage diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index a82af2b28..f7cdfd09d 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -306,8 +306,6 @@ public partial class RealtimeMessageHttpApiHostModule options.Resources .Get() .AddVirtualJson("/Localization/Resources"); - - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj index 5d64b47f8..745d7593b 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj @@ -13,7 +13,7 @@ - net6.0 + net7.0 LY.MicroService.TaskManagement diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs index f137d01ea..fb20e263b 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs @@ -265,8 +265,6 @@ public partial class TaskManagementHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - // 动态语言支持 - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj index a0c769763..85a334ca8 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.WebhooksManagement diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj index 96a3cde97..3f6264345 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.WorkflowManagement diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs index 46dcf29c3..12ed161d5 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs @@ -11,10 +11,8 @@ using LINGYUN.Abp.Serilog.Enrichers.Application; using Medallion.Threading; using Medallion.Threading.Redis; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Routing; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.StackExchangeRedis; using Microsoft.Extensions.Configuration; @@ -348,8 +346,6 @@ public partial class WorkflowManagementHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - // 动态语言支持 - options.Resources.AddDynamic(); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs index 32adfa3be..ac84ba3ce 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs @@ -263,8 +263,6 @@ public partial class IdentityServerHttpApiHostModule options.Resources .Get() .AddVirtualJson("/Localization/Resources"); - - options.Resources.AddDynamic(typeof(IdentityResource)); }); Configure(options => diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj index b1907465a..334030ab2 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 LY.MicroService.IdentityServer diff --git a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj index 7caed8bd4..75ded82c0 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 InProcess LY.MicroService.IdentityServer diff --git a/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj index fe7127866..aa981a026 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Mvc.Tests/LINGYUN.Abp.AspNetCore.Mvc.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Mvc.Tests/LINGYUN.Abp.AspNetCore.Mvc.Tests.csproj index cc2fbdb18..726e26f77 100644 --- a/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Mvc.Tests/LINGYUN.Abp.AspNetCore.Mvc.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Mvc.Tests/LINGYUN.Abp.AspNetCore.Mvc.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Tests/LINGYUN.Abp.AspNetCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Tests/LINGYUN.Abp.AspNetCore.Tests.csproj index ca8f6bbfd..9426da9e7 100644 --- a/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Tests/LINGYUN.Abp.AspNetCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.AspNetCore.Tests/LINGYUN.Abp.AspNetCore.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests.csproj index 5d1d9a8a5..4ae22ac64 100644 --- a/aspnet-core/tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests/LINGYUN.Abp.AuditLogging.Elasticsearch.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj index 46f74ebf6..932bed865 100644 --- a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Dapr.Actors.Tests/LINGYUN.Abp.Dapr.Actors.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Dapr.Actors.Tests/LINGYUN.Abp.Dapr.Actors.Tests.csproj index 0815b4b7c..f68666f84 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Dapr.Actors.Tests/LINGYUN.Abp.Dapr.Actors.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Dapr.Actors.Tests/LINGYUN.Abp.Dapr.Actors.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj b/aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj index 7011dc109..1b86e16b2 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 diff --git a/aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj index f137662a1..b4f8f60b0 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj index eb29a1812..accb41b06 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.DataProtection.Tests/LINGYUN.Abp.DataProtection.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.DataProtection.Tests/LINGYUN.Abp.DataProtection.Tests.csproj index 0d72a6506..ab910168b 100644 --- a/aspnet-core/tests/LINGYUN.Abp.DataProtection.Tests/LINGYUN.Abp.DataProtection.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.DataProtection.Tests/LINGYUN.Abp.DataProtection.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests.csproj index c7ddee95c..8240eb976 100644 --- a/aspnet-core/tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests/LINGYUN.Abp.DynamicQueryable.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj index d7bd553f1..1ccc51473 100644 --- a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 diff --git a/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj index 0e295cc0f..122829599 100644 --- a/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj index f5ce9b05e..c38b3f22a 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj index 165fcda67..4413d216f 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.IdGenerator.Tests/LINGYUN.Abp.IdGenerator.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.IdGenerator.Tests/LINGYUN.Abp.IdGenerator.Tests.csproj index 17494db2d..18b1b3b98 100644 --- a/aspnet-core/tests/LINGYUN.Abp.IdGenerator.Tests/LINGYUN.Abp.IdGenerator.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.IdGenerator.Tests/LINGYUN.Abp.IdGenerator.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj index 97ddff19b..484346602 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj index ac9361faf..ad69fcc5e 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj index 99fbc409d..801e22e83 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj index 313c56a73..13a89972c 100644 --- a/aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj index 5ed3cea46..a5546ed7c 100644 --- a/aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN.Abp.Notifications.Sms.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN.Abp.Notifications.Sms.Tests.csproj index acd212ccb..d372ed0d1 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN.Abp.Notifications.Sms.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN.Abp.Notifications.Sms.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN.Abp.Notifications.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN.Abp.Notifications.Tests.csproj index 38eee1bf5..bfda28432 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN.Abp.Notifications.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN.Abp.Notifications.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj index 24df96843..7f8538aa2 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests/LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj index cf4b5028a..cb34747c4 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj index c5a7e8e7c..2608e21ac 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.WxPusher.Tests/LINGYUN.Abp.Notifications.WxPusher.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.OpenApi.Tests/LINGYUN.Abp.OpenApi.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.OpenApi.Tests/LINGYUN.Abp.OpenApi.Tests.csproj index 92c0b0935..ecc05f72d 100644 --- a/aspnet-core/tests/LINGYUN.Abp.OpenApi.Tests/LINGYUN.Abp.OpenApi.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.OpenApi.Tests/LINGYUN.Abp.OpenApi.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.PushPlus.Tests/LINGYUN.Abp.PushPlus.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.PushPlus.Tests/LINGYUN.Abp.PushPlus.Tests.csproj index 3d29463d8..c8542906a 100644 --- a/aspnet-core/tests/LINGYUN.Abp.PushPlus.Tests/LINGYUN.Abp.PushPlus.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.PushPlus.Tests/LINGYUN.Abp.PushPlus.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Rules.NRules.Tests/LINGYUN.Abp.Rules.NRules.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Rules.NRules.Tests/LINGYUN.Abp.Rules.NRules.Tests.csproj index 68c7aa26f..03061ee9f 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Rules.NRules.Tests/LINGYUN.Abp.Rules.NRules.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Rules.NRules.Tests/LINGYUN.Abp.Rules.NRules.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj index ef3f8856f..7e659a0a8 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj index 89d4ee026..817f7c0df 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj index 3604d3e4a..4329a0d39 100644 --- a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN/Abp/Tests/Features/FakeFeatureStore.cs b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN/Abp/Tests/Features/FakeFeatureStore.cs index 3470b0a1a..6a98fe4a4 100644 --- a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN/Abp/Tests/Features/FakeFeatureStore.cs +++ b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN/Abp/Tests/Features/FakeFeatureStore.cs @@ -17,16 +17,16 @@ namespace LINGYUN.Abp.Tests.Features FeatureDefinitionManager = featureDefinitionManager; } - public Task GetOrNullAsync(string name, string providerName, string providerKey) + public async Task GetOrNullAsync(string name, string providerName, string providerKey) { - var feature = FeatureDefinitionManager.Get(name); + var feature = await FeatureDefinitionManager.GetAsync(name); if (FakeFeatureOptions.FeatureMaps.TryGetValue(name, out var featureFunc)) { - return Task.FromResult(featureFunc(feature)); + return featureFunc(feature); } - return Task.FromResult(feature.DefaultValue); + return feature.DefaultValue; } } } diff --git a/aspnet-core/tests/LINGYUN.Abp.TuiJuhe.Tests/LINGYUN.Abp.TuiJuhe.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.TuiJuhe.Tests/LINGYUN.Abp.TuiJuhe.Tests.csproj index 1a416f446..e161c184e 100644 --- a/aspnet-core/tests/LINGYUN.Abp.TuiJuhe.Tests/LINGYUN.Abp.TuiJuhe.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.TuiJuhe.Tests/LINGYUN.Abp.TuiJuhe.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj index 8aca85f09..7dd266486 100644 --- a/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.Wrapper.Tests/LINGYUN.Abp.Wrapper.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Wrapper.Tests/LINGYUN.Abp.Wrapper.Tests.csproj index c4b1df467..3fe46bea1 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Wrapper.Tests/LINGYUN.Abp.Wrapper.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Wrapper.Tests/LINGYUN.Abp.Wrapper.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Abp.WxPusher.Tests/LINGYUN.Abp.WxPusher.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.WxPusher.Tests/LINGYUN.Abp.WxPusher.Tests.csproj index 8af003eb7..817bc66cb 100644 --- a/aspnet-core/tests/LINGYUN.Abp.WxPusher.Tests/LINGYUN.Abp.WxPusher.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.WxPusher.Tests/LINGYUN.Abp.WxPusher.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Linq.Dynamic.Queryable.Tests/LINGYUN.Linq.Dynamic.Queryable.Tests.csproj b/aspnet-core/tests/LINGYUN.Linq.Dynamic.Queryable.Tests/LINGYUN.Linq.Dynamic.Queryable.Tests.csproj index 06a5a5e68..837cfee4b 100644 --- a/aspnet-core/tests/LINGYUN.Linq.Dynamic.Queryable.Tests/LINGYUN.Linq.Dynamic.Queryable.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Linq.Dynamic.Queryable.Tests/LINGYUN.Linq.Dynamic.Queryable.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj index 1ecdd25b4..a89a3c4c7 100644 --- a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj index 24bbe554e..779a71c3b 100644 --- a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false diff --git a/build/modules.dependencies.json b/build/modules.dependencies.json index 4d01194c0..3a50cfa50 100644 --- a/build/modules.dependencies.json +++ b/build/modules.dependencies.json @@ -5,7 +5,7 @@ { "service": "Backend-Admin", "path": "/../aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Modules/", - "depPath": "/../aspnet-core/LocalNuget/net6.0/", + "depPath": "/../aspnet-core/LocalNuget/net7.0/", "dependencies": [ "LINGYUN.Abp.Aliyun.SettingManagement.dll", "LINGYUN.Abp.Sms.Aliyun.dll", @@ -32,7 +32,7 @@ { "service": "Backend-Admin", "path": "/../aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Modules/", - "depPath": "/../aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/bin/Debug/net6.0", + "depPath": "/../aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/bin/Debug/net7.0", "dependencies": [ "LINGYUN.Abp.Account.Application.Contracts.dll", "Volo.Abp.Account.Application.Contracts.dll", @@ -43,7 +43,8 @@ "Volo.Abp.Users.Domain.Shared.dll", "Volo.Abp.Users.Abstractions.dll", "LINGYUN.Abp.IdentityServer.Application.Contracts.dll", - "Volo.Abp.IdentityServer.Domain.Shared.dll" + "Volo.Abp.IdentityServer.Domain.Shared.dll", + "Volo.Abp.Json.Newtonsoft.dll" ] } ] @@ -62,8 +63,11 @@ "LINGYUN.Abp.WorkflowManagement.Application.Contracts.dll", "LINGYUN.Abp.WorkflowManagement.Domain.Shared.dll", "LINGYUN.Abp.BackgroundTasks.Abstractions.dll", + "LINGYUN.Linq.Dynamic.Queryable.dll", + "LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.dll", "LINGYUN.Abp.TaskManagement.Application.Contracts.dll", "LINGYUN.Abp.TaskManagement.Domain.Shared.dll", + "LINGYUN.Abp.Notifications.Core.dll", "LINGYUN.Abp.Notifications.Common.dll", "LINGYUN.Abp.Notifications.dll" ] diff --git a/common.props b/common.props index 0bb3d80a6..346d4d93f 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 6.0.1 + 7.0.0 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.csproj b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.csproj index 9c736397a..14e900f62 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.csproj +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.csproj @@ -4,7 +4,7 @@ Exe - net6.0 + net7.0 LINGYUN.MicroService.Internal.ApiGateway diff --git a/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj b/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj index e74b6f639..0b2055e7c 100644 --- a/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj +++ b/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 From 1e5f15e1f777b66595dda8fdf665de21bebaef8d Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:38:02 +0800 Subject: [PATCH 02/26] refactor the dynamic notification definition --- .../RealtimeMessageMigrationsDbContext.cs | 2 + ...oService.RealtimeMessage.DbMigrator.csproj | 1 + ...3428_Initial-Realtime-Message.Designer.cs} | 28 ++----- ...0230110063428_Initial-Realtime-Message.cs} | 8 -- ...MessageMigrationsDbContextModelSnapshot.cs | 26 ++---- .../RealtimeMessageDbMigratorModule.cs | 2 + .../appsettings.json | 5 +- .../Localization/ApplicationContracts/en.json | 1 - .../ApplicationContracts/zh-Hans.json | 1 - .../Localization/Resources/en.json | 1 - .../Localization/Resources/zh-Hans.json | 1 - .../MessageServiceErrorCodes.cs | 4 - .../Localization/DomainShared/en.json | 4 +- .../Localization/DomainShared/zh-Hans.json | 4 +- ...NotificationDefinitionGroupRecordConsts.cs | 2 - .../NotificationDefinitionRecordConsts.cs | 2 - .../Notifications/NotificationsErrorCodes.cs | 2 +- .../AbpNotificationsDomainModule.cs | 8 +- .../AbpNotificationsManagementOptions.cs | 6 +- .../DynamicNotificationDefinitionCache.cs | 84 +++++++++---------- .../DynamicNotificationDefinitionStore.cs | 6 +- .../NotificationDefinitionGroupRecord.cs | 34 +------- .../NotificationDefinitionRecord.cs | 32 ------- .../NotificationDefinitionSerializer.cs | 2 - .../NotificationsManagementOptions.cs | 18 ---- ...pNotificationsEntityFrameworkCoreModule.cs | 24 ++---- .../NotificationsDbContext.cs | 5 -- ...cationsDbContextModelCreatingExtensions.cs | 8 -- .../AbpNotificationsHttpApiModule.cs | 2 +- ...ervice.RealtimeMessage.HttpApi.Host.csproj | 3 + ...ltimeMessageHttpApiHostModule.Configure.cs | 2 +- .../RealtimeMessageHttpApiHostModule.cs | 20 +++-- .../appsettings.Development.json | 23 ++--- 33 files changed, 117 insertions(+), 254 deletions(-) rename aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/{20230110023420_Initial-Realtime-Message.Designer.cs => 20230110063428_Initial-Realtime-Message.Designer.cs} (93%) rename aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/{20230110023420_Initial-Realtime-Message.cs => 20230110063428_Initial-Realtime-Message.cs} (96%) delete mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs index cc6f3ddff..245a8bbb7 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using LINGYUN.Abp.Notifications.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; @@ -18,6 +19,7 @@ public class RealtimeMessageMigrationsDbContext : AbpDbContext + diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.Designer.cs similarity index 93% rename from aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs rename to aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.Designer.cs index 732f48480..b1ea34d95 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.Designer.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.Designer.cs @@ -12,7 +12,7 @@ using Volo.Abp.EntityFrameworkCore; namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations { [DbContext(typeof(RealtimeMessageMigrationsDbContext))] - [Migration("20230110023420_Initial-Realtime-Message")] + [Migration("20230110063428_Initial-Realtime-Message")] partial class InitialRealtimeMessage { /// @@ -516,7 +516,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppUserGroupCards", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.Notification", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -568,7 +568,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppNotifications", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionGroupRecord", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionGroupRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -589,25 +589,17 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasColumnType("longtext") .HasColumnName("ExtraProperties"); - b.Property("Localization") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - b.Property("Name") .IsRequired() .HasMaxLength(64) .HasColumnType("varchar(64)"); - b.Property("ResourceName") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - b.HasKey("Id"); b.ToTable("AppNotificationDefinitionGroups", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionRecord", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -638,10 +630,6 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasMaxLength(64) .HasColumnType("varchar(64)"); - b.Property("Localization") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - b.Property("Name") .IsRequired() .HasMaxLength(64) @@ -657,16 +645,12 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasMaxLength(200) .HasColumnType("varchar(200)"); - b.Property("ResourceName") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - b.HasKey("Id"); b.ToTable("AppNotificationDefinitions", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.UserNotification", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -693,7 +677,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppUserNotifications", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.UserSubscribe", b => { b.Property("Id") .ValueGeneratedOnAdd() diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.cs similarity index 96% rename from aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs rename to aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.cs index 7571152fb..b1ebde592 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110023420_Initial-Realtime-Message.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/20230110063428_Initial-Realtime-Message.cs @@ -108,10 +108,6 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), - ResourceName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Localization = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), AllowSubscriptionToClients = table.Column(type: "tinyint(1)", nullable: false), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") @@ -135,10 +131,6 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), - ResourceName = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Localization = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), NotificationLifetime = table.Column(type: "int", nullable: false), NotificationType = table.Column(type: "int", nullable: false), ContentType = table.Column(type: "int", nullable: false, defaultValue: 0), diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs index 2c3d93160..b1af499c3 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs @@ -513,7 +513,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppUserGroupCards", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.Notification", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -565,7 +565,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppNotifications", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionGroupRecord", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionGroupRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -586,25 +586,17 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasColumnType("longtext") .HasColumnName("ExtraProperties"); - b.Property("Localization") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - b.Property("Name") .IsRequired() .HasMaxLength(64) .HasColumnType("varchar(64)"); - b.Property("ResourceName") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - b.HasKey("Id"); b.ToTable("AppNotificationDefinitionGroups", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionRecord", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -635,10 +627,6 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasMaxLength(64) .HasColumnType("varchar(64)"); - b.Property("Localization") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - b.Property("Name") .IsRequired() .HasMaxLength(64) @@ -654,16 +642,12 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations .HasMaxLength(200) .HasColumnType("varchar(200)"); - b.Property("ResourceName") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - b.HasKey("Id"); b.ToTable("AppNotificationDefinitions", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.UserNotification", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -690,7 +674,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations b.ToTable("AppUserNotifications", (string)null); }); - modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + modelBuilder.Entity("LINGYUN.Abp.Notifications.UserSubscribe", b => { b.Property("Id") .ValueGeneratedOnAdd() diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs index 9aecbb142..8c7f3f5a3 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/RealtimeMessageDbMigratorModule.cs @@ -6,6 +6,7 @@ using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; +using LINGYUN.Abp.Notifications.EntityFrameworkCore; namespace LY.MicroService.RealtimeMessage.DbMigrator; @@ -14,6 +15,7 @@ namespace LY.MicroService.RealtimeMessage.DbMigrator; typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpNotificationsEntityFrameworkCoreModule), typeof(AbpMessageServiceEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAutofacModule) diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json index e12143b82..60c33068b 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "Default": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", + "Notifications": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", + "MessageService": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/en.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/en.json index 42f2f097d..cdd8b18d3 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/en.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/en.json @@ -2,7 +2,6 @@ "culture": "en", "texts": { "Permission:MessageService": "Message service", - "Permission:Notification": "Notification", "Permission:Delete": "Delete", "Permission:Hangfire": "Hangfire", "Permission:Dashboard": "Dashboard", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/zh-Hans.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/zh-Hans.json index 078827ace..eb1ee953d 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/zh-Hans.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Localization/ApplicationContracts/zh-Hans.json @@ -2,7 +2,6 @@ "culture": "zh-Hans", "texts": { "Permission:MessageService": "消息服务", - "Permission:Notification": "通知管理", "Permission:Delete": "删除", "Permission:Hangfire": "Hangfire", "Permission:Dashboard": "仪表板", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json index bd71bebcb..7a13975df 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json @@ -18,7 +18,6 @@ "LINGYUN.Abp.Message:03404": "Sending the message failed: the user does not exist or is deactivated!", "LINGYUN.Abp.Message:03410": "Users refuse to add friends", "LINGYUN.Abp.Message:03411": "The other party is already your friend or has sent an authentication request. The operation cannot be repeated!", - "LINGYUN.Abp.Message:05404": "The notification template does not exist!", "Notifications:IM": "Instant Messaging", "Notifications:FriendValidation": "Friend verification notification", "Notifications:NewFriend": "New friend notification", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json index 069f1bc65..ba4233ca3 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json @@ -18,7 +18,6 @@ "LINGYUN.Abp.Message:03404": "发送消息失败: 用户不存在或已注销账号!", "LINGYUN.Abp.Message:03410": "用户拒绝添加好友", "LINGYUN.Abp.Message:03411": "对方已是您的好友或已发送验证请求,不能重复操作!", - "LINGYUN.Abp.Message:05404": "通知模板不存在!", "Notifications:IM": "即时通讯", "Notifications:FriendValidation": "好友验证通知", "Notifications:NewFriend": "新好友通知", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs index b7afe06bc..1245784b2 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs @@ -99,9 +99,5 @@ /// 你需要验证问题才能添加好友 /// public const string YouNeedValidationQuestingByAddFriend = Namespace + ":03302"; - /// - /// 通知模板不存在! - /// - public const string NotificationTemplateNotFound = Namespace + ":05404"; } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json index 153609b48..67c920688 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/en.json @@ -1,6 +1,8 @@ { "culture": "en", "texts": { - + "Permission:Notification": "Notification", + "Permission:Delete": "Delete", + "LINGYUN.Abp.Notifications:01404": "The notification template does not exist!" } } \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json index 50324cb8c..65283d752 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/Localization/DomainShared/zh-Hans.json @@ -1,6 +1,8 @@ { "culture": "zh-Hans", "texts": { - + "Permission:Notification": "通知管理", + "Permission:Delete": "删除", + "LINGYUN.Abp.Notifications:01404": "通知模板不存在!" } } \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs index b3e19b50a..c03019a18 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecordConsts.cs @@ -4,7 +4,5 @@ public static class NotificationDefinitionGroupRecordConsts { public static int MaxNameLength { get; set; } = 64; public static int MaxDisplayNameLength { get; set; } = 255; - public static int MaxResourceNameLength { get; set; } = 64; - public static int MaxLocalizationLength { get; set; } = 128; public static int MaxDescriptionLength { get; set; } = 255; } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs index d103ffeae..7d4c3b8d0 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationDefinitionRecordConsts.cs @@ -4,8 +4,6 @@ public static class NotificationDefinitionRecordConsts { public static int MaxNameLength { get; set; } = 64; public static int MaxDisplayNameLength { get; set; } = 255; - public static int MaxResourceNameLength { get; set; } = 64; - public static int MaxLocalizationLength { get; set; } = 128; public static int MaxDescriptionLength { get; set; } = 255; public static int MaxProvidersLength { get; set; } = 200; } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs index 23630baea..852017e6e 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain.Shared/LINGYUN/Abp/Notifications/NotificationsErrorCodes.cs @@ -30,6 +30,6 @@ /// /// 通知模板不存在! /// - public const string NotificationTemplateNotFound = Namespace + ":05404"; + public const string NotificationTemplateNotFound = Namespace + ":01404"; } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs index a44cd376d..b8deb5543 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsDomainModule.cs @@ -29,7 +29,7 @@ public class AbpNotificationsDomainModule : AbpModule { if (context.Services.IsDataMigrationEnvironment()) { - Configure(options => + Configure(options => { options.SaveStaticNotificationsToDatabase = false; options.IsDynamicNotificationsStoreEnabled = false; @@ -58,7 +58,7 @@ public class AbpNotificationsDomainModule : AbpModule { var options = context .ServiceProvider - .GetRequiredService>() + .GetRequiredService>() .Value; if (!options.SaveStaticNotificationsToDatabase && !options.IsDynamicNotificationsStoreEnabled) @@ -100,7 +100,7 @@ public class AbpNotificationsDomainModule : AbpModule } private async static Task SaveStaticNotificationsToDatabaseAsync( - NotificationsManagementOptions options, + AbpNotificationsManagementOptions options, IServiceScope scope, ICancellationTokenProvider cancellationTokenProvider) { @@ -134,7 +134,7 @@ public class AbpNotificationsDomainModule : AbpModule }, cancellationTokenProvider.Token); } - private async static Task PreCacheDynamicNotificationsAsync(NotificationsManagementOptions options, IServiceScope scope) + private async static Task PreCacheDynamicNotificationsAsync(AbpNotificationsManagementOptions options, IServiceScope scope) { if (!options.IsDynamicNotificationsStoreEnabled) { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs index 7db82663b..bc2c9de77 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs @@ -2,9 +2,11 @@ public class AbpNotificationsManagementOptions { - public bool IsDynamicNotificationStoreEnabled { get; set; } + public bool SaveStaticNotificationsToDatabase { get; set; } + public bool IsDynamicNotificationsStoreEnabled { get; set; } public AbpNotificationsManagementOptions() { - IsDynamicNotificationStoreEnabled = true; + SaveStaticNotificationsToDatabase = true; + IsDynamicNotificationsStoreEnabled = true; } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs index b12e23da1..db331e254 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs @@ -1,8 +1,6 @@ -using LINGYUN.Abp.Notifications; -using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.Options; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -32,8 +30,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition protected INotificationDefinitionGroupRecordRepository NotificationDefinitionGroupRecordRepository { get; } protected INotificationDefinitionRecordRepository NotificationDefinitionRecordRepository { get; } - - protected AbpLocalizationOptions LocalizationOptions { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } protected IStringLocalizerFactory StringLocalizerFactory { get; } static DynamicNotificationDefinitionCache() @@ -48,8 +45,8 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition IDistributedCache dynamicNotificationGroupL3Cache, IDistributedCache dynamicNotificationsL3Cache, INotificationDefinitionGroupRecordRepository notificationDefinitionGroupRecordRepository, - INotificationDefinitionRecordRepository notificationDefinitionRecordRepository, - IOptions localizationOptions, + INotificationDefinitionRecordRepository notificationDefinitionRecordRepository, + ILocalizableStringSerializer localizableStringSerializer, IStringLocalizerFactory stringLocalizerFactory) { DynamicNotificationL2Cache = dynamicNotificationL2Cache; @@ -57,7 +54,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition DynamicNotificationsL3Cache = dynamicNotificationsL3Cache; NotificationDefinitionGroupRecordRepository = notificationDefinitionGroupRecordRepository; NotificationDefinitionRecordRepository = notificationDefinitionRecordRepository; - LocalizationOptions = localizationOptions.Value; + LocalizableStringSerializer = localizableStringSerializer; StringLocalizerFactory = stringLocalizerFactory; } @@ -74,7 +71,11 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition foreach (var group in l2GroupCache.Groups) { var groupGroup = NotificationGroupDefinition - .Create(group.Name, new FixedLocalizableString(group.DisplayName), group.AllowSubscriptionToClients); + .Create( + group.Name, + LocalizableStringSerializer.Deserialize(group.DisplayName), + group.AllowSubscriptionToClients); + var notificationsInThisGroup = notifications.Notifications .Where(p => p.GroupName == groupGroup.Name); @@ -82,8 +83,8 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition { var notificationDefine = groupGroup.AddNotification( notification.Name, - new FixedLocalizableString(notification.DisplayName), - new FixedLocalizableString(notification.Description), + LocalizableStringSerializer.Deserialize(notification.DisplayName), + LocalizableStringSerializer.Deserialize(notification.Description), notification.NotificationType, notification.Lifetime, notification.ContentType, @@ -114,8 +115,8 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition { var notificationDefinition = new NotificationDefinition( notification.Name, - new FixedLocalizableString(notification.DisplayName), - new FixedLocalizableString(notification.Description), + LocalizableStringSerializer.Deserialize(notification.DisplayName), + LocalizableStringSerializer.Deserialize(notification.Description), notification.NotificationType, notification.Lifetime, notification.ContentType, @@ -181,18 +182,19 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition foreach (var record in records) { var displayName = record.DisplayName; - var description = record.Description; + if (!displayName.IsNullOrWhiteSpace()) + { + displayName = await LocalizableStringSerializer + .Deserialize(displayName) + .LocalizeAsync(StringLocalizerFactory); + } - if (!record.ResourceName.IsNullOrWhiteSpace() && !record.Localization.IsNullOrWhiteSpace()) + var description = record.Description; + if (!description.IsNullOrWhiteSpace()) { - var resource = GetResourceOrNull(record.ResourceName); - if (resource != null) - { - var localizer = await StringLocalizerFactory.CreateByResourceNameAsync(resource.ResourceName); - - displayName = localizer[$"DisplayName:{record.Localization}"]; - description = localizer[$"Description:{record.Localization}"]; - } + description = await LocalizableStringSerializer + .Deserialize(description) + .LocalizeAsync(StringLocalizerFactory); } recordCaches.Add(new NotificationDefinitionGroupCacheItem( @@ -263,24 +265,26 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition foreach (var record in records) { - var displayName = record.Name; - var description = record.Name; - var providers = new List(); - if (!record.Providers.IsNullOrWhiteSpace()) + var displayName = record.DisplayName; + if (!displayName.IsNullOrWhiteSpace()) { - providers = record.Providers.Split(';').ToList(); + displayName = await LocalizableStringSerializer + .Deserialize(displayName) + .LocalizeAsync(StringLocalizerFactory); } - if (record.ResourceName.IsNullOrWhiteSpace() && record.Localization.IsNullOrWhiteSpace()) + var description = record.Description; + if (!description.IsNullOrWhiteSpace()) + { + description = await LocalizableStringSerializer + .Deserialize(description) + .LocalizeAsync(StringLocalizerFactory); + } + + var providers = new List(); + if (!record.Providers.IsNullOrWhiteSpace()) { - var resource = GetResourceOrNull(record.ResourceName); - if (resource != null) - { - var localizer = await StringLocalizerFactory.CreateByResourceNameAsync(resource.ResourceName); - - displayName = localizer[$"DisplayName:{record.Localization}"]; - description = localizer[$"Description:{record.Localization}"]; - } + providers = record.Providers.Split(';').ToList(); } var recordCache = new NotificationDefinitionCacheItem( @@ -319,10 +323,4 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition return records; } - - protected virtual LocalizationResourceBase GetResourceOrNull(string resourceName) - { - return LocalizationOptions.Resources.Values - .FirstOrDefault(x => x.ResourceName.Equals(resourceName)); - } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs index fdc3bc190..a270ab465 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs @@ -22,7 +22,7 @@ public class DynamicNotificationDefinitionStore : IDynamicNotificationDefinition public async virtual Task> GetGroupsAsync() { - if (!_notificationsManagementOptions.IsDynamicNotificationStoreEnabled) + if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) { return Array.Empty(); } @@ -31,7 +31,7 @@ public class DynamicNotificationDefinitionStore : IDynamicNotificationDefinition public async virtual Task> GetNotificationsAsync() { - if (!_notificationsManagementOptions.IsDynamicNotificationStoreEnabled) + if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) { return Array.Empty(); } @@ -40,7 +40,7 @@ public class DynamicNotificationDefinitionStore : IDynamicNotificationDefinition public async virtual Task GetOrNullAsync(string name) { - if (!_notificationsManagementOptions.IsDynamicNotificationStoreEnabled) + if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) { return null; } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs index e5241a7b3..21d9293d8 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionGroupRecord.cs @@ -26,24 +26,6 @@ public class NotificationDefinitionGroupRecord : BasicAggregateRoot, IHasE /// public virtual string Description { get; set; } /// - /// 资源名称 - /// - /// - /// 如果不为空,作为参与本地化资源的名称 - /// DisplayName = L["DisplayName:Localization"] - /// Description = L["Description:Localization"] - /// - public virtual string ResourceName { get; protected set; } - /// - /// 本地化键值名称 - /// - /// - /// 如果不为空,作为参与本地化键值的名称 - /// DisplayName = L["DisplayName:Localization"] - /// Description = L["Description:Localization"] - /// - public virtual string Localization { get; protected set; } - /// /// 允许客户端订阅 /// public virtual bool AllowSubscriptionToClients { get; set; } @@ -60,32 +42,18 @@ public class NotificationDefinitionGroupRecord : BasicAggregateRoot, IHasE Guid id, string name, string displayName = null, - string description = null, - string resourceName = null, - string localization = null) + string description = null) : base(id) { Name = Check.NotNullOrWhiteSpace(name, nameof(name), NotificationDefinitionGroupRecordConsts.MaxNameLength); DisplayName = Check.Length(displayName, nameof(displayName), NotificationDefinitionGroupRecordConsts.MaxDisplayNameLength); Description = Check.Length(description, nameof(description), NotificationDefinitionGroupRecordConsts.MaxDescriptionLength); - SetLocalization(resourceName, localization); - ExtraProperties = new ExtraPropertyDictionary(); this.SetDefaultsForExtraProperties(); AllowSubscriptionToClients = true; } - /// - /// 设置本地化资源 - /// - /// - /// - public void SetLocalization(string resourceName, string localization) - { - ResourceName = Check.Length(resourceName, nameof(resourceName), NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); - Localization = Check.Length(localization, nameof(localization), NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); - } public bool HasSameData(NotificationDefinitionGroupRecord otherRecord) { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs index d6a0ad633..1498ad208 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionRecord.cs @@ -32,24 +32,6 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP /// public virtual string Description { get; set; } /// - /// 资源名称 - /// - /// - /// 如果不为空,作为参与本地化资源的名称 - /// DisplayName = L["DisplayName:Localization"] - /// Description = L["Description:Localization"] - /// - public virtual string ResourceName { get; protected set; } - /// - /// 本地化键值名称 - /// - /// - /// 如果不为空,作为参与本地化键值的名称 - /// DisplayName = L["DisplayName:Localization"] - /// Description = L["Description:Localization"] - /// - public virtual string Localization { get; protected set; } - /// /// 存活类型 /// public virtual NotificationLifetime NotificationLifetime { get; set; } @@ -86,8 +68,6 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP string groupName, string displayName = null, string description = null, - string resourceName = null, - string localization = null, NotificationLifetime lifetime = NotificationLifetime.Persistent, NotificationType notificationType = NotificationType.Application, NotificationContentType contentType = NotificationContentType.Text) @@ -101,23 +81,11 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP NotificationType = notificationType; ContentType = contentType; - SetLocalization(resourceName, localization); - ExtraProperties = new ExtraPropertyDictionary(); this.SetDefaultsForExtraProperties(); AllowSubscriptionToClients = true; } - /// - /// 设置本地化资源 - /// - /// - /// - public void SetLocalization(string resourceName, string localization) - { - ResourceName = Check.Length(resourceName, nameof(resourceName), NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); - Localization = Check.Length(localization, nameof(localization), NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); - } public void UseProviders(params string[] providers) { diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs index a0cab7267..f64f99ecd 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionSerializer.cs @@ -76,8 +76,6 @@ public class NotificationDefinitionSerializer : INotificationDefinitionSerialize notificationGroup?.Name, LocalizableStringSerializer.Serialize(notification.DisplayName), LocalizableStringSerializer.Serialize(notification.Description), - null, - null, notification.NotificationLifetime, notification.NotificationType, notification.ContentType diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs deleted file mode 100644 index 2d18a4d7a..000000000 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationsManagementOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace LINGYUN.Abp.Notifications; - -public class NotificationsManagementOptions -{ - /// - /// Default: true. - /// - public bool SaveStaticNotificationsToDatabase { get; set; } = true; - - /// - /// Default: false. - /// - public bool IsDynamicNotificationsStoreEnabled { get; set; } - - public NotificationsManagementOptions() - { - } -} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs index d87f093e3..c9fa4a5f1 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/AbpNotificationsEntityFrameworkCoreModule.cs @@ -13,24 +13,18 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; typeof(AbpNotificationsDomainSharedModule))] public class AbpNotificationsEntityFrameworkCoreModule : AbpModule { - [DependsOn( - typeof(AbpNotificationsDomainModule), - typeof(AbpEntityFrameworkCoreModule))] - public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddAbpDbContext(options => { - context.Services.AddAbpDbContext(options => - { - options.AddDefaultRepositories(); + options.AddDefaultRepositories(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - }); - } + options.AddRepository(); + options.AddRepository(); + }); } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs index 5ae9b78a7..65f429e19 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs @@ -1,9 +1,4 @@ using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs index 9fa15f6c3..8e6db1b92 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs @@ -72,10 +72,6 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDisplayNameLength); b.Property(p => p.Description) .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxDescriptionLength); - b.Property(p => p.ResourceName) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxResourceNameLength); - b.Property(p => p.Localization) - .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxLocalizationLength); b.ConfigureByConvention(); }); @@ -95,10 +91,6 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore .HasMaxLength(NotificationDefinitionRecordConsts.MaxDisplayNameLength); b.Property(p => p.Description) .HasMaxLength(NotificationDefinitionRecordConsts.MaxDescriptionLength); - b.Property(p => p.ResourceName) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxResourceNameLength); - b.Property(p => p.Localization) - .HasMaxLength(NotificationDefinitionRecordConsts.MaxLocalizationLength); b.Property(p => p.Providers) .HasMaxLength(NotificationDefinitionRecordConsts.MaxProvidersLength); diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs index c19e4e64e..f9960f64c 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.HttpApi/LINGYUN/Abp/Notifications/AbpNotificationsHttpApiModule.cs @@ -4,7 +4,7 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.Modularity; -namespace LINGYUN.Abp.Notifications.HttpApi; +namespace LINGYUN.Abp.Notifications; [DependsOn( typeof(AbpAspNetCoreMvcModule), diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index ba3e0495d..0e067d558 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -59,6 +59,9 @@ + + + diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index f7cdfd09d..d3ae2dacd 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -348,7 +348,7 @@ public partial class RealtimeMessageHttpApiHostModule if (isDevelopment) { - // services.AddAlwaysAllowAuthorization(); + services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index fc5cf0382..c5181b437 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -1,14 +1,15 @@ -using DotNetCore.CAP; -using LINGYUN.Abp.AspNetCore.HttpOverrides; +using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Localization; +using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; -using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; +using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; using LINGYUN.Abp.BackgroundTasks.Quartz; using LINGYUN.Abp.Data.DbMigrator; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Notifications; +using LINGYUN.Abp.Http.Client.Wrapper; using LINGYUN.Abp.Identity.EntityFrameworkCore; using LINGYUN.Abp.Identity.WeChat; using LINGYUN.Abp.IM.SignalR; @@ -16,12 +17,16 @@ using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.MessageService; using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications.Common; using LINGYUN.Abp.Notifications.Emailing; +using LINGYUN.Abp.Notifications.EntityFrameworkCore; using LINGYUN.Abp.Notifications.Jobs; +using LINGYUN.Abp.Notifications.PushPlus; using LINGYUN.Abp.Notifications.SignalR; using LINGYUN.Abp.Notifications.Sms; using LINGYUN.Abp.Notifications.WeChat.MiniProgram; +using LINGYUN.Abp.Notifications.WxPusher; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; @@ -38,15 +43,11 @@ using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Caching.StackExchangeRedis; -using Volo.Abp.Modularity; using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TextTemplating.Scriban; -using LINGYUN.Abp.Notifications.PushPlus; -using LINGYUN.Abp.Notifications.WxPusher; -using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; namespace LY.MicroService.RealtimeMessage; @@ -59,12 +60,15 @@ namespace LY.MicroService.RealtimeMessage; typeof(AbpAspNetCoreMvcLocalizationModule), typeof(AbpMessageServiceApplicationModule), typeof(AbpMessageServiceHttpApiModule), + typeof(AbpNotificationsApplicationModule), + typeof(AbpNotificationsHttpApiModule), typeof(AbpIdentityWeChatModule), typeof(AbpBackgroundTasksQuartzModule), typeof(AbpBackgroundTasksDistributedLockingModule), typeof(AbpBackgroundTasksExceptionHandlingModule), typeof(TaskManagementEntityFrameworkCoreModule), typeof(AbpMessageServiceEntityFrameworkCoreModule), + typeof(AbpNotificationsEntityFrameworkCoreModule), typeof(AbpSaasEntityFrameworkCoreModule), typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json index 6b89a4d80..273ea5c8e 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.Message", "secret": "1q2w3E*", @@ -35,16 +35,17 @@ } }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456", - "MessageService": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456", - "TaskManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpTextTemplating": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", + "MessageService": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", + "Notifications": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", + "TaskManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpTextTemplating": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" }, "Redis": { "IsEnabled": true, From 58d1c734c53a91916346ebfb23bb1ea68888530b Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:24:53 +0800 Subject: [PATCH 03/26] add support static localization persistence --- aspnet-core/LINGYUN.MicroService.All.sln | 21 ++- ...ture-Name-With-Resource-Record.Designer.cs | 174 ++++++++++++++++++ ...fault-Culture-Name-With-Resource-Record.cs | 30 +++ ...agementMigrationsDbContextModelSnapshot.cs | 5 + .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++ ...INGYUN.Abp.Localization.Persistence.csproj | 16 ++ .../AbpLocalizationPersistenceModule.cs | 15 ++ .../AbpLocalizationPersistenceOptions.cs | 35 ++++ .../Persistence/IStaticLocalizationSaver.cs | 8 + .../StaticLocalizationSaverHostService.cs | 28 +++ .../README.md | 41 +++++ .../LINGYUN.Abp.Localization.csproj | 19 ++ .../LocalizationManagement/ResourceConsts.cs | 1 + ...N.Abp.LocalizationManagement.Domain.csproj | 3 +- .../AbpLocalizationManagementDomainModule.cs | 16 +- .../LocalizationManagement/ITextRepository.cs | 6 + ...calizationManagementExternalContributor.cs | 92 +++++++++ .../Abp/LocalizationManagement/Resource.cs | 11 +- .../StaticLocalizationSaver.cs | 124 +++++++++++++ .../EfCoreTextRepository.cs | 15 ++ ...lizationDbContextModelBuilderExtensions.cs | 3 + ...onManagementHttpApiHostModule.Configure.cs | 2 +- .../appsettings.Development.json | 12 +- 24 files changed, 690 insertions(+), 20 deletions(-) create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.cs create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xml create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xsd create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN.Abp.Localization.Persistence.csproj create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceModule.cs create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceOptions.cs create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/IStaticLocalizationSaver.cs create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/StaticLocalizationSaverHostService.cs create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/README.md create mode 100644 aspnet-core/modules/localization/LINGYUN.Abp.Localization/LINGYUN.Abp.Localization.csproj create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 834a0c4bb..1be7d20b1 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -521,7 +521,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "platform", "platform", "{F2 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "realtime-message", "realtime-message", "{B1AC656F-8F4C-43D5-B5A0-CCF5F119EA44}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LY.MicroService.BackendAdmin.DbMigrator", "migrations\LY.MicroService.BackendAdmin.DbMigrator\LY.MicroService.BackendAdmin.DbMigrator.csproj", "{EA144C64-CE14-40DF-A876-5D302A4FC208}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.BackendAdmin.DbMigrator", "migrations\LY.MicroService.BackendAdmin.DbMigrator\LY.MicroService.BackendAdmin.DbMigrator.csproj", "{EA144C64-CE14-40DF-A876-5D302A4FC208}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.AuthServer.DbMigrator", "migrations\LY.MicroService.AuthServer.DbMigrator\LY.MicroService.AuthServer.DbMigrator.csproj", "{D25156E6-532F-4BCC-8EE0-8A3F1986E10E}" EndProject @@ -535,17 +535,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.RealtimeMes EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notifications", "notifications", "{1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Domain.Shared", "modules\notifications\LINGYUN.Abp.Notifications.Domain.Shared\LINGYUN.Abp.Notifications.Domain.Shared.csproj", "{4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Domain.Shared", "modules\notifications\LINGYUN.Abp.Notifications.Domain.Shared\LINGYUN.Abp.Notifications.Domain.Shared.csproj", "{4CF6F78C-22BE-46C4-BC9B-824E8FEEF719}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Domain", "modules\notifications\LINGYUN.Abp.Notifications.Domain\LINGYUN.Abp.Notifications.Domain.csproj", "{CDD4CC0F-5493-40C2-B889-3670263888D8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Domain", "modules\notifications\LINGYUN.Abp.Notifications.Domain\LINGYUN.Abp.Notifications.Domain.csproj", "{CDD4CC0F-5493-40C2-B889-3670263888D8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.EntityFrameworkCore", "modules\notifications\LINGYUN.Abp.Notifications.EntityFrameworkCore\LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj", "{F74AAE01-7B87-44CA-85ED-9A6307D51504}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.EntityFrameworkCore", "modules\notifications\LINGYUN.Abp.Notifications.EntityFrameworkCore\LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj", "{F74AAE01-7B87-44CA-85ED-9A6307D51504}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Application.Contracts", "modules\notifications\LINGYUN.Abp.Notifications.Application.Contracts\LINGYUN.Abp.Notifications.Application.Contracts.csproj", "{E3F010C7-6C96-4EEA-B5FA-BF80515E195F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Application.Contracts", "modules\notifications\LINGYUN.Abp.Notifications.Application.Contracts\LINGYUN.Abp.Notifications.Application.Contracts.csproj", "{E3F010C7-6C96-4EEA-B5FA-BF80515E195F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Application", "modules\notifications\LINGYUN.Abp.Notifications.Application\LINGYUN.Abp.Notifications.Application.csproj", "{B153F98A-7DA9-4A12-A1D7-105BE9408FA1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Application", "modules\notifications\LINGYUN.Abp.Notifications.Application\LINGYUN.Abp.Notifications.Application.csproj", "{B153F98A-7DA9-4A12-A1D7-105BE9408FA1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.HttpApi", "modules\notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj", "{EFC5C34F-81A1-4EFC-966F-50B646C54FA6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.HttpApi", "modules\notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj", "{EFC5C34F-81A1-4EFC-966F-50B646C54FA6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Localization.Persistence", "modules\localization\LINGYUN.Abp.Localization.Persistence\LINGYUN.Abp.Localization.Persistence.csproj", "{42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1397,6 +1399,10 @@ Global {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU {EFC5C34F-81A1-4EFC-966F-50B646C54FA6}.Release|Any CPU.Build.0 = Release|Any CPU + {42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1663,6 +1669,7 @@ Global {E3F010C7-6C96-4EEA-B5FA-BF80515E195F} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} {B153F98A-7DA9-4A12-A1D7-105BE9408FA1} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} {EFC5C34F-81A1-4EFC-966F-50B646C54FA6} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E} + {42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF} = {90E88EAC-4291-4406-8D88-EFDF61B11292} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.Designer.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.Designer.cs new file mode 100644 index 000000000..86c6cab55 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.Designer.cs @@ -0,0 +1,174 @@ +// +using System; +using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations +{ + [DbContext(typeof(LocalizationManagementMigrationsDbContext))] + [Migration("20230110091142_Add-Default-Culture-Name-With-Resource-Record")] + partial class AddDefaultCultureNameWithResourceRecord + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("FlagIcon") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("FlagIcon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("UiCultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("UiCultureName"); + + b.HasKey("Id"); + + b.HasIndex("CultureName"); + + b.ToTable("AbpLocalizationLanguages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DefaultCultureName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DefaultCultureName"); + + b.Property("Description") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DisplayName"); + + b.Property("Enable") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AbpLocalizationResources", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CultureName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("CultureName"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Key"); + + b.Property("ResourceName") + .HasColumnType("longtext"); + + b.Property("Value") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)") + .HasColumnName("Value"); + + b.HasKey("Id"); + + b.HasIndex("Key"); + + b.ToTable("AbpLocalizationTexts", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.cs new file mode 100644 index 000000000..93d5ed418 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/20230110091142_Add-Default-Culture-Name-With-Resource-Record.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations +{ + /// + public partial class AddDefaultCultureNameWithResourceRecord : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DefaultCultureName", + table: "AbpLocalizationResources", + type: "varchar(64)", + maxLength: 64, + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DefaultCultureName", + table: "AbpLocalizationResources"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs index 18a431aff..6203ebf62 100644 --- a/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/Migrations/LocalizationManagementMigrationsDbContextModelSnapshot.cs @@ -92,6 +92,11 @@ namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations .HasColumnType("char(36)") .HasColumnName("CreatorId"); + b.Property("DefaultCultureName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("DefaultCultureName"); + b.Property("Description") .HasMaxLength(64) .HasColumnType("varchar(64)") diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xml b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xsd b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN.Abp.Localization.Persistence.csproj b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN.Abp.Localization.Persistence.csproj new file mode 100644 index 000000000..68a757b72 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN.Abp.Localization.Persistence.csproj @@ -0,0 +1,16 @@ + + + + + + + netstandard2.0 + + + + + + + + + diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceModule.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceModule.cs new file mode 100644 index 000000000..7ca157451 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceModule.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Localization.Persistence; + +[DependsOn( + typeof(AbpLocalizationModule))] +public class AbpLocalizationPersistenceModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHostedService(); + } +} diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceOptions.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceOptions.cs new file mode 100644 index 000000000..941de16d0 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/AbpLocalizationPersistenceOptions.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.Localization.Persistence; + +public class AbpLocalizationPersistenceOptions +{ + public bool SaveStaticLocalizationsToPersistence { get; set; } + + public HashSet SaveToPersistenceResources { get; } + + public AbpLocalizationPersistenceOptions() + { + SaveStaticLocalizationsToPersistence = true; + + SaveToPersistenceResources = new HashSet(); + } + + public void AddPersistenceResource() + { + AddPersistenceResource(typeof(TResource)); + } + + public void AddPersistenceResource(Type resourceType) + { + var resourceName = LocalizationResourceNameAttribute.GetName(resourceType); + if (SaveToPersistenceResources.Contains(resourceName)) + { + return; + } + + SaveToPersistenceResources.Add(resourceName); + } +} diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/IStaticLocalizationSaver.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/IStaticLocalizationSaver.cs new file mode 100644 index 000000000..025f0c1bd --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/IStaticLocalizationSaver.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Localization.Persistence; + +public interface IStaticLocalizationSaver +{ + Task SaveAsync(); +} diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/StaticLocalizationSaverHostService.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/StaticLocalizationSaverHostService.cs new file mode 100644 index 000000000..32c74535d --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/LINGYUN/Abp/Localization/Persistence/StaticLocalizationSaverHostService.cs @@ -0,0 +1,28 @@ +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Localization.Persistence; + +public class StaticLocalizationSaverHostService : BackgroundService +{ + private readonly AbpLocalizationPersistenceOptions _options; + private readonly IStaticLocalizationSaver _staticLocalizationSaver; + + public StaticLocalizationSaverHostService( + IOptions options, + IStaticLocalizationSaver staticLocalizationSaver) + { + _options = options.Value; + _staticLocalizationSaver = staticLocalizationSaver; + } + + protected async override Task ExecuteAsync(CancellationToken stoppingToken) + { + if (_options.SaveStaticLocalizationsToPersistence) + { + await _staticLocalizationSaver.SaveAsync(); + } + } +} diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/README.md b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/README.md new file mode 100644 index 000000000..85a964815 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Persistence/README.md @@ -0,0 +1,41 @@ +# LINGYUN.Abp.Localization.Persistence + +## 模块说明 + +本地化组件持久层模块, 引用模块可将需要的本地化文档持久化到存储设施 + +### 基础模块 + +### 高阶模块 + +### 权限定义 + +### 功能定义 + +### 配置定义 + +### 如何使用 + + +```csharp + + [DependsOn( + typeof(AbpLocalizationPersistenceModule))] + public class YouProjectModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + // 启用持久化设施 + options.SaveStaticLocalizationsToPersistence = true; + + // 指定你的本地化资源类型, 此类型下定义的静态文档将被持久化到存储设施 + options.AddPersistenceResource(); + }); + } + } + +``` + +### 更新日志 diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization/LINGYUN.Abp.Localization.csproj b/aspnet-core/modules/localization/LINGYUN.Abp.Localization/LINGYUN.Abp.Localization.csproj new file mode 100644 index 000000000..a14eb7ce5 --- /dev/null +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization/LINGYUN.Abp.Localization.csproj @@ -0,0 +1,19 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain.Shared/LINGYUN/Abp/LocalizationManagement/ResourceConsts.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain.Shared/LINGYUN/Abp/LocalizationManagement/ResourceConsts.cs index 2a2d9e2d5..83994ceed 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain.Shared/LINGYUN/Abp/LocalizationManagement/ResourceConsts.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain.Shared/LINGYUN/Abp/LocalizationManagement/ResourceConsts.cs @@ -5,5 +5,6 @@ public static int MaxNameLength { get; set; } = 50; public static int MaxDisplayNameLength { get; set; } = 64; public static int MaxDescriptionLength { get; set; } = 64; + public static int MaxDefaultCultureNameLength { get; set; } = 64; } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj index 78c91b6ad..60e64ae09 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN.Abp.LocalizationManagement.Domain.csproj @@ -1,4 +1,4 @@ - + @@ -14,6 +14,7 @@ + diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs index c5e1c30f1..47d253f82 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs @@ -1,13 +1,17 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; using Volo.Abp.Domain; +using Volo.Abp.Localization; using Volo.Abp.Modularity; - +using LINGYUN.Abp.Localization.Persistence; +using LINGYUN.Abp.LocalizationManagement.Localization; + namespace LINGYUN.Abp.LocalizationManagement { [DependsOn( typeof(AbpAutoMapperModule), typeof(AbpDddDomainModule), + typeof(AbpLocalizationPersistenceModule), typeof(AbpLocalizationManagementDomainSharedModule))] public class AbpLocalizationManagementDomainModule : AbpModule { @@ -20,6 +24,16 @@ namespace LINGYUN.Abp.LocalizationManagement options.AddProfile(validate: true); }); + Configure(options => + { + options.GlobalContributors.Add(); + }); + + Configure(options => + { + options.AddPersistenceResource(); + }); + // 分布式事件 //Configure(options => //{ diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ITextRepository.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ITextRepository.cs index 64613f44b..db2f36253 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ITextRepository.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ITextRepository.cs @@ -7,6 +7,12 @@ namespace LINGYUN.Abp.LocalizationManagement { public interface ITextRepository : IRepository { + Task> GetExistsKeysAsync( + string resourceName, + string cultureName, + IEnumerable keys, + CancellationToken cancellationToken = default); + Task GetByCultureKeyAsync( string resourceName, string cultureName, diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs new file mode 100644 index 000000000..3dac52cc7 --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs @@ -0,0 +1,92 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.LocalizationManagement; + +public class LocalizationManagementExternalContributor : ILocalizationResourceContributor +{ + public bool IsDynamic => true; + + private LocalizationResourceBase _resource; + private ITextRepository _textRepository; + private IResourceRepository _resourceRepository; + private ILanguageRepository _languageRepository; + + public void Initialize(LocalizationResourceInitializationContext context) + { + _resource = context.Resource; + _textRepository = context.ServiceProvider.GetRequiredService(); + _resourceRepository = context.ServiceProvider.GetRequiredService(); + _languageRepository = context.ServiceProvider.GetRequiredService(); + } + + public virtual void Fill(string cultureName, Dictionary dictionary) + { + FillInternalAsync(_resource.ResourceName, cultureName, dictionary).GetAwaiter().GetResult(); + } + + public async virtual Task FillAsync(string cultureName, Dictionary dictionary) + { + await FillInternalAsync(_resource.ResourceName, cultureName, dictionary); + } + + public virtual LocalizedString GetOrNull(string cultureName, string name) + { + return GetOrNullInternal(_resource.ResourceName, cultureName, name); + } + + protected virtual LocalizedString GetOrNullInternal(string resourceName, string cultureName, string name) + { + var resource = GetResourceOrNullAsync(name).GetAwaiter().GetResult(); + if (resource == null) + { + return null; + } + var text = _textRepository.GetByCultureKeyAsync(resourceName, cultureName, name).GetAwaiter().GetResult(); + if (text != null) + { + return new LocalizedString(name, text.Value); + } + + return null; + } + + public async virtual Task> GetSupportedCulturesAsync() + { + var languages = await _languageRepository.GetActivedListAsync(); + + return languages + .Select(x => x.CultureName) + .ToList(); + } + + protected async virtual Task FillInternalAsync(string resourceName, string cultureName, Dictionary dictionary) + { + var resource = await GetResourceOrNullAsync(resourceName); + if (resource == null) + { + return; + } + + var texts = await GetTextListByResourceAsync(resourceName, cultureName); + + foreach (var text in texts) + { + dictionary[text.Key] = new LocalizedString(text.Key, text.Value); + } + } + + protected async virtual Task GetResourceOrNullAsync(string resourceName) + { + return await _resourceRepository.FindByNameAsync(resourceName); + } + + protected async virtual Task> GetTextListByResourceAsync(string resourceName, string cultureName = null) + { + return await _textRepository.GetListAsync(resourceName, cultureName); + } +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/Resource.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/Resource.cs index c8fedf660..db763a96f 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/Resource.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/Resource.cs @@ -11,18 +11,21 @@ namespace LINGYUN.Abp.LocalizationManagement public virtual string Name { get; set; } public virtual string DisplayName { get; set; } public virtual string Description { get; set; } + public virtual string DefaultCultureName { get; set; } protected Resource() { } public Resource( [NotNull] string name, [CanBeNull] string displayName = null, - [CanBeNull] string description = null) + [CanBeNull] string description = null, + [CanBeNull] string defaultCultureName = null) { Name = Check.NotNullOrWhiteSpace(name, nameof(name), ResourceConsts.MaxNameLength); - DisplayName = displayName ?? Name; - Description = description; + DisplayName = Check.Length(displayName ?? Name, nameof(displayName), ResourceConsts.MaxDisplayNameLength);; + Description = Check.Length(description, nameof(description), ResourceConsts.MaxDescriptionLength); + DefaultCultureName = Check.Length(defaultCultureName, nameof(defaultCultureName), ResourceConsts.MaxDefaultCultureNameLength); - Enable = true; + Enable = true; } } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs new file mode 100644 index 000000000..816bfbd1a --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs @@ -0,0 +1,124 @@ +using LINGYUN.Abp.Localization.Persistence; +using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; +using Volo.Abp.Uow; + +namespace LINGYUN.Abp.LocalizationManagement; + +[Dependency(ReplaceServices = true)] +public class StaticLocalizationSaver : IStaticLocalizationSaver, ITransientDependency +{ + protected ILanguageRepository LanguageRepository { get; } + protected ITextRepository TextRepository { get; } + protected IResourceRepository ResourceRepository { get; } + protected IStringLocalizerFactory StringLocalizerFactory { get; } + protected AbpLocalizationOptions LocalizationOptions { get; } + protected IServiceProvider ServiceProvider { get; } + protected AbpLocalizationPersistenceOptions LocalizationPersistenceOptions { get; } + + public StaticLocalizationSaver( + IServiceProvider serviceProvider, + ILanguageRepository languageRepository, + ITextRepository textRepository, + IResourceRepository resourceRepository, + IStringLocalizerFactory stringLocalizerFactory, + IOptions localizationOptions, + IOptions localizationPersistenceOptions) + { + ServiceProvider = serviceProvider; + LanguageRepository = languageRepository; + TextRepository = textRepository; + ResourceRepository = resourceRepository; + StringLocalizerFactory = stringLocalizerFactory; + LocalizationOptions = localizationOptions.Value; + LocalizationPersistenceOptions = localizationPersistenceOptions.Value; + } + + [UnitOfWork] + public async virtual Task SaveAsync() + { + var insertNewTexts = new List(); + + foreach (var language in LocalizationOptions.Languages) + { + if (await LanguageRepository.FindByCultureNameAsync(language.CultureName) == null) + { + await LanguageRepository.InsertAsync( + new Language( + language.CultureName, + language.UiCultureName, + language.DisplayName, + language.FlagIcon)); + } + + foreach (var resource in LocalizationPersistenceOptions.SaveToPersistenceResources) + { + using (CultureHelper.Use(language.CultureName, language.UiCultureName)) + { + var localizationResource = LocalizationOptions.Resources.GetOrDefault(resource); + if (localizationResource == null) + { + continue; + } + + var context = new LocalizationResourceInitializationContext(localizationResource, ServiceProvider); + + if (await ResourceRepository.FindByNameAsync(localizationResource.ResourceName) == null) + { + await ResourceRepository.InsertAsync( + new Resource( + localizationResource.ResourceName, + localizationResource.ResourceName, + localizationResource.ResourceName, + localizationResource.DefaultCultureName)); + } + + foreach (var contributor in localizationResource.Contributors) + { + if (contributor.IsDynamic) + { + continue; + } + + contributor.Initialize(context); + var fillTexts = new Dictionary(); + + await contributor.FillAsync(language.CultureName, fillTexts); + + var existsKeys = await TextRepository.GetExistsKeysAsync( + localizationResource.ResourceName, + language.CultureName, + fillTexts.Values.Select(x => x.Name)); + + var notExistsKeys = fillTexts.Values.Where(x => !existsKeys.Contains(x.Name)); + notExistsKeys = notExistsKeys.Where(x => !insertNewTexts.Any(t => t.Key == x.Name)); + + foreach (var notExistsKey in notExistsKeys) + { + if (!insertNewTexts.Any(x => x.CultureName == language.CultureName && x.Key == notExistsKey.Name)) + { + insertNewTexts.Add( + new Text( + localizationResource.ResourceName, + language.CultureName, + notExistsKey.Name, + notExistsKey.Value)); + } + } + } + } + } + } + + if (insertNewTexts.Any()) + { + await TextRepository.InsertManyAsync(insertNewTexts); + } + } +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs index 331bc0fce..0a1ae3d23 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +19,20 @@ namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore { } + public async virtual Task> GetExistsKeysAsync( + string resourceName, + string cultureName, + IEnumerable keys, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.ResourceName.Equals(resourceName) && x.CultureName.Equals(cultureName) + && keys.Contains(x.Key)) + .Select(x => x.Key) + .Distinct() + .ToListAsync(GetCancellationToken(cancellationToken)); + } + public async virtual Task GetByCultureKeyAsync( string resourceName, string cultureName, diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/LocalizationDbContextModelBuilderExtensions.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/LocalizationDbContextModelBuilderExtensions.cs index 81ca35f8a..c5c384627 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/LocalizationDbContextModelBuilderExtensions.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/LocalizationDbContextModelBuilderExtensions.cs @@ -65,6 +65,9 @@ namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore x.Property(p => p.Description) .HasMaxLength(ResourceConsts.MaxDescriptionLength) .HasColumnName(nameof(Resource.Description)); + x.Property(p => p.DefaultCultureName) + .HasMaxLength(ResourceConsts.MaxDefaultCultureNameLength) + .HasColumnName(nameof(Resource.DefaultCultureName)); x.Property(p => p.Enable) .HasDefaultValue(true); diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index 9a68a4698..f3b306d68 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -258,7 +258,7 @@ public partial class LocalizationManagementHttpApiHostModule if (isDevelopment) { - // services.AddAlwaysAllowAuthorization(); + services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.Development.json index 47bae649e..b25a694b0 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.Localization", "secret": "1q2w3E*", @@ -23,11 +23,11 @@ } }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" }, "CAP": { "EventBus": { From 1dcf12979335b9430d9ada49f04af8207122dce6 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:28:56 +0800 Subject: [PATCH 04/26] fix: remove unnecessary duplicate key checks --- .../Abp/LocalizationManagement/StaticLocalizationSaver.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs index 816bfbd1a..fd8efef2e 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs @@ -97,7 +97,6 @@ public class StaticLocalizationSaver : IStaticLocalizationSaver, ITransientDepen fillTexts.Values.Select(x => x.Name)); var notExistsKeys = fillTexts.Values.Where(x => !existsKeys.Contains(x.Name)); - notExistsKeys = notExistsKeys.Where(x => !insertNewTexts.Any(t => t.Key == x.Name)); foreach (var notExistsKey in notExistsKeys) { From cde5ce63a30aeb388682a99f24327e3548f50e52 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:36:21 +0800 Subject: [PATCH 05/26] fix: resolve unimplemented dynamic prop with localization contributor --- .../Xml/XmlFileLocalizationResourceContributorBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs index 84e8a078b..d8f637991 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlFileLocalizationResourceContributorBase.cs @@ -19,7 +19,7 @@ namespace LINGYUN.Abp.Localization.Xml private bool _subscribedForChanges; private readonly object _syncObj = new object(); - public bool IsDynamic => throw new NotImplementedException(); + public bool IsDynamic => false; protected XmlFileLocalizationResourceContributorBase(string filePath) { From 96efcccb1f32e6e5adef17021f9719503ce92f73 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:42:24 +0800 Subject: [PATCH 06/26] adjust localization resource context order --- .../Abp/LocalizationManagement/StaticLocalizationSaver.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs index fd8efef2e..9b6e46233 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/StaticLocalizationSaver.cs @@ -67,8 +67,6 @@ public class StaticLocalizationSaver : IStaticLocalizationSaver, ITransientDepen continue; } - var context = new LocalizationResourceInitializationContext(localizationResource, ServiceProvider); - if (await ResourceRepository.FindByNameAsync(localizationResource.ResourceName) == null) { await ResourceRepository.InsertAsync( @@ -79,6 +77,7 @@ public class StaticLocalizationSaver : IStaticLocalizationSaver, ITransientDepen localizationResource.DefaultCultureName)); } + var context = new LocalizationResourceInitializationContext(localizationResource, ServiceProvider); foreach (var contributor in localizationResource.Contributors) { if (contributor.IsDynamic) From 5c7049d8fb23a1f4017c1ad469abdedcf3bc3394 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 08:05:32 +0800 Subject: [PATCH 07/26] UPDATE README,md --- aspnet-core/modules/lt/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnet-core/modules/lt/README.md b/aspnet-core/modules/lt/README.md index 0d2dbd9cd..e51a19138 100644 --- a/aspnet-core/modules/lt/README.md +++ b/aspnet-core/modules/lt/README.md @@ -6,7 +6,7 @@ ### 基础模块 -* [LINGYUN.Abp.Localization.Dynamic](../common/LINGYUN.Abp.Localization.Dynamic/LINGYUN.Abp.Localization.Dynamic) 本地化扩展模块,增加 DynamicLocalizationResourceContributor 通过 ILocalizationStore 接口获取动态的本地化资源信息 +* [LINGYUN.Abp.Localization.Persistence](../localization/LINGYUN.Abp.Localization.Persistence) 本地化持久化模块,实现IStaticLocalizationSaver接口以将本地静态资源持久化到存储设施 * [LINGYUN.Abp.LocalizationManagement.Domain.Shared](./LINGYUN.Abp.LocalizationManagement.Domain.Shared) 领域层公共模块,定义了错误代码、本地化、模块设置 * [LINGYUN.Abp.LocalizationManagement.Domain](./LINGYUN.Abp.LocalizationManagement.Domain) 领域层模块,实现 ILocalizationStore 接口 * [LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore](./LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore) 数据访问层模块,集成EfCore From f3f3e361fea6ebb56646a079a3d5a0fffff8e194 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:07:07 +0800 Subject: [PATCH 08/26] add localization in memory cache --- .../AbpLocalizationManagementOptions.cs | 24 ++ .../ILocalizationStoreCache.cs | 21 ++ .../LocalizationDictionary.cs | 8 + .../LocalizationDictionaryWithCulture.cs | 6 + .../LocalizationDictionaryWithResource.cs | 6 + .../LocalizationLanguageDictionary.cs | 7 + ...calizationManagementExternalContributor.cs | 77 ++---- .../LocalizationStore.cs | 100 ++++---- ...LocalizationStoreCacheInitializeContext.cs | 12 + .../LocalizationStoreInMemoryCache.cs | 242 ++++++++++++++++++ 10 files changed, 403 insertions(+), 100 deletions(-) create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementOptions.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ILocalizationStoreCache.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionary.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithCulture.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithResource.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationLanguageDictionary.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreCacheInitializeContext.cs create mode 100644 aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementOptions.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementOptions.cs new file mode 100644 index 000000000..1008e21ec --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementOptions.cs @@ -0,0 +1,24 @@ +using System; + +namespace LINGYUN.Abp.LocalizationManagement; + +public class AbpLocalizationManagementOptions +{ + /// + /// 申请时间戳超时时间 + /// default: 2 minutes + /// + public TimeSpan LocalizationCacheStampTimeOut { get; set; } + /// + /// 时间戳过期时间 + /// default: 30 minutes + /// + public TimeSpan LocalizationCacheStampExpiration { get; set; } + + public AbpLocalizationManagementOptions() + { + LocalizationCacheStampTimeOut = TimeSpan.FromMinutes(2); + // 30分钟过期重新刷新缓存 + LocalizationCacheStampExpiration = TimeSpan.FromMinutes(30); + } +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ILocalizationStoreCache.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ILocalizationStoreCache.cs new file mode 100644 index 000000000..649a6666e --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/ILocalizationStoreCache.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.Localization; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.LocalizationManagement; + +public interface ILocalizationStoreCache +{ + Task InitializeAsync(LocalizationStoreCacheInitializeContext context); + + LocalizationResourceBase GetResourceOrNull(string resourceName); + + LocalizedString GetLocalizedStringOrNull(string resourceName, string cultureName, string name); + + IReadOnlyList GetResources(); + + IReadOnlyList GetLanguages(); + + IDictionary GetAllLocalizedStrings(string cultureName); +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionary.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionary.cs new file mode 100644 index 000000000..e98f9fe40 --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionary.cs @@ -0,0 +1,8 @@ +using Microsoft.Extensions.Localization; +using System.Collections.Generic; + +namespace LINGYUN.Abp.LocalizationManagement; +public class LocalizationDictionary : Dictionary +{ + +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithCulture.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithCulture.cs new file mode 100644 index 000000000..68152887c --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithCulture.cs @@ -0,0 +1,6 @@ +using System.Collections.Generic; + +namespace LINGYUN.Abp.LocalizationManagement; +public class LocalizationDictionaryWithCulture : Dictionary +{ +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithResource.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithResource.cs new file mode 100644 index 000000000..901aa2d35 --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationDictionaryWithResource.cs @@ -0,0 +1,6 @@ +using System.Collections.Generic; + +namespace LINGYUN.Abp.LocalizationManagement; +public class LocalizationDictionaryWithResource : Dictionary +{ +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationLanguageDictionary.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationLanguageDictionary.cs new file mode 100644 index 000000000..d05c7d52f --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationLanguageDictionary.cs @@ -0,0 +1,7 @@ +using System.Collections.Generic; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.LocalizationManagement; +public class LocalizationLanguageDictionary : Dictionary +{ +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs index 3dac52cc7..2f0c334ed 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationManagementExternalContributor.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp.Localization; +using Volo.Abp.Threading; namespace LINGYUN.Abp.LocalizationManagement; @@ -12,81 +13,53 @@ public class LocalizationManagementExternalContributor : ILocalizationResourceCo public bool IsDynamic => true; private LocalizationResourceBase _resource; - private ITextRepository _textRepository; - private IResourceRepository _resourceRepository; - private ILanguageRepository _languageRepository; + + private ILocalizationStoreCache _localizationStoreCache; + private LocalizationStoreCacheInitializeContext _cacheInitializeContext; public void Initialize(LocalizationResourceInitializationContext context) { _resource = context.Resource; - _textRepository = context.ServiceProvider.GetRequiredService(); - _resourceRepository = context.ServiceProvider.GetRequiredService(); - _languageRepository = context.ServiceProvider.GetRequiredService(); + + _cacheInitializeContext = new LocalizationStoreCacheInitializeContext(context.ServiceProvider); + _localizationStoreCache = context.ServiceProvider.GetRequiredService(); } public virtual void Fill(string cultureName, Dictionary dictionary) { - FillInternalAsync(_resource.ResourceName, cultureName, dictionary).GetAwaiter().GetResult(); + AsyncHelper.RunSync(async () => await FillAsync(cultureName, dictionary)); } public async virtual Task FillAsync(string cultureName, Dictionary dictionary) { - await FillInternalAsync(_resource.ResourceName, cultureName, dictionary); - } + await _localizationStoreCache.InitializeAsync(_cacheInitializeContext); - public virtual LocalizedString GetOrNull(string cultureName, string name) - { - return GetOrNullInternal(_resource.ResourceName, cultureName, name); - } + var localizedStrings = _localizationStoreCache.GetAllLocalizedStrings(cultureName); - protected virtual LocalizedString GetOrNullInternal(string resourceName, string cultureName, string name) - { - var resource = GetResourceOrNullAsync(name).GetAwaiter().GetResult(); - if (resource == null) + var localizedStringsInResource = localizedStrings.GetOrDefault(_resource.ResourceName); + if (localizedStringsInResource != null) { - return null; + foreach (var localizedString in localizedStringsInResource) + { + dictionary[localizedString.Key] = localizedString.Value; + } } - var text = _textRepository.GetByCultureKeyAsync(resourceName, cultureName, name).GetAwaiter().GetResult(); - if (text != null) - { - return new LocalizedString(name, text.Value); - } - - return null; } - public async virtual Task> GetSupportedCulturesAsync() + public virtual LocalizedString GetOrNull(string cultureName, string name) { - var languages = await _languageRepository.GetActivedListAsync(); - - return languages - .Select(x => x.CultureName) - .ToList(); + return _localizationStoreCache + .GetLocalizedStringOrNull(_resource.ResourceName, cultureName, name); } - protected async virtual Task FillInternalAsync(string resourceName, string cultureName, Dictionary dictionary) + public virtual Task> GetSupportedCulturesAsync() { - var resource = await GetResourceOrNullAsync(resourceName); - if (resource == null) - { - return; - } - - var texts = await GetTextListByResourceAsync(resourceName, cultureName); + var languageInfos = _localizationStoreCache.GetLanguages(); - foreach (var text in texts) - { - dictionary[text.Key] = new LocalizedString(text.Key, text.Value); - } - } - - protected async virtual Task GetResourceOrNullAsync(string resourceName) - { - return await _resourceRepository.FindByNameAsync(resourceName); - } + IEnumerable languages = languageInfos + .Select(x => x.CultureName) + .ToList(); - protected async virtual Task> GetTextListByResourceAsync(string resourceName, string cultureName = null) - { - return await _textRepository.GetListAsync(resourceName, cultureName); + return Task.FromResult(languages); } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs index 4bd7ce6bc..9989560b1 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStore.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -18,29 +19,25 @@ namespace LINGYUN.Abp.LocalizationManagement typeof(LocalizationStore))] public class LocalizationStore : IExternalLocalizationStore { - protected ILanguageRepository LanguageRepository { get; } - protected ITextRepository TextRepository { get; } - protected IResourceRepository ResourceRepository { get; } + protected IServiceProvider ServiceProvider { get; } + protected ILocalizationStoreCache LocalizationStoreCache { get; } - public LocalizationStore( - ILanguageRepository languageRepository, - ITextRepository textRepository, - IResourceRepository resourceRepository) - { - TextRepository = textRepository; - LanguageRepository = languageRepository; - ResourceRepository = resourceRepository; + public LocalizationStore( + IServiceProvider serviceProvider, + ILocalizationStoreCache localizationStoreCache) + { + ServiceProvider = serviceProvider; + LocalizationStoreCache = localizationStoreCache; } [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task> GetLanguageListAsync( CancellationToken cancellationToken = default) { - var languages = await LanguageRepository.GetActivedListAsync(cancellationToken); + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); - return languages - .Select(x => new LanguageInfo(x.CultureName, x.UiCultureName, x.DisplayName, x.FlagIcon)) - .ToList(); + return LocalizationStoreCache.GetLanguages().ToList(); } [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] @@ -48,26 +45,31 @@ namespace LINGYUN.Abp.LocalizationManagement string resourceName, CancellationToken cancellationToken = default) { - // TODO: 引用缓存? var dictionaries = new Dictionary(); - var resource = await ResourceRepository.FindByNameAsync(resourceName, cancellationToken); - if (resource == null || !resource.Enable) + + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); + + var resource = LocalizationStoreCache.GetResourceOrNull(resourceName); + + if (resource == null) { // 资源不存在或未启用返回空 return dictionaries; } - var texts = await TextRepository.GetListAsync(resourceName, null, cancellationToken); + var texts = LocalizationStoreCache.GetAllLocalizedStrings(CultureInfo.CurrentCulture.Name); - foreach (var textGroup in texts.GroupBy(x => x.CultureName)) + foreach (var textGroup in texts) { var cultureTextDictionaires = new Dictionary(); - foreach (var text in textGroup) + + foreach (var text in textGroup.Value) { // 本地化名称去重 if (!cultureTextDictionaires.ContainsKey(text.Key)) { - cultureTextDictionaires[text.Key] = new LocalizedString(text.Key, text.Value.NormalizeLineEndings()); + cultureTextDictionaires[text.Key] = new LocalizedString(text.Key, text.Value.Value.NormalizeLineEndings()); } } @@ -85,27 +87,28 @@ namespace LINGYUN.Abp.LocalizationManagement public async virtual Task>> GetAllLocalizationDictionaryAsync(CancellationToken cancellationToken = default) { var result = new Dictionary>(); - var textList = await TextRepository.GetListAsync(resourceName: null, cancellationToken: cancellationToken); - foreach (var resourcesGroup in textList.GroupBy(x => x.ResourceName)) + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); + + var textList = LocalizationStoreCache.GetAllLocalizedStrings(CultureInfo.CurrentCulture.Name); + + foreach (var resourcesGroup in textList) { var dictionaries = new Dictionary(); - foreach (var textGroup in resourcesGroup.GroupBy(x => x.CultureName)) + foreach (var text in resourcesGroup.Value) { var cultureTextDictionaires = new Dictionary(); - foreach (var text in textGroup) + // 本地化名称去重 + if (!cultureTextDictionaires.ContainsKey(text.Key)) { - // 本地化名称去重 - if (!cultureTextDictionaires.ContainsKey(text.Key)) - { - cultureTextDictionaires[text.Key] = new LocalizedString(text.Key, text.Value.NormalizeLineEndings()); - } + cultureTextDictionaires[text.Key] = new LocalizedString(text.Key, text.Value.Value.NormalizeLineEndings()); } // 本地化语言去重 - if (!dictionaries.ContainsKey(textGroup.Key)) + if (!dictionaries.ContainsKey(text.Key)) { - dictionaries[textGroup.Key] = new StaticLocalizationDictionary(textGroup.Key, cultureTextDictionaires); + dictionaries[text.Key] = new StaticLocalizationDictionary(text.Key, cultureTextDictionaires); } } @@ -118,40 +121,41 @@ namespace LINGYUN.Abp.LocalizationManagement [Obsolete("The framework already supports dynamic languages and will be deprecated in the next release")] public async virtual Task ResourceExistsAsync(string resourceName, CancellationToken cancellationToken = default) { - return await ResourceRepository.ExistsAsync(resourceName, cancellationToken); + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); + + return LocalizationStoreCache.GetResourceOrNull(resourceName) != null; } public LocalizationResourceBase GetResourceOrNull(string resourceName) { - return GetResourceOrNullAsync(resourceName) - .ConfigureAwait(continueOnCapturedContext: false) - .GetAwaiter() - .GetResult(); + return AsyncHelper.RunSync(async () => await GetResourceOrNullAsync(resourceName)); } public async virtual Task GetResourceOrNullAsync(string resourceName) { - var resource = await ResourceRepository.FindByNameAsync(resourceName); - if (resource == null) - { - return null; - } + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); - return new NonTypedLocalizationResource(resource.Name); + return LocalizationStoreCache.GetResourceOrNull(resourceName); } public async virtual Task GetResourceNamesAsync() { - var resources = await ResourceRepository.GetListAsync(); + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); - return resources.Select(r => r.Name).ToArray(); + return LocalizationStoreCache.GetResources() + .Select(x => x.ResourceName) + .ToArray(); } public async virtual Task GetResourcesAsync() { - var resources = await ResourceRepository.GetListAsync(); + var context = new LocalizationStoreCacheInitializeContext(ServiceProvider); + await LocalizationStoreCache.InitializeAsync(context); - return resources.Select(r => new NonTypedLocalizationResource(r.Name)).ToArray(); + return LocalizationStoreCache.GetResources().ToArray(); } } } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreCacheInitializeContext.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreCacheInitializeContext.cs new file mode 100644 index 000000000..462a2ca56 --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreCacheInitializeContext.cs @@ -0,0 +1,12 @@ +using System; + +namespace LINGYUN.Abp.LocalizationManagement; + +public class LocalizationStoreCacheInitializeContext +{ + public IServiceProvider ServiceProvider { get; } + public LocalizationStoreCacheInitializeContext(IServiceProvider serviceProvider) + { + ServiceProvider = serviceProvider; + } +} diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs new file mode 100644 index 000000000..91a2d0b24 --- /dev/null +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs @@ -0,0 +1,242 @@ +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Localization; +using Volo.Abp.Threading; +using Volo.Abp.Timing; + +namespace LINGYUN.Abp.LocalizationManagement; + +[ExposeServices( + typeof(ILocalizationStoreCache), + typeof(LocalizationStoreInMemoryCache))] +public class LocalizationStoreInMemoryCache : ILocalizationStoreCache, ISingletonDependency +{ + private string _cacheStamp; + private DateTime? _lastCheckTime; + private readonly SemaphoreSlim _syncSemaphore; + + protected LocalizationResourceDictionary Resources { get; } + protected LocalizationLanguageDictionary Languages { get; } + protected LocalizationDictionaryWithResource LocalizedStrings { get; } + + private readonly IClock _clock; + private readonly IDistributedCache _distributedCache; + private readonly IAbpDistributedLock _distributedLock; + private readonly AbpDistributedCacheOptions _distributedCacheOptions; + private readonly AbpLocalizationManagementOptions _managementOptions; + + public LocalizationStoreInMemoryCache( + IClock clock, + IDistributedCache distributedCache, + IAbpDistributedLock distributedLock, + IOptions distributedCacheOptions, + IOptions managementOptions) + { + _clock = clock; + _distributedCache = distributedCache; + _distributedLock = distributedLock; + _distributedCacheOptions = distributedCacheOptions.Value; + _managementOptions = managementOptions.Value; + + _syncSemaphore = new SemaphoreSlim(1, 1); + Resources = new LocalizationResourceDictionary(); + Languages = new LocalizationLanguageDictionary(); + LocalizedStrings = new LocalizationDictionaryWithResource(); + } + + public async virtual Task InitializeAsync(LocalizationStoreCacheInitializeContext context) + { + using (await _syncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(context); + } + } + + public virtual IDictionary GetAllLocalizedStrings(string cultureName) + { + var localizedStrings = new Dictionary(); + + foreach (var resource in Resources) + { + var localizedStringsInResource = LocalizedStrings.GetOrDefault(resource.Key); + if (localizedStringsInResource == null) + { + continue; + } + + var localizedStringsInCurrentCulture = localizedStringsInResource.GetOrDefault(cultureName); + if (localizedStringsInCurrentCulture == null) + { + continue; + } + + var currentCultureLocalizedStrings = new LocalizationDictionary(); + + foreach (var localizedString in localizedStringsInCurrentCulture) + { + if (!currentCultureLocalizedStrings.ContainsKey(localizedString.Key)) + { + currentCultureLocalizedStrings.Add(localizedString.Key, localizedString.Value); + } + } + + localizedStrings[resource.Key] = currentCultureLocalizedStrings; + } + + return localizedStrings; + } + + public virtual LocalizedString GetLocalizedStringOrNull(string resourceName, string cultureName, string name) + { + var localizedStringsInResource = LocalizedStrings.GetOrDefault(resourceName); + if (localizedStringsInResource == null) + { + return null; + } + + var currentCultureLocalizedStrings = localizedStringsInResource.GetOrDefault(cultureName); + if (currentCultureLocalizedStrings == null) + { + return null; + } + + return currentCultureLocalizedStrings.GetOrDefault(name); + } + + public virtual LocalizationResourceBase GetResourceOrNull(string resourceName) + { + return Resources.GetOrDefault(resourceName); + } + + public virtual IReadOnlyList GetResources() + { + return Resources.Values.ToImmutableList(); + } + + public virtual IReadOnlyList GetLanguages() + { + return Languages.Values.ToImmutableList(); + } + + protected async virtual Task EnsureCacheIsUptoDateAsync(LocalizationStoreCacheInitializeContext context) + { + if (_lastCheckTime.HasValue && + _clock.Now.Subtract(_lastCheckTime.Value).TotalSeconds < 30) + { + return; + } + + var stampInDistributedCache = await GetOrSetStampInDistributedCache(); + + if (stampInDistributedCache == _cacheStamp) + { + _lastCheckTime = _clock.Now; + return; + } + + await UpdateInMemoryStoreCache(context); + + _cacheStamp = stampInDistributedCache; + _lastCheckTime = _clock.Now; + } + + protected async virtual Task UpdateInMemoryStoreCache(LocalizationStoreCacheInitializeContext context) + { + var textRepository = context.ServiceProvider.GetRequiredService(); + var languageRepository = context.ServiceProvider.GetRequiredService(); + var resourceRepository = context.ServiceProvider.GetRequiredService(); + + var resourceRecords = await resourceRepository.GetListAsync(); + var languageRecords = await languageRepository.GetActivedListAsync(); + var textRecords = await textRepository.GetListAsync(); + + Resources.Clear(); + Languages.Clear(); + + foreach (var resourceRecord in resourceRecords) + { + Resources[resourceRecord.Name] = new NonTypedLocalizationResource(resourceRecord.Name, resourceRecord.DefaultCultureName); + + var localizedStrings = LocalizedStrings.GetOrDefault(resourceRecord.Name); + + localizedStrings ??= new LocalizationDictionaryWithCulture(); + localizedStrings.Clear(); + + var currentCultureLocalizedStrings = new LocalizationDictionary(); + + foreach (var textRecord in textRecords.Where(x => x.ResourceName == resourceRecord.Name)) + { + currentCultureLocalizedStrings[textRecord.Key] = new LocalizedString(textRecord.Key, textRecord.Value); + } + + localizedStrings[CultureInfo.CurrentCulture.Name] = currentCultureLocalizedStrings; + + LocalizedStrings[resourceRecord.Name] = localizedStrings; + } + + foreach (var language in languageRecords) + { + Languages[language.CultureName] = new LanguageInfo( + language.CultureName, + language.UiCultureName, + language.DisplayName, + language.FlagIcon); + } + } + + protected async virtual Task GetOrSetStampInDistributedCache() + { + var cacheKey = $"{_distributedCacheOptions.KeyPrefix}_AbpInMemoryLocalizationCacheStamp"; + + var stampInDistributedCache = await _distributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + var distributedLockKey = $"{_distributedCacheOptions.KeyPrefix}_AbpLocalizationUpdateLock"; + await using (var commonLockHandle = await _distributedLock + .TryAcquireAsync(distributedLockKey, _managementOptions.LocalizationCacheStampTimeOut)) + { + if (commonLockHandle == null) + { + /* This request will fail */ + throw new AbpException( + "Could not acquire distributed lock for localization stamp check!" + ); + } + + stampInDistributedCache = await _distributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + stampInDistributedCache = Guid.NewGuid().ToString(); + + await _distributedCache.SetStringAsync( + cacheKey, + stampInDistributedCache, + new DistributedCacheEntryOptions + { + SlidingExpiration = _managementOptions.LocalizationCacheStampExpiration + } + ); + } + + return stampInDistributedCache; + } +} From ba73d7687ceca80848e011d37d72de79b4a8ae6f Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:43:41 +0800 Subject: [PATCH 09/26] Instead of asynchronous IWebhookDefinitionManager interface --- .../IDynamicWebhookDefinitionStore.cs | 13 +++ .../Webhooks/IStaticWebhookDefinitionStore.cs | 13 +++ .../Abp/Webhooks/IWebhookDefinitionManager.cs | 12 +- .../NullDynamicWebhookDefinitionStore.cs | 34 ++++++ .../Webhooks/StaticWebhookDefinitionStore.cs | 101 +++++++++++++++++ .../Abp/Webhooks/WebhookDefinitionManager.cs | 106 +++++++----------- ...sManagementPermissionDefinitionProvider.cs | 3 +- .../WebhookSubscriptionAppService.cs | 2 +- ...ksManagementHttpApiHostModule.Configure.cs | 3 - 9 files changed, 208 insertions(+), 79 deletions(-) create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IDynamicWebhookDefinitionStore.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IStaticWebhookDefinitionStore.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/NullDynamicWebhookDefinitionStore.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/StaticWebhookDefinitionStore.cs diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IDynamicWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IDynamicWebhookDefinitionStore.cs new file mode 100644 index 000000000..b50313e51 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IDynamicWebhookDefinitionStore.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Webhooks; + +public interface IDynamicWebhookDefinitionStore +{ + Task GetOrNullAsync(string name); + + Task> GetWebhooksAsync(); + + Task> GetGroupsAsync(); +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IStaticWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IStaticWebhookDefinitionStore.cs new file mode 100644 index 000000000..21f7b4ed3 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IStaticWebhookDefinitionStore.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Webhooks; + +public interface IStaticWebhookDefinitionStore +{ + Task GetOrNullAsync(string name); + + Task> GetWebhooksAsync(); + + Task> GetGroupsAsync(); +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IWebhookDefinitionManager.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IWebhookDefinitionManager.cs index a284ab693..6732743c5 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IWebhookDefinitionManager.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/IWebhookDefinitionManager.cs @@ -1,4 +1,5 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -10,24 +11,25 @@ namespace LINGYUN.Abp.Webhooks /// Gets a webhook definition by name. /// Returns null if there is no webhook definition with given name. /// - WebhookDefinition GetOrNull(string name); + [NotNull] + Task GetOrNullAsync(string name); /// /// Gets a webhook definition by name. /// Throws exception if there is no webhook definition with given name. /// - WebhookDefinition Get(string name); + Task GetAsync(string name); /// /// Gets all webhook definitions. /// - IReadOnlyList GetAll(); + Task> GetWebhooksAsync(); /// /// Gets all webhook group definitions. /// /// - IReadOnlyList GetGroups(); + Task> GetGroupsAsync(); /// /// Checks if given webhook name is available for given tenant. diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/NullDynamicWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/NullDynamicWebhookDefinitionStore.cs new file mode 100644 index 000000000..b9c95e991 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/NullDynamicWebhookDefinitionStore.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Webhooks; + +[Dependency(TryRegister = true)] +public class NullDynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ISingletonDependency +{ + private readonly static Task CachedWebhookResult = Task.FromResult((WebhookDefinition)null); + + private readonly static Task> CachedWebhooksResult = + Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); + + private readonly static Task> CachedGroupsResult = + Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); + + public Task GetOrNullAsync(string name) + { + return CachedWebhookResult; + } + + public Task> GetWebhooksAsync() + { + return CachedWebhooksResult; + } + + public Task> GetGroupsAsync() + { + return CachedGroupsResult; + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/StaticWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/StaticWebhookDefinitionStore.cs new file mode 100644 index 000000000..6ed2ba69a --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/StaticWebhookDefinitionStore.cs @@ -0,0 +1,101 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Webhooks; + +public class StaticWebhookDefinitionStore : IStaticWebhookDefinitionStore, ISingletonDependency +{ + protected IDictionary WebhookGroupDefinitions => _lazyWebhookGroupDefinitions.Value; + private readonly Lazy> _lazyWebhookGroupDefinitions; + + protected IDictionary WebhookDefinitions => _lazyWebhookDefinitions.Value; + private readonly Lazy> _lazyWebhookDefinitions; + + protected AbpWebhooksOptions Options { get; } + + private readonly IServiceScopeFactory _serviceScopeFactory; + + public StaticWebhookDefinitionStore( + IServiceScopeFactory serviceScopeFactory, + IOptions options) + { + _serviceScopeFactory = serviceScopeFactory; + Options = options.Value; + + _lazyWebhookDefinitions = new Lazy>( + CreateWebhookDefinitions, + isThreadSafe: true + ); + + _lazyWebhookGroupDefinitions = new Lazy>( + CreateWebhookGroupDefinitions, + isThreadSafe: true + ); + } + + protected virtual Dictionary CreateWebhookDefinitions() + { + var Webhooks = new Dictionary(); + + foreach (var groupDefinition in WebhookGroupDefinitions.Values) + { + foreach (var Webhook in groupDefinition.Webhooks) + { + if (Webhooks.ContainsKey(Webhook.Name)) + { + throw new AbpException("Duplicate webhook name: " + Webhook.Name); + } + + Webhooks[Webhook.Name] = Webhook; + } + } + + return Webhooks; + } + + protected virtual Dictionary CreateWebhookGroupDefinitions() + { + var definitions = new Dictionary(); + + using (var scope = _serviceScopeFactory.CreateScope()) + { + var providers = Options + .DefinitionProviders + .Select(p => scope.ServiceProvider.GetRequiredService(p) as WebhookDefinitionProvider) + .ToList(); + + foreach (var provider in providers) + { + provider.Define(new WebhookDefinitionContext(definitions)); + } + } + + return definitions; + } + + public Task GetOrNullAsync(string name) + { + return Task.FromResult(WebhookDefinitions.GetOrDefault(name)); + } + + public virtual Task> GetWebhooksAsync() + { + return Task.FromResult>( + WebhookDefinitions.Values.ToImmutableList() + ); + } + + public Task> GetGroupsAsync() + { + return Task.FromResult>( + WebhookGroupDefinitions.Values.ToImmutableList() + ); + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionManager.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionManager.cs index c0f96f20e..7db2082bd 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionManager.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionManager.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -14,54 +13,65 @@ namespace LINGYUN.Abp.Webhooks { internal class WebhookDefinitionManager : IWebhookDefinitionManager, ISingletonDependency { - protected IDictionary WebhookGroupDefinitions => _lazyWebhookGroupDefinitions.Value; - private readonly Lazy> _lazyWebhookGroupDefinitions; - - protected IDictionary WebhookDefinitions => _lazyWebhookDefinitions.Value; - private readonly Lazy> _lazyWebhookDefinitions; - private readonly IServiceProvider _serviceProvider; - private readonly AbpWebhooksOptions _options; + private readonly IStaticWebhookDefinitionStore _staticStore; + private readonly IDynamicWebhookDefinitionStore _dynamicStore; public WebhookDefinitionManager( IServiceProvider serviceProvider, - IOptions options) + IStaticWebhookDefinitionStore staticStore, + IDynamicWebhookDefinitionStore dynamicStore) { _serviceProvider = serviceProvider; - _options = options.Value; - - _lazyWebhookGroupDefinitions = new Lazy>(CreateWebhookGroupDefinitions); - _lazyWebhookDefinitions = new Lazy>(CreateWebhookDefinitions); + _staticStore = staticStore; + _dynamicStore = dynamicStore; } - public WebhookDefinition GetOrNull(string name) + public async virtual Task GetOrNullAsync(string name) { - if (!WebhookDefinitions.ContainsKey(name)) - { - return null; - } + Check.NotNull(name, nameof(name)); - return WebhookDefinitions[name]; + return await _staticStore.GetOrNullAsync(name) ?? + await _dynamicStore.GetOrNullAsync(name); } - public WebhookDefinition Get(string name) + public async virtual Task GetAsync(string name) { - if (!WebhookDefinitions.ContainsKey(name)) + var webhook = await GetOrNullAsync(name); + if (webhook == null) { - throw new KeyNotFoundException($"Webhook definitions does not contain a definition with the key \"{name}\"."); + throw new AbpException("Undefined webhook: " + name); } - return WebhookDefinitions[name]; + return webhook; } - public IReadOnlyList GetAll() + public async virtual Task> GetWebhooksAsync() { - return WebhookDefinitions.Values.ToImmutableList(); + var staticWebhooks = await _staticStore.GetWebhooksAsync(); + var staticWebhookNames = staticWebhooks + .Select(p => p.Name) + .ToImmutableHashSet(); + + var dynamicWebhooks = await _dynamicStore.GetWebhooksAsync(); + + return staticWebhooks + .Concat(dynamicWebhooks.Where(d => !staticWebhookNames.Contains(d.Name))) + .ToImmutableList(); } - public IReadOnlyList GetGroups() + public async virtual Task> GetGroupsAsync() { - return WebhookGroupDefinitions.Values.ToImmutableList(); + var staticGroups = await _staticStore.GetGroupsAsync(); + var staticGroupNames = staticGroups + .Select(p => p.Name) + .ToImmutableHashSet(); + + var dynamicGroups = await _dynamicStore.GetGroupsAsync(); + + return staticGroups + .Concat(dynamicGroups.Where(d => !staticGroupNames.Contains(d.Name))) + .ToImmutableList(); } public async Task IsAvailableAsync(Guid? tenantId, string name) @@ -71,7 +81,7 @@ namespace LINGYUN.Abp.Webhooks return true; } - var webhookDefinition = GetOrNull(name); + var webhookDefinition = await GetOrNullAsync(name); if (webhookDefinition == null) { @@ -95,45 +105,5 @@ namespace LINGYUN.Abp.Webhooks return true; } - - protected virtual Dictionary CreateWebhookDefinitions() - { - var definitions = new Dictionary(); - - foreach (var groupDefinition in WebhookGroupDefinitions.Values) - { - foreach (var webhook in groupDefinition.Webhooks) - { - if (definitions.ContainsKey(webhook.Name)) - { - throw new AbpException("Duplicate webhook name: " + webhook.Name); - } - - definitions[webhook.Name] = webhook; - } - } - - return definitions; - } - - protected virtual Dictionary CreateWebhookGroupDefinitions() - { - var definitions = new Dictionary(); - - using (var scope = _serviceProvider.CreateScope()) - { - var providers = _options - .DefinitionProviders - .Select(p => scope.ServiceProvider.GetRequiredService(p) as WebhookDefinitionProvider) - .ToList(); - - foreach (var provider in providers) - { - provider.Define(new WebhookDefinitionContext(definitions)); - } - } - - return definitions; - } } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs index ab14529b1..c2b835506 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs @@ -11,8 +11,7 @@ public class WebhooksManagementPermissionDefinitionProvider : PermissionDefiniti { var group = context.AddGroup( WebhooksManagementPermissions.GroupName, - L("Permission:WebhooksManagement"), - MultiTenancySides.Host); + L("Permission:WebhooksManagement")); var subscription = group.AddPermission( WebhooksManagementPermissions.WebhookSubscription.Default, diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs index 71bb55b99..2e151e871 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs @@ -109,7 +109,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I public async virtual Task> GetAllAvailableWebhooksAsync() { - var groups = WebhookDefinitionManager.GetGroups(); + var groups = await WebhookDefinitionManager.GetGroupsAsync(); var definitions = new List(); foreach (var groupDefinition in groups) diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index 6c12fe19b..148702021 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -1,6 +1,5 @@ using DotNetCore.CAP; using LINGYUN.Abp.BackgroundTasks; -using LINGYUN.Abp.Dapr.Client.DynamicProxying; using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Serilog.Enrichers.Application; @@ -302,8 +301,6 @@ public partial class WebhooksManagementHttpApiHostModule { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - // 动态语言支持 - options.Resources.AddDynamic(); }); } From 4f8af251d9fc4bbcc26b6fa53db66ac9be0da29b Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:05:52 +0800 Subject: [PATCH 10/26] add webhook definition record --- .../WebhookDefinitionRecordConsts.cs | 14 ++ .../WebhookGroupDefinitionRecordConsts.cs | 7 + .../IWebhookDefinitionRecordRepository.cs | 13 ++ ...IWebhookGroupDefinitionRecordRepository.cs | 7 + .../WebhookDefinitionRecord.cs | 153 ++++++++++++++++++ .../WebhookGroupDefinitionRecord.cs | 81 ++++++++++ ...EfCoreWebhookDefinitionRecordRepository.cs | 29 ++++ ...eWebhookGroupDefinitionRecordRepository.cs | 16 ++ ...agementDbContextModelCreatingExtensions.cs | 35 ++++ ...ooksManagementEntityFrameworkCoreModule.cs | 3 + 10 files changed, 358 insertions(+) create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecordConsts.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookGroupDefinitionRecordRepository.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookGroupDefinitionRecordRepository.cs diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs new file mode 100644 index 000000000..1b6dae892 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs @@ -0,0 +1,14 @@ +namespace LINGYUN.Abp.WebhooksManagement; + +public static class WebhookDefinitionRecordConsts +{ + public static int MaxNameLength { get; set; } = 128; + + public static int MaxDisplayNameLength { get; set; } = 256; + + public static int MaxDescriptionLength { get; set; } = 256; + + public static int MaxProvidersLength { get; set; } = 128; + + public static int MaxRequiredFeaturesLength { get; set; } = 256; +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecordConsts.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecordConsts.cs new file mode 100644 index 000000000..71b72a0de --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecordConsts.cs @@ -0,0 +1,7 @@ +namespace LINGYUN.Abp.WebhooksManagement; +public static class WebhookGroupDefinitionRecordConsts +{ + public static int MaxNameLength { get; set; } = 128; + + public static int MaxDisplayNameLength { get; set; } = 256; +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs new file mode 100644 index 000000000..2c2e90353 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Abp.WebhooksManagement; + +public interface IWebhookDefinitionRecordRepository : IBasicRepository +{ + Task FindByNameAsync( + string name, + CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookGroupDefinitionRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookGroupDefinitionRecordRepository.cs new file mode 100644 index 000000000..0bce807f9 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookGroupDefinitionRecordRepository.cs @@ -0,0 +1,7 @@ +using System; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Abp.WebhooksManagement; +public interface IWebhookGroupDefinitionRecordRepository : IBasicRepository +{ +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs new file mode 100644 index 000000000..7140d30a8 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs @@ -0,0 +1,153 @@ +using System; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities; + +namespace LINGYUN.Abp.WebhooksManagement; + +public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProperties +{ + [System.Text.Json.Serialization.JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + public override Guid Id { get; protected set; } + + public string GroupName { get; set; } + + public string Name { get; set; } + + public string DisplayName { get; set; } + + public string Description { get; set; } + + public bool IsEnabled { get; set; } + + public string Providers { get; set; } + + public string RequiredFeatures { get; set; } + + public ExtraPropertyDictionary ExtraProperties { get; protected set; } + + public WebhookDefinitionRecord() + { + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public WebhookDefinitionRecord( + Guid id, + string groupName, + string name, + string displayName, + string description = null, + bool isEnabled = true, + string providers = null, + string requiredFeatures = null) + : base(id) + { + GroupName = Check.NotNullOrWhiteSpace(groupName, nameof(groupName), WebhookGroupDefinitionRecordConsts.MaxNameLength); + Name = Check.NotNullOrWhiteSpace(name, nameof(name), WebhookDefinitionRecordConsts.MaxNameLength); + DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), WebhookDefinitionRecordConsts.MaxDisplayNameLength); + Description = Check.Length(description, nameof(description), WebhookDefinitionRecordConsts.MaxDescriptionLength); + + Providers = Check.Length(providers, nameof(providers), WebhookDefinitionRecordConsts.MaxProvidersLength); + RequiredFeatures = Check.Length(requiredFeatures, nameof(requiredFeatures), WebhookDefinitionRecordConsts.MaxRequiredFeaturesLength); + + IsEnabled = isEnabled; + + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public bool HasSameData(WebhookDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + return false; + } + + if (GroupName != otherRecord.GroupName) + { + return false; + } + + if (DisplayName != otherRecord.DisplayName) + { + return false; + } + + if (Description != otherRecord.Description) + { + return false; + } + + if (IsEnabled != otherRecord.IsEnabled) + { + return false; + } + + if (Providers != otherRecord.Providers) + { + return false; + } + + if (RequiredFeatures != otherRecord.RequiredFeatures) + { + return false; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + return false; + } + + return true; + } + + public void Patch(WebhookDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + Name = otherRecord.Name; + } + + if (GroupName != otherRecord.GroupName) + { + GroupName = otherRecord.GroupName; + } + + if (DisplayName != otherRecord.DisplayName) + { + DisplayName = otherRecord.DisplayName; + } + + if (Description != otherRecord.Description) + { + Description = otherRecord.Description; + } + + if (IsEnabled != otherRecord.IsEnabled) + { + IsEnabled = otherRecord.IsEnabled; + } + + if (Providers != otherRecord.Providers) + { + Providers = otherRecord.Providers; + } + + if (RequiredFeatures != otherRecord.RequiredFeatures) + { + RequiredFeatures = otherRecord.RequiredFeatures; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + ExtraProperties.Clear(); + + foreach (var property in otherRecord.ExtraProperties) + { + ExtraProperties.Add(property.Key, property.Value); + } + } + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs new file mode 100644 index 000000000..ed1a0ba52 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs @@ -0,0 +1,81 @@ +using System; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities; + +namespace LINGYUN.Abp.WebhooksManagement; + +public class WebhookGroupDefinitionRecord : BasicAggregateRoot, IHasExtraProperties +{ + [System.Text.Json.Serialization.JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + public override Guid Id { get; protected set; } + + public string Name { get; set; } + + public string DisplayName { get; set; } + + public ExtraPropertyDictionary ExtraProperties { get; protected set; } + + public WebhookGroupDefinitionRecord() + { + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public WebhookGroupDefinitionRecord( + Guid id, + string name, + string displayName) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), WebhookGroupDefinitionRecordConsts.MaxNameLength); + DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), WebhookGroupDefinitionRecordConsts.MaxDisplayNameLength); ; + + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public bool HasSameData(WebhookGroupDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + return false; + } + + if (DisplayName != otherRecord.DisplayName) + { + return false; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + return false; + } + + return true; + } + + public void Patch(WebhookGroupDefinitionRecord otherRecord) + { + if (Name != otherRecord.Name) + { + Name = otherRecord.Name; + } + + if (DisplayName != otherRecord.DisplayName) + { + DisplayName = otherRecord.DisplayName; + } + + if (!this.HasSameExtraProperties(otherRecord)) + { + ExtraProperties.Clear(); + + foreach (var property in otherRecord.ExtraProperties) + { + ExtraProperties.Add(property.Key, property.Value); + } + } + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs new file mode 100644 index 000000000..fe2db854d --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; + +public class EfCoreWebhookDefinitionRecordRepository : + EfCoreRepository, + IWebhookDefinitionRecordRepository +{ + public EfCoreWebhookDefinitionRecordRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async Task FindByNameAsync( + string name, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .OrderBy(x => x.Id) + .FirstOrDefaultAsync(r => r.Name == name, cancellationToken); + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookGroupDefinitionRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookGroupDefinitionRecordRepository.cs new file mode 100644 index 000000000..3e69cece4 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookGroupDefinitionRecordRepository.cs @@ -0,0 +1,16 @@ +using System; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; + +public class EfCoreWebhookGroupDefinitionRecordRepository : + EfCoreRepository, + IWebhookGroupDefinitionRecordRepository +{ + public EfCoreWebhookGroupDefinitionRecordRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs index 6d63d6278..d9f9aad42 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs @@ -80,5 +80,40 @@ public static class WebhooksManagementDbContextModelCreatingExtensions b.ConfigureByConvention(); }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "WebhookGroups", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.Name).HasMaxLength(WebhookGroupDefinitionRecordConsts.MaxNameLength).IsRequired(); + b.Property(x => x.DisplayName).HasMaxLength(WebhookGroupDefinitionRecordConsts.MaxDisplayNameLength).IsRequired(); + + b.HasIndex(x => new { x.Name }).IsUnique(); + + b.ApplyObjectExtensionMappings(); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Webhooks", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.GroupName).HasMaxLength(WebhookGroupDefinitionRecordConsts.MaxNameLength).IsRequired(); + b.Property(x => x.Name).HasMaxLength(WebhookDefinitionRecordConsts.MaxNameLength).IsRequired(); + b.Property(x => x.DisplayName).HasMaxLength(WebhookDefinitionRecordConsts.MaxDisplayNameLength).IsRequired(); + b.Property(x => x.Description).HasMaxLength(WebhookDefinitionRecordConsts.MaxDescriptionLength); + b.Property(x => x.Providers).HasMaxLength(WebhookDefinitionRecordConsts.MaxProvidersLength); + b.Property(x => x.RequiredFeatures).HasMaxLength(WebhookDefinitionRecordConsts.MaxRequiredFeaturesLength); + + b.HasIndex(x => new { x.Name }).IsUnique(); + b.HasIndex(x => new { x.GroupName }); + + b.ApplyObjectExtensionMappings(); + }); + + builder.TryConfigureObjectExtensions(); } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementEntityFrameworkCoreModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementEntityFrameworkCoreModule.cs index c175c4007..5ffe60615 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementEntityFrameworkCoreModule.cs @@ -17,6 +17,9 @@ public class WebhooksManagementEntityFrameworkCoreModule : AbpModule options.AddRepository(); options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddDefaultRepositories(); }); } From d31d791a4b859d63738553f0bdea594ef6c503b9 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:36:21 +0800 Subject: [PATCH 11/26] implement IDynamicWebhookDefinitionStore --- .../LINGYUN/Abp/Webhooks/WebhookDefinition.cs | 5 + .../WebhookDefinitionRecordConsts.cs | 2 - .../DynamicWebhookDefinitionStore.cs | 172 ++++++++++++++++++ ...amicWebhookDefinitionStoreInMemoryCache.cs | 114 ++++++++++++ .../IDynamicWebhookDefinitionStoreCache.cs | 26 +++ .../IWebhookDefinitionSerializer.cs | 19 ++ .../WebhookDefinitionRecord.cs | 15 -- .../WebhookDefinitionSerializer.cs | 99 ++++++++++ .../WebhookManagementOptions.cs | 10 + ...agementDbContextModelCreatingExtensions.cs | 1 - 10 files changed, 445 insertions(+), 18 deletions(-) create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IDynamicWebhookDefinitionStoreCache.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionSerializer.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionSerializer.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinition.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinition.cs index 9c82db155..5e60ec080 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinition.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinition.cs @@ -27,6 +27,11 @@ namespace LINGYUN.Abp.Webhooks public Dictionary Properties { get; } + public object this[string name] { + get => Properties.GetOrDefault(name); + set => Properties[name] = value; + } + public WebhookDefinition(string name, ILocalizableString displayName = null, ILocalizableString description = null) { if (name.IsNullOrWhiteSpace()) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs index 1b6dae892..6fda18a60 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecordConsts.cs @@ -8,7 +8,5 @@ public static class WebhookDefinitionRecordConsts public static int MaxDescriptionLength { get; set; } = 256; - public static int MaxProvidersLength { get; set; } = 128; - public static int MaxRequiredFeaturesLength { get; set; } = 256; } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs new file mode 100644 index 000000000..76d05070f --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs @@ -0,0 +1,172 @@ +using LINGYUN.Abp.Webhooks; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Threading; + +namespace LINGYUN.Abp.WebhooksManagement; + +[Dependency(ReplaceServices = true)] +public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITransientDependency +{ + protected IWebhookGroupDefinitionRecordRepository WebhookGroupRepository { get; } + protected IWebhookDefinitionRecordRepository WebhookRepository { get; } + protected IWebhookDefinitionSerializer WebhookDefinitionSerializer { get; } + protected IDynamicWebhookDefinitionStoreCache StoreCache { get; } + protected IDistributedCache DistributedCache { get; } + protected IAbpDistributedLock DistributedLock { get; } + public WebhookManagementOptions WebhookManagementOptions { get; } + protected AbpDistributedCacheOptions CacheOptions { get; } + + public DynamicWebhookDefinitionStore( + IWebhookGroupDefinitionRecordRepository webhookGroupRepository, + IWebhookDefinitionRecordRepository webhookRepository, + IWebhookDefinitionSerializer webhookDefinitionSerializer, + IDynamicWebhookDefinitionStoreCache storeCache, + IDistributedCache distributedCache, + IOptions cacheOptions, + IOptions webhookManagementOptions, + IAbpDistributedLock distributedLock) + { + WebhookGroupRepository = webhookGroupRepository; + WebhookRepository = webhookRepository; + WebhookDefinitionSerializer = webhookDefinitionSerializer; + StoreCache = storeCache; + DistributedCache = distributedCache; + DistributedLock = distributedLock; + WebhookManagementOptions = webhookManagementOptions.Value; + CacheOptions = cacheOptions.Value; + } + + public virtual async Task GetOrNullAsync(string name) + { + if (!WebhookManagementOptions.IsDynamicWebhookStoreEnabled) + { + return null; + } + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetWebhookOrNull(name); + } + } + + public virtual async Task> GetWebhooksAsync() + { + if (!WebhookManagementOptions.IsDynamicWebhookStoreEnabled) + { + return Array.Empty(); + } + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetWebhooks().ToImmutableList(); + } + } + + public virtual async Task> GetGroupsAsync() + { + if (!WebhookManagementOptions.IsDynamicWebhookStoreEnabled) + { + return Array.Empty(); + } + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetGroups().ToImmutableList(); + } + } + + protected virtual async Task EnsureCacheIsUptoDateAsync() + { + if (StoreCache.LastCheckTime.HasValue && + DateTime.Now.Subtract(StoreCache.LastCheckTime.Value).TotalSeconds < 30) + { + /* We get the latest webhook with a small delay for optimization */ + return; + } + + var stampInDistributedCache = await GetOrSetStampInDistributedCache(); + + if (stampInDistributedCache == StoreCache.CacheStamp) + { + StoreCache.LastCheckTime = DateTime.Now; + return; + } + + await UpdateInMemoryStoreCache(); + + StoreCache.CacheStamp = stampInDistributedCache; + StoreCache.LastCheckTime = DateTime.Now; + } + + protected virtual async Task UpdateInMemoryStoreCache() + { + var webhookGroupRecords = await WebhookGroupRepository.GetListAsync(); + var webhookRecords = await WebhookRepository.GetListAsync(); + + await StoreCache.FillAsync(webhookGroupRecords, webhookRecords); + } + + protected virtual async Task GetOrSetStampInDistributedCache() + { + var cacheKey = GetCommonStampCacheKey(); + + var stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + await using (var commonLockHandle = await DistributedLock + .TryAcquireAsync(GetCommonDistributedLockKey(), TimeSpan.FromMinutes(2))) + { + if (commonLockHandle == null) + { + /* This request will fail */ + throw new AbpException( + "Could not acquire distributed lock for webhook definition common stamp check!" + ); + } + + stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + stampInDistributedCache = Guid.NewGuid().ToString(); + + await DistributedCache.SetStringAsync( + cacheKey, + stampInDistributedCache, + new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + } + ); + } + + return stampInDistributedCache; + } + + protected virtual string GetCommonStampCacheKey() + { + return $"{CacheOptions.KeyPrefix}_AbpInMemoryWebhookCacheStamp"; + } + + protected virtual string GetCommonDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_Common_AbpWebhookUpdateLock"; + } +} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs new file mode 100644 index 000000000..212e76061 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs @@ -0,0 +1,114 @@ +using LINGYUN.Abp.Webhooks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; +using Volo.Abp.SimpleStateChecking; + +namespace LINGYUN.Abp.WebhooksManagement; + +[ExposeServices( + typeof(IDynamicWebhookDefinitionStoreCache), + typeof(DynamicWebhookDefinitionStoreInMemoryCache))] +public class DynamicWebhookDefinitionStoreInMemoryCache : + IDynamicWebhookDefinitionStoreCache, + ISingletonDependency +{ + public string CacheStamp { get; set; } + + protected IDictionary WebhookGroupDefinitions { get; } + protected IDictionary WebhookDefinitions { get; } + protected ISimpleStateCheckerSerializer StateCheckerSerializer { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } + + public SemaphoreSlim SyncSemaphore { get; } = new(1, 1); + + public DateTime? LastCheckTime { get; set; } + + public DynamicWebhookDefinitionStoreInMemoryCache( + ISimpleStateCheckerSerializer stateCheckerSerializer, + ILocalizableStringSerializer localizableStringSerializer) + { + StateCheckerSerializer = stateCheckerSerializer; + LocalizableStringSerializer = localizableStringSerializer; + + WebhookGroupDefinitions = new Dictionary(); + WebhookDefinitions = new Dictionary(); + } + + public Task FillAsync( + List webhookGroupRecords, + List webhookRecords) + { + WebhookGroupDefinitions.Clear(); + WebhookDefinitions.Clear(); + + var context = new WebhookDefinitionContext(null); + + foreach (var webhookGroupRecord in webhookGroupRecords) + { + var webhookGroup = context.AddGroup( + webhookGroupRecord.Name, + LocalizableStringSerializer.Deserialize(webhookGroupRecord.DisplayName) + ); + + WebhookGroupDefinitions[webhookGroup.Name] = webhookGroup; + + foreach (var property in webhookGroupRecord.ExtraProperties) + { + webhookGroup[property.Key] = property.Value; + } + + var webhookRecordsInThisGroup = webhookRecords + .Where(p => p.GroupName == webhookGroup.Name); + + foreach (var webhookRecord in webhookRecordsInThisGroup) + { + AddWebhook(webhookGroup, webhookRecord); + } + } + + return Task.CompletedTask; + } + + public WebhookDefinition GetWebhookOrNull(string name) + { + return WebhookDefinitions.GetOrDefault(name); + } + + public IReadOnlyList GetWebhooks() + { + return WebhookDefinitions.Values.ToList(); + } + + public IReadOnlyList GetGroups() + { + return WebhookGroupDefinitions.Values.ToList(); + } + + private void AddWebhook( + WebhookGroupDefinition webhookGroup, + WebhookDefinitionRecord webhookRecord) + { + var webhook = webhookGroup.AddWebhook( + webhookRecord.Name, + LocalizableStringSerializer.Deserialize(webhookRecord.DisplayName), + LocalizableStringSerializer.Deserialize(webhookRecord.Description) + ); + + WebhookDefinitions[webhook.Name] = webhook; + + if (!webhookRecord.RequiredFeatures.IsNullOrWhiteSpace()) + { + webhook.RequiredFeatures.AddRange(webhookRecord.RequiredFeatures.Split(',')); + } + + foreach (var property in webhookRecord.ExtraProperties) + { + webhook[property.Key] = property.Value; + } + } +} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IDynamicWebhookDefinitionStoreCache.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IDynamicWebhookDefinitionStoreCache.cs new file mode 100644 index 000000000..7e8b89e59 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IDynamicWebhookDefinitionStoreCache.cs @@ -0,0 +1,26 @@ +using LINGYUN.Abp.Webhooks; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.WebhooksManagement; + +public interface IDynamicWebhookDefinitionStoreCache +{ + string CacheStamp { get; set; } + + SemaphoreSlim SyncSemaphore { get; } + + DateTime? LastCheckTime { get; set; } + + Task FillAsync( + List webhookGroupRecords, + List webhookRecords); + + WebhookDefinition GetWebhookOrNull(string name); + + IReadOnlyList GetWebhooks(); + + IReadOnlyList GetGroups(); +} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionSerializer.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionSerializer.cs new file mode 100644 index 000000000..b66f33292 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionSerializer.cs @@ -0,0 +1,19 @@ +using JetBrains.Annotations; +using LINGYUN.Abp.Webhooks; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.WebhooksManagement; + +public interface IWebhookDefinitionSerializer +{ + Task<(WebhookGroupDefinitionRecord[], WebhookDefinitionRecord[])> + SerializeAsync(IEnumerable WebhookGroups); + + Task SerializeAsync( + WebhookGroupDefinition WebhookGroup); + + Task SerializeAsync( + WebhookDefinition Webhook, + [CanBeNull] WebhookGroupDefinition WebhookGroup); +} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs index 7140d30a8..0346c31fc 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs @@ -21,8 +21,6 @@ public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProper public bool IsEnabled { get; set; } - public string Providers { get; set; } - public string RequiredFeatures { get; set; } public ExtraPropertyDictionary ExtraProperties { get; protected set; } @@ -40,7 +38,6 @@ public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProper string displayName, string description = null, bool isEnabled = true, - string providers = null, string requiredFeatures = null) : base(id) { @@ -48,8 +45,6 @@ public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProper Name = Check.NotNullOrWhiteSpace(name, nameof(name), WebhookDefinitionRecordConsts.MaxNameLength); DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), WebhookDefinitionRecordConsts.MaxDisplayNameLength); Description = Check.Length(description, nameof(description), WebhookDefinitionRecordConsts.MaxDescriptionLength); - - Providers = Check.Length(providers, nameof(providers), WebhookDefinitionRecordConsts.MaxProvidersLength); RequiredFeatures = Check.Length(requiredFeatures, nameof(requiredFeatures), WebhookDefinitionRecordConsts.MaxRequiredFeaturesLength); IsEnabled = isEnabled; @@ -85,11 +80,6 @@ public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProper return false; } - if (Providers != otherRecord.Providers) - { - return false; - } - if (RequiredFeatures != otherRecord.RequiredFeatures) { return false; @@ -130,11 +120,6 @@ public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProper IsEnabled = otherRecord.IsEnabled; } - if (Providers != otherRecord.Providers) - { - Providers = otherRecord.Providers; - } - if (RequiredFeatures != otherRecord.RequiredFeatures) { RequiredFeatures = otherRecord.RequiredFeatures; diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionSerializer.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionSerializer.cs new file mode 100644 index 000000000..89f1cfc7a --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionSerializer.cs @@ -0,0 +1,99 @@ +using LINGYUN.Abp.Webhooks; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.Localization; +using Volo.Abp.SimpleStateChecking; + +namespace LINGYUN.Abp.WebhooksManagement; + +public class WebhookDefinitionSerializer : IWebhookDefinitionSerializer, ITransientDependency +{ + protected ISimpleStateCheckerSerializer StateCheckerSerializer { get; } + protected IGuidGenerator GuidGenerator { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } + + public WebhookDefinitionSerializer( + IGuidGenerator guidGenerator, + ISimpleStateCheckerSerializer stateCheckerSerializer, + ILocalizableStringSerializer localizableStringSerializer) + { + StateCheckerSerializer = stateCheckerSerializer; + LocalizableStringSerializer = localizableStringSerializer; + GuidGenerator = guidGenerator; + } + + public async Task<(WebhookGroupDefinitionRecord[], WebhookDefinitionRecord[])> + SerializeAsync(IEnumerable webhookGroups) + { + var webhookGroupRecords = new List(); + var webhookRecords = new List(); + + foreach (var webhookGroup in webhookGroups) + { + webhookGroupRecords.Add(await SerializeAsync(webhookGroup)); + + foreach (var webhook in webhookGroup.Webhooks) + { + webhookRecords.Add(await SerializeAsync(webhook, webhookGroup)); + } + } + + return (webhookGroupRecords.ToArray(), webhookRecords.ToArray()); + } + + public Task SerializeAsync(WebhookGroupDefinition webhookGroup) + { + using (CultureHelper.Use(CultureInfo.InvariantCulture)) + { + var webhookGroupRecord = new WebhookGroupDefinitionRecord( + GuidGenerator.Create(), + webhookGroup.Name, + LocalizableStringSerializer.Serialize(webhookGroup.DisplayName) + ); + + foreach (var property in webhookGroup.Properties) + { + webhookGroupRecord.SetProperty(property.Key, property.Value); + } + + return Task.FromResult(webhookGroupRecord); + } + } + + public Task SerializeAsync( + WebhookDefinition webhook, + WebhookGroupDefinition webhookGroup) + { + using (CultureHelper.Use(CultureInfo.InvariantCulture)) + { + var webhookRecord = new WebhookDefinitionRecord( + GuidGenerator.Create(), + webhookGroup?.Name, + webhook.Name, + LocalizableStringSerializer.Serialize(webhook.DisplayName), + LocalizableStringSerializer.Serialize(webhook.Description), + true, + SerializeRequiredFeatures(webhook.RequiredFeatures) + ); + + foreach (var property in webhook.Properties) + { + webhookRecord.SetProperty(property.Key, property.Value); + } + + return Task.FromResult(webhookRecord); + } + } + + protected virtual string SerializeRequiredFeatures(List requiredFeatures) + { + return requiredFeatures.Any() + ? requiredFeatures.JoinAsString(",") + : null; + } +} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs new file mode 100644 index 000000000..ca900b88f --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs @@ -0,0 +1,10 @@ +namespace LINGYUN.Abp.WebhooksManagement; +public class WebhookManagementOptions +{ + public bool IsDynamicWebhookStoreEnabled { get; set; } + + public WebhookManagementOptions() + { + IsDynamicWebhookStoreEnabled = true; + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs index d9f9aad42..bf39ddf1a 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs @@ -105,7 +105,6 @@ public static class WebhooksManagementDbContextModelCreatingExtensions b.Property(x => x.Name).HasMaxLength(WebhookDefinitionRecordConsts.MaxNameLength).IsRequired(); b.Property(x => x.DisplayName).HasMaxLength(WebhookDefinitionRecordConsts.MaxDisplayNameLength).IsRequired(); b.Property(x => x.Description).HasMaxLength(WebhookDefinitionRecordConsts.MaxDescriptionLength); - b.Property(x => x.Providers).HasMaxLength(WebhookDefinitionRecordConsts.MaxProvidersLength); b.Property(x => x.RequiredFeatures).HasMaxLength(WebhookDefinitionRecordConsts.MaxRequiredFeaturesLength); b.HasIndex(x => new { x.Name }).IsUnique(); From 02007e6aa23b519f339bdde49973c4b86eb23ff5 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:47:39 +0800 Subject: [PATCH 12/26] implement the IStaticWebhookSaver --- .../Abp/Webhooks/AbpWebhooksOptions.cs | 8 + ...NGYUN.Abp.WebhooksManagement.Domain.csproj | 1 + .../WebhooksManagement/IStaticWebhookSaver.cs | 8 + .../WebhooksManagement/StaticWebhookSaver.cs | 296 ++++++++++++++++++ .../WebhookManagementOptions.cs | 2 + .../WebhooksManagementDomainModule.cs | 146 ++++++++- 6 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IStaticWebhookSaver.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/StaticWebhookSaver.cs diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/AbpWebhooksOptions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/AbpWebhooksOptions.cs index 971ecf571..1411be14f 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/AbpWebhooksOptions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/AbpWebhooksOptions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Volo.Abp.Collections; namespace LINGYUN.Abp.Webhooks; @@ -24,6 +25,10 @@ public class AbpWebhooksOptions public ITypeList DefinitionProviders { get; } + public HashSet DeletedWebhooks { get; } + + public HashSet DeletedWebhookGroups { get; } + public AbpWebhooksOptions() { TimeoutDuration = TimeSpan.FromSeconds(60); @@ -31,5 +36,8 @@ public class AbpWebhooksOptions MaxConsecutiveFailCountBeforeDeactivateSubscription = MaxSendAttemptCount * 3; DefinitionProviders = new TypeList(); + + DeletedWebhooks = new HashSet(); + DeletedWebhookGroups = new HashSet(); } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN.Abp.WebhooksManagement.Domain.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN.Abp.WebhooksManagement.Domain.csproj index 36f7a7d04..0f23dd8fb 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN.Abp.WebhooksManagement.Domain.csproj +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN.Abp.WebhooksManagement.Domain.csproj @@ -12,6 +12,7 @@ + diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IStaticWebhookSaver.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IStaticWebhookSaver.cs new file mode 100644 index 000000000..930945ec8 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IStaticWebhookSaver.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.WebhooksManagement; + +public interface IStaticWebhookSaver +{ + Task SaveAsync(); +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/StaticWebhookSaver.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/StaticWebhookSaver.cs new file mode 100644 index 000000000..dc3bc7df8 --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/StaticWebhookSaver.cs @@ -0,0 +1,296 @@ +using LINGYUN.Abp.Webhooks; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Threading; +using Volo.Abp.Uow; + +namespace LINGYUN.Abp.WebhooksManagement; +public class StaticWebhookSaver : IStaticWebhookSaver, ITransientDependency +{ + protected IStaticWebhookDefinitionStore StaticStore { get; } + protected IWebhookGroupDefinitionRecordRepository WebhookGroupRepository { get; } + protected IWebhookDefinitionRecordRepository WebhookRepository { get; } + protected IWebhookDefinitionSerializer WebhookSerializer { get; } + protected IDistributedCache Cache { get; } + protected IApplicationInfoAccessor ApplicationInfoAccessor { get; } + protected IAbpDistributedLock DistributedLock { get; } + protected AbpWebhooksOptions WebhookOptions { get; } + protected ICancellationTokenProvider CancellationTokenProvider { get; } + protected AbpDistributedCacheOptions CacheOptions { get; } + + public StaticWebhookSaver( + IStaticWebhookDefinitionStore staticStore, + IWebhookGroupDefinitionRecordRepository webhookGroupRepository, + IWebhookDefinitionRecordRepository webhookRepository, + IWebhookDefinitionSerializer webhookSerializer, + IDistributedCache cache, + IOptions cacheOptions, + IApplicationInfoAccessor applicationInfoAccessor, + IAbpDistributedLock distributedLock, + IOptions webhookOptions, + ICancellationTokenProvider cancellationTokenProvider) + { + StaticStore = staticStore; + WebhookGroupRepository = webhookGroupRepository; + WebhookRepository = webhookRepository; + WebhookSerializer = webhookSerializer; + Cache = cache; + ApplicationInfoAccessor = applicationInfoAccessor; + DistributedLock = distributedLock; + CancellationTokenProvider = cancellationTokenProvider; + WebhookOptions = webhookOptions.Value; + CacheOptions = cacheOptions.Value; + } + + [UnitOfWork] + public virtual async Task SaveAsync() + { + await using var applicationLockHandle = await DistributedLock.TryAcquireAsync( + GetApplicationDistributedLockKey() + ); + + if (applicationLockHandle == null) + { + /* Another application instance is already doing it */ + return; + } + + /* NOTE: This can be further optimized by using 4 cache values for: + * Groups, webhooks, deleted groups and deleted webhooks. + * But the code would be more complex. This is enough for now. + */ + + var cacheKey = GetApplicationHashCacheKey(); + var cachedHash = await Cache.GetStringAsync(cacheKey, CancellationTokenProvider.Token); + + var (webhookGroupRecords, webhookRecords) = await WebhookSerializer.SerializeAsync( + await StaticStore.GetGroupsAsync() + ); + + var currentHash = CalculateHash( + webhookGroupRecords, + webhookRecords, + WebhookOptions.DeletedWebhookGroups, + WebhookOptions.DeletedWebhooks + ); + + if (cachedHash == currentHash) + { + return; + } + + await using (var commonLockHandle = await DistributedLock.TryAcquireAsync( + GetCommonDistributedLockKey(), + TimeSpan.FromMinutes(5))) + { + if (commonLockHandle == null) + { + /* It will re-try */ + throw new AbpException("Could not acquire distributed lock for saving static webhooks!"); + } + + var hasChangesInGroups = await UpdateChangedWebhookGroupsAsync(webhookGroupRecords); + var hasChangesInWebhooks = await UpdateChangedWebhooksAsync(webhookRecords); + + if (hasChangesInGroups || hasChangesInWebhooks) + { + await Cache.SetStringAsync( + GetCommonStampCacheKey(), + Guid.NewGuid().ToString(), + new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + }, + CancellationTokenProvider.Token + ); + } + } + + await Cache.SetStringAsync( + cacheKey, + currentHash, + new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + }, + CancellationTokenProvider.Token + ); + } + + private async Task UpdateChangedWebhookGroupsAsync( + IEnumerable webhookGroupRecords) + { + var newRecords = new List(); + var changedRecords = new List(); + + var webhookGroupRecordsInDatabase = (await WebhookGroupRepository.GetListAsync()) + .ToDictionary(x => x.Name); + + foreach (var webhookGroupRecord in webhookGroupRecords) + { + var webhookGroupRecordInDatabase = webhookGroupRecordsInDatabase.GetOrDefault(webhookGroupRecord.Name); + if (webhookGroupRecordInDatabase == null) + { + /* New group */ + newRecords.Add(webhookGroupRecord); + continue; + } + + if (webhookGroupRecord.HasSameData(webhookGroupRecordInDatabase)) + { + /* Not changed */ + continue; + } + + /* Changed */ + webhookGroupRecordInDatabase.Patch(webhookGroupRecord); + changedRecords.Add(webhookGroupRecordInDatabase); + } + + /* Deleted */ + var deletedRecords = WebhookOptions.DeletedWebhookGroups.Any() + ? webhookGroupRecordsInDatabase.Values + .Where(x => WebhookOptions.DeletedWebhookGroups.Contains(x.Name)) + .ToArray() + : Array.Empty(); + + if (newRecords.Any()) + { + await WebhookGroupRepository.InsertManyAsync(newRecords); + } + + if (changedRecords.Any()) + { + await WebhookGroupRepository.UpdateManyAsync(changedRecords); + } + + if (deletedRecords.Any()) + { + await WebhookGroupRepository.DeleteManyAsync(deletedRecords); + } + + return newRecords.Any() || changedRecords.Any() || deletedRecords.Any(); + } + + private async Task UpdateChangedWebhooksAsync( + IEnumerable webhookRecords) + { + var newRecords = new List(); + var changedRecords = new List(); + + var webhookRecordsInDatabase = (await WebhookRepository.GetListAsync()) + .ToDictionary(x => x.Name); + + foreach (var webhookRecord in webhookRecords) + { + var webhookRecordInDatabase = webhookRecordsInDatabase.GetOrDefault(webhookRecord.Name); + if (webhookRecordInDatabase == null) + { + /* New group */ + newRecords.Add(webhookRecord); + continue; + } + + if (webhookRecord.HasSameData(webhookRecordInDatabase)) + { + /* Not changed */ + continue; + } + + /* Changed */ + webhookRecordInDatabase.Patch(webhookRecord); + changedRecords.Add(webhookRecordInDatabase); + } + + /* Deleted */ + var deletedRecords = new List(); + + if (WebhookOptions.DeletedWebhooks.Any()) + { + deletedRecords.AddRange( + webhookRecordsInDatabase.Values + .Where(x => WebhookOptions.DeletedWebhooks.Contains(x.Name)) + ); + } + + if (WebhookOptions.DeletedWebhookGroups.Any()) + { + deletedRecords.AddIfNotContains( + webhookRecordsInDatabase.Values + .Where(x => WebhookOptions.DeletedWebhookGroups.Contains(x.GroupName)) + ); + } + + if (newRecords.Any()) + { + await WebhookRepository.InsertManyAsync(newRecords); + } + + if (changedRecords.Any()) + { + await WebhookRepository.UpdateManyAsync(changedRecords); + } + + if (deletedRecords.Any()) + { + await WebhookRepository.DeleteManyAsync(deletedRecords); + } + + return newRecords.Any() || changedRecords.Any() || deletedRecords.Any(); + } + + private string GetApplicationDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_{ApplicationInfoAccessor.ApplicationName}_AbpWebhookUpdateLock"; + } + + private string GetCommonDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_Common_AbpWebhookUpdateLock"; + } + + private string GetApplicationHashCacheKey() + { + return $"{CacheOptions.KeyPrefix}_{ApplicationInfoAccessor.ApplicationName}_AbpWebhooksHash"; + } + + private string GetCommonStampCacheKey() + { + return $"{CacheOptions.KeyPrefix}_AbpInMemoryWebhookCacheStamp"; + } + + private static string CalculateHash( + WebhookGroupDefinitionRecord[] webhookGroupRecords, + WebhookDefinitionRecord[] webhookRecords, + IEnumerable deletedWebhookGroups, + IEnumerable deletedWebhooks) + { + var stringBuilder = new StringBuilder(); + + stringBuilder.Append("WebhookGroupRecords:"); + stringBuilder.AppendLine(JsonSerializer.Serialize(webhookGroupRecords)); + + stringBuilder.Append("WebhookRecords:"); + stringBuilder.AppendLine(JsonSerializer.Serialize(webhookRecords)); + + stringBuilder.Append("DeletedWebhookGroups:"); + stringBuilder.AppendLine(deletedWebhookGroups.JoinAsString(",")); + + stringBuilder.Append("DeletedWebhook:"); + stringBuilder.Append(deletedWebhooks.JoinAsString(",")); + + return stringBuilder + .ToString() + .ToMd5(); + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs index ca900b88f..f9c4069d6 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs @@ -1,10 +1,12 @@ namespace LINGYUN.Abp.WebhooksManagement; public class WebhookManagementOptions { + public bool SaveStaticWebhooksToDatabase { get; set; } public bool IsDynamicWebhookStoreEnabled { get; set; } public WebhookManagementOptions() { IsDynamicWebhookStoreEnabled = true; + SaveStaticWebhooksToDatabase = true; } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs index 18903b4b3..0b530ea72 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs @@ -1,7 +1,17 @@ using LINGYUN.Abp.Webhooks; using LINGYUN.Abp.WebhooksManagement.ObjectExtending; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Polly; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.AutoMapper; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Modularity; using Volo.Abp.ObjectExtending.Modularity; @@ -15,7 +25,8 @@ namespace LINGYUN.Abp.WebhooksManagement; typeof(WebhooksManagementDomainSharedModule))] public class WebhooksManagementDomainModule : AbpModule { - private static readonly OneTimeRunner OneTimeRunner = new(); + private readonly CancellationTokenSource _cancellationTokenSource = new(); + private readonly static OneTimeRunner OneTimeRunner = new(); public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper(); @@ -35,6 +46,15 @@ public class WebhooksManagementDomainModule : AbpModule options.AutoEventSelectors.Add(); options.AutoEventSelectors.Add(); }); + + if (context.Services.IsDataMigrationEnvironment()) + { + Configure(options => + { + options.SaveStaticWebhooksToDatabase = false; + options.IsDynamicWebhookStoreEnabled = false; + }); + } } public override void PostConfigureServices(ServiceConfigurationContext context) @@ -59,4 +79,128 @@ public class WebhooksManagementDomainModule : AbpModule ); }); } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); + } + + public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + InitializeDynamicWebhooks(context); + return Task.CompletedTask; + } + + public override Task OnApplicationShutdownAsync(ApplicationShutdownContext context) + { + _cancellationTokenSource.Cancel(); + return Task.CompletedTask; + } + + private void InitializeDynamicWebhooks(ApplicationInitializationContext context) + { + var options = context + .ServiceProvider + .GetRequiredService>() + .Value; + + if (!options.SaveStaticWebhooksToDatabase && !options.IsDynamicWebhookStoreEnabled) + { + return; + } + + var rootServiceProvider = context.ServiceProvider.GetRequiredService(); + + Task.Run(async () => + { + using var scope = rootServiceProvider.CreateScope(); + var applicationLifetime = scope.ServiceProvider.GetService(); + var cancellationTokenProvider = scope.ServiceProvider.GetRequiredService(); + var cancellationToken = applicationLifetime?.ApplicationStopping ?? _cancellationTokenSource.Token; + + try + { + using (cancellationTokenProvider.Use(cancellationToken)) + { + if (cancellationTokenProvider.Token.IsCancellationRequested) + { + return; + } + + await SaveStaticWebhooksToDatabaseAsync(options, scope, cancellationTokenProvider); + + if (cancellationTokenProvider.Token.IsCancellationRequested) + { + return; + } + + await PreCacheDynamicWebhooksAsync(options, scope); + } + } + // ReSharper disable once EmptyGeneralCatchClause (No need to log since it is logged above) + catch { } + }); + } + + private async static Task SaveStaticWebhooksToDatabaseAsync( + WebhookManagementOptions options, + IServiceScope scope, + ICancellationTokenProvider cancellationTokenProvider) + { + if (!options.SaveStaticWebhooksToDatabase) + { + return; + } + + await Policy + .Handle() + .WaitAndRetryAsync(8, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt) * 10)) + .ExecuteAsync(async _ => + { + try + { + // ReSharper disable once AccessToDisposedClosure + await scope + .ServiceProvider + .GetRequiredService() + .SaveAsync(); + } + catch (Exception ex) + { + // ReSharper disable once AccessToDisposedClosure + scope.ServiceProvider + .GetService>()? + .LogException(ex); + + throw; // Polly will catch it + } + }, cancellationTokenProvider.Token); + } + + private async static Task PreCacheDynamicWebhooksAsync(WebhookManagementOptions options, IServiceScope scope) + { + if (!options.IsDynamicWebhookStoreEnabled) + { + return; + } + + try + { + // Pre-cache permissions, so first request doesn't wait + await scope + .ServiceProvider + .GetRequiredService() + .GetGroupsAsync(); + } + catch (Exception ex) + { + // ReSharper disable once AccessToDisposedClosure + scope + .ServiceProvider + .GetService>()? + .LogException(ex); + + throw; // It will be cached in InitializeDynamicWebhooks + } + } } From c5729e476c951e699a3709bc520852468a92dc86 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:20:45 +0800 Subject: [PATCH 13/26] add webhook definition extension entity --- .../WebhooksManagementModuleExtensionConsts.cs | 2 ++ .../WebhooksManagementDomainModule.cs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/ObjectExtending/WebhooksManagementModuleExtensionConsts.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/ObjectExtending/WebhooksManagementModuleExtensionConsts.cs index a51d51035..68e6b42f5 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/ObjectExtending/WebhooksManagementModuleExtensionConsts.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/ObjectExtending/WebhooksManagementModuleExtensionConsts.cs @@ -9,5 +9,7 @@ public static class WebhooksManagementModuleExtensionConsts public const string WebhookEvent = "WebhookEvent"; public const string WebhookSendAttempt = "WebhookSendAttempt"; public const string WebhookSubscription = "WebhookSubscription"; + public const string WebhookGroupDefinition = "WebhookGroupDefinition"; + public const string WebhookDefinition = "WebhookDefinition"; } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs index 0b530ea72..9b1c7f446 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs @@ -77,6 +77,16 @@ public class WebhooksManagementDomainModule : AbpModule WebhooksManagementModuleExtensionConsts.EntityNames.WebhookSendAttempt, typeof(WebhookSendRecord) ); + ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity( + WebhooksManagementModuleExtensionConsts.ModuleName, + WebhooksManagementModuleExtensionConsts.EntityNames.WebhookGroupDefinition, + typeof(WebhookGroupDefinitionRecord) + ); + ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity( + WebhooksManagementModuleExtensionConsts.ModuleName, + WebhooksManagementModuleExtensionConsts.EntityNames.WebhookDefinition, + typeof(WebhookDefinitionRecord) + ); }); } From 26632e5633ad23e92910254e75874e8c3ebf2bec Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:33:30 +0800 Subject: [PATCH 14/26] configurable webhook caching --- .../DynamicWebhookDefinitionStore.cs | 8 ++--- .../WebhookManagementOptions.cs | 31 +++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs index 76d05070f..126c720c7 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs @@ -22,7 +22,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr protected IDynamicWebhookDefinitionStoreCache StoreCache { get; } protected IDistributedCache DistributedCache { get; } protected IAbpDistributedLock DistributedLock { get; } - public WebhookManagementOptions WebhookManagementOptions { get; } + protected WebhookManagementOptions WebhookManagementOptions { get; } protected AbpDistributedCacheOptions CacheOptions { get; } public DynamicWebhookDefinitionStore( @@ -90,7 +90,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr protected virtual async Task EnsureCacheIsUptoDateAsync() { if (StoreCache.LastCheckTime.HasValue && - DateTime.Now.Subtract(StoreCache.LastCheckTime.Value).TotalSeconds < 30) + DateTime.Now.Subtract(StoreCache.LastCheckTime.Value) < WebhookManagementOptions.WebhooksCacheRefreshInterval) { /* We get the latest webhook with a small delay for optimization */ return; @@ -129,7 +129,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr } await using (var commonLockHandle = await DistributedLock - .TryAcquireAsync(GetCommonDistributedLockKey(), TimeSpan.FromMinutes(2))) + .TryAcquireAsync(GetCommonDistributedLockKey(), WebhookManagementOptions.WebhooksCacheStampTimeOut)) { if (commonLockHandle == null) { @@ -152,7 +152,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr stampInDistributedCache, new DistributedCacheEntryOptions { - SlidingExpiration = TimeSpan.FromDays(30) //TODO: Make it configurable? + SlidingExpiration = WebhookManagementOptions.WebhooksCacheStampExpiration } ); } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs index f9c4069d6..1cdac2185 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs @@ -1,12 +1,39 @@ -namespace LINGYUN.Abp.WebhooksManagement; +using System; + +namespace LINGYUN.Abp.WebhooksManagement; public class WebhookManagementOptions { + /// + /// Default: true. + /// public bool SaveStaticWebhooksToDatabase { get; set; } + /// + /// Default: false. + /// public bool IsDynamicWebhookStoreEnabled { get; set; } - + /// + /// 缓存刷新时间 + /// default: 30 seconds + /// + public TimeSpan WebhooksCacheRefreshInterval { get; set; } + /// + /// 申请时间戳超时时间 + /// default: 2 minutes + /// + public TimeSpan WebhooksCacheStampTimeOut { get; set; } + /// + /// 时间戳过期时间 + /// default: 30 minutes + /// + public TimeSpan WebhooksCacheStampExpiration { get; set; } public WebhookManagementOptions() { IsDynamicWebhookStoreEnabled = true; SaveStaticWebhooksToDatabase = true; + + WebhooksCacheRefreshInterval = TimeSpan.FromSeconds(30); + WebhooksCacheStampTimeOut = TimeSpan.FromMinutes(2); + // 30分钟过期重新刷新缓存 + WebhooksCacheStampExpiration = TimeSpan.FromMinutes(30); } } From 4f97c825beeb647e429676b62d552c1ebaa3378b Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:03:15 +0800 Subject: [PATCH 15/26] add webhook migrations --- ...INGYUN.MicroService.WebhooksManagement.sln | 13 +- .../WebhooksManagementDbMigrationService.cs | 216 +++++++++++++++ .../WebhooksManagementMigrationsDbContext.cs | 23 ++ ...oksManagementMigrationsDbContextFactory.cs | 29 ++ ...rvice.WebhooksManagement.DbMigrator.csproj | 55 ++++ ...17_Initial-Webhooks-Management.Designer.cs | 250 ++++++++++++++++++ ...30112004517_Initial-Webhooks-Management.cs | 177 +++++++++++++ ...agementMigrationsDbContextModelSnapshot.cs | 247 +++++++++++++++++ .../Program.cs | 40 +++ .../Properties/launchSettings.json | 11 + .../Usings.cs | 7 + ...bhooksManagementDbMigratorHostedService.cs | 51 ++++ ...oksManagementDbMigratorModule.Configure.cs | 18 ++ .../WebhooksManagementDbMigratorModule.cs | 29 ++ .../appsettings.json | 79 ++++++ .../Abp/Webhooks/WebhookDefinitionContext.cs | 4 +- ...amicWebhookDefinitionStoreInMemoryCache.cs | 2 +- .../WebhookDefinitionRecord.cs | 2 + .../WebhooksManagement/WebhookEventRecord.cs | 2 + .../WebhookGroupDefinitionRecord.cs | 2 + .../WebhooksManagement/WebhookSendRecord.cs | 2 + .../WebhooksManagement/WebhookSubscription.cs | 2 + .../IWebhooksManagementDbContext.cs | 2 + .../WebhooksManagementDbContext.cs | 2 + ...agementDbContextModelCreatingExtensions.cs | 5 + .../appsettings.Development.json | 16 +- 26 files changed, 1273 insertions(+), 13 deletions(-) create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContext.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json diff --git a/aspnet-core/LINGYUN.MicroService.WebhooksManagement.sln b/aspnet-core/LINGYUN.MicroService.WebhooksManagement.sln index 7ec7c4a19..29874944c 100644 --- a/aspnet-core/LINGYUN.MicroService.WebhooksManagement.sln +++ b/aspnet-core/LINGYUN.MicroService.WebhooksManagement.sln @@ -35,9 +35,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.Identi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.Saas", "modules\webhooks\LINGYUN.Abp.Webhooks.Saas\LINGYUN.Abp.Webhooks.Saas.csproj", "{D7F2B64C-02F2-4097-80C1-DC41CE8FEE38}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Webhooks.EventBus", "modules\webhooks\LINGYUN.Abp.Webhooks.EventBus\LINGYUN.Abp.Webhooks.EventBus.csproj", "{46C08EF3-4C81-411E-B5E4-AC3A5040DC67}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.EventBus", "modules\webhooks\LINGYUN.Abp.Webhooks.EventBus\LINGYUN.Abp.Webhooks.EventBus.csproj", "{46C08EF3-4C81-411E-B5E4-AC3A5040DC67}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Webhooks.Core", "modules\webhooks\LINGYUN.Abp.Webhooks.Core\LINGYUN.Abp.Webhooks.Core.csproj", "{BBF1C93D-EF73-4B00-919F-5E7F360BDB03}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.Core", "modules\webhooks\LINGYUN.Abp.Webhooks.Core\LINGYUN.Abp.Webhooks.Core.csproj", "{BBF1C93D-EF73-4B00-919F-5E7F360BDB03}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{2868332B-7D4F-4B43-8FC3-BA5CACC36C7E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.WebhooksManagement.DbMigrator", "migrations\LY.MicroService.WebhooksManagement.DbMigrator\LY.MicroService.WebhooksManagement.DbMigrator.csproj", "{3BC77471-D273-4C9C-8985-7FE450DA4686}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -105,6 +109,10 @@ Global {BBF1C93D-EF73-4B00-919F-5E7F360BDB03}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBF1C93D-EF73-4B00-919F-5E7F360BDB03}.Release|Any CPU.ActiveCfg = Release|Any CPU {BBF1C93D-EF73-4B00-919F-5E7F360BDB03}.Release|Any CPU.Build.0 = Release|Any CPU + {3BC77471-D273-4C9C-8985-7FE450DA4686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BC77471-D273-4C9C-8985-7FE450DA4686}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BC77471-D273-4C9C-8985-7FE450DA4686}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BC77471-D273-4C9C-8985-7FE450DA4686}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -125,6 +133,7 @@ Global {D7F2B64C-02F2-4097-80C1-DC41CE8FEE38} = {FB7A9794-06D2-42CF-939E-4626497B97BD} {46C08EF3-4C81-411E-B5E4-AC3A5040DC67} = {FB7A9794-06D2-42CF-939E-4626497B97BD} {BBF1C93D-EF73-4B00-919F-5E7F360BDB03} = {FB7A9794-06D2-42CF-939E-4626497B97BD} + {3BC77471-D273-4C9C-8985-7FE450DA4686} = {2868332B-7D4F-4B43-8FC3-BA5CACC36C7E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {80ED12A5-C899-459F-A181-ADCC9D680DE5} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementDbMigrationService.cs new file mode 100644 index 000000000..40cbe4a47 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; + +public class WebhooksManagementDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public WebhooksManagementDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new WebhooksManagementMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.WebhooksManagement.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContext.cs new file mode 100644 index 000000000..afc598796 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContext.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("WebhooksManagementDbMigrator")] +public class WebhooksManagementMigrationsDbContext : AbpDbContext +{ + public WebhooksManagementMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureWebhooksManagement(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs new file mode 100644 index 000000000..42e523f10 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; + +public class WebhooksManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public WebhooksManagementMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new WebhooksManagementMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false) + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj new file mode 100644 index 000000000..cd2c05e23 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj @@ -0,0 +1,55 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.Designer.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.Designer.cs new file mode 100644 index 000000000..5634a8214 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.Designer.cs @@ -0,0 +1,250 @@ +// +using System; +using LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.DbMigrator.Migrations +{ + [DbContext(typeof(WebhooksManagementMigrationsDbContext))] + [Migration("20230112004517_Initial-Webhooks-Management")] + partial class InitialWebhooksManagement + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("RequiredFeatures") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpWebhooksWebhooks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("Data") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Data"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("WebhookName"); + + b.HasKey("Id"); + + b.ToTable("AbpWebhooksEvents", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpWebhooksWebhookGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("RequestHeaders") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("RequestHeaders"); + + b.Property("Response") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Response"); + + b.Property("ResponseHeaders") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("ResponseHeaders"); + + b.Property("ResponseStatusCode") + .HasColumnType("int"); + + b.Property("SendExactSameData") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookEventId") + .HasColumnType("char(36)"); + + b.Property("WebhookSubscriptionId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("WebhookEventId"); + + b.ToTable("AbpWebhooksSendAttempts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Headers") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Headers"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Secret") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("Secret"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookUri") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("WebhookUri"); + + b.Property("Webhooks") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Webhooks"); + + b.HasKey("Id"); + + b.ToTable("AbpWebhooksSubscriptions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.HasOne("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", "WebhookEvent") + .WithOne() + .HasForeignKey("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", "WebhookEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WebhookEvent"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.cs new file mode 100644 index 000000000..8d16414cc --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/20230112004517_Initial-Webhooks-Management.cs @@ -0,0 +1,177 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.DbMigrator.Migrations +{ + /// + public partial class InitialWebhooksManagement : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpWebhooksEvents", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Data = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + DeletionTime = table.Column(type: "datetime(6)", nullable: true), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpWebhooksEvents", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpWebhooksSubscriptions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookUri = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Secret = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + Webhooks = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Headers = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpWebhooksSubscriptions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpWebhooksWebhookGroups", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpWebhooksWebhookGroups", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpWebhooksWebhooks", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GroupName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DisplayName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + RequiredFeatures = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AbpWebhooksWebhooks", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AbpWebhooksSendAttempts", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookEventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + WebhookSubscriptionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Response = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseStatusCode = table.Column(type: "int", nullable: true), + RequestHeaders = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseHeaders = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SendExactSameData = table.Column(type: "tinyint(1)", nullable: false), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpWebhooksSendAttempts", x => x.Id); + table.ForeignKey( + name: "FK_AbpWebhooksSendAttempts_AbpWebhooksEvents_WebhookEventId", + column: x => x.WebhookEventId, + principalTable: "AbpWebhooksEvents", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AbpWebhooksSendAttempts_WebhookEventId", + table: "AbpWebhooksSendAttempts", + column: "WebhookEventId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpWebhooksWebhookGroups_Name", + table: "AbpWebhooksWebhookGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpWebhooksWebhooks_GroupName", + table: "AbpWebhooksWebhooks", + column: "GroupName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpWebhooksWebhooks_Name", + table: "AbpWebhooksWebhooks", + column: "Name", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpWebhooksSendAttempts"); + + migrationBuilder.DropTable( + name: "AbpWebhooksSubscriptions"); + + migrationBuilder.DropTable( + name: "AbpWebhooksWebhookGroups"); + + migrationBuilder.DropTable( + name: "AbpWebhooksWebhooks"); + + migrationBuilder.DropTable( + name: "AbpWebhooksEvents"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..4bbaa84c0 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,247 @@ +// +using System; +using LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.DbMigrator.Migrations +{ + [DbContext(typeof(WebhooksManagementMigrationsDbContext))] + partial class WebhooksManagementMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("RequiredFeatures") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpWebhooksWebhooks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("Data") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Data"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("WebhookName"); + + b.HasKey("Id"); + + b.ToTable("AbpWebhooksEvents", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpWebhooksWebhookGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("RequestHeaders") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("RequestHeaders"); + + b.Property("Response") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Response"); + + b.Property("ResponseHeaders") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("ResponseHeaders"); + + b.Property("ResponseStatusCode") + .HasColumnType("int"); + + b.Property("SendExactSameData") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookEventId") + .HasColumnType("char(36)"); + + b.Property("WebhookSubscriptionId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("WebhookEventId"); + + b.ToTable("AbpWebhooksSendAttempts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Headers") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Headers"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Secret") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("Secret"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookUri") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("WebhookUri"); + + b.Property("Webhooks") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Webhooks"); + + b.HasKey("Id"); + + b.ToTable("AbpWebhooksSubscriptions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.HasOne("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", "WebhookEvent") + .WithOne() + .HasForeignKey("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", "WebhookEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WebhookEvent"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Program.cs new file mode 100644 index 000000000..e2aa2d438 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.WebhooksManagement.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.WebhooksManagement.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.WebhooksManagement.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..815771745 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.WebhooksManagement.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorHostedService.cs new file mode 100644 index 000000000..07962a564 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.WebhooksManagement.DbMigrator; + +public class WebhooksManagementDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public WebhooksManagementDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.Configure.cs new file mode 100644 index 000000000..55bd1dae1 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.WebhooksManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.WebhooksManagement.DbMigrator; +public partial class WebhooksManagementDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.cs new file mode 100644 index 000000000..9eef33565 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/WebhooksManagementDbMigratorModule.cs @@ -0,0 +1,29 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.WebhooksManagement.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(WebhooksManagementEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreMySQLModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class WebhooksManagementDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json new file mode 100644 index 000000000..17c97c7af --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json @@ -0,0 +1,79 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "WebhooksManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionContext.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionContext.cs index 5e8987a8b..20887def3 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionContext.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Core/LINGYUN/Abp/Webhooks/WebhookDefinitionContext.cs @@ -7,9 +7,9 @@ namespace LINGYUN.Abp.Webhooks { public class WebhookDefinitionContext : IWebhookDefinitionContext { - protected Dictionary Groups { get; } + protected IDictionary Groups { get; } - public WebhookDefinitionContext(Dictionary webhooks) + public WebhookDefinitionContext(IDictionary webhooks) { Groups = webhooks; } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs index 212e76061..2fe883ab9 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs @@ -46,7 +46,7 @@ public class DynamicWebhookDefinitionStoreInMemoryCache : WebhookGroupDefinitions.Clear(); WebhookDefinitions.Clear(); - var context = new WebhookDefinitionContext(null); + var context = new WebhookDefinitionContext(WebhookGroupDefinitions); foreach (var webhookGroupRecord in webhookGroupRecords) { diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs index 0346c31fc..c8b1a53c5 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookDefinitionRecord.cs @@ -2,9 +2,11 @@ using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement; +[IgnoreMultiTenancy] public class WebhookDefinitionRecord : BasicAggregateRoot, IHasExtraProperties { [System.Text.Json.Serialization.JsonIgnore] diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookEventRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookEventRecord.cs index 943acb2dd..a576d6bae 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookEventRecord.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookEventRecord.cs @@ -2,9 +2,11 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement; +[IgnoreMultiTenancy] public class WebhookEventRecord : Entity, IHasCreationTime, IHasDeletionTime { public virtual Guid? TenantId { get; protected set; } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs index ed1a0ba52..134898dd5 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookGroupDefinitionRecord.cs @@ -2,9 +2,11 @@ using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement; +[IgnoreMultiTenancy] public class WebhookGroupDefinitionRecord : BasicAggregateRoot, IHasExtraProperties { [System.Text.Json.Serialization.JsonIgnore] diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendRecord.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendRecord.cs index 83cf5ef51..3e5fc5065 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendRecord.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendRecord.cs @@ -4,9 +4,11 @@ using System.Net; using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement; +[IgnoreMultiTenancy] public class WebhookSendRecord : Entity, IHasCreationTime, IHasModificationTime { public virtual Guid? TenantId { get; protected set; } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs index 1a11af2fb..298c2c253 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs @@ -1,9 +1,11 @@ using System; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement; +[IgnoreMultiTenancy] public class WebhookSubscription : CreationAuditedEntity { public virtual Guid? TenantId { get; protected set; } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs index f6d9c17a8..86642632e 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs @@ -1,8 +1,10 @@ using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; +[IgnoreMultiTenancy] [ConnectionStringName(WebhooksManagementDbProperties.ConnectionStringName)] public interface IWebhooksManagementDbContext : IEfCoreDbContext { diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs index de73188aa..3854f1176 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs @@ -1,9 +1,11 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; +[IgnoreMultiTenancy] [ConnectionStringName(WebhooksManagementDbProperties.ConnectionStringName)] public class WebhooksManagementDbContext : AbpDbContext, IWebhooksManagementDbContext { diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs index bf39ddf1a..af12d0aa7 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContextModelCreatingExtensions.cs @@ -19,6 +19,11 @@ public static class WebhooksManagementDbContextModelCreatingExtensions ); optionsAction?.Invoke(options); + if (builder.IsTenantOnlyDatabase()) + { + return; + } + builder.Entity(b => { b.ToTable(options.TablePrefix + "Events", options.Schema); diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json index 16da35d62..4dce35345 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.WebhooksManagement", "secret": "1q2w3E*", @@ -20,13 +20,13 @@ } }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "WebhooksManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "TaskManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "WebhooksManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "TaskManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" }, "DistributedLock": { "IsEnabled": true, From 6c2e5a4d49633e3be6ac303ba7d6ce1addd90545 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:17:06 +0800 Subject: [PATCH 16/26] temporary anonymous access to development environment --- .../WebhooksManagementHttpApiHostModule.Configure.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index 148702021..6ceab3ba7 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -314,6 +314,11 @@ public partial class WebhooksManagementHttpApiHostModule options.Audience = configuration["AuthServer:ApiName"]; }); + if (isDevelopment) + { + services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); From 0cb6f0a9790a3bb129efeb4f600df79c3ce249da Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:51:10 +0800 Subject: [PATCH 17/26] refactoring DynamicNotificationDefinitionStore --- ...onsCommonNotificationDefinitionProvider.cs | 4 +- .../INotificationDefinitionContext.cs | 1 + .../Notifications/NotificationDefinition.cs | 5 + .../NotificationDefinitionContext.cs | 3 +- .../NotificationGroupDefinition.cs | 12 +- .../AbpNotificationsManagementOptions.cs | 24 +- .../DynamicNotificationDefinitionCache.cs | 326 ------------------ ...amicNotificationDefinitionInMemoryCache.cs | 113 ++++++ .../DynamicNotificationDefinitionStore.cs | 156 ++++++++- .../IDynamicNotificationDefinitionCache.cs | 13 - ...DynamicNotificationDefinitionStoreCache.cs | 25 ++ 11 files changed, 320 insertions(+), 362 deletions(-) delete mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionInMemoryCache.cs delete mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionStoreCache.cs diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs index 91d5856ec..d4a206366 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs @@ -12,7 +12,7 @@ public class NotificationsCommonNotificationDefinitionProvider : NotificationDef var commonGroup = context.AddGroup( NotificationsCommonNotificationNames.GroupName, L("Notifications:Primitives"), - false); + allowSubscriptionToClients: false); commonGroup.AddNotification( name: NotificationsCommonNotificationNames.ExceptionHandling, @@ -33,7 +33,7 @@ public class NotificationsCommonNotificationDefinitionProvider : NotificationDef var tenantsGroup = context.AddGroup( TenantNotificationNames.GroupName, L("Notifications:MultiTenancy"), - false); + allowSubscriptionToClients: false); tenantsGroup.AddNotification( TenantNotificationNames.NewTenantRegistered, diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/INotificationDefinitionContext.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/INotificationDefinitionContext.cs index e6839d1df..a225abd3f 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/INotificationDefinitionContext.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/INotificationDefinitionContext.cs @@ -8,6 +8,7 @@ namespace LINGYUN.Abp.Notifications NotificationGroupDefinition AddGroup( [NotNull] string name, ILocalizableString displayName = null, + ILocalizableString description = null, bool allowSubscriptionToClients = true); NotificationGroupDefinition GetGroupOrNull(string name); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs index 9e8ee042d..25ede1f4b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs @@ -64,6 +64,11 @@ namespace LINGYUN.Abp.Notifications [NotNull] public Dictionary Properties { get; } + public object this[string name] { + get => Properties.GetOrDefault(name); + set => Properties[name] = value; + } + public NotificationDefinition( string name, ILocalizableString displayName = null, diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinitionContext.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinitionContext.cs index b0da3077c..52dc2dc8e 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinitionContext.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinitionContext.cs @@ -17,6 +17,7 @@ namespace LINGYUN.Abp.Notifications public NotificationGroupDefinition AddGroup( [NotNull] string name, ILocalizableString displayName = null, + ILocalizableString description = null, bool allowSubscriptionToClients = true) { Check.NotNull(name, nameof(name)); @@ -26,7 +27,7 @@ namespace LINGYUN.Abp.Notifications throw new AbpException($"There is already an existing notification group with name: {name}"); } - return Groups[name] = new NotificationGroupDefinition(name, displayName, allowSubscriptionToClients); + return Groups[name] = new NotificationGroupDefinition(name, displayName, description, allowSubscriptionToClients); } public NotificationGroupDefinition GetGroupOrNull(string name) diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs index 031557e1a..d1dce9c1c 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs @@ -32,23 +32,31 @@ namespace LINGYUN.Abp.Notifications public IReadOnlyList Notifications => _notifications.ToImmutableList(); private readonly List _notifications; - public Dictionary Properties { get; } + public Dictionary Properties { get; } + + public object this[string name] { + get => Properties.GetOrDefault(name); + set => Properties[name] = value; + } public static NotificationGroupDefinition Create( string name, ILocalizableString displayName = null, + ILocalizableString description = null, bool allowSubscriptionToClients = false) { - return new NotificationGroupDefinition(name, displayName, allowSubscriptionToClients); + return new NotificationGroupDefinition(name, displayName, description, allowSubscriptionToClients); } protected internal NotificationGroupDefinition( string name, ILocalizableString displayName = null, + ILocalizableString description = null, bool allowSubscriptionToClients = false) { Name = name; DisplayName = displayName ?? new FixedLocalizableString(Name); + Description = description ?? DisplayName; AllowSubscriptionToClients = allowSubscriptionToClients; _notifications = new List(); diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs index bc2c9de77..70ddb801d 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs @@ -1,12 +1,34 @@ -namespace LINGYUN.Abp.Notifications; +using System; + +namespace LINGYUN.Abp.Notifications; public class AbpNotificationsManagementOptions { public bool SaveStaticNotificationsToDatabase { get; set; } public bool IsDynamicNotificationsStoreEnabled { get; set; } + /// + /// 缓存刷新时间 + /// default: 30 seconds + /// + public TimeSpan NotificationsCacheRefreshInterval { get; set; } + /// + /// 申请时间戳超时时间 + /// default: 2 minutes + /// + public TimeSpan NotificationsCacheStampTimeOut { get; set; } + /// + /// 时间戳过期时间 + /// default: 30 days + /// + public TimeSpan NotificationsCacheStampExpiration { get; set; } public AbpNotificationsManagementOptions() { SaveStaticNotificationsToDatabase = true; IsDynamicNotificationsStoreEnabled = true; + + NotificationsCacheRefreshInterval = TimeSpan.FromSeconds(30); + NotificationsCacheStampTimeOut = TimeSpan.FromMinutes(2); + // 30天过期重新刷新缓存 + NotificationsCacheStampExpiration = TimeSpan.FromDays(30); } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs deleted file mode 100644 index db331e254..000000000 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionCache.cs +++ /dev/null @@ -1,326 +0,0 @@ -using Microsoft.Extensions.Caching.Distributed; -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Localization; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.Caching; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Localization; -using Volo.Abp.Threading; - -namespace LINGYUN.Abp.Notifications; - -public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinitionCache, ISingletonDependency -{ - private readonly static ConcurrentDictionary _dynamicNotificationGroupL1Cache; - private readonly static ConcurrentDictionary _dynamicNotificationsL1Cache; - - private readonly static SemaphoreSlim _l2CacheSyncLock; - protected IMemoryCache DynamicNotificationL2Cache { get; } - - protected IDistributedCache DynamicNotificationGroupL3Cache { get; } - protected IDistributedCache DynamicNotificationsL3Cache { get; } - - - protected INotificationDefinitionGroupRecordRepository NotificationDefinitionGroupRecordRepository { get; } - protected INotificationDefinitionRecordRepository NotificationDefinitionRecordRepository { get; } - protected ILocalizableStringSerializer LocalizableStringSerializer { get; } - protected IStringLocalizerFactory StringLocalizerFactory { get; } - - static DynamicNotificationDefinitionCache() - { - _l2CacheSyncLock = new SemaphoreSlim(1, 1); - _dynamicNotificationsL1Cache = new ConcurrentDictionary(); - _dynamicNotificationGroupL1Cache = new ConcurrentDictionary(); - } - - public DynamicNotificationDefinitionCache( - IMemoryCache dynamicNotificationL2Cache, - IDistributedCache dynamicNotificationGroupL3Cache, - IDistributedCache dynamicNotificationsL3Cache, - INotificationDefinitionGroupRecordRepository notificationDefinitionGroupRecordRepository, - INotificationDefinitionRecordRepository notificationDefinitionRecordRepository, - ILocalizableStringSerializer localizableStringSerializer, - IStringLocalizerFactory stringLocalizerFactory) - { - DynamicNotificationL2Cache = dynamicNotificationL2Cache; - DynamicNotificationGroupL3Cache = dynamicNotificationGroupL3Cache; - DynamicNotificationsL3Cache = dynamicNotificationsL3Cache; - NotificationDefinitionGroupRecordRepository = notificationDefinitionGroupRecordRepository; - NotificationDefinitionRecordRepository = notificationDefinitionRecordRepository; - LocalizableStringSerializer = localizableStringSerializer; - StringLocalizerFactory = stringLocalizerFactory; - } - - public async virtual Task> GetGroupsAsync() - { - var cacheKey = NotificationDefinitionGroupsCacheItem.CalculateCacheKey(CultureInfo.CurrentCulture.Name); - - if (!_dynamicNotificationGroupL1Cache.Any()) - { - var l2GroupCache = await GetGroupsFormL2CacheAsync(cacheKey); - var notifications = await GetNotificationsFormL2CacheAsync( - NotificationDefinitionsCacheItem.CalculateCacheKey(CultureInfo.CurrentCulture.Name)); - - foreach (var group in l2GroupCache.Groups) - { - var groupGroup = NotificationGroupDefinition - .Create( - group.Name, - LocalizableStringSerializer.Deserialize(group.DisplayName), - group.AllowSubscriptionToClients); - - var notificationsInThisGroup = notifications.Notifications - .Where(p => p.GroupName == groupGroup.Name); - - foreach (var notification in notificationsInThisGroup) - { - var notificationDefine = groupGroup.AddNotification( - notification.Name, - LocalizableStringSerializer.Deserialize(notification.DisplayName), - LocalizableStringSerializer.Deserialize(notification.Description), - notification.NotificationType, - notification.Lifetime, - notification.ContentType, - notification.AllowSubscriptionToClients); - - notificationDefine.Properties.AddIfNotContains(notification.Properties); - } - - _dynamicNotificationGroupL1Cache.TryAdd(group.Name, groupGroup); - } - - //NotificationGroupDefinition - // .Create(g.Name, new FixedLocalizableString(g.DisplayName), g.AllowSubscriptionToClients) - } - - return _dynamicNotificationGroupL1Cache.Values.ToImmutableList(); - } - - public async virtual Task> GetNotificationsAsync() - { - var cacheKey = NotificationDefinitionsCacheItem.CalculateCacheKey(CultureInfo.CurrentCulture.Name); - - if (!_dynamicNotificationsL1Cache.Any()) - { - var l2cache = await GetNotificationsFormL2CacheAsync(cacheKey); - - foreach (var notification in l2cache.Notifications) - { - var notificationDefinition = new NotificationDefinition( - notification.Name, - LocalizableStringSerializer.Deserialize(notification.DisplayName), - LocalizableStringSerializer.Deserialize(notification.Description), - notification.NotificationType, - notification.Lifetime, - notification.ContentType, - notification.AllowSubscriptionToClients); - - notificationDefinition.WithProviders(notification.Providers.ToArray()); - notificationDefinition.Properties.AddIfNotContains(notification.Properties); - - _dynamicNotificationsL1Cache.TryAdd(notification.Name, notificationDefinition); - } - } - - return _dynamicNotificationsL1Cache.Values.ToImmutableList(); - } - - public async virtual Task GetOrNullAsync(string name) - { - if (_dynamicNotificationsL1Cache.Any()) - { - return _dynamicNotificationsL1Cache.GetOrDefault(name); - } - var notifications = await GetNotificationsAsync(); - - return notifications.FirstOrDefault(n => n.Name.Equals(name)); - } - - protected async virtual Task GetGroupsFormL2CacheAsync(string cacheKey) - { - var cacheItem = DynamicNotificationL2Cache.Get(cacheKey); - - if (cacheItem == null) - { - using (await _l2CacheSyncLock.LockAsync()) - { - var l2cache = await GetGroupsFormL3CacheAsync(cacheKey); - - var options = new MemoryCacheEntryOptions(); - options.SetAbsoluteExpiration(TimeSpan.FromMinutes(5)); - options.SetPriority(CacheItemPriority.High); - options.RegisterPostEvictionCallback((key, value, reason, state) => - { - _dynamicNotificationGroupL1Cache.Clear(); - }); - - DynamicNotificationL2Cache.Set(cacheKey, l2cache, options); - - return l2cache; - } - } - - return cacheItem; - } - - protected async virtual Task GetGroupsFormL3CacheAsync(string cacheKey) - { - var cacheItem = await DynamicNotificationGroupL3Cache.GetAsync(cacheKey); - - if (cacheItem == null) - { - var records = await GetGroupsFormRepositoryAsync(); - var recordCaches = new List(); - - foreach (var record in records) - { - var displayName = record.DisplayName; - if (!displayName.IsNullOrWhiteSpace()) - { - displayName = await LocalizableStringSerializer - .Deserialize(displayName) - .LocalizeAsync(StringLocalizerFactory); - } - - var description = record.Description; - if (!description.IsNullOrWhiteSpace()) - { - description = await LocalizableStringSerializer - .Deserialize(description) - .LocalizeAsync(StringLocalizerFactory); - } - - recordCaches.Add(new NotificationDefinitionGroupCacheItem( - record.Name, - displayName, - description, - record.AllowSubscriptionToClients)); - } - - cacheItem = new NotificationDefinitionGroupsCacheItem(recordCaches.ToArray()); - - await DynamicNotificationGroupL3Cache.SetAsync( - cacheKey, - cacheItem, - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(2), - SlidingExpiration = TimeSpan.FromHours(1), - }); - } - - return cacheItem; - } - - protected async virtual Task> GetGroupsFormRepositoryAsync() - { - var records = await NotificationDefinitionGroupRecordRepository.GetListAsync(); - - return records; - } - - - protected async virtual Task GetNotificationsFormL2CacheAsync(string cacheKey) - { - var cacheItem = DynamicNotificationL2Cache.Get(cacheKey); - - if (cacheItem == null) - { - using (await _l2CacheSyncLock.LockAsync()) - { - var l2cache = await GetNotificationsFormL3CacheAsync(cacheKey); - - var options = new MemoryCacheEntryOptions(); - options.SetAbsoluteExpiration(TimeSpan.FromMinutes(5)); - options.SetPriority(CacheItemPriority.High); - options.RegisterPostEvictionCallback((key, value, reason, state) => - { - _dynamicNotificationsL1Cache.Clear(); - }); - - DynamicNotificationL2Cache.Set(cacheKey, l2cache, options); - - return l2cache; - } - } - - return cacheItem; - } - - protected async virtual Task GetNotificationsFormL3CacheAsync(string cacheKey) - { - var cacheItem = await DynamicNotificationsL3Cache.GetAsync(cacheKey); - - if (cacheItem == null) - { - var records = await GetNotificationsFormRepositoryAsync(); - var recordCaches = new List(); - - foreach (var record in records) - { - var displayName = record.DisplayName; - if (!displayName.IsNullOrWhiteSpace()) - { - displayName = await LocalizableStringSerializer - .Deserialize(displayName) - .LocalizeAsync(StringLocalizerFactory); - } - - var description = record.Description; - if (!description.IsNullOrWhiteSpace()) - { - description = await LocalizableStringSerializer - .Deserialize(description) - .LocalizeAsync(StringLocalizerFactory); - } - - var providers = new List(); - if (!record.Providers.IsNullOrWhiteSpace()) - { - providers = record.Providers.Split(';').ToList(); - } - - var recordCache = new NotificationDefinitionCacheItem( - record.Name, - record.GroupName, - displayName, - description, - record.NotificationLifetime, - record.NotificationType, - record.ContentType, - providers, - record.AllowSubscriptionToClients); - recordCache.Properties.AddIfNotContains(record.ExtraProperties); - - recordCaches.Add(recordCache); - } - - cacheItem = new NotificationDefinitionsCacheItem(recordCaches.ToArray()); - - await DynamicNotificationsL3Cache.SetAsync( - cacheKey, - cacheItem, - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(2), - SlidingExpiration = TimeSpan.FromHours(1), - }); - } - - return cacheItem; - } - - protected async virtual Task> GetNotificationsFormRepositoryAsync() - { - var records = await NotificationDefinitionRecordRepository.GetListAsync(); - - return records; - } -} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionInMemoryCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionInMemoryCache.cs new file mode 100644 index 000000000..404a6c3c2 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionInMemoryCache.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.Notifications; + +[ExposeServices( + typeof(IDynamicNotificationDefinitionStoreCache), + typeof(DynamicNotificationDefinitionInMemoryCache))] +public class DynamicNotificationDefinitionInMemoryCache : IDynamicNotificationDefinitionStoreCache, ISingletonDependency +{ + public string CacheStamp { get; set; } + + protected IDictionary NotificationGroupDefinitions { get; } + protected IDictionary NotificationDefinitions { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } + + public SemaphoreSlim SyncSemaphore { get; } = new(1, 1); + + public DateTime? LastCheckTime { get; set; } + + public DynamicNotificationDefinitionInMemoryCache( + ILocalizableStringSerializer localizableStringSerializer) + { + LocalizableStringSerializer = localizableStringSerializer; + + NotificationGroupDefinitions = new Dictionary(); + NotificationDefinitions = new Dictionary(); + } + + public Task FillAsync( + List notificationGroupRecords, + List notificationRecords) + { + NotificationGroupDefinitions.Clear(); + NotificationDefinitions.Clear(); + + var context = new NotificationDefinitionContext(); + + foreach (var notificationGroupRecord in notificationGroupRecords) + { + var notificationGroup = context.AddGroup( + notificationGroupRecord.Name, + LocalizableStringSerializer.Deserialize(notificationGroupRecord.DisplayName), + LocalizableStringSerializer.Deserialize(notificationGroupRecord.Description), + notificationGroupRecord.AllowSubscriptionToClients + ); + + NotificationGroupDefinitions[notificationGroup.Name] = notificationGroup; + + foreach (var property in notificationGroupRecord.ExtraProperties) + { + notificationGroup[property.Key] = property.Value; + } + + var notificationRecordsInThisGroup = notificationRecords + .Where(p => p.GroupName == notificationGroup.Name); + + foreach (var notificationRecord in notificationRecordsInThisGroup) + { + AddNotification(notificationGroup, notificationRecord); + } + } + + return Task.CompletedTask; + } + + public NotificationDefinition GetNotificationOrNull(string name) + { + return NotificationDefinitions.GetOrDefault(name); + } + + public IReadOnlyList GetNotifications() + { + return NotificationDefinitions.Values.ToList(); + } + + public IReadOnlyList GetGroups() + { + return NotificationGroupDefinitions.Values.ToList(); + } + + private void AddNotification( + NotificationGroupDefinition notificationGroup, + NotificationDefinitionRecord notificationRecord) + { + var notification = notificationGroup.AddNotification( + notificationRecord.Name, + LocalizableStringSerializer.Deserialize(notificationRecord.DisplayName), + LocalizableStringSerializer.Deserialize(notificationRecord.Description), + notificationRecord.NotificationType, + notificationRecord.NotificationLifetime, + notificationRecord.ContentType, + notificationRecord.AllowSubscriptionToClients + ); + + NotificationDefinitions[notification.Name] = notification; + + if (!notificationRecord.Providers.IsNullOrWhiteSpace()) + { + notification.Providers.AddRange(notificationRecord.Providers.Split(',', ';')); + } + + foreach (var property in notificationRecord.ExtraProperties) + { + notification[property.Key] = property.Value; + } + } +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs index a270ab465..b8675d4aa 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/DynamicNotificationDefinitionStore.cs @@ -1,49 +1,171 @@ -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Threading; namespace LINGYUN.Abp.Notifications; [Dependency(ReplaceServices = true)] public class DynamicNotificationDefinitionStore : IDynamicNotificationDefinitionStore, ITransientDependency { - private readonly AbpNotificationsManagementOptions _notificationsManagementOptions; - private readonly IDynamicNotificationDefinitionCache _dynamicNotificationDefinitionCache; + protected INotificationDefinitionGroupRecordRepository NotificationGroupRepository { get; } + protected INotificationDefinitionRecordRepository NotificationRepository { get; } + protected INotificationDefinitionSerializer NotificationDefinitionSerializer { get; } + protected IDynamicNotificationDefinitionStoreCache StoreCache { get; } + protected IDistributedCache DistributedCache { get; } + protected IAbpDistributedLock DistributedLock { get; } + protected AbpNotificationsManagementOptions NotificationManagementOptions { get; } + protected AbpDistributedCacheOptions CacheOptions { get; } public DynamicNotificationDefinitionStore( - IDynamicNotificationDefinitionCache dynamicNotificationDefinitionCache, - IOptions notificationsManagementOptions) + INotificationDefinitionGroupRecordRepository notificationGroupRepository, + INotificationDefinitionRecordRepository notificationRepository, + INotificationDefinitionSerializer notificationDefinitionSerializer, + IDynamicNotificationDefinitionStoreCache storeCache, + IDistributedCache distributedCache, + IOptions cacheOptions, + IOptions notificationManagementOptions, + IAbpDistributedLock distributedLock) { - _dynamicNotificationDefinitionCache = dynamicNotificationDefinitionCache; - _notificationsManagementOptions = notificationsManagementOptions.Value; + NotificationGroupRepository = notificationGroupRepository; + NotificationRepository = notificationRepository; + NotificationDefinitionSerializer = notificationDefinitionSerializer; + StoreCache = storeCache; + DistributedCache = distributedCache; + DistributedLock = distributedLock; + NotificationManagementOptions = notificationManagementOptions.Value; + CacheOptions = cacheOptions.Value; } - public async virtual Task> GetGroupsAsync() + public async virtual Task GetOrNullAsync(string name) { - if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) + if (!NotificationManagementOptions.IsDynamicNotificationsStoreEnabled) { - return Array.Empty(); + return null; + } + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetNotificationOrNull(name); } - return await _dynamicNotificationDefinitionCache.GetGroupsAsync(); } public async virtual Task> GetNotificationsAsync() { - if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) + if (!NotificationManagementOptions.IsDynamicNotificationsStoreEnabled) { return Array.Empty(); } - return await _dynamicNotificationDefinitionCache.GetNotificationsAsync(); + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetNotifications().ToImmutableList(); + } } - public async virtual Task GetOrNullAsync(string name) + public async virtual Task> GetGroupsAsync() { - if (!_notificationsManagementOptions.IsDynamicNotificationsStoreEnabled) + if (!NotificationManagementOptions.IsDynamicNotificationsStoreEnabled) { - return null; + return Array.Empty(); + } + + using (await StoreCache.SyncSemaphore.LockAsync()) + { + await EnsureCacheIsUptoDateAsync(); + return StoreCache.GetGroups().ToImmutableList(); + } + } + + protected async virtual Task EnsureCacheIsUptoDateAsync() + { + if (StoreCache.LastCheckTime.HasValue && + DateTime.Now.Subtract(StoreCache.LastCheckTime.Value) < NotificationManagementOptions.NotificationsCacheRefreshInterval) + { + /* We get the latest Notification with a small delay for optimization */ + return; + } + + var stampInDistributedCache = await GetOrSetStampInDistributedCache(); + + if (stampInDistributedCache == StoreCache.CacheStamp) + { + StoreCache.LastCheckTime = DateTime.Now; + return; } - return await _dynamicNotificationDefinitionCache.GetOrNullAsync(name); + + await UpdateInMemoryStoreCache(); + + StoreCache.CacheStamp = stampInDistributedCache; + StoreCache.LastCheckTime = DateTime.Now; + } + + protected async virtual Task UpdateInMemoryStoreCache() + { + var NotificationGroupRecords = await NotificationGroupRepository.GetListAsync(); + var NotificationRecords = await NotificationRepository.GetListAsync(); + + await StoreCache.FillAsync(NotificationGroupRecords, NotificationRecords); + } + + protected async virtual Task GetOrSetStampInDistributedCache() + { + var cacheKey = GetCommonStampCacheKey(); + + var stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + await using (var commonLockHandle = await DistributedLock + .TryAcquireAsync(GetCommonDistributedLockKey(), NotificationManagementOptions.NotificationsCacheStampTimeOut)) + { + if (commonLockHandle == null) + { + /* This request will fail */ + throw new AbpException( + "Could not acquire distributed lock for Notification definition common stamp check!" + ); + } + + stampInDistributedCache = await DistributedCache.GetStringAsync(cacheKey); + if (stampInDistributedCache != null) + { + return stampInDistributedCache; + } + + stampInDistributedCache = Guid.NewGuid().ToString(); + + await DistributedCache.SetStringAsync( + cacheKey, + stampInDistributedCache, + new DistributedCacheEntryOptions + { + SlidingExpiration = NotificationManagementOptions.NotificationsCacheStampExpiration + } + ); + } + + return stampInDistributedCache; + } + + protected virtual string GetCommonStampCacheKey() + { + return $"{CacheOptions.KeyPrefix}_AbpInMemoryNotificationCacheStamp"; + } + + protected virtual string GetCommonDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_Common_AbpNotificationUpdateLock"; } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs deleted file mode 100644 index fcebc3e87..000000000 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionCache.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Notifications; - -public interface IDynamicNotificationDefinitionCache -{ - Task GetOrNullAsync(string name); - - Task> GetNotificationsAsync(); - - Task> GetGroupsAsync(); -} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionStoreCache.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionStoreCache.cs new file mode 100644 index 000000000..adf8d41c7 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/IDynamicNotificationDefinitionStoreCache.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Notifications; + +public interface IDynamicNotificationDefinitionStoreCache +{ + string CacheStamp { get; set; } + + SemaphoreSlim SyncSemaphore { get; } + + DateTime? LastCheckTime { get; set; } + + Task FillAsync( + List webhookGroupRecords, + List webhookRecords); + + NotificationDefinition GetNotificationOrNull(string name); + + IReadOnlyList GetNotifications(); + + IReadOnlyList GetGroups(); +} From b13d9929658c9288acd5390ae6ae52a6002a145c Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:27:43 +0800 Subject: [PATCH 18/26] add task management migrations --- .../LINGYUN.MicroService.TaskManagement.sln | 9 + .../TaskManagementDbMigrationService.cs | 216 +++++++ .../TaskManagementMigrationsDbContext.cs | 23 + ...skManagementMigrationsDbContextFactory.cs} | 13 +- ...roService.TaskManagement.DbMigrator.csproj | 55 ++ ...021621_Initial-Task-Management.Designer.cs | 273 ++++++++ .../20230112021621_Initial-Task-Management.cs | 156 +++++ ...agementMigrationsDbContextModelSnapshot.cs | 270 ++++++++ .../Program.cs | 40 ++ .../Properties/launchSettings.json | 11 + .../TaskManagementDbMigratorHostedService.cs | 51 ++ ...askManagementDbMigratorModule.Configure.cs | 18 + .../TaskManagementDbMigratorModule.cs | 29 + .../Usings.cs | 7 + .../appsettings.json | 81 +++ .../Queryable/AbpDynamicQueryableOptions.cs | 2 + .../LINGYUN.Abp.Notifications.Domain.csproj | 4 + .../appsettings.Development.json | 2 +- .../Properties/launchSettings.json | 4 +- ...Add-Module-Workflow-Management.Designer.cs | 557 ---------------- ...12074420_Add-Module-Workflow-Management.cs | 385 ----------- ...rkflow-Data-With-WF-Management.Designer.cs | 610 ------------------ ...Entity-Workflow-Data-With-WF-Management.cs | 147 ----- ...agementMigrationsDbContextModelSnapshot.cs | 608 ----------------- 24 files changed, 1254 insertions(+), 2317 deletions(-) create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementDbMigrationService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContext.cs rename aspnet-core/{services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContextFactory.cs => migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs} (57%) create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Program.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Properties/launchSettings.json create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorHostedService.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.Configure.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Usings.cs create mode 100644 aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json delete mode 100644 aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.Designer.cs delete mode 100644 aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.cs delete mode 100644 aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.Designer.cs delete mode 100644 aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.cs delete mode 100644 aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/WorkflowManagementMigrationsDbContextModelSnapshot.cs diff --git a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln index bbf134dbd..d46cf64f1 100644 --- a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln +++ b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln @@ -80,6 +80,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryab EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryable.HttpApi", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.HttpApi\LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj", "{DF963ABB-E713-49E9-A03C-DEB431E369DF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{820A8FA4-17C4-44DF-8C31-9F211D00F790}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.TaskManagement.DbMigrator", "migrations\LY.MicroService.TaskManagement.DbMigrator\LY.MicroService.TaskManagement.DbMigrator.csproj", "{52FD8F39-0AB6-4C51-A584-187C219AC8B5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -198,6 +202,10 @@ Global {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Release|Any CPU.Build.0 = Release|Any CPU + {52FD8F39-0AB6-4C51-A584-187C219AC8B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52FD8F39-0AB6-4C51-A584-187C219AC8B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52FD8F39-0AB6-4C51-A584-187C219AC8B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52FD8F39-0AB6-4C51-A584-187C219AC8B5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -231,6 +239,7 @@ Global {B54F200C-D648-477B-BE39-B40A1D956F13} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} {FEC5FD25-9B26-4245-88D8-7621B26C7C3A} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} {DF963ABB-E713-49E9-A03C-DEB431E369DF} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} + {52FD8F39-0AB6-4C51-A584-187C219AC8B5} = {820A8FA4-17C4-44DF-8C31-9F211D00F790} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E1FD1F4C-D344-408B-97CF-B6F1F6D7D293} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementDbMigrationService.cs new file mode 100644 index 000000000..60d21acb2 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementDbMigrationService.cs @@ -0,0 +1,216 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; + +namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; + +public class TaskManagementDbMigrationService : ITransientDependency +{ + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IDbSchemaMigrator _dbSchemaMigrator; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public TaskManagementDbMigrationService( + IDataSeeder dataSeeder, + IDbSchemaMigrator dbSchemaMigrator, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) + { + _dataSeeder = dataSeeder; + _dbSchemaMigrator = dbSchemaMigrator; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; + + Logger = NullLogger.Instance; + } + + public async Task MigrateAsync() + { + var initialMigrationAdded = AddInitialMigrationIfNotExist(); + + if (initialMigrationAdded) + { + return; + } + + Logger.LogInformation("Started database migrations..."); + + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); + + Logger.LogInformation($"Successfully completed host database migrations."); + + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) + { + if (tenant.ConnectionStrings.Any()) + { + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); + + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); + + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); + } + } + + await SeedDataAsync(tenant); + } + + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + } + + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } + + private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + // 迁移租户数据 + await _dbSchemaMigrator.MigrateAsync( + (connectionString, builder) => + { + builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); + + return new TaskManagementMigrationsDbContext(builder.Options); + }); + } + + private async Task SeedDataAsync(Tenant? tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(tenant?.Id); + } + + private bool AddInitialMigrationIfNotExist() + { + try + { + if (!DbMigrationsProjectExists()) + { + return false; + } + } + catch (Exception) + { + return false; + } + + try + { + if (!MigrationsFolderExists()) + { + AddInitialMigration(); + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; + } + } + + private bool DbMigrationsProjectExists() + { + return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); + } + + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } + + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); + + string argumentPrefix; + string fileName; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; + } + else + { + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } + + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" + ); + + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); + + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); + } + + return Path.Combine(slnDirectoryPath, "LY.MicroService.TaskManagement.DbMigrator"); + } + + private string? GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + + // parent host + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) + { + return currentDirectory.FullName; + } + } + + return null; + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContext.cs new file mode 100644 index 000000000..edd68ae13 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContext.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; + +[ConnectionStringName("TaskManagementDbMigrator")] +public class TaskManagementMigrationsDbContext : AbpDbContext +{ + public TaskManagementMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureTaskManagement(); + } +} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs similarity index 57% rename from aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContextFactory.cs rename to aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs index fbb81a49c..bc48317d7 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContextFactory.cs +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs @@ -1,21 +1,20 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -using System.IO; -namespace LY.MicroService.WorkflowManagement.EntityFrameworkCore; +namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; -public class WorkflowManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory +public class TaskManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory { - public WorkflowManagementMigrationsDbContext CreateDbContext(string[] args) + public TaskManagementMigrationsDbContext CreateDbContext(string[] args) { var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("WorkflowManagement"); + var connectionString = configuration.GetConnectionString("Default"); - var builder = new DbContextOptionsBuilder() + var builder = new DbContextOptionsBuilder() .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - return new WorkflowManagementMigrationsDbContext(builder.Options); + return new TaskManagementMigrationsDbContext(builder!.Options); } private static IConfigurationRoot BuildConfiguration() diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj new file mode 100644 index 000000000..1ad4a5f12 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj @@ -0,0 +1,55 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.Designer.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.Designer.cs new file mode 100644 index 000000000..88dfad48b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.Designer.cs @@ -0,0 +1,273 @@ +// +using System; +using LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.TaskManagement.DbMigrator.Migrations +{ + [DbContext(typeof(TaskManagementMigrationsDbContext))] + [Migration("20230112021621_Initial-Task-Management")] + partial class InitialTaskManagement + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("JobId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("Paramters") + .HasColumnType("longtext") + .HasColumnName("Paramters"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("TK_BackgroundJobActions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobInfo", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("Args") + .HasColumnType("longtext") + .HasColumnName("Args"); + + b.Property("BeginTime") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Cron") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Cron"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("EndTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Group"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("IsAbandoned") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("JobType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastRunTime") + .HasColumnType("datetime(6)"); + + b.Property("LockTimeOut") + .HasColumnType("int"); + + b.Property("MaxCount") + .HasColumnType("int"); + + b.Property("MaxTryCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("NextRunTime") + .HasColumnType("datetime(6)"); + + b.Property("NodeName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("NodeName"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("Result") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Result"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TriggerCount") + .HasColumnType("int"); + + b.Property("TryCount") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Type"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Group"); + + b.ToTable("TK_BackgroundJobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Exception") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)") + .HasColumnName("Exception"); + + b.Property("JobGroup") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("JobGroup"); + + b.Property("JobId") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); + + b.Property("JobName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("JobName"); + + b.Property("JobType") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("JobType"); + + b.Property("Message") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Message"); + + b.Property("RunTime") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("JobGroup", "JobName"); + + b.ToTable("TK_BackgroundJobLogs", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.cs new file mode 100644 index 000000000..3d8081aee --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/20230112021621_Initial-Task-Management.cs @@ -0,0 +1,156 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.TaskManagement.DbMigrator.Migrations +{ + /// + public partial class InitialTaskManagement : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "TK_BackgroundJobActions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + JobId = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + Paramters = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_TK_BackgroundJobActions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "TK_BackgroundJobLogs", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + JobId = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + JobName = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + JobGroup = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + JobType = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Message = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RunTime = table.Column(type: "datetime(6)", nullable: false), + Exception = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_TK_BackgroundJobLogs", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "TK_BackgroundJobs", + columns: table => new + { + Id = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Group = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Type = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Result = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Args = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "int", nullable: false), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LockTimeOut = table.Column(type: "int", nullable: false), + BeginTime = table.Column(type: "datetime(6)", nullable: false), + EndTime = table.Column(type: "datetime(6)", nullable: true), + LastRunTime = table.Column(type: "datetime(6)", nullable: true), + NextRunTime = table.Column(type: "datetime(6)", nullable: true), + JobType = table.Column(type: "int", nullable: false), + Cron = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Source = table.Column(type: "int", nullable: false), + Priority = table.Column(type: "int", nullable: false), + TriggerCount = table.Column(type: "int", nullable: false), + TryCount = table.Column(type: "int", nullable: false), + MaxTryCount = table.Column(type: "int", nullable: false), + MaxCount = table.Column(type: "int", nullable: false), + Interval = table.Column(type: "int", nullable: false), + IsAbandoned = table.Column(type: "tinyint(1)", nullable: false), + NodeName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_TK_BackgroundJobs", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_TK_BackgroundJobActions_Name", + table: "TK_BackgroundJobActions", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_TK_BackgroundJobLogs_JobGroup_JobName", + table: "TK_BackgroundJobLogs", + columns: new[] { "JobGroup", "JobName" }); + + migrationBuilder.CreateIndex( + name: "IX_TK_BackgroundJobs_Name_Group", + table: "TK_BackgroundJobs", + columns: new[] { "Name", "Group" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TK_BackgroundJobActions"); + + migrationBuilder.DropTable( + name: "TK_BackgroundJobLogs"); + + migrationBuilder.DropTable( + name: "TK_BackgroundJobs"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..c32dad0f1 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,270 @@ +// +using System; +using LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.TaskManagement.DbMigrator.Migrations +{ + [DbContext(typeof(TaskManagementMigrationsDbContext))] + partial class TaskManagementMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("JobId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("Paramters") + .HasColumnType("longtext") + .HasColumnName("Paramters"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("TK_BackgroundJobActions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobInfo", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("Args") + .HasColumnType("longtext") + .HasColumnName("Args"); + + b.Property("BeginTime") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Cron") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Cron"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("EndTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Group"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("IsAbandoned") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("JobType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastRunTime") + .HasColumnType("datetime(6)"); + + b.Property("LockTimeOut") + .HasColumnType("int"); + + b.Property("MaxCount") + .HasColumnType("int"); + + b.Property("MaxTryCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("NextRunTime") + .HasColumnType("datetime(6)"); + + b.Property("NodeName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("NodeName"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("Result") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Result"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TriggerCount") + .HasColumnType("int"); + + b.Property("TryCount") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Type"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Group"); + + b.ToTable("TK_BackgroundJobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Exception") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)") + .HasColumnName("Exception"); + + b.Property("JobGroup") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("JobGroup"); + + b.Property("JobId") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); + + b.Property("JobName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("JobName"); + + b.Property("JobType") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("JobType"); + + b.Property("Message") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Message"); + + b.Property("RunTime") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("JobGroup", "JobName"); + + b.ToTable("TK_BackgroundJobLogs", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Program.cs new file mode 100644 index 000000000..185fb7e53 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.TaskManagement.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.TaskManagement.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.TaskManagement.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Properties/launchSettings.json b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Properties/launchSettings.json new file mode 100644 index 000000000..3000e4aba --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "LY.MicroService.TaskManagement.DbMigrator": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorHostedService.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorHostedService.cs new file mode 100644 index 000000000..5eba27666 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorHostedService.cs @@ -0,0 +1,51 @@ +using LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; +using Volo.Abp.Data; + +namespace LY.MicroService.TaskManagement.DbMigrator; + +public class TaskManagementDbMigratorHostedService : IHostedService +{ + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public TaskManagementDbMigratorHostedService( + IHostApplicationLifetime hostApplicationLifetime, + IConfiguration configuration) + { + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using var application = await AbpApplicationFactory + .CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + options.AddDataMigrationEnvironment(); + }); + await application.InitializeAsync(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + await application.ShutdownAsync(); + + _hostApplicationLifetime.StopApplication(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.Configure.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.Configure.cs new file mode 100644 index 000000000..6fd7f7551 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.Configure.cs @@ -0,0 +1,18 @@ +using LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace LY.MicroService.TaskManagement.DbMigrator; +public partial class TaskManagementDbMigratorModule +{ + private void ConfigureDbContext(IServiceCollection services) + { + services.AddAbpDbContext(); + + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.cs new file mode 100644 index 000000000..a10892b76 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/TaskManagementDbMigratorModule.cs @@ -0,0 +1,29 @@ +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace LY.MicroService.TaskManagement.DbMigrator; + +[DependsOn( + typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(TaskManagementEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreMySQLModule), + typeof(AbpDataDbMigratorModule), + typeof(AbpAutofacModule) + )] +public partial class TaskManagementDbMigratorModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureDbContext(context.Services); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Usings.cs b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Usings.cs new file mode 100644 index 000000000..8d1695408 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/Usings.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using LINGYUN.Abp; diff --git a/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json new file mode 100644 index 000000000..355c02f19 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json @@ -0,0 +1,81 @@ +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "TaskManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Information" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs index 9450db7d9..687d7b40d 100644 --- a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Volo.Abp.Auditing; +using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Dynamic.Queryable; @@ -12,6 +13,7 @@ public class AbpDynamicQueryableOptions { IgnoreFields = new List { + nameof(IEntity.Id), nameof(IMultiTenant.TenantId), nameof(IDeletionAuditedObject.IsDeleted), nameof(IDeletionAuditedObject.DeleterId), diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj index d957d22ac..33f71325d 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN.Abp.Notifications.Domain.csproj @@ -8,6 +8,10 @@ + + + + diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json index 57d86bdca..c03b0e207 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.TaskManagement", "secret": "1q2w3E*", diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json index 7e93c505e..5678ad837 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json @@ -11,11 +11,11 @@ "LY.MicroService.WebhooksManagement.HttpApi.Host": { "commandName": "Project", "launchBrowser": false, + "dotnetRunMessages": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://127.0.0.1:30045", - "dotnetRunMessages": "true" + "applicationUrl": "http://127.0.0.1:30045" } } } \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.Designer.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.Designer.cs deleted file mode 100644 index 464735504..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.Designer.cs +++ /dev/null @@ -1,557 +0,0 @@ -// -using System; -using LY.MicroService.WorkflowManagement.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Volo.Abp.EntityFrameworkCore; - -#nullable disable - -namespace LY.MicroService.WorkflowManagement.Migrations -{ - [DbContext(typeof(WorkflowManagementMigrationsDbContext))] - [Migration("20211212074420_Add-Module-Workflow-Management")] - partial class AddModuleWorkflowManagement - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("IsProcessed") - .HasColumnType("tinyint(1)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("CreationTime"); - - b.HasIndex("IsProcessed"); - - b.HasIndex("EventName", "EventKey"); - - b.ToTable("WF_Event", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionError", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ErrorTime") - .HasColumnType("datetime(6)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Message") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_ExecutionError", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Active") - .HasColumnType("tinyint(1)"); - - b.Property("Children") - .HasColumnType("longtext"); - - b.Property("ContextItem") - .HasColumnType("longtext"); - - b.Property("EndTime") - .HasColumnType("datetime(6)"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventPublished") - .HasColumnType("tinyint(1)"); - - b.Property("Outcome") - .HasColumnType("longtext"); - - b.Property("PersistenceData") - .HasColumnType("longtext"); - - b.Property("PredecessorId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("RetryCount") - .HasColumnType("int"); - - b.Property("Scope") - .HasColumnType("longtext"); - - b.Property("SleepUntil") - .HasColumnType("datetime(6)"); - - b.Property("StartTime") - .HasColumnType("datetime(6)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("StepName") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("WorkflowId"); - - b.ToTable("WF_ExecutionPointer", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Key") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ExecutionPointerId"); - - b.ToTable("WF_ExtensionAttribute", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedScheduledCommand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("CommandName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Data") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExecuteTime") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("ExecuteTime"); - - b.HasIndex("CommandName", "Data") - .IsUnique(); - - b.ToTable("WF_ScheduledCommand", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("ExternalToken") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExternalTokenExpiry") - .HasColumnType("datetime(6)"); - - b.Property("ExternalWorkerId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("SubscribeAsOf") - .HasColumnType("datetime(6)"); - - b.Property("SubscriptionData") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("EventKey"); - - b.HasIndex("EventName"); - - b.ToTable("WF_Subscription", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CompleteTime") - .HasColumnType("datetime(6)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Data") - .HasColumnType("longtext"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("NextExecution") - .HasColumnType("bigint"); - - b.Property("Reference") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.Property("WorkflowDefinitionId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("NextExecution"); - - b.ToTable("WF_Workflow", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.CompensateNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Compensate", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.StepNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Step", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.Workflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Description") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("DisplayName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("ErrorRetryInterval") - .HasColumnType("time(6)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("IsEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WF_Definition", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", "Workflow") - .WithMany("ExecutionPointers") - .HasForeignKey("WorkflowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Workflow"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", "ExecutionPointer") - .WithMany("ExtensionAttributes") - .HasForeignKey("ExecutionPointerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExecutionPointer"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Navigation("ExtensionAttributes"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Navigation("ExecutionPointers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.cs deleted file mode 100644 index e6abb6314..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211212074420_Add-Module-Workflow-Management.cs +++ /dev/null @@ -1,385 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LY.MicroService.WorkflowManagement.Migrations -{ - public partial class AddModuleWorkflowManagement : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Compensate", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StepType = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CancelCondition = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ErrorBehavior = table.Column(type: "int", nullable: true), - RetryInterval = table.Column(type: "time(6)", nullable: true), - Saga = table.Column(type: "tinyint(1)", nullable: false), - ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - Inputs = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Outputs = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SelectNextStep = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Compensate", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Definition", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - IsEnabled = table.Column(type: "tinyint(1)", nullable: false), - Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Version = table.Column(type: "int", nullable: false), - ErrorBehavior = table.Column(type: "int", nullable: false), - ErrorRetryInterval = table.Column(type: "time(6)", nullable: true), - ExtraProperties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreationTime = table.Column(type: "datetime(6)", nullable: false), - CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - LastModificationTime = table.Column(type: "datetime(6)", nullable: true), - LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Definition", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Event", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - EventName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EventKey = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EventData = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - IsProcessed = table.Column(type: "tinyint(1)", nullable: false), - CreationTime = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Event", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_ExecutionError", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - ExecutionPointerId = table.Column(type: "char(50)", maxLength: 50, nullable: false, collation: "ascii_general_ci"), - ErrorTime = table.Column(type: "datetime(6)", nullable: false), - Message = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_ExecutionError", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_ScheduledCommand", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - CommandName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Data = table.Column(type: "varchar(500)", maxLength: 500, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ExecuteTime = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WF_ScheduledCommand", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Step", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StepType = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CancelCondition = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ErrorBehavior = table.Column(type: "int", nullable: true), - RetryInterval = table.Column(type: "time(6)", nullable: true), - Saga = table.Column(type: "tinyint(1)", nullable: false), - ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - Inputs = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Outputs = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SelectNextStep = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Step", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Subscription", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - StepId = table.Column(type: "int", nullable: false), - ExecutionPointerId = table.Column(type: "char(50)", maxLength: 50, nullable: false, collation: "ascii_general_ci"), - EventName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EventKey = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SubscribeAsOf = table.Column(type: "datetime(6)", nullable: false), - SubscriptionData = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ExternalToken = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ExternalWorkerId = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ExternalTokenExpiry = table.Column(type: "datetime(6)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Subscription", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_Workflow", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowDefinitionId = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Version = table.Column(type: "int", nullable: false), - Description = table.Column(type: "varchar(500)", maxLength: 500, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Reference = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NextExecution = table.Column(type: "bigint", nullable: true), - Status = table.Column(type: "int", nullable: false), - Data = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CompleteTime = table.Column(type: "datetime(6)", nullable: true), - ExtraProperties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreationTime = table.Column(type: "datetime(6)", nullable: false), - CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - LastModificationTime = table.Column(type: "datetime(6)", nullable: true), - LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_Workflow", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_ExecutionPointer", - columns: table => new - { - Id = table.Column(type: "char(50)", maxLength: 50, nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - StepId = table.Column(type: "int", nullable: false), - Active = table.Column(type: "tinyint(1)", nullable: false), - SleepUntil = table.Column(type: "datetime(6)", nullable: true), - PersistenceData = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StartTime = table.Column(type: "datetime(6)", nullable: true), - EndTime = table.Column(type: "datetime(6)", nullable: true), - EventName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EventKey = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EventPublished = table.Column(type: "tinyint(1)", nullable: false), - EventData = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StepName = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - RetryCount = table.Column(type: "int", nullable: false), - Children = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ContextItem = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PredecessorId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Outcome = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "int", nullable: false), - Scope = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_ExecutionPointer", x => x.Id); - table.ForeignKey( - name: "FK_WF_ExecutionPointer_WF_Workflow_WorkflowId", - column: x => x.WorkflowId, - principalTable: "WF_Workflow", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_ExtensionAttribute", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - ExecutionPointerId = table.Column(type: "char(50)", maxLength: 50, nullable: false, collation: "ascii_general_ci"), - Key = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WF_ExtensionAttribute", x => x.Id); - table.ForeignKey( - name: "FK_WF_ExtensionAttribute_WF_ExecutionPointer_ExecutionPointerId", - column: x => x.ExecutionPointerId, - principalTable: "WF_ExecutionPointer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_WF_Event_CreationTime", - table: "WF_Event", - column: "CreationTime"); - - migrationBuilder.CreateIndex( - name: "IX_WF_Event_EventName_EventKey", - table: "WF_Event", - columns: new[] { "EventName", "EventKey" }); - - migrationBuilder.CreateIndex( - name: "IX_WF_Event_IsProcessed", - table: "WF_Event", - column: "IsProcessed"); - - migrationBuilder.CreateIndex( - name: "IX_WF_ExecutionPointer_WorkflowId", - table: "WF_ExecutionPointer", - column: "WorkflowId"); - - migrationBuilder.CreateIndex( - name: "IX_WF_ExtensionAttribute_ExecutionPointerId", - table: "WF_ExtensionAttribute", - column: "ExecutionPointerId"); - - migrationBuilder.CreateIndex( - name: "IX_WF_ScheduledCommand_CommandName_Data", - table: "WF_ScheduledCommand", - columns: new[] { "CommandName", "Data" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_WF_ScheduledCommand_ExecuteTime", - table: "WF_ScheduledCommand", - column: "ExecuteTime"); - - migrationBuilder.CreateIndex( - name: "IX_WF_Subscription_EventKey", - table: "WF_Subscription", - column: "EventKey"); - - migrationBuilder.CreateIndex( - name: "IX_WF_Subscription_EventName", - table: "WF_Subscription", - column: "EventName"); - - migrationBuilder.CreateIndex( - name: "IX_WF_Workflow_NextExecution", - table: "WF_Workflow", - column: "NextExecution"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "WF_Compensate"); - - migrationBuilder.DropTable( - name: "WF_Definition"); - - migrationBuilder.DropTable( - name: "WF_Event"); - - migrationBuilder.DropTable( - name: "WF_ExecutionError"); - - migrationBuilder.DropTable( - name: "WF_ExtensionAttribute"); - - migrationBuilder.DropTable( - name: "WF_ScheduledCommand"); - - migrationBuilder.DropTable( - name: "WF_Step"); - - migrationBuilder.DropTable( - name: "WF_Subscription"); - - migrationBuilder.DropTable( - name: "WF_ExecutionPointer"); - - migrationBuilder.DropTable( - name: "WF_Workflow"); - } - } -} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.Designer.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.Designer.cs deleted file mode 100644 index 5214e38aa..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.Designer.cs +++ /dev/null @@ -1,610 +0,0 @@ -// -using System; -using LY.MicroService.WorkflowManagement.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Volo.Abp.EntityFrameworkCore; - -#nullable disable - -namespace LY.MicroService.WorkflowManagement.Migrations -{ - [DbContext(typeof(WorkflowManagementMigrationsDbContext))] - [Migration("20211214085456_Add-Entity-Workflow-Data-With-WF-Management")] - partial class AddEntityWorkflowDataWithWFManagement - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("IsProcessed") - .HasColumnType("tinyint(1)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("CreationTime"); - - b.HasIndex("IsProcessed"); - - b.HasIndex("EventName", "EventKey"); - - b.ToTable("WF_Event", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionError", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ErrorTime") - .HasColumnType("datetime(6)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Message") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_ExecutionError", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Active") - .HasColumnType("tinyint(1)"); - - b.Property("Children") - .HasColumnType("longtext"); - - b.Property("ContextItem") - .HasColumnType("longtext"); - - b.Property("EndTime") - .HasColumnType("datetime(6)"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventPublished") - .HasColumnType("tinyint(1)"); - - b.Property("Outcome") - .HasColumnType("longtext"); - - b.Property("PersistenceData") - .HasColumnType("longtext"); - - b.Property("PredecessorId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("RetryCount") - .HasColumnType("int"); - - b.Property("Scope") - .HasColumnType("longtext"); - - b.Property("SleepUntil") - .HasColumnType("datetime(6)"); - - b.Property("StartTime") - .HasColumnType("datetime(6)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("StepName") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("WorkflowId"); - - b.ToTable("WF_ExecutionPointer", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Key") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ExecutionPointerId"); - - b.ToTable("WF_ExtensionAttribute", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedScheduledCommand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("CommandName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Data") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExecuteTime") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("ExecuteTime"); - - b.HasIndex("CommandName", "Data") - .IsUnique(); - - b.ToTable("WF_ScheduledCommand", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("ExternalToken") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExternalTokenExpiry") - .HasColumnType("datetime(6)"); - - b.Property("ExternalWorkerId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("SubscribeAsOf") - .HasColumnType("datetime(6)"); - - b.Property("SubscriptionData") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("EventKey"); - - b.HasIndex("EventName"); - - b.ToTable("WF_Subscription", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CompleteTime") - .HasColumnType("datetime(6)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Data") - .HasColumnType("longtext"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("NextExecution") - .HasColumnType("bigint"); - - b.Property("Reference") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.Property("WorkflowDefinitionId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("NextExecution"); - - b.ToTable("WF_Workflow", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.CompensateNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Compensate", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.StepNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Step", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.Workflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Description") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("DisplayName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("ErrorRetryInterval") - .HasColumnType("time(6)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("IsEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WF_Definition", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.WorkflowData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("DataType") - .HasColumnType("int"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("IsCaseSensitive") - .HasColumnType("tinyint(1)"); - - b.Property("IsRequired") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("WorkflowId"); - - b.ToTable("WF_DefinitionData", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", "Workflow") - .WithMany("ExecutionPointers") - .HasForeignKey("WorkflowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Workflow"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", "ExecutionPointer") - .WithMany("ExtensionAttributes") - .HasForeignKey("ExecutionPointerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExecutionPointer"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.WorkflowData", b => - { - b.HasOne("LINGYUN.Abp.WorkflowManagement.Workflow", null) - .WithMany("Datas") - .HasForeignKey("WorkflowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Navigation("ExtensionAttributes"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Navigation("ExecutionPointers"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.Workflow", b => - { - b.Navigation("Datas"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.cs deleted file mode 100644 index 07ee32061..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/20211214085456_Add-Entity-Workflow-Data-With-WF-Management.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LY.MicroService.WorkflowManagement.Migrations -{ - public partial class AddEntityWorkflowDataWithWFManagement : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_Subscription", - type: "char(50)", - maxLength: 50, - nullable: false, - collation: "ascii_general_ci", - oldClrType: typeof(string), - oldType: "char(50)", - oldMaxLength: 50) - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_ExtensionAttribute", - type: "char(50)", - maxLength: 50, - nullable: false, - collation: "ascii_general_ci", - oldClrType: typeof(string), - oldType: "char(50)", - oldMaxLength: 50) - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "WF_ExecutionPointer", - type: "char(50)", - maxLength: 50, - nullable: false, - collation: "ascii_general_ci", - oldClrType: typeof(string), - oldType: "char(50)", - oldMaxLength: 50) - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_ExecutionError", - type: "char(50)", - maxLength: 50, - nullable: false, - collation: "ascii_general_ci", - oldClrType: typeof(string), - oldType: "char(50)", - oldMaxLength: 50) - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WF_DefinitionData", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - WorkflowId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DataType = table.Column(type: "int", nullable: false), - IsRequired = table.Column(type: "tinyint(1)", nullable: false), - IsCaseSensitive = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WF_DefinitionData", x => x.Id); - table.ForeignKey( - name: "FK_WF_DefinitionData_WF_Definition_WorkflowId", - column: x => x.WorkflowId, - principalTable: "WF_Definition", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_WF_DefinitionData_WorkflowId", - table: "WF_DefinitionData", - column: "WorkflowId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "WF_DefinitionData"); - - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_Subscription", - type: "char(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(Guid), - oldType: "char(50)", - oldMaxLength: 50) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_ExtensionAttribute", - type: "char(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(Guid), - oldType: "char(50)", - oldMaxLength: 50) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "WF_ExecutionPointer", - type: "char(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(Guid), - oldType: "char(50)", - oldMaxLength: 50) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AlterColumn( - name: "ExecutionPointerId", - table: "WF_ExecutionError", - type: "char(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(Guid), - oldType: "char(50)", - oldMaxLength: 50) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - } - } -} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/WorkflowManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/WorkflowManagementMigrationsDbContextModelSnapshot.cs deleted file mode 100644 index f39be2376..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Migrations/WorkflowManagementMigrationsDbContextModelSnapshot.cs +++ /dev/null @@ -1,608 +0,0 @@ -// -using System; -using LY.MicroService.WorkflowManagement.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Volo.Abp.EntityFrameworkCore; - -#nullable disable - -namespace LY.MicroService.WorkflowManagement.Migrations -{ - [DbContext(typeof(WorkflowManagementMigrationsDbContext))] - partial class WorkflowManagementMigrationsDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("IsProcessed") - .HasColumnType("tinyint(1)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("CreationTime"); - - b.HasIndex("IsProcessed"); - - b.HasIndex("EventName", "EventKey"); - - b.ToTable("WF_Event", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionError", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ErrorTime") - .HasColumnType("datetime(6)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Message") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_ExecutionError", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Active") - .HasColumnType("tinyint(1)"); - - b.Property("Children") - .HasColumnType("longtext"); - - b.Property("ContextItem") - .HasColumnType("longtext"); - - b.Property("EndTime") - .HasColumnType("datetime(6)"); - - b.Property("EventData") - .HasColumnType("longtext"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventPublished") - .HasColumnType("tinyint(1)"); - - b.Property("Outcome") - .HasColumnType("longtext"); - - b.Property("PersistenceData") - .HasColumnType("longtext"); - - b.Property("PredecessorId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("RetryCount") - .HasColumnType("int"); - - b.Property("Scope") - .HasColumnType("longtext"); - - b.Property("SleepUntil") - .HasColumnType("datetime(6)"); - - b.Property("StartTime") - .HasColumnType("datetime(6)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("StepName") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("WorkflowId"); - - b.ToTable("WF_ExecutionPointer", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("Key") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ExecutionPointerId"); - - b.ToTable("WF_ExtensionAttribute", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedScheduledCommand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("CommandName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Data") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExecuteTime") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("ExecuteTime"); - - b.HasIndex("CommandName", "Data") - .IsUnique(); - - b.ToTable("WF_ScheduledCommand", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("EventKey") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("EventName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExecutionPointerId") - .HasMaxLength(50) - .HasColumnType("char(50)"); - - b.Property("ExternalToken") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ExternalTokenExpiry") - .HasColumnType("datetime(6)"); - - b.Property("ExternalWorkerId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("StepId") - .HasColumnType("int"); - - b.Property("SubscribeAsOf") - .HasColumnType("datetime(6)"); - - b.Property("SubscriptionData") - .HasColumnType("longtext"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("EventKey"); - - b.HasIndex("EventName"); - - b.ToTable("WF_Subscription", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CompleteTime") - .HasColumnType("datetime(6)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Data") - .HasColumnType("longtext"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("NextExecution") - .HasColumnType("bigint"); - - b.Property("Reference") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.Property("WorkflowDefinitionId") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("NextExecution"); - - b.ToTable("WF_Workflow", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.CompensateNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Compensate", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.StepNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CancelCondition") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("Inputs") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Outputs") - .HasColumnType("longtext"); - - b.Property("ParentId") - .HasColumnType("char(36)"); - - b.Property("RetryInterval") - .HasColumnType("time(6)"); - - b.Property("Saga") - .HasColumnType("tinyint(1)"); - - b.Property("SelectNextStep") - .HasColumnType("longtext"); - - b.Property("StepType") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("WF_Step", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.Workflow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); - - b.Property("Description") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("DisplayName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("ErrorBehavior") - .HasColumnType("int"); - - b.Property("ErrorRetryInterval") - .HasColumnType("time(6)"); - - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); - - b.Property("IsEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("Version") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WF_Definition", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.WorkflowData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("DataType") - .HasColumnType("int"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("IsCaseSensitive") - .HasColumnType("tinyint(1)"); - - b.Property("IsRequired") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("WorkflowId") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("WorkflowId"); - - b.ToTable("WF_DefinitionData", (string)null); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", "Workflow") - .WithMany("ExecutionPointers") - .HasForeignKey("WorkflowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Workflow"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExtensionAttribute", b => - { - b.HasOne("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", "ExecutionPointer") - .WithMany("ExtensionAttributes") - .HasForeignKey("ExecutionPointerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExecutionPointer"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.WorkflowData", b => - { - b.HasOne("LINGYUN.Abp.WorkflowManagement.Workflow", null) - .WithMany("Datas") - .HasForeignKey("WorkflowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedExecutionPointer", b => - { - b.Navigation("ExtensionAttributes"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowCore.Persistence.PersistedWorkflow", b => - { - b.Navigation("ExecutionPointers"); - }); - - modelBuilder.Entity("LINGYUN.Abp.WorkflowManagement.Workflow", b => - { - b.Navigation("Datas"); - }); -#pragma warning restore 612, 618 - } - } -} From 6d911edcd172b1cb208b7a6a082982f05c9d6e7c Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:45:48 +0800 Subject: [PATCH 19/26] remove Microsoft.EntityFrameworkCore.Tools package from start the project --- ...icroService.AuthServer.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- .../AuthServerMigrationsDbContextFactory.cs | 29 ----------------- .../LY.MicroService.AuthServer.csproj | 4 --- .../LY.MicroService.AuthServer/Program.cs | 6 ---- .../BackendAdminMigrationsDbContextFactory.cs | 30 ----------------- ...roService.BackendAdmin.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...ionManagementMigrationsDbContextFactory.cs | 30 ----------------- ...LocalizationManagement.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...ormManagementMigrationsDbContextFactory.cs | 29 ----------------- ...ice.PlatformManagement.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...altimeMessageMigrationsDbContextFactory.cs | 30 ----------------- ...ervice.RealtimeMessage.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...askManagementMigrationsDbContextFactory.cs | 30 ----------------- ...Service.TaskManagement.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...oksManagementMigrationsDbContextFactory.cs | 32 ------------------- ...ice.WebhooksManagement.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...ice.WorkflowManagement.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...Service.identityServer.HttpApi.Host.csproj | 4 --- .../Program.cs | 6 ---- ...entityServertMigrationsDbContextFactory.cs | 29 ----------------- .../LY.MicroService.IdentityServer.csproj | 4 --- .../LY.MicroService.identityServer/Program.cs | 6 ---- 30 files changed, 349 deletions(-) delete mode 100644 aspnet-core/services/LY.MicroService.AuthServer/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/EntityFrameworkCore/PlatformManagementMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs delete mode 100644 aspnet-core/services/LY.MicroService.identityServer/EntityFrameworkCore/IdentityServertMigrationsDbContextFactory.cs diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj index a547aff4f..f739271bd 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj @@ -10,10 +10,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs index 2775d4256..08d7ce10a 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.AuthServer/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.AuthServer/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs deleted file mode 100644 index e633ffec3..000000000 --- a/aspnet-core/services/LY.MicroService.AuthServer/EntityFrameworkCore/AuthServerMigrationsDbContextFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.AuthServer.EntityFrameworkCore; - -public class AuthServerMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public AuthServerMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new AuthServerMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj index 775483dde..72f138d6b 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj @@ -24,10 +24,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.AuthServer/Program.cs b/aspnet-core/services/LY.MicroService.AuthServer/Program.cs index ff28b72df..4fb8e18ed 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/Program.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs deleted file mode 100644 index afd271840..000000000 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContextFactory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; - -namespace LY.MicroService.BackendAdmin.EntityFrameworkCore; - -public class BackendAdminMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public BackendAdminMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new BackendAdminMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj index b661f31cb..3da5478ef 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj @@ -14,10 +14,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs index 5a261d41a..a00fed23c 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs @@ -55,12 +55,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs deleted file mode 100644 index 4d5e9382e..000000000 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/EntityFrameworkCore/LocalizationManagementMigrationsDbContextFactory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.LocalizationManagement.EntityFrameworkCore -{ - public class LocalizationManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory - { - public LocalizationManagementMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new LocalizationManagementMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } - } -} diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj index e6b386858..943087712 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj @@ -10,10 +10,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs index d4c95df2f..ac8e4e347 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/EntityFrameworkCore/PlatformManagementMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/EntityFrameworkCore/PlatformManagementMigrationsDbContextFactory.cs deleted file mode 100644 index aca45745f..000000000 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/EntityFrameworkCore/PlatformManagementMigrationsDbContextFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.IO; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; - -namespace LY.MicroService.PlatformManagement.EntityFrameworkCore; - -public class PlatformManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public PlatformManagementMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new PlatformManagementMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj index e1ee24ec4..e55a39583 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj @@ -10,10 +10,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs index 445819ec5..023d63470 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs deleted file mode 100644 index 9095ef26b..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EntityFrameworkCore/RealtimeMessageMigrationsDbContextFactory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.RealtimeMessage.EntityFrameworkCore -{ - public class RealtimeMessageMigrationsDbContextFactory : IDesignTimeDbContextFactory - { - public RealtimeMessageMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new RealtimeMessageMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } - } -} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index 0e067d558..4d21ca581 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -14,10 +14,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs index c63c8ebd8..819f9fba7 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs deleted file mode 100644 index 7ef7887cc..000000000 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EntityFrameworkCore/TaskManagementMigrationsDbContextFactory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.TaskManagement.EntityFrameworkCore; - -public class TaskManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public TaskManagementMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("TaskManagement"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new TaskManagementMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false) - .AddJsonFile("appsettings.Development.json", optional: true); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj index 745d7593b..77b9cfef0 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj @@ -22,10 +22,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs index 6926956e0..c128e7393 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs deleted file mode 100644 index 88755770b..000000000 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/EntityFrameworkCore/WebhooksManagementMigrationsDbContextFactory.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.WebhooksManagement.EntityFrameworkCore; - -public class WebhooksManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public WebhooksManagementMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("WebhooksManagement"); - - DbContextOptionsBuilder builder = null; - - builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new WebhooksManagementMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false) - .AddJsonFile("appsettings.Development.json", optional: true); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj index 85a334ca8..e6240579d 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj @@ -11,10 +11,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs index 97a4ef925..0b48c72e9 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj index 3f6264345..0a0d24f71 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj @@ -18,10 +18,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs index d77acded8..41aef61b2 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj index 334030ab2..fddf04ef2 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj @@ -18,10 +18,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs index 403f33f9a..572f802aa 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); diff --git a/aspnet-core/services/LY.MicroService.identityServer/EntityFrameworkCore/IdentityServertMigrationsDbContextFactory.cs b/aspnet-core/services/LY.MicroService.identityServer/EntityFrameworkCore/IdentityServertMigrationsDbContextFactory.cs deleted file mode 100644 index e7fbfcb48..000000000 --- a/aspnet-core/services/LY.MicroService.identityServer/EntityFrameworkCore/IdentityServertMigrationsDbContextFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace LY.MicroService.IdentityServer.EntityFrameworkCore; - -public class IdentityServertMigrationsDbContextFactory : IDesignTimeDbContextFactory -{ - public IdentityServertMigrationsDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - var connectionString = configuration.GetConnectionString("Default"); - - var builder = new DbContextOptionsBuilder() - .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); - - return new IdentityServertMigrationsDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.Development.json", optional: false); - - return builder.Build(); - } -} diff --git a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj index 75ded82c0..ef7fa1c3b 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj @@ -24,10 +24,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/aspnet-core/services/LY.MicroService.identityServer/Program.cs b/aspnet-core/services/LY.MicroService.identityServer/Program.cs index 7e229f95e..b7f1f9f0d 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/Program.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/Program.cs @@ -54,12 +54,6 @@ public class Program } catch (Exception ex) { - var type = ex.GetType().Name; - if (type.Equals("StopTheHostException", StringComparison.Ordinal)) - { - throw; - } - Log.Fatal(ex, "Host terminated unexpectedly!"); Console.WriteLine("Host terminated unexpectedly!"); Console.WriteLine(ex.ToString()); From 2e0f9e3413cabe9ab1b9ec2eec236607db50cea5 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:48:26 +0800 Subject: [PATCH 20/26] agile config is disabled by default --- .../appsettings.Development.json | 2 +- .../appsettings.Development.json | 2 +- .../LY.MicroService.identityServer/appsettings.Development.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json index ffcd82faf..74d17f1f3 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.AuthServer.Admin", "secret": "1q2w3E*", diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.Development.json index 8ca9ad210..a6b151399 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.IdentityServer.Admin", "secret": "1q2w3E*", diff --git a/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json b/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json index 4d7597d38..68c773bec 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json @@ -1,6 +1,6 @@ { "AgileConfig": { - "IsEnabled": true, + "IsEnabled": false, "env": "DEV", "appId": "LINGYUN.Abp.AuthServer", "secret": "1q2w3E*", From 3a0ccc8a82d8123c73678eec277e0b8c2c0f35da Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:52:43 +0800 Subject: [PATCH 21/26] remove AddAlwaysAllowAuthorization --- .../LY.MicroService.AuthServer/AuthServerModule.Configure.cs | 5 +++++ .../LocalizationManagementHttpApiHostModule.Configure.cs | 2 +- .../RealtimeMessageHttpApiHostModule.Configure.cs | 2 +- .../TaskManagementHttpApiHostModule.Configure.cs | 2 +- .../WebhooksManagementHttpApiHostModule.Configure.cs | 2 +- .../WorkflowManagementHttpApiHostModule.Configure.cs | 2 +- .../IdentityServerHttpApiHostModule.Configure.cs | 5 +++++ .../IdentityServerModule.Configure.cs | 5 +++++ 8 files changed, 20 insertions(+), 5 deletions(-) diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs index a9475e291..10bdbacdf 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -280,6 +280,11 @@ public partial class AuthServerModule // options.Audience = configuration["AuthServer:ApiName"]; // }); + if (isDevelopment) + { + // services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index f3b306d68..9a68a4698 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -258,7 +258,7 @@ public partial class LocalizationManagementHttpApiHostModule if (isDevelopment) { - services.AddAlwaysAllowAuthorization(); + // services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index d3ae2dacd..f7cdfd09d 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -348,7 +348,7 @@ public partial class RealtimeMessageHttpApiHostModule if (isDevelopment) { - services.AddAlwaysAllowAuthorization(); + // services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs index fb20e263b..f60b924ec 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs @@ -292,7 +292,7 @@ public partial class TaskManagementHttpApiHostModule if (isDevelopment) { - services.AddAlwaysAllowAuthorization(); + // services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index 6ceab3ba7..b278692fa 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -316,7 +316,7 @@ public partial class WebhooksManagementHttpApiHostModule if (isDevelopment) { - services.AddAlwaysAllowAuthorization(); + // services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs index 12ed161d5..53b47a7a2 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs @@ -383,7 +383,7 @@ public partial class WorkflowManagementHttpApiHostModule if (isDevelopment) { - services.AddAlwaysAllowAuthorization(); + // services.AddAlwaysAllowAuthorization(); } if (!isDevelopment) diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs index ac84ba3ce..5220cc915 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs @@ -312,6 +312,11 @@ public partial class IdentityServerHttpApiHostModule options.Audience = configuration["AuthServer:ApiName"]; }); + if (isDevelopment) + { + // services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs index bbd187310..555f0e4fd 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs @@ -219,6 +219,11 @@ public partial class IdentityServerModule options.Audience = configuration["AuthServer:ApiName"]; }); + if (isDevelopment) + { + // services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); From 0863ad444d76ab6ecca05104626545f2e52e7855 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:25:19 +0800 Subject: [PATCH 22/26] enabled DynamicFeatureStore --- aspnet-core/LINGYUN.MicroService.All.sln | 2 +- .../Properties/launchSettings.json | 27 ------------------- .../AbpNotificationsManagementOptions.cs | 7 ++++- .../Properties/launchSettings.json | 12 --------- .../Properties/launchSettings.json | 12 --------- .../DynamicWebhookDefinitionStore.cs | 4 +-- .../WebhooksManagementDomainModule.cs | 8 +++--- ...ptions.cs => WebhooksManagementOptions.cs} | 5 ++-- .../AuthServerHttpApiHostModule.Configure.cs | 9 +++++++ .../AuthServerHttpApiHostModule.cs | 3 +++ ...icroService.AuthServer.HttpApi.Host.csproj | 1 + .../AuthServerModule.Configure.cs | 9 +++++++ .../AuthServerModule.cs | 1 + ...BackendAdminHttpApiHostModule.Configure.cs | 2 ++ ...LocalizationManagement.HttpApi.Host.csproj | 1 + ...onManagementHttpApiHostModule.Configure.cs | 9 +++++++ ...LocalizationManagementHttpApiHostModule.cs | 3 +++ ...rmManagementHttpApiHostModule.Configure.cs | 9 +++++++ .../PlatformManagementHttpApiHostModule.cs | 1 + ...ltimeMessageHttpApiHostModule.Configure.cs | 19 +++++++++++++ .../RealtimeMessageHttpApiHostModule.cs | 2 ++ ...skManagementHttpApiHostModule.Configure.cs | 9 +++++++ .../TaskManagementHttpApiHostModule.cs | 1 + ...ksManagementHttpApiHostModule.Configure.cs | 24 +++++++++++++++++ .../WebhooksManagementHttpApiHostModule.cs | 18 +++++-------- .../WorkflowManagementHttpApiHostModule.cs | 1 - ...entityServerHttpApiHostModule.Configure.cs | 9 +++++++ .../IdentityServerHttpApiHostModule.cs | 1 + ...Service.identityServer.HttpApi.Host.csproj | 1 + .../IdentityServerModule.Configure.cs | 9 +++++++ .../IdentityServerModule.cs | 1 + .../Properties/launchSettings.json | 8 ------ 32 files changed, 146 insertions(+), 82 deletions(-) delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/Properties/launchSettings.json delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json delete mode 100644 aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json rename aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/{WebhookManagementOptions.cs => WebhooksManagementOptions.cs} (86%) delete mode 100644 aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/Properties/launchSettings.json diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 1be7d20b1..ebefea6f9 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -547,7 +547,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.HttpApi", "modules\notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj", "{EFC5C34F-81A1-4EFC-966F-50B646C54FA6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Localization.Persistence", "modules\localization\LINGYUN.Abp.Localization.Persistence\LINGYUN.Abp.Localization.Persistence.csproj", "{42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Persistence", "modules\localization\LINGYUN.Abp.Localization.Persistence\LINGYUN.Abp.Localization.Persistence.csproj", "{42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/Properties/launchSettings.json b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/Properties/launchSettings.json deleted file mode 100644 index 7cd042c63..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Client/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:41514/", - "sslPort": 44331 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "LINGYUN.Abp.AspNetCore.Mvc.Client": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs index 70ddb801d..b0f0d828d 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/AbpNotificationsManagementOptions.cs @@ -4,7 +4,13 @@ namespace LINGYUN.Abp.Notifications; public class AbpNotificationsManagementOptions { + /// + /// Default: true. + /// public bool SaveStaticNotificationsToDatabase { get; set; } + /// + /// Default: false. + /// public bool IsDynamicNotificationsStoreEnabled { get; set; } /// /// 缓存刷新时间 @@ -24,7 +30,6 @@ public class AbpNotificationsManagementOptions public AbpNotificationsManagementOptions() { SaveStaticNotificationsToDatabase = true; - IsDynamicNotificationsStoreEnabled = true; NotificationsCacheRefreshInterval = TimeSpan.FromSeconds(30); NotificationsCacheStampTimeOut = TimeSpan.FromMinutes(2); diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json deleted file mode 100644 index 5cb98d623..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "LINGYUN.Abp.OssManagement.Tencent": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:58740;http://localhost:58741" - } - } -} \ No newline at end of file diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json deleted file mode 100644 index 9959c3f46..000000000 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "LINGYUN.Abp.MultiTenancy.Saas": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:58776;http://localhost:58777" - } - } -} \ No newline at end of file diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs index 126c720c7..2ae65ead3 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs @@ -22,7 +22,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr protected IDynamicWebhookDefinitionStoreCache StoreCache { get; } protected IDistributedCache DistributedCache { get; } protected IAbpDistributedLock DistributedLock { get; } - protected WebhookManagementOptions WebhookManagementOptions { get; } + protected WebhooksManagementOptions WebhookManagementOptions { get; } protected AbpDistributedCacheOptions CacheOptions { get; } public DynamicWebhookDefinitionStore( @@ -32,7 +32,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr IDynamicWebhookDefinitionStoreCache storeCache, IDistributedCache distributedCache, IOptions cacheOptions, - IOptions webhookManagementOptions, + IOptions webhookManagementOptions, IAbpDistributedLock distributedLock) { WebhookGroupRepository = webhookGroupRepository; diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs index 9b1c7f446..1ed8d8d40 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementDomainModule.cs @@ -49,7 +49,7 @@ public class WebhooksManagementDomainModule : AbpModule if (context.Services.IsDataMigrationEnvironment()) { - Configure(options => + Configure(options => { options.SaveStaticWebhooksToDatabase = false; options.IsDynamicWebhookStoreEnabled = false; @@ -111,7 +111,7 @@ public class WebhooksManagementDomainModule : AbpModule { var options = context .ServiceProvider - .GetRequiredService>() + .GetRequiredService>() .Value; if (!options.SaveStaticWebhooksToDatabase && !options.IsDynamicWebhookStoreEnabled) @@ -153,7 +153,7 @@ public class WebhooksManagementDomainModule : AbpModule } private async static Task SaveStaticWebhooksToDatabaseAsync( - WebhookManagementOptions options, + WebhooksManagementOptions options, IServiceScope scope, ICancellationTokenProvider cancellationTokenProvider) { @@ -187,7 +187,7 @@ public class WebhooksManagementDomainModule : AbpModule }, cancellationTokenProvider.Token); } - private async static Task PreCacheDynamicWebhooksAsync(WebhookManagementOptions options, IServiceScope scope) + private async static Task PreCacheDynamicWebhooksAsync(WebhooksManagementOptions options, IServiceScope scope) { if (!options.IsDynamicWebhookStoreEnabled) { diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementOptions.cs similarity index 86% rename from aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs rename to aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementOptions.cs index 1cdac2185..3f77f6ffc 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookManagementOptions.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhooksManagementOptions.cs @@ -1,7 +1,7 @@ using System; namespace LINGYUN.Abp.WebhooksManagement; -public class WebhookManagementOptions +public class WebhooksManagementOptions { /// /// Default: true. @@ -26,9 +26,8 @@ public class WebhookManagementOptions /// default: 30 minutes /// public TimeSpan WebhooksCacheStampExpiration { get; set; } - public WebhookManagementOptions() + public WebhooksManagementOptions() { - IsDynamicWebhookStoreEnabled = true; SaveStaticWebhooksToDatabase = true; WebhooksCacheRefreshInterval = TimeSpan.FromSeconds(30); diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs index a9bf5ca33..68d7528c7 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs @@ -24,6 +24,7 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.Caching; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -112,6 +113,14 @@ public partial class AuthServerHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigurePermissionManagement() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs index fadd89a68..6fd04ba1a 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs @@ -24,6 +24,7 @@ using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.Modularity; using Volo.Abp.OpenIddict.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore; @@ -47,6 +48,7 @@ namespace LY.MicroService.AuthServer; typeof(AbpOpenIddictEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), @@ -82,6 +84,7 @@ public partial class AuthServerHttpApiHostModule : AbpModule ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigurePermissionManagement(); ConfigureUrls(configuration); ConfigureCaching(configuration); diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj index f739271bd..66c71169f 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj @@ -31,6 +31,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs index 10bdbacdf..85d2e807c 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -24,6 +24,7 @@ using Volo.Abp.Account.Localization; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -172,6 +173,14 @@ public partial class AuthServerModule } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureJsonSerializer() { // 统一时间日期格式 diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs index ab8e6ba32..4753ceeab 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs @@ -97,6 +97,7 @@ public partial class AuthServerModule : AbpModule ConfigureCaching(configuration); ConfigureIdentity(configuration); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureLocalization(); ConfigureDataSeeder(); ConfigureUrls(configuration); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs index ef9943f4d..6211c845e 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs @@ -96,6 +96,8 @@ public partial class BackendAdminHttpApiHostModule { options.ProviderPolicies[EditionFeatureValueProvider.ProviderName] = AbpSaasPermissions.Editions.ManageFeatures; options.ProviderPolicies[TenantFeatureValueProvider.ProviderName] = AbpSaasPermissions.Tenants.ManageFeatures; + + options.IsDynamicFeatureStoreEnabled = true; }); } diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj index 943087712..30e3b0329 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj @@ -26,6 +26,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index 9a68a4698..fd4f31285 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -20,6 +20,7 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -84,6 +85,14 @@ public partial class LocalizationManagementHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureJsonSerializer() { // 统一时间日期格式 diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs index c58e879bb..7f37984bc 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs @@ -23,6 +23,7 @@ using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; @@ -40,6 +41,7 @@ namespace LY.MicroService.LocalizationManagement typeof(AbpLocalizationManagementEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), @@ -75,6 +77,7 @@ namespace LY.MicroService.LocalizationManagement ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureSwagger(context.Services); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs index ce2ef05f6..537f7a854 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs @@ -25,6 +25,7 @@ using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -88,6 +89,14 @@ public partial class PlatformManagementHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureJsonSerializer() { // 统一时间日期格式 diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs index a4ecd9b1d..f7dbb4567 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs @@ -109,6 +109,7 @@ public partial class PlatformManagementHttpApiHostModule : AbpModule ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureSwagger(context.Services); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index f7cdfd09d..ce63cc9c7 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -3,6 +3,7 @@ using LINGYUN.Abp.BackgroundTasks; using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.MessageService.Localization; +using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LY.MicroService.RealtimeMessage.BackgroundJobs; @@ -26,6 +27,7 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -126,6 +128,14 @@ public partial class RealtimeMessageHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureJsonSerializer() { // 统一时间日期格式 @@ -217,6 +227,15 @@ public partial class RealtimeMessageHttpApiHostModule }); } + private void ConfigureNotifications() + { + Configure(options => + { + // 宿主项目启用动态通知 + options.IsDynamicNotificationsStoreEnabled = true; + }); + } + private void ConfigureMultiTenancy(IConfiguration configuration) { // 多租户 diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index c5181b437..0b538013b 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -121,10 +121,12 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); + ConfigureNotifications(); ConfigureJsonSerializer(); ConfigureBackgroundTasks(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureSwagger(context.Services); diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs index f60b924ec..c541b3f63 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs @@ -23,6 +23,7 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -114,6 +115,14 @@ public partial class TaskManagementHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureDistributedLock(IServiceCollection services, IConfiguration configuration) { var redis = ConnectionMultiplexer.Connect(configuration["DistributedLock:Redis:Configuration"]); diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs index b69663ef5..e6d7eaa3b 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs @@ -100,6 +100,7 @@ public partial class TaskManagementHttpApiHostModule : AbpModule ConfigureBackgroundTasks(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index b278692fa..1871e9ea9 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -4,6 +4,8 @@ using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; +using LINGYUN.Abp.Webhooks; +using LINGYUN.Abp.WebhooksManagement; using LINGYUN.Abp.Wrapper; using Medallion.Threading; using Medallion.Threading.Redis; @@ -12,6 +14,7 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Caching.StackExchangeRedis; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.OpenApi.Models; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -25,6 +28,7 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; @@ -294,6 +298,26 @@ public partial class WebhooksManagementHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + + private void ConfigureWebhooks(IServiceCollection services) + { + Configure(options => + { + // 宿主应用中启用动态webhook + options.IsDynamicWebhookStoreEnabled = true; + }); + + // 宿主应用中使用默认发布者 + services.Replace(ServiceDescriptor.Transient()); + } + private void ConfigureLocalization() { // 支持本地化语言类型 diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs index 6fd69c944..05c6ad7a8 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs @@ -1,18 +1,20 @@ -using DotNetCore.CAP; -using LINGYUN.Abp.AspNetCore.Mvc.Localization; +using LINGYUN.Abp.AspNetCore.Mvc.Localization; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; -using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; +using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; using LINGYUN.Abp.BackgroundTasks.Quartz; +using LINGYUN.Abp.Dapr.Client.Wrapper; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; +using LINGYUN.Abp.Http.Client.Wrapper; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; +using LINGYUN.Abp.Webhooks.EventBus; using LINGYUN.Abp.Webhooks.Identity; using LINGYUN.Abp.Webhooks.Saas; using LINGYUN.Abp.WebhooksManagement; @@ -35,11 +37,6 @@ using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.Swashbuckle; -using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Dapr.Client.Wrapper; -using Microsoft.Extensions.DependencyInjection.Extensions; -using LINGYUN.Abp.Webhooks; -using LINGYUN.Abp.Webhooks.EventBus; namespace LY.MicroService.WebhooksManagement; @@ -103,17 +100,16 @@ public partial class WebhooksManagementHttpApiHostModule : AbpModule ConfigureBackgroundTasks(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); + ConfigureWebhooks(context.Services); ConfigureOpenTelemetry(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); - - // 分布式事件发布者不在这个项目使用, 强制替换 - context.Services.Replace(ServiceDescriptor.Transient()); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs index c9309d141..c98b31cce 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs @@ -112,7 +112,6 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule ConfigureCors(context.Services, configuration); ConfigureBlobStoring(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); - ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); context.Services.AddRazorPages(); diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs index 5220cc915..bbcdccb6e 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs @@ -23,6 +23,7 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.Caching; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.Identity.Localization; using Volo.Abp.Json; @@ -111,6 +112,14 @@ public partial class IdentityServerHttpApiHostModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigurePermissionManagement() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs index 865c20707..07ba75184 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs @@ -84,6 +84,7 @@ public partial class IdentityServerHttpApiHostModule : AbpModule ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigurePermissionManagement(); ConfigureUrls(configuration); ConfigureCaching(configuration); diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj index fddf04ef2..94c13e1a4 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj @@ -38,6 +38,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs index 555f0e4fd..4bba3d848 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs @@ -23,6 +23,7 @@ using Volo.Abp.Account.Localization; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; using Volo.Abp.GlobalFeatures; using Volo.Abp.IdentityServer; using Volo.Abp.Json; @@ -120,6 +121,14 @@ public partial class IdentityServerModule }); } + private void ConfigureFeatureManagement() + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + private void ConfigureJsonSerializer() { // 统一时间日期格式 diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs index 0e4693734..712daf95f 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs @@ -98,6 +98,7 @@ public partial class IdentityServerModule : AbpModule ConfigureCaching(configuration); ConfigureIdentity(configuration); ConfigureVirtualFileSystem(); + ConfigureFeatureManagement(); ConfigureLocalization(); ConfigureAuditing(); ConfigureDataSeeder(); diff --git a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/Properties/launchSettings.json b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/Properties/launchSettings.json deleted file mode 100644 index 8aa9e542e..000000000 --- a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "WSL": { - "commandName": "WSL2", - "distributionName": "" - } - } -} \ No newline at end of file From 7d8101e5945b16230067bcfb3423011d9f507568 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:27:52 +0800 Subject: [PATCH 23/26] add dependson AbpFeatureManagementEntityFrameworkCoreModule --- .../IdentityServerHttpApiHostModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs index 07ba75184..65bb3a130 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs @@ -24,6 +24,7 @@ using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; @@ -46,6 +47,7 @@ namespace LY.MicroService.IdentityServer; typeof(LINGYUN.Abp.IdentityServer.EntityFrameworkCore.AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpSaasEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), From ee3a5bd5deecd4fe83d03e4050d118f7061988e0 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:41:01 +0800 Subject: [PATCH 24/26] fix(saas): fixed failure to query tenant list when not associated with edition --- .../RealtimeMessageMigrationsDbContext.cs | 1 + ...pNotificationsEntityFrameworkCoreModule.cs | 11 ++++-- ...ficationDefinitionGroupRecordRepository.cs | 4 +-- ...eNotificationDefinitionRecordRepository.cs | 4 +-- .../INotificationsDefinitionDbContext.cs | 11 ++++++ ...cationsDbContextModelCreatingExtensions.cs | 19 ++++++++-- .../NotificationsDefinitionDbContext.cs | 23 ++++++++++++ .../EfCoreTenantRepository.cs | 36 ++++++++++++------- .../Saas/EntityFrameworkCore/SaasDbContext.cs | 2 ++ 9 files changed, 90 insertions(+), 21 deletions(-) create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs create mode 100644 aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs diff --git a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs index 245a8bbb7..3b64d1c37 100644 --- a/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs +++ b/aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/EntityFrameworkCore/RealtimeMessageMigrationsDbContext.cs @@ -20,6 +20,7 @@ public class RealtimeMessageMigrationsDbContext : AbpDbContext(); options.AddRepository(); - options.AddRepository(); - options.AddRepository(); options.AddRepository(); options.AddRepository(); }); + + context.Services.AddAbpDbContext(options => + { + options.AddDefaultRepositories(); + + options.AddRepository(); + options.AddRepository(); + }); } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs index fc08242a0..5981de1c9 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionGroupRecordRepository.cs @@ -6,12 +6,12 @@ using Volo.Abp.EntityFrameworkCore; namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; public class EfCoreNotificationDefinitionGroupRecordRepository : - EfCoreRepository, + EfCoreRepository, INotificationDefinitionGroupRecordRepository, ITransientDependency { public EfCoreNotificationDefinitionGroupRecordRepository( - IDbContextProvider dbContextProvider) + IDbContextProvider dbContextProvider) : base(dbContextProvider) { } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs index 65ed69c5c..8686d64a9 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreNotificationDefinitionRecordRepository.cs @@ -6,12 +6,12 @@ using Volo.Abp.EntityFrameworkCore; namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; public class EfCoreNotificationDefinitionRecordRepository : - EfCoreRepository, + EfCoreRepository, INotificationDefinitionRecordRepository, ITransientDependency { public EfCoreNotificationDefinitionRecordRepository( - IDbContextProvider dbContextProvider) + IDbContextProvider dbContextProvider) : base(dbContextProvider) { } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs new file mode 100644 index 000000000..22230257d --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +[IgnoreMultiTenancy] +[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] +public interface INotificationsDefinitionDbContext : IEfCoreDbContext +{ +} diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs index 8e6db1b92..4c5b51d4e 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContextModelCreatingExtensions.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; using System; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; @@ -59,11 +60,26 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore .HasDatabaseName("IX_Tenant_User_Notification_Name") .IsUnique(); }); + } + + public static void ConfigureNotificationsDefinition( + this ModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + if (!builder.IsHostOnlyDatabase()) + { + return; + } + + var options = new AbpNotificationsModelBuilderConfigurationOptions(); + + optionsAction?.Invoke(options); builder.Entity(b => { b.ToTable(options.TablePrefix + "NotificationDefinitionGroups", options.Schema); - b.Property(p => p.Name) .HasMaxLength(NotificationDefinitionGroupRecordConsts.MaxNameLength) .IsRequired(); @@ -79,7 +95,6 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore builder.Entity(b => { b.ToTable(options.TablePrefix + "NotificationDefinitions", options.Schema); - b.Property(p => p.Name) .HasMaxLength(NotificationDefinitionRecordConsts.MaxNameLength) .IsRequired(); diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs new file mode 100644 index 000000000..683382198 --- /dev/null +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; + +[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] +public class NotificationsDefinitionDbContext : AbpDbContext, INotificationsDefinitionDbContext +{ + public NotificationsDefinitionDbContext(DbContextOptions options) + : base(options) + { + } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.SetMultiTenancySide(MultiTenancySides.Host); + + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureNotificationsDefinition(); + } +} diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs index db423ab7d..345999820 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs @@ -175,24 +175,36 @@ public class EfCoreTenantRepository : EfCoreRepository() .IncludeDetails(includeDetails); - var queryable = tenantDbSet + tenantDbSet = tenantDbSet .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.Name.Contains(filter)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(Tenant.Name) : sorting); - var combinedResult = await queryable - .Join( - editionDbSet, - o => o.EditionId, - i => i.Id, - (tenant, edition) => new { tenant, edition }) - .Skip(skipCount) - .Take(maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + var combinedResult = await (from tenant in tenantDbSet + join edition in editionDbSet on tenant.EditionId equals edition.Id + into eg from e in eg.DefaultIfEmpty() + select new + { + Tenant = tenant, + Edition = e, + }) + .Skip(skipCount) + .Take(maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + + //var combinedResult = await tenantDbSet + // .Join( + // editionDbSet, + // o => o.EditionId, + // i => i.Id, + // (tenant, edition) => new { tenant, edition }) + // .Skip(skipCount) + // .Take(maxResultCount) + // .ToListAsync(GetCancellationToken(cancellationToken)); return combinedResult.Select(s => { - s.tenant.Edition = s.edition; - return s.tenant; + s.Tenant.Edition = s.Edition; + return s.Tenant; }).ToList(); } diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/SaasDbContext.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/SaasDbContext.cs index b3e9b95f4..abcf2e657 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/SaasDbContext.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/SaasDbContext.cs @@ -24,6 +24,8 @@ public class SaasDbContext : AbpDbContext, ISaasDbContext protected override void OnModelCreating(ModelBuilder builder) { + builder.SetMultiTenancySide(MultiTenancySides.Host); + base.OnModelCreating(builder); builder.ConfigureSaas(); From 98092f05c5660fddeb975eb4a540fc883d6e15b8 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:42:35 +0800 Subject: [PATCH 25/26] add IgnoreMultiTenancyAttribute to NotificationsDefinitionDbContext --- .../EntityFrameworkCore/NotificationsDefinitionDbContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs index 683382198..89a025b20 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs @@ -5,6 +5,7 @@ using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; +[IgnoreMultiTenancy] [ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] public class NotificationsDefinitionDbContext : AbpDbContext, INotificationsDefinitionDbContext { From e7954f63cc333384d239fa6f102b5f98c4189afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=8C?= Date: Sat, 21 Jan 2023 17:38:21 +0800 Subject: [PATCH 26/26] update api endpoint --- apps/vue/src/api/messages/notifications.ts | 10 +++++----- .../ocelot.Development.json | 12 ++++++------ .../ocelot.messages.json | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/vue/src/api/messages/notifications.ts b/apps/vue/src/api/messages/notifications.ts index 74a95060d..23224e65f 100644 --- a/apps/vue/src/api/messages/notifications.ts +++ b/apps/vue/src/api/messages/notifications.ts @@ -8,11 +8,11 @@ import { import { format } from '/@/utils/strings'; enum Api { - GetById = '/api/my-notifilers/{id}', - GetList = '/api/my-notifilers', - GetAssignableNotifiers = '/api/notifilers/assignables', - Read = '/api/my-notifilers/{id}/read', - MarkReadState = '/api/my-notifilers/mark-read-state', + GetById = '/api/notifications/my-notifilers/{id}', + GetList = '/api/notifications/my-notifilers', + GetAssignableNotifiers = '/api/notifications/notifilers/assignables', + Read = '/api/notifications/my-notifilers/{id}/read', + MarkReadState = '/api/notifications/my-notifilers/mark-read-state', } export const markReadState = ( diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.Development.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.Development.json index 2b329698a..cd0c241a5 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.Development.json +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.Development.json @@ -1320,7 +1320,7 @@ "Key": "my-subscribes" }, { - "DownstreamPathTemplate": "/api/notifilers/{everything}", + "DownstreamPathTemplate": "/api/notifications/notifilers/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -1328,7 +1328,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/notifilers/{everything}", + "UpstreamPathTemplate": "/api/notifications/notifilers/{everything}", "UpstreamHttpMethod": [ "GET", "POST" @@ -1353,7 +1353,7 @@ } }, { - "DownstreamPathTemplate": "/api/my-notifilers", + "DownstreamPathTemplate": "/api/notifications/my-notifilers", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -1361,7 +1361,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/my-notifilers", + "UpstreamPathTemplate": "/api/notifications/my-notifilers", "UpstreamHttpMethod": [ "GET" ], "LoadBalancerOptions": { "Type": "RoundRobin" @@ -1383,7 +1383,7 @@ } }, { - "DownstreamPathTemplate": "/api/my-notifilers/{id}", + "DownstreamPathTemplate": "/api/notifications/my-notifilers/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -1391,7 +1391,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/my-notifilers/{id}", + "UpstreamPathTemplate": "/api/notifications/my-notifilers/{id}", "UpstreamHttpMethod": [ "GET", "POST", diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.messages.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.messages.json index eb9fffd10..2042784b6 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.messages.json +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.messages.json @@ -216,7 +216,7 @@ }, // �û�����֪ͨ { - "DownstreamPathTemplate": "/api/my-notifilers/assignables", + "DownstreamPathTemplate": "/api/notifications/my-notifilers/assignables", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -224,7 +224,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/my-notifilers/assignables", + "UpstreamPathTemplate": "/api/notifications/my-notifilers/assignables", "UpstreamHttpMethod": [ "GET" ], "LoadBalancerOptions": { "Type": "RoundRobin" @@ -249,7 +249,7 @@ }, // �û�֪ͨ { - "DownstreamPathTemplate": "/api/my-notifilers", + "DownstreamPathTemplate": "/api/notifications/my-notifilers", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -257,7 +257,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/my-notifilers", + "UpstreamPathTemplate": "/api/notifications/my-notifilers", "UpstreamHttpMethod": [ "GET" ], "LoadBalancerOptions": { "Type": "RoundRobin" @@ -279,7 +279,7 @@ } }, { - "DownstreamPathTemplate": "/api/my-notifilers/{id}", + "DownstreamPathTemplate": "/api/notifications/my-notifilers/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { @@ -287,7 +287,7 @@ "Port": 30020 } ], - "UpstreamPathTemplate": "/api/my-notifilers/{id}", + "UpstreamPathTemplate": "/api/notifications/my-notifilers/{id}", "UpstreamHttpMethod": [ "GET", "POST",