├── .gitignore ├── CoreFramework ├── .template.config │ └── template.json ├── CoreFramework.sln ├── src │ ├── Core.Amazon.S3 │ │ ├── AmazonS3ClientExtensions.cs │ │ ├── AmazonS3ClientFactoryExtensions.cs │ │ ├── AmazonS3ClientHttpClientNameConstants.cs │ │ ├── AmazonS3Module.cs │ │ ├── AmazonS3Options.cs │ │ ├── AmazonS3StorageException.cs │ │ ├── AmazonS3StorageServiceCollectionExtensions.cs │ │ ├── Core.Amazon.S3.csproj │ │ ├── DefaultAmazonS3Builder.cs │ │ ├── DefaultAmazonS3ClientFactory.cs │ │ ├── DefaultTypeClientFactory.cs │ │ ├── IAmazonS3Builder.cs │ │ ├── IAmazonS3ClientFactory.cs │ │ └── ITypeClientFactory.cs │ ├── Core.Application │ │ ├── ApplicationServiceCollectionExtensions.cs │ │ ├── Commands │ │ │ ├── Command.cs │ │ │ └── CommandResult.cs │ │ ├── Core.Application.csproj │ │ ├── CoreApplicationModule.cs │ │ ├── Exceptions │ │ │ └── ValidationException.cs │ │ ├── Queries │ │ │ ├── Query.cs │ │ │ └── QueryResult.cs │ │ └── ValidationRequestPreProcessor.cs │ ├── Core.AspNetCore │ │ ├── ApiResult.cs │ │ ├── ApiResultWrapAttribute.cs │ │ └── Core.AspNetCore.csproj │ ├── Core.Configuration.Dashboard │ │ ├── Core.Configuration.Dashboard.csproj │ │ ├── DashboardEndpointRouteExtensions.cs │ │ ├── DashboardOptions.cs │ │ ├── DashboardOptionsExtensions.cs │ │ ├── DashboardServiceCollectionExtensions.cs │ │ ├── DashboardStaticFileStartupFilter.cs │ │ ├── IDashboardRouteProvider.cs │ │ ├── IMethod.cs │ │ ├── Method.cs │ │ ├── MethodModel.cs │ │ ├── RouteProvider │ │ │ ├── DashboardActionRoute.cs │ │ │ └── DashboardActionRouteProvider.cs │ │ ├── ServerCallHandler.cs │ │ ├── ServiceMethodProviderContext.cs │ │ ├── ServiceRouteBuilder.cs │ │ └── wwwroot │ │ │ └── dist │ │ │ ├── css │ │ │ ├── chunk-1939524c.e374acd7.css │ │ │ ├── chunk-3b55dc7e.3fa8276e.css │ │ │ ├── chunk-7381cc8c.f3976377.css │ │ │ ├── chunk-7592249c.200fdbc3.css │ │ │ ├── chunk-7a1d0272.59c183eb.css │ │ │ ├── chunk-7af68eda.af8c3925.css │ │ │ ├── chunk-7c518a68.587716c5.css │ │ │ ├── chunk-a5f2b902.11c50a80.css │ │ │ ├── chunk-c1fb19f0.8e29003d.css │ │ │ ├── chunk-de3d7390.fa808e46.css │ │ │ ├── chunk-vendors.230de3f5.css │ │ │ ├── chunk-vendors.230de3f5.css.gz │ │ │ └── index.cdb09893.css │ │ │ ├── favicon.ico │ │ │ ├── img │ │ │ ├── boxShadow.51818d84.png │ │ │ ├── login_bg.993b9c92.png │ │ │ ├── login_footer.0402bdb6.png │ │ │ ├── logoTitleNew.201b37cb.png │ │ │ └── pieBg.c69b4de0.c69b4de0.png │ │ │ ├── index.html │ │ │ ├── js │ │ │ ├── chunk-1939524c.329bb04a.js │ │ │ ├── chunk-1939524c.329bb04a.js.gz │ │ │ ├── chunk-3b55dc7e.dc8c010e.js │ │ │ ├── chunk-3b55dc7e.dc8c010e.js.gz │ │ │ ├── chunk-7381cc8c.6bde186b.js │ │ │ ├── chunk-7381cc8c.6bde186b.js.gz │ │ │ ├── chunk-7592249c.311b35c7.js │ │ │ ├── chunk-7592249c.311b35c7.js.gz │ │ │ ├── chunk-7a1d0272.f5a9e99f.js │ │ │ ├── chunk-7af68eda.f77c397f.js │ │ │ ├── chunk-7af68eda.f77c397f.js.gz │ │ │ ├── chunk-7c518a68.90291691.js │ │ │ ├── chunk-7c518a68.90291691.js.gz │ │ │ ├── chunk-a5f2b902.b6ea9744.js │ │ │ ├── chunk-a5f2b902.b6ea9744.js.gz │ │ │ ├── chunk-c1fb19f0.dac6ed4e.js │ │ │ ├── chunk-c1fb19f0.dac6ed4e.js.gz │ │ │ ├── chunk-de3d7390.eae09dc8.js │ │ │ ├── chunk-vendors.2317c5e0.js │ │ │ ├── chunk-vendors.2317c5e0.js.gz │ │ │ ├── index.81715ba9.js │ │ │ └── index.81715ba9.js.gz │ │ │ ├── lang │ │ │ ├── en.json │ │ │ └── zh.json │ │ │ └── static │ │ │ ├── business.js │ │ │ └── config.js │ ├── Core.Configuration.MySql │ │ ├── Core.Configuration.MySql.csproj │ │ ├── MySqlConfigurationBuilderExtensions.cs │ │ ├── MySqlConfigurationProvider.cs │ │ ├── MySqlConfigurationSource.cs │ │ └── MySqlConfigurationStorage.cs │ ├── Core.Configuration.PostgreSql │ │ ├── Core.Configuration.PostgreSql.csproj │ │ ├── PostgreSqlConfigurationBuilderExtensions.cs │ │ ├── PostgreSqlConfigurationProvider.cs │ │ ├── PostgreSqlConfigurationSource.cs │ │ └── PostgreSqlConfigurationStorage.cs │ ├── Core.Configuration.SqlServer │ │ ├── Core.Configuration.SqlServer.csproj │ │ ├── SqlServerConfigurationBuilderExtensions.cs │ │ ├── SqlServerConfigurationProvider.cs │ │ ├── SqlServerConfigurationSource.cs │ │ └── SqlServerConfigurationStorage.cs │ ├── Core.Configuration │ │ ├── ConfigurationOptions.cs │ │ ├── ConfigurationServiceCollectionExtensions.cs │ │ ├── Core.Configuration.csproj │ │ ├── CoreConfigurationModule.cs │ │ ├── DbConfigurationProvider.cs │ │ ├── DbConfigurationSource.cs │ │ ├── IConfigurationOptionsExtensions.cs │ │ └── Storage │ │ │ ├── ConfigurationMessage.cs │ │ │ ├── ConfigurationStorageBase.cs │ │ │ ├── ConfigurationStorageExtensions.cs │ │ │ ├── DbConnectionExtensions.cs │ │ │ ├── IConfigurationStorage.cs │ │ │ └── Model │ │ │ ├── CreateMessageModel.cs │ │ │ ├── MessageQueryModel.cs │ │ │ ├── ModifyMessageModel.cs │ │ │ ├── PageBaseDto.cs │ │ │ └── PageResultDto.cs │ ├── Core.Ddd.Domain │ │ ├── Core.Ddd.Domain.csproj │ │ ├── Entities │ │ │ ├── AggregateRoot.cs │ │ │ ├── Entity.cs │ │ │ ├── IAggregateRoot.cs │ │ │ ├── IEntity.cs │ │ │ └── ISoftDeleted.cs │ │ ├── Events │ │ │ └── EntityEventReport.cs │ │ ├── Repositories │ │ │ └── IRepository .cs │ │ ├── Services │ │ │ └── IDomainService.cs │ │ └── Values │ │ │ └── ValueObject.cs │ ├── Core.ElasticSearch │ │ ├── Core.ElasticSearch.csproj │ │ ├── CoreElasticSearchModule.cs │ │ ├── DefaultElasticClientBuilder.cs │ │ ├── ElasticClientFactory.cs │ │ ├── ElasticClientFactoryExtensions.cs │ │ ├── ElasticClientTrackingEntry.cs │ │ ├── ElasticSearchRepositories.cs │ │ ├── ElasticSearchServiceCollectionExtensions.cs │ │ ├── IElasticClientFactory.cs │ │ ├── IElasticSearchRepositories.cs │ │ └── Options │ │ │ └── ElasticClientFactoryOptions.cs │ ├── Core.EmailClient.Mysql │ │ ├── Core.EmailClient.Mysql.csproj │ │ ├── EmailClientMysqlModule.cs │ │ ├── EmailClientOptionsExtensions.cs │ │ ├── MysqlEmailStorageOptions.cs │ │ ├── MysqlServiceCollectionExtensions.cs │ │ └── MysqlStorage.cs │ ├── Core.EmailClient.PostgreSql │ │ ├── Core.EmailClient.PostgreSql.csproj │ │ ├── EmailClientOptionsExtensions.cs │ │ ├── EmailClientPostgreSqlModule.cs │ │ ├── PostgreSqlEmailStorageOptions.cs │ │ ├── PostgreSqlServiceCollectionExtensions.cs │ │ └── PostgreSqlStorage.cs │ ├── Core.EmailClient │ │ ├── Core.EmailClient.csproj │ │ ├── CoreEmailClientModule.cs │ │ ├── DefaultEmailClient.cs │ │ ├── EmailClientBackgroundService.cs │ │ ├── EmailClientBase.cs │ │ ├── EmailClientOptions.cs │ │ ├── EmailClientServiceCollectionExtensions.cs │ │ ├── EmailSendMailBox.cs │ │ ├── IEmailClient.cs │ │ ├── IEmailClientOptionsExtensions.cs │ │ ├── MailBodyEntity.cs │ │ ├── MimeMessageExtensions.cs │ │ └── Storage │ │ │ ├── DbConnectionExtensions.cs │ │ │ ├── EmailMessage.cs │ │ │ ├── IEmailStorage.cs │ │ │ └── Model │ │ │ ├── AddEmailModel.cs │ │ │ ├── QueryEmailModel.cs │ │ │ └── UpdateEmailModel.cs │ ├── Core.EntityFrameworkCore.Sharding │ │ ├── Core.EntityFrameworkCore.Sharding.csproj │ │ ├── CoreDbContextModelSource.cs │ │ ├── CoreEntityFrameworkServiceCollectionExtensions.cs │ │ ├── CoreShardingDbContext.cs │ │ ├── DbContextModelExtensions.cs │ │ └── RepositoryExtensions.cs │ ├── Core.EntityFrameworkCore │ │ ├── Core.EntityFrameworkCore.csproj │ │ ├── CoreDbContext.cs │ │ ├── CoreEfCoreModule.cs │ │ ├── DbContextExtensions.cs │ │ ├── DbContextNameAttribute.cs │ │ ├── EfCoreServiceCollectionExtensions.cs │ │ ├── EntityFrameworkCore │ │ │ ├── DefaultDbContextProvider.cs │ │ │ ├── EfCoreDatabaseApi.cs │ │ │ ├── EfCoreTransactionApi.cs │ │ │ └── IDbContextProvider.cs │ │ └── Repositories │ │ │ ├── EfCoreRepository.cs │ │ │ ├── IEfCoreRepository.cs │ │ │ └── QueryableExtensions.cs │ ├── Core.EventBus.Mysql │ │ ├── Core.EventBus.Mysql.csproj │ │ ├── CoreEventBusMysqlModule.cs │ │ ├── EventBusMysqlOptions.cs │ │ ├── EventBusOptionsExtensions.cs │ │ ├── MysqlServiceCollectionExtensions.cs │ │ └── MysqlStorage.cs │ ├── Core.EventBus.PostgreSql │ │ ├── Core.EventBus.PostgreSql.csproj │ │ ├── CoreEventBusPostgreSqlModule.cs │ │ ├── EventBusOptionsExtensions.cs │ │ ├── EventBusPostgreSqlOptions.cs │ │ ├── PostgreSqlServiceCollectionExtensions.cs │ │ └── PostgreSqlStorage.cs │ ├── Core.EventBus.RabbitMQ │ │ ├── Core.EventBus.RabbitMQ.csproj │ │ ├── CoreEventBusRabbitMqModule.cs │ │ ├── EventBusOptionsExtensions.cs │ │ ├── EventBusRabbitMqOptions.cs │ │ ├── EventBusRabbitMqServiceCollectionExtensions.cs │ │ ├── RabbitMqMessagePublisher.cs │ │ └── RabbitMqMessageSubscribe.cs │ ├── Core.EventBus.SqlServer │ │ ├── Core.EventBus.SqlServer.csproj │ │ ├── CoreEventBusSqlServerModule.cs │ │ ├── EventBusOptionsExtensions.cs │ │ ├── EventBusSqlServerOptions.cs │ │ ├── SqlServerServiceCollectionExtensions.cs │ │ └── SqlServerStorage.cs │ ├── Core.EventBus │ │ ├── Core.EventBus.csproj │ │ ├── CoreEventBusModule.cs │ │ ├── EventBusBackgroundService.cs │ │ ├── EventBusOptions.cs │ │ ├── EventBusServiceCollectionExtensions.cs │ │ ├── IEventBusOptionsExtensions.cs │ │ ├── Integration │ │ │ ├── IIntegrationMessageHandlerManager.cs │ │ │ ├── IIntegrationMessageHandlerProvider.cs │ │ │ ├── IIntegrationMessagePublisher.cs │ │ │ ├── IIntegrationMessageSubscribe.cs │ │ │ ├── IOutBoxSender.cs │ │ │ ├── IntegrationMessageHandlerManager.cs │ │ │ ├── IntegrationMessageHandlerProvider.cs │ │ │ ├── IntegrationMessagePublisherBase.cs │ │ │ ├── IntegrationServiceCollectionExtensions.cs │ │ │ └── OutBoxSender.cs │ │ ├── Local │ │ │ ├── CoreEventBusLocalModule.cs │ │ │ ├── EventBusLocalCollectionExtensions.cs │ │ │ ├── EventBusOptionsExtensions.cs │ │ │ ├── ILocalMessageHandlerManager.cs │ │ │ ├── ILocalMessageHandlerProvider.cs │ │ │ ├── ILocalMessagePublisher.cs │ │ │ ├── ILocalMessageSubscribe.cs │ │ │ ├── LocalMessageHandlerManager.cs │ │ │ ├── LocalMessageHandlerProvider.cs │ │ │ ├── LocalMessagePublisher.cs │ │ │ └── LocalMessageSubscribe.cs │ │ ├── Messaging │ │ │ ├── Attributes │ │ │ │ ├── MessageGroupAttribute.cs │ │ │ │ ├── MessageHandlerLifetimeAttribute.cs │ │ │ │ ├── MessageHandlerPriorityAttribute.cs │ │ │ │ └── MessageNameAttribute.cs │ │ │ ├── Diagnostics │ │ │ │ ├── DiagnosticListenerConstants.cs │ │ │ │ └── EventBusDiagnosticListener.cs │ │ │ ├── IMessage.cs │ │ │ ├── IMessageHandler.cs │ │ │ ├── IMessageHandlerManager.cs │ │ │ ├── IMessageHandlerProvider.cs │ │ │ ├── IMessageHandlerWrapper.cs │ │ │ ├── IMessagePublisher.cs │ │ │ ├── IMessageSubscribe.cs │ │ │ ├── Message.cs │ │ │ ├── MessageHandlerExtensions.cs │ │ │ ├── MessageHandlerLifetime.cs │ │ │ ├── MessageHandlerManager.cs │ │ │ ├── MessageHandlerProvider.cs │ │ │ ├── MessageHandlerWrapper.cs │ │ │ ├── MessagePublisherMailBox.cs │ │ │ └── MessageSubscribeBase.cs │ │ ├── Storage │ │ │ ├── DbConnectionExtensions.cs │ │ │ ├── IStorage.cs │ │ │ ├── MediumMessage.cs │ │ │ └── StorageMarkerService.cs │ │ └── Transaction │ │ │ ├── DbTransactionExtensions.cs │ │ │ ├── ITransaction.cs │ │ │ ├── ITransactionAccessor.cs │ │ │ ├── Transaction.cs │ │ │ └── TransactionAccessor.cs │ ├── Core.Excel │ │ ├── Core.Excel.csproj │ │ ├── ExcelCellStyle.cs │ │ ├── ExcelCellStyleAttribute.cs │ │ ├── ExcelColumn.cs │ │ ├── ExcelColumnAttribute.cs │ │ ├── ExcelColumnExtensions.cs │ │ └── ExcelHelper.cs │ ├── Core.Framework │ │ └── Core.Framework.csproj │ ├── Core.HttpClient │ │ ├── BaseHttpClient.cs │ │ ├── Core.HttpClient.csproj │ │ ├── HttpClientResponse.cs │ │ ├── HttpClientServiceCollectionExtensions.cs │ │ └── IBaseHttpClient.cs │ ├── Core.Infrastructure │ │ ├── Core.Infrastructure.csproj │ │ ├── Exceptions │ │ │ └── DomainException.cs │ │ ├── Recursive │ │ │ ├── IRecursiveModel.cs │ │ │ ├── RecursiveException.cs │ │ │ ├── RecursiveLoader.cs │ │ │ └── RecursiveModelDescriptor.cs │ │ └── Timer │ │ │ ├── AsyncTimer.cs │ │ │ └── NonCapturingTimer.cs │ ├── Core.Json │ │ ├── Core.Json.csproj │ │ └── Newtonsoft │ │ │ └── NewtonsoftJsonSerializer.cs │ ├── Core.Modularity │ │ ├── Abstraction │ │ │ ├── ICoreApplicationManager.cs │ │ │ ├── ICoreModule.cs │ │ │ ├── ICoreModuleDescriptor.cs │ │ │ └── IModuleLoader.cs │ │ ├── ApplicationBuilderContext.cs │ │ ├── Attribute │ │ │ └── DependsOnAttribute.cs │ │ ├── Core.Modularity.csproj │ │ ├── CoreApplicationManager.cs │ │ ├── CoreApplicationManagerFactory.cs │ │ ├── CoreFrameworkApplicationBuilderExtensions.cs │ │ ├── CoreFrameworkServiceCollectionExtensions.cs │ │ ├── CoreModuleBase.cs │ │ ├── CoreModuleDescriptor.cs │ │ ├── CoreModuleHelper.cs │ │ ├── ModuleLoader.cs │ │ ├── ServiceCollectionContext.cs │ │ └── ShutdownApplicationContext.cs │ ├── Core.Permission.PostgreSql │ │ ├── Core.Permission.PostgreSql.csproj │ │ ├── PermissionPostgreSqlOptions.cs │ │ ├── PostgreSqlConfigurationBuilderExtensions.cs │ │ ├── PostgreSqlOptionsExtensions.cs │ │ └── PostgreSqlPermissionGrantsStorage.cs │ ├── Core.Permission │ │ ├── Core.Permission.csproj │ │ ├── DefaultPermissionHandlerProvider.cs │ │ ├── DefaultPermissionService.cs │ │ ├── DefaultRolePermissionHandler.cs │ │ ├── IPermissionHandler.cs │ │ ├── IPermissionHandlerProvider.cs │ │ ├── IPermissionOptionsExtensions.cs │ │ ├── IPermissionService.cs │ │ ├── PermissionAppBuilderExtensions.cs │ │ ├── PermissionAttribute.cs │ │ ├── PermissionBackgroundService.cs │ │ ├── PermissionHandlerContext.cs │ │ ├── PermissionMiddleware.cs │ │ ├── PermissionOptions.cs │ │ ├── PermissionResult.cs │ │ ├── PermissionServiceCollectionExtensions.cs │ │ └── Storage │ │ │ ├── DbConnectionExtensions.cs │ │ │ ├── IPermissionGrantsStorage.cs │ │ │ ├── InMemoryConfigurationBuilderExtensions.cs │ │ │ ├── InMemoryOptionsExtensions.cs │ │ │ ├── InMemoryPermissionGrantsStorage.cs │ │ │ ├── Model │ │ │ ├── MessageQueryModel.cs │ │ │ ├── ModifyMessageModel.cs │ │ │ ├── PageBaseDto.cs │ │ │ └── PageResultDto.cs │ │ │ └── PermissionGrantsEntity.cs │ ├── Core.Pipeline │ │ ├── Core.Pipeline.csproj │ │ ├── DefaultPipelineBuilder.cs │ │ ├── DefaultPipelineBuilderFactory.cs │ │ ├── DefaultPipelineProvider.cs │ │ ├── HandlerPriorityAttribute.cs │ │ ├── IPipeline.cs │ │ ├── IPipelineBuilder.cs │ │ ├── IPipelineBuilderFactory.cs │ │ ├── IPipelineProvider.cs │ │ ├── IRequest.cs │ │ ├── IRequestHandler.cs │ │ ├── IRequestPreHandler.cs │ │ ├── IRequestProHandler.cs │ │ ├── PipelineModule.cs │ │ ├── PipelinePriorityAttribute.cs │ │ ├── PipelineServiceCollectionExtensions.cs │ │ ├── RequestHandlerPipeline.cs │ │ ├── RequestPipelineDelegate.cs │ │ ├── RequestPrePipeline.cs │ │ └── RequestProPipeline.cs │ ├── Core.RabbitMQ │ │ ├── Core.RabbitMQ.csproj │ │ ├── CoreRabbitMqModule.cs │ │ ├── DefaultRabbitMqMessageConsumer.cs │ │ ├── DefaultRabbitMqMessageConsumerManager.cs │ │ ├── DefaultRabbitMqPersistentConnection.cs │ │ ├── IRabbitMqMessageConsumer.cs │ │ ├── IRabbitMqMessageConsumerManager.cs │ │ ├── IRabbitMqPersistentConnection.cs │ │ ├── RabbitMqConnectionConfigure.cs │ │ ├── RabbitMqExchangeDeclareConfigure.cs │ │ ├── RabbitMqOptions.cs │ │ ├── RabbitMqQueueDeclareConfigure.cs │ │ └── RabbitMqServiceCollectionExtensions.cs │ ├── Core.Redis │ │ ├── Core.Redis.csproj │ │ ├── CoreRedisModule.cs │ │ ├── IRedisCache.cs │ │ ├── RedisCacheOptions.cs │ │ ├── RedisCacheServiceCollectionExtensions.cs │ │ └── StackExchangeRedis.cs │ ├── Core.Threading.Tasks │ │ ├── Concurrent │ │ │ ├── ConcurrentManager.cs │ │ │ ├── ConcurrentOptions.cs │ │ │ ├── ConcurrentResult.cs │ │ │ └── IConcurrentResult.cs │ │ └── Core.Threading.Tasks.csproj │ ├── Core.Translate │ │ ├── BaiDu │ │ │ ├── BaiDuTranslateOptions.cs │ │ │ ├── BaiDuTranslateProvider.cs │ │ │ ├── BaiDuTranslateResponseDto.cs │ │ │ └── BaiDuTranslateServiceCollectionExtensions.cs │ │ ├── Core.Translate.csproj │ │ ├── ITranslateProvider.cs │ │ ├── TranslateModule.cs │ │ └── TranslateQueryDto.cs │ └── Core.Uow │ │ ├── Core.Uow.csproj │ │ ├── DefaultUnitOfWork.cs │ │ ├── DefaultUnitOfWorkAccessor.cs │ │ ├── IDatabaseApi.cs │ │ ├── IDatabaseApiContainer.cs │ │ ├── ISupportsSavingChanges.cs │ │ ├── ITransactionApi.cs │ │ ├── ITransactionApiContainer.cs │ │ ├── IUnitOfWork.cs │ │ ├── IUnitOfWorkAccessor.cs │ │ ├── UnitOfWorkAppBuilderExtensions.cs │ │ ├── UnitOfWorkAttribute.cs │ │ ├── UnitOfWorkMiddleware.cs │ │ ├── UnitOfWorkModule.cs │ │ ├── UnitOfWorkOptions.cs │ │ └── UnitOfWorkServiceCollectionExtensions.cs └── test │ ├── EntityFrameworkCore.Api │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── CustomerDbContext.cs │ ├── Entities │ │ └── Student.cs │ ├── EntityFrameworkCore.Api.csproj │ ├── Events │ │ ├── AddStudentEvent.cs │ │ └── AddStudentEventHandler.cs │ ├── Migrations │ │ ├── 20201030060852_Init.Designer.cs │ │ ├── 20201030060852_Init.cs │ │ └── CustomerDbContextModelSnapshot.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── StartupModule.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json │ ├── Test │ ├── AmazonS3Test.cs │ ├── BaseTest.cs │ ├── EmailClientTest.cs │ ├── PipelineTest.cs │ ├── Test.csproj │ └── wwwroot │ │ ├── email_content.html │ │ └── picture.gif │ └── eventBus │ ├── PublishApi │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── Event │ │ ├── CustomerEvent.cs │ │ └── CustomerHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── PublishApi.csproj │ ├── Startup.cs │ ├── StartupModule.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json │ └── SubscriptionApi │ ├── Controllers │ └── WeatherForecastController.cs │ ├── Event │ ├── CustomerEvent.cs │ ├── EventHandler.cs │ └── EventHandler1.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── StartupModule.cs │ ├── SubscriptionApi.csproj │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json └── README.md /CoreFramework/.template.config/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "author": "GaoBo", 4 | "classifications": [ "AspNetCoreTemplate" ], 5 | "name": "AspNetCoreTemplate", 6 | "identity": "AspNetCoreTemplate", // Unique name for this template 7 | "shortName": "CoreTemplate", // Short name that can be used on the cli 8 | "tags": { 9 | "language": "C#" // Specify that this template is in C#. 10 | }, 11 | "sourceName": "Core.", // Will replace the string 'Sayedha.StarterWeb' with the value provided via -n. 12 | "preferNameDirectory": true 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/AmazonS3ClientFactoryExtensions.cs: -------------------------------------------------------------------------------- 1 | using Amazon.S3; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public static class AmazonS3ClientFactoryExtensions 6 | { 7 | public static AmazonS3Client CreateClient(this IAmazonS3ClientFactory clientFactory) 8 | { 9 | return clientFactory.CreateClient(Microsoft.Extensions.Options.Options.DefaultName); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/AmazonS3ClientHttpClientNameConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Amazon.S3 2 | { 3 | public class AmazonS3ClientHttpClientNameConstants 4 | { 5 | public const string AmazonS3ClientHttpClientName = nameof(AmazonS3ClientHttpClientName); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/AmazonS3Module.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.Amazon.S3 6 | { 7 | public class AmazonS3Module : CoreModuleBase 8 | { 9 | public IConfiguration Configuration { get; } 10 | 11 | public AmazonS3Module(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public override void ConfigureServices(ServiceCollectionContext context) 17 | { 18 | context.Services.AddAmazonS3(Configuration.GetSection("Amazon:S3")); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/AmazonS3Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public class AmazonS3Options 6 | { 7 | public string ServiceURL { get; set; } 8 | 9 | public string UserName { get; set; } 10 | 11 | public string Password { get; set; } 12 | 13 | public int RetryCount { get; set; } = 100; 14 | 15 | public TimeSpan? Timeout { get; set; } = TimeSpan.FromMinutes(60); 16 | 17 | public bool UseHttp { get; set; } = true; 18 | 19 | public bool ForcePathStyle { get; set; } = true; 20 | 21 | public string SignatureVersion { get; set; } = "v1"; 22 | 23 | public int MaxConnectionsPerServer { get; set; } = int.MaxValue; 24 | 25 | public bool AllowAutoRedirect { get; set; } = false; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/AmazonS3StorageException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Core.Amazon.S3 5 | { 6 | public class AmazonS3StorageException : Exception 7 | { 8 | public HttpStatusCode Status { get; } 9 | public string Reason { get; } 10 | 11 | public AmazonS3StorageException(HttpStatusCode status, string reason, string message) 12 | : base($"Request to amazon s3 storage failed, status code: {(int)status}, reason: {(string.IsNullOrEmpty(reason) ? status.ToString() : reason)}, message:{message}") 13 | { 14 | Status = status; 15 | Reason = reason; 16 | } 17 | 18 | public AmazonS3StorageException(HttpStatusCode status, string reason, string message, Exception innerException) 19 | : base($"Request to amazon s3 storage failed, status code: {(int)status}, reason: {(string.IsNullOrEmpty(reason) ? status.ToString() : reason)}, message:{message}", innerException) 20 | { 21 | Status = status; 22 | Reason = reason; 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/Core.Amazon.S3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/DefaultAmazonS3Builder.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public class DefaultAmazonS3Builder : IAmazonS3Builder 6 | { 7 | public DefaultAmazonS3Builder(IServiceCollection services, string name) 8 | { 9 | Services = services; 10 | Name = name; 11 | } 12 | 13 | public string Name { get; } 14 | 15 | public IServiceCollection Services { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/IAmazonS3Builder.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public interface IAmazonS3Builder 6 | { 7 | string Name { get; } 8 | 9 | IServiceCollection Services { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/IAmazonS3ClientFactory.cs: -------------------------------------------------------------------------------- 1 | using Amazon.S3; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public interface IAmazonS3ClientFactory 6 | { 7 | AmazonS3Client CreateClient(string clientName); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Amazon.S3/ITypeClientFactory.cs: -------------------------------------------------------------------------------- 1 | using Amazon.S3; 2 | 3 | namespace Core.Amazon.S3 4 | { 5 | public interface ITypeClientFactory 6 | where TClient : class 7 | { 8 | TClient CreateClient(AmazonS3Client adapter); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace Core.Application.Commands 4 | { 5 | public interface ICommand : IRequest 6 | { 7 | } 8 | 9 | public interface ICommand : IRequest 10 | where TResponse : ICommandResult 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/Commands/CommandResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Application.Commands 2 | { 3 | public interface ICommandResult 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/Core.Application.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/CoreApplicationModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace Core.Application 5 | { 6 | public class CoreApplicationModule : CoreModuleBase 7 | { 8 | public override void ConfigureServices(ServiceCollectionContext context) 9 | { 10 | context.Services.AddApplication(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/Exceptions/ValidationException.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Application.Exceptions 2 | { 3 | public class ValidationException : Exception 4 | { 5 | public ValidationException(string message) 6 | : base(message) 7 | { 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Application/Queries/QueryResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Application.Queries 2 | { 3 | public interface IQueryResult 4 | { 5 | } 6 | 7 | public abstract class QueryPagedResult : IQueryResult 8 | { 9 | protected QueryPagedResult(IQueryPaging queryPaging) 10 | { 11 | PageIndex = queryPaging.PageIndex; 12 | PageSize = queryPaging.PageSize; 13 | } 14 | 15 | public int PageIndex { get; set; } 16 | 17 | public int PageSize { get; set; } 18 | 19 | public int TotalPages 20 | { 21 | get 22 | { 23 | if (TotalCount <= 0) 24 | return 0; 25 | if (PageSize <= 1) 26 | { 27 | return TotalCount; 28 | } 29 | var pageCount = TotalCount / PageSize; 30 | if (TotalCount % PageSize > 0) 31 | { 32 | pageCount++; 33 | } 34 | return pageCount; 35 | } 36 | } 37 | 38 | public int TotalCount { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.AspNetCore/Core.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/DashboardEndpointRouteExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Routing; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | 5 | namespace Core.Configuration.Dashboard 6 | { 7 | public static class DashboardEndpointRouteExtensions 8 | { 9 | public static void MapDbConfigurationDashboard(this IEndpointRouteBuilder builder) 10 | { 11 | if (builder == null) 12 | throw new ArgumentNullException(nameof(builder)); 13 | builder.ServiceProvider.GetRequiredService().Build(builder); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/DashboardOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Configuration.Dashboard 5 | { 6 | public class DashboardOptions 7 | { 8 | public DashboardOptions() 9 | { 10 | PathMatch = "/config/dashboard"; 11 | Attributes = new List(); 12 | } 13 | 14 | public string PathMatch { get; set; } 15 | 16 | public List Attributes { get; } 17 | 18 | public DashboardOptions AddAttribute(params Attribute[] attributes) 19 | { 20 | if (attributes != null && attributes.Length > 0) 21 | Attributes.AddRange(attributes); 22 | return this; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/DashboardOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.Extensions.DependencyInjection.Extensions; 5 | 6 | namespace Core.Configuration.Dashboard 7 | { 8 | public class DashboardOptionsExtensions : IConfigurationOptionsExtensions 9 | { 10 | private readonly Action _options; 11 | 12 | public DashboardOptionsExtensions(Action options) 13 | { 14 | _options = options; 15 | } 16 | public void AddServices(IServiceCollection services) 17 | { 18 | services.AddTransient(); 19 | services.Configure(_options); 20 | services.TryAddSingleton(typeof(ServiceRouteBuilder)); 21 | services.TryAddEnumerable(new ServiceDescriptor(typeof(IDashboardRouteProvider), typeof(DashboardActionRouteProvider),ServiceLifetime.Singleton)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/DashboardServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Configuration.Dashboard 4 | { 5 | public static class DashboardServiceCollectionExtensions 6 | { 7 | public static ConfigurationOptions AddDashboard(this ConfigurationOptions options, Action actionOptions) 8 | { 9 | options.AddExtensions(new DashboardOptionsExtensions(actionOptions)); 10 | return options; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/IDashboardRouteProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Dashboard 2 | { 3 | public interface IDashboardRouteProvider 4 | { 5 | ServiceMethodProviderContext OnServiceMethodDiscovery(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/IMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Core.Configuration.Dashboard 6 | { 7 | public interface IMethod 8 | { 9 | string MethodName { get; } 10 | 11 | Type MethodParameter { get; } 12 | 13 | string HttpMetadata { get; } 14 | 15 | string RouteTemplate { get; } 16 | 17 | List MethodMetadata { get; } 18 | 19 | MethodInfo MethodInvoke { get; } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/MethodModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Routing.Patterns; 3 | using System.Collections.Generic; 4 | 5 | namespace Core.Configuration.Dashboard 6 | { 7 | public class MethodModel 8 | { 9 | public MethodModel( 10 | RoutePattern pattern, 11 | IList metadata, 12 | RequestDelegate requestDelegate) 13 | { 14 | Pattern = pattern; 15 | Metadata = metadata; 16 | RequestDelegate = requestDelegate; 17 | } 18 | public RoutePattern Pattern { get; } 19 | 20 | public IList Metadata { get; } 21 | 22 | public RequestDelegate RequestDelegate { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/RouteProvider/DashboardActionRouteProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Dashboard 2 | { 3 | public class DashboardActionRouteProvider : IDashboardRouteProvider 4 | { 5 | public ServiceMethodProviderContext OnServiceMethodDiscovery() 6 | { 7 | var context = new ServiceMethodProviderContext(); 8 | var methods = DashboardActionRoute.GetMethods(); 9 | foreach (var method in methods) 10 | { 11 | context.AddMethod(method); 12 | } 13 | return context; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/ServiceMethodProviderContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.AspNetCore.Routing.Patterns; 3 | 4 | namespace Core.Configuration.Dashboard 5 | { 6 | public class ServiceMethodProviderContext 7 | { 8 | public ServiceMethodProviderContext() 9 | { 10 | Methods = new List(); 11 | } 12 | internal List Methods { get; } 13 | 14 | public void AddMethod(Method method) where TService : class 15 | { 16 | var callHandler = new ServerCallHandler(method); 17 | var methodModel = new MethodModel(RoutePatternFactory.Parse(method.RouteTemplate), method.MethodMetadata, callHandler.HandleCallAsync); 18 | Methods.Add(methodModel); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-1939524c.e374acd7.css: -------------------------------------------------------------------------------- 1 | .fx_manage[data-v-b3098b68] .ant-table-empty .ant-table-body{height:0}.ant-upload-select-picture-card i[data-v-b3098b68]{font-size:32px;color:#999}.ant-upload-select-picture-card .ant-upload-text[data-v-b3098b68]{margin-top:8px;color:#666} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-7592249c.200fdbc3.css: -------------------------------------------------------------------------------- 1 | [data-v-941d70bc] .ant-table{background:#fff!important}.ant-table[data-v-941d70bc] tr.ant-table-row.fx_darkRow{background-color:#fafafa}.ant-table[data-v-941d70bc] tr.ant-table-row.fx_lightRow{background-color:#fff}.ant-pagination[data-v-941d70bc]{margin-top:16px;text-align:right}.ant-pagination-options[data-v-941d70bc]{position:relative}[data-v-941d70bc] .ant-select-dropdown-menu-item{text-align:center}[data-v-3b99ac05] .ant-input{width:90%;margin-right:5px}.fx_top[data-v-0b20ff06]{display:flex;align-items:center;justify-content:space-between}.fx_searchForm[data-v-0b20ff06]{text-align:right}.fx_btnBox>a[data-v-17b33fbb]{margin-left:2px} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-7a1d0272.59c183eb.css: -------------------------------------------------------------------------------- 1 | .fx_contentBox[data-v-9c600c4c]{height:100vh;padding-top:185px;padding-left:69px;background:#f8f8f9}.fx_contentBox .fx_errorImage[data-v-9c600c4c]{display:inline-block}.fx_contentBox .fx_infoBox[data-v-9c600c4c]{display:inline-block;position:relative;top:85px;left:20px}.fx_contentBox .fx_infoBox .fx_errorCode[data-v-9c600c4c]{font-size:96px;font-family:PingFangSC,PingFangSC-Semibold;font-weight:600;text-align:left;color:#17233d;line-height:135px}.fx_contentBox .fx_infoBox .fx_errorInfo[data-v-9c600c4c]{font-size:16px;font-family:PingFangSC,PingFangSC-Regular;font-weight:400;text-align:left;color:#515a6e;line-height:22px}.fx_contentBox .fx_infoBox .fx_returnButton[data-v-9c600c4c]{margin-top:24px;width:80px;height:32px;background:#4b78ff;border-radius:2px;font-size:14px;font-family:PingFangSC,PingFangSC-Regular;font-weight:400;text-align:center;color:#fff;line-height:32px;cursor:pointer} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-7c518a68.587716c5.css: -------------------------------------------------------------------------------- 1 | [data-v-7e12f9cd] .ant-card-body{height:400px;overflow:auto;overflow:overlay}.fx_manage[data-v-38f424d0] .ant-table-empty .ant-table-body{height:0}.fx_title[data-v-7b98a365]{display:flex;align-items:center;margin-bottom:16px;padding:0 10px;font-size:14px;line-height:1;color:#17233d;border-left:2px solid #006aff}.fx_title>span[data-v-7b98a365]{margin-right:8px}.fx_title>span[data-v-7b98a365]:first-of-type{cursor:pointer;color:rgba(0,0,0,.45)}.fx_title>span[data-v-7b98a365]:nth-of-type(2){color:rgba(0,0,0,.65)}.fx_title .anticon[data-v-7b98a365]{margin-right:8px;font-size:12px;color:rgba(0,0,0,.45)} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-a5f2b902.11c50a80.css: -------------------------------------------------------------------------------- 1 | .fx_button[data-v-778103f0]{float:right}.ant-upload-select-picture-card i[data-v-778103f0]{font-size:32px;color:#999}.ant-upload-select-picture-card .ant-upload-text[data-v-778103f0]{margin-top:8px;color:#666} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-de3d7390.fa808e46.css: -------------------------------------------------------------------------------- 1 | .fx_title[data-v-227d10d2]{display:flex;align-items:center;margin-bottom:16px;padding:0 10px;font-size:14px;line-height:1;color:#17233d;border-left:2px solid #006aff}.fx_title>span[data-v-227d10d2]{margin-right:8px}.fx_title>span[data-v-227d10d2]:first-of-type{cursor:pointer;color:rgba(0,0,0,.45)}.fx_title>span[data-v-227d10d2]:nth-of-type(2){color:rgba(0,0,0,.65)}.fx_title .anticon[data-v-227d10d2]{margin-right:8px;font-size:12px;color:rgba(0,0,0,.45)}.fx_iframe[data-v-227d10d2]{width:100%;height:100vh} -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-vendors.230de3f5.css.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/css/chunk-vendors.230de3f5.css.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/favicon.ico -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/boxShadow.51818d84.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/boxShadow.51818d84.png -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/login_bg.993b9c92.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/login_bg.993b9c92.png -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/login_footer.0402bdb6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/login_footer.0402bdb6.png -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/logoTitleNew.201b37cb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/logoTitleNew.201b37cb.png -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/pieBg.c69b4de0.c69b4de0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/img/pieBg.c69b4de0.c69b4de0.png -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-1939524c.329bb04a.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-1939524c.329bb04a.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-3b55dc7e.dc8c010e.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-3b55dc7e.dc8c010e.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7381cc8c.6bde186b.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7381cc8c.6bde186b.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7592249c.311b35c7.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7592249c.311b35c7.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7a1d0272.f5a9e99f.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7a1d0272"],{"39a7":function(t,n,c){},c245:function(t,n,c){"use strict";c("39a7")},fde5:function(t,n,c){"use strict";c.r(n);var e=function(){var t=this,n=t.$createElement,c=t._self._c||n;return c("div",{staticClass:"fx_contentBox"})},u=[],o={data:function(){return{}},computed:{},methods:{},created:function(){this.$router.push("/home")},mounted:function(){}},s=o,a=(c("c245"),c("2877")),i=Object(a["a"])(s,e,u,!1,null,"9c600c4c",null);n["default"]=i.exports}}]); -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7af68eda.f77c397f.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7af68eda.f77c397f.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7c518a68.90291691.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-7c518a68.90291691.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-a5f2b902.b6ea9744.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-a5f2b902.b6ea9744.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-c1fb19f0.dac6ed4e.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-c1fb19f0.dac6ed4e.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-de3d7390.eae09dc8.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-de3d7390"],{"2ec10":function(t,e,n){"use strict";n.r(e);var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("iframe",{staticClass:"fx_iframe",attrs:{src:t.editorUrl,frameborder:"0"}})])},a=[],i=window.staticContentConfig.staticData.editorUrl,o={data:function(){return{editorUrl:i}},computed:{},mounted:function(){},methods:{}},c=o,d=(n("4f1d"),n("2877")),s=Object(d["a"])(c,r,a,!1,null,"227d10d2",null);e["default"]=s.exports},"4f1d":function(t,e,n){"use strict";n("aab9")},aab9:function(t,e,n){}}]); -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-vendors.2317c5e0.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/chunk-vendors.2317c5e0.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/index.81715ba9.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/js/index.81715ba9.js.gz -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/lang/en.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/lang/zh.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": { 3 | "projectName": "管理系统", 4 | "footerName": "Copyright©2021 版权所有" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/static/business.js: -------------------------------------------------------------------------------- 1 | window.staticConfig = { 2 | // 屏幕最大时一行四列 3 | responsiveSmall: { 4 | xs: 24, 5 | sm:24, 6 | md: 12, 7 | lg:12, 8 | xl:8, 9 | xxl:6 10 | }, 11 | // 屏幕最大时一行三列 12 | responsive: { 13 | xs: 24, 14 | sm:24, 15 | md: 24, 16 | lg:16, 17 | xl:12, 18 | xxl:8 19 | }, 20 | // 屏幕最大时一行两列 21 | responsiveLarge: { 22 | xs: 24, 23 | sm:24, 24 | md: 24, 25 | lg:24, 26 | xl:12, 27 | xxl:12 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.Dashboard/wwwroot/dist/static/config.js: -------------------------------------------------------------------------------- 1 | const Year = new Date().getFullYear() 2 | window.staticContentConfig = { 3 | "staticData": { 4 | "loginTitle": "", 5 | "listName": "数据中台", 6 | "projectName": "管理系统", 7 | "potalEnteryName": "公安部“互联网+政务服务”平台", 8 | "abbreviation": "管理系统", 9 | "footerName": "Copyright©" + Year + " 版权所有", 10 | "IconfontUrl": "//at.alicdn.com/t/font_2003100_9fypcxbiv2r.js", 11 | "editorUrl": "http://localhost:8010/editor/changeFlowIndex" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.MySql/Core.Configuration.MySql.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.15 7 | asp net core basic framework 8 | gaobo 9 | gaobo 10 | MIT 11 | https://github.com/Boy-boy/CoreFramework 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.MySql/MySqlConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Configuration.MySql; 3 | 4 | namespace Microsoft.Extensions.Configuration 5 | { 6 | public static class MySqlConfigurationBuilderExtensions 7 | { 8 | public static IConfigurationBuilder AddMySqlConfigure(this IConfigurationBuilder builder, Action configureSource) 9 | => builder.Add(configureSource); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.MySql/MySqlConfigurationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Configuration.MySql 5 | { 6 | public class MySqlConfigurationProvider : DbConfigurationProvider 7 | { 8 | public MySqlConfigurationProvider(MySqlConfigurationSource source, MySqlConfigurationStorage storage) 9 | : base(source, storage) 10 | { 11 | } 12 | 13 | public override void Load() 14 | { 15 | Data = new Dictionary(StringComparer.OrdinalIgnoreCase); 16 | var configurations = Storage.GetAsync(Source.Environment, Source.NameSpace).GetAwaiter().GetResult(); 17 | foreach (var configuration in configurations) 18 | { 19 | if (Data.ContainsKey(configuration.Key)) 20 | { 21 | Data[configuration.Key] = configuration.Value; 22 | } 23 | else 24 | { 25 | Data.Add(configuration.Key, configuration.Value); 26 | } 27 | } 28 | OnReload(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.MySql/MySqlConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using Core.Configuration.Storage; 2 | using Microsoft.Extensions.Configuration; 3 | 4 | namespace Core.Configuration.MySql 5 | { 6 | public class MySqlConfigurationSource : DbConfigurationSource 7 | { 8 | public override IConfigurationProvider Build(IConfigurationBuilder builder) 9 | { 10 | var storage = new MySqlConfigurationStorage(this); 11 | ConfigurationStorageExtensions.ConfigurationStorage = storage; 12 | return new MySqlConfigurationProvider(this, storage); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.PostgreSql/Core.Configuration.PostgreSql.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.15 7 | gaobo 8 | gaobo 9 | MIT 10 | https://github.com/Boy-boy/CoreFramework 11 | asp net core basic framework 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.PostgreSql/PostgreSqlConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Configuration.PostgreSql; 2 | using System; 3 | 4 | namespace Microsoft.Extensions.Configuration 5 | { 6 | public static class PostgreSqlConfigurationBuilderExtensions 7 | { 8 | public static IConfigurationBuilder AddPostgreSqlConfigure(this IConfigurationBuilder builder, Action configureSource) 9 | => builder.Add(configureSource); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.PostgreSql/PostgreSqlConfigurationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Configuration.PostgreSql 5 | { 6 | public class PostgreSqlConfigurationProvider : DbConfigurationProvider 7 | { 8 | public PostgreSqlConfigurationProvider(PostgreSqlConfigurationSource source, PostgreSqlConfigurationStorage storage) 9 | : base(source, storage) 10 | { 11 | } 12 | 13 | public override void Load() 14 | { 15 | Data = new Dictionary(StringComparer.OrdinalIgnoreCase); 16 | var configurations = Storage.GetAsync(Source.Environment, Source.NameSpace).GetAwaiter().GetResult(); ; 17 | foreach (var configuration in configurations) 18 | { 19 | if (Data.ContainsKey(configuration.Key)) 20 | { 21 | Data[configuration.Key] = configuration.Value; 22 | } 23 | else 24 | { 25 | Data.Add(configuration.Key, configuration.Value); 26 | } 27 | } 28 | OnReload(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.PostgreSql/PostgreSqlConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using Core.Configuration.Storage; 2 | using Microsoft.Extensions.Configuration; 3 | 4 | namespace Core.Configuration.PostgreSql 5 | { 6 | public class PostgreSqlConfigurationSource : DbConfigurationSource 7 | { 8 | public override IConfigurationProvider Build(IConfigurationBuilder builder) 9 | { 10 | var storage = new PostgreSqlConfigurationStorage(this); 11 | ConfigurationStorageExtensions.ConfigurationStorage = storage; 12 | return new PostgreSqlConfigurationProvider(this, storage); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.SqlServer/Core.Configuration.SqlServer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.15 7 | gaobo 8 | asp net core basic framework 9 | MIT 10 | https://github.com/Boy-boy/CoreFramework 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.SqlServer/SqlServerConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Configuration.SqlServer; 2 | using System; 3 | 4 | namespace Microsoft.Extensions.Configuration 5 | { 6 | public static class SqlServerConfigurationBuilderExtensions 7 | { 8 | public static IConfigurationBuilder AddSqlServerConfigure(this IConfigurationBuilder builder, Action configureSource) 9 | => builder.Add(configureSource); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.SqlServer/SqlServerConfigurationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Configuration.SqlServer 5 | { 6 | public class SqlServerConfigurationProvider : DbConfigurationProvider 7 | { 8 | public SqlServerConfigurationProvider(SqlServerConfigurationSource source, SqlServerConfigurationStorage storage) 9 | : base(source, storage) 10 | { 11 | } 12 | 13 | public override void Load() 14 | { 15 | Data = new Dictionary(StringComparer.OrdinalIgnoreCase); 16 | var configurations = Storage.GetAsync(Source.Environment, Source.NameSpace).GetAwaiter().GetResult(); ; 17 | foreach (var configuration in configurations) 18 | { 19 | if (Data.ContainsKey(configuration.Key)) 20 | { 21 | Data[configuration.Key] = configuration.Value; 22 | } 23 | else 24 | { 25 | Data.Add(configuration.Key, configuration.Value); 26 | } 27 | } 28 | OnReload(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration.SqlServer/SqlServerConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using Core.Configuration.Storage; 2 | using Microsoft.Extensions.Configuration; 3 | 4 | namespace Core.Configuration.SqlServer 5 | { 6 | public class SqlServerConfigurationSource : DbConfigurationSource 7 | { 8 | public override IConfigurationProvider Build(IConfigurationBuilder builder) 9 | { 10 | var storage = new SqlServerConfigurationStorage(this); 11 | ConfigurationStorageExtensions.ConfigurationStorage = storage; 12 | return new SqlServerConfigurationProvider(this, storage); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/ConfigurationOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Configuration 5 | { 6 | public class ConfigurationOptions 7 | { 8 | public ConfigurationOptions() 9 | { 10 | Extensions = new List(); 11 | } 12 | public List Extensions { get; set; } 13 | } 14 | 15 | public static class EventBusOptionsExtensions 16 | { 17 | public static void AddExtensions(this ConfigurationOptions options, IConfigurationOptionsExtensions eventBusOptionExtensions) 18 | { 19 | if (eventBusOptionExtensions == null) 20 | throw new AggregateException(nameof(eventBusOptionExtensions)); 21 | options.Extensions.Add(eventBusOptionExtensions); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/ConfigurationServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Configuration; 3 | using Core.Configuration.Storage; 4 | using Microsoft.Extensions.DependencyInjection.Extensions; 5 | 6 | namespace Microsoft.Extensions.DependencyInjection 7 | { 8 | public static class ConfigurationServiceCollectionExtensions 9 | { 10 | public static IServiceCollection AddDbConfiguration(this IServiceCollection services, Action configureOptions = null) 11 | { 12 | services.TryAddSingleton(_ => ConfigurationStorageExtensions.ConfigurationStorage); 13 | 14 | if (configureOptions == null) 15 | return services; 16 | 17 | var options = new ConfigurationOptions(); 18 | configureOptions.Invoke(options); 19 | foreach (var extension in options.Extensions) 20 | { 21 | extension.AddServices(services); 22 | } 23 | 24 | return services; 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Core.Configuration.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.13 7 | asp net core basic framework 8 | MIT 9 | https://github.com/Boy-boy/CoreFramework 10 | gaobo 11 | gaobo 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/CoreConfigurationModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.Configuration 6 | { 7 | public class CoreConfigurationModule : CoreModuleBase 8 | { 9 | public IConfiguration Configuration { get; } 10 | 11 | public CoreConfigurationModule(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public override void ConfigureServices(ServiceCollectionContext context) 17 | { 18 | context.Services.AddDbConfiguration(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/IConfigurationOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Configuration 4 | { 5 | public interface IConfigurationOptionsExtensions 6 | { 7 | void AddServices(IServiceCollection services); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/ConfigurationMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Configuration.Storage 4 | { 5 | public class ConfigurationMessage 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Environment { get; set; } = Environments.Product; 10 | 11 | public string Key { get; set; } 12 | 13 | public string Value { get; set; } 14 | 15 | public string Description { get; set; } 16 | 17 | public string NameSpace{ get; set; } 18 | 19 | public DateTime CreateTime { get; set; } 20 | 21 | public DateTime UpdateTime { get; set; } 22 | 23 | public DateTime UtcTime { get; set; } 24 | } 25 | 26 | public static class Environments 27 | { 28 | public static readonly string Develop = "develop"; 29 | public static readonly string Test = "test"; 30 | public static readonly string Product = "product"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/ConfigurationStorageExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Storage 2 | { 3 | public class ConfigurationStorageExtensions 4 | { 5 | public static ConfigurationStorageBase ConfigurationStorage { get; set; } 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/Model/CreateMessageModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Storage 2 | { 3 | public class CreateMessageModel 4 | { 5 | public string Key { get; set; } 6 | 7 | public string Value { get; set; } 8 | 9 | public string Description { get; set; } = ""; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/Model/MessageQueryModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Storage 2 | { 3 | public class MessageQueryModel : PageBaseDto 4 | { 5 | public int? Id { get; set; } 6 | 7 | public string Key { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/Model/ModifyMessageModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Configuration.Storage 2 | { 3 | public class ModifyMessageModel 4 | { 5 | public int Id { get; set; } 6 | 7 | public string Key { get; set; } 8 | 9 | public string Value { get; set; } 10 | 11 | public string Description { get; set; } = ""; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/Model/PageBaseDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Configuration.Storage 4 | { 5 | public class PageBaseDto 6 | { 7 | private int _pageIndex; 8 | 9 | private int _pageSize; 10 | 11 | public virtual int PageIndex 12 | { 13 | get => _pageIndex; 14 | set 15 | { 16 | if (value - 1 < 0) 17 | throw new Exception("分页索引不能小于0"); 18 | _pageIndex = value - 1; 19 | } 20 | } 21 | 22 | public virtual int PageSize 23 | { 24 | get => _pageSize; 25 | set 26 | { 27 | if (value < 0) 28 | throw new Exception("分页大小不能小于0"); 29 | _pageSize = value == 0 ? 10 : value; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Configuration/Storage/Model/PageResultDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Core.Configuration.Storage 4 | { 5 | public class PageResultDto 6 | { 7 | public int Count { get; set; } 8 | 9 | public List Items { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Core.Ddd.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | gaobo 7 | gaobo 8 | 9 | asp net core basic framework 10 | https://github.com/Boy-boy/CoreFramework 11 | 3.1.9.16 12 | 3.1.9.16 13 | 3.1.9.16 14 | MIT 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Entities/Entity.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Ddd.Domain.Entities 2 | { 3 | public class Entity : IEntity 4 | { 5 | } 6 | 7 | public class Entity : Entity, IEntity 8 | { 9 | public TKey Id { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Entities/IAggregateRoot.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Ddd.Domain.Entities 2 | { 3 | public interface IAggregateRoot : IEntity 4 | { 5 | } 6 | 7 | public interface IAggregateRoot : IEntity, IAggregateRoot 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Ddd.Domain.Entities 2 | { 3 | public interface IEntity 4 | { 5 | } 6 | 7 | public interface IEntity : IEntity 8 | { 9 | TKey Id { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Entities/ISoftDeleted.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Ddd.Domain.Entities 2 | { 3 | public interface ISoftDeleted 4 | { 5 | /// 6 | /// 软删除 7 | /// 8 | public bool IsDeleted { get; set; } 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Events/EntityEventReport.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.EventBus; 3 | 4 | namespace Core.Ddd.Domain.Events 5 | { 6 | public class EntityEventReport 7 | { 8 | public List DomainEvents { get; } 9 | 10 | public List DistributedEvents { get; } 11 | 12 | public EntityEventReport() 13 | { 14 | DomainEvents = new List(); 15 | DistributedEvents = new List(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Ddd.Domain/Services/IDomainService.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Ddd.Domain.Services 2 | { 3 | public interface IDomainService 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/Core.ElasticSearch.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 3.1.9.12 6 | gaobo 7 | asp net core basic framework 8 | Core.ElasticSearch 9 | https://github.com/Boy-boy/CoreFramework 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/CoreElasticSearchModule.cs: -------------------------------------------------------------------------------- 1 | using Core.ElasticSearch.Options; 2 | using Core.Modularity; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.ElasticSearch 7 | { 8 | public class CoreElasticSearchModule : CoreModuleBase 9 | { 10 | public IConfiguration Configuration { get; } 11 | 12 | public CoreElasticSearchModule(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public override void ConfigureServices(ServiceCollectionContext context) 18 | { 19 | context.Services.Configure(Configuration.GetSection("ElasticSearch")); 20 | context.Services.AddElasticClientFactory(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/DefaultElasticClientBuilder.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.ElasticSearch 4 | { 5 | public class DefaultElasticClientBuilder 6 | { 7 | public DefaultElasticClientBuilder(IServiceCollection services, string name) 8 | { 9 | Services = services; 10 | Name = name; 11 | } 12 | 13 | public string Name { get; } 14 | 15 | public IServiceCollection Services { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/ElasticClientFactoryExtensions.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Core.ElasticSearch 4 | { 5 | public static class ElasticClientFactoryExtensions 6 | { 7 | public static ElasticClient CreateClient(this IElasticClientFactory elasticClientFactory) 8 | { 9 | return elasticClientFactory.CreateClient(Microsoft.Extensions.Options.Options.DefaultName); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/IElasticClientFactory.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Core.ElasticSearch 4 | { 5 | public interface IElasticClientFactory 6 | { 7 | ElasticClient CreateClient(string name); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.ElasticSearch/Options/ElasticClientFactoryOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Core.ElasticSearch.Options 5 | { 6 | public class ElasticClientFactoryOptions 7 | { 8 | private readonly TimeSpan _minimumElasticClientLifeTime = TimeSpan.FromHours(1.0); 9 | private TimeSpan _elasticClientLifeTime = TimeSpan.FromHours(24.0); 10 | 11 | public TimeSpan ElasticClientLifeTime 12 | { 13 | get => _elasticClientLifeTime; 14 | set 15 | { 16 | if (value != Timeout.InfiniteTimeSpan && value < _minimumElasticClientLifeTime) 17 | throw new ArgumentException(nameof(value)); 18 | _elasticClientLifeTime = value; 19 | } 20 | } 21 | 22 | public string UserName { get; set; } 23 | 24 | public string PassWord { get; set; } 25 | 26 | public string[] Urls { get; set; } 27 | 28 | public string DefaultIndex { get; set; } = "elastic_search_default_index"; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.Mysql/Core.EmailClient.Mysql.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.Mysql/EmailClientMysqlModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.EmailClient.Mysql 7 | { 8 | [DependsOn(typeof(CoreEmailClientModule))] 9 | public class EmailClientMysqlModule : CoreModuleBase 10 | { 11 | public IConfiguration Configuration { get; } 12 | 13 | public EmailClientMysqlModule(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public override void ConfigureServices(ServiceCollectionContext context) 19 | { 20 | context.Services.Configure(options => 21 | { 22 | options.AddMysql(Configuration.GetSection("EmailClient:Storage")); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.Mysql/MysqlEmailStorageOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EmailClient.Mysql 2 | { 3 | public class MysqlEmailStorageOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在table,即创建新的table 12 | /// 13 | public string DbTable { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.Mysql/MysqlServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.EmailClient; 2 | using Core.EmailClient.Mysql; 3 | using Microsoft.Extensions.Configuration; 4 | 5 | namespace Microsoft.Extensions.DependencyInjection 6 | { 7 | public static class MysqlServiceCollectionExtensions 8 | { 9 | public static EmailClientOptions AddMysql(this EmailClientOptions options, Action actionOptions) 10 | { 11 | options.AddExtensions(new EmailClientOptionsExtensions(actionOptions)); 12 | return options; 13 | } 14 | 15 | public static EmailClientOptions AddMysql(this EmailClientOptions options, IConfiguration configuration) 16 | { 17 | options.AddExtensions(new EmailClientOptionsExtensions(configuration)); 18 | return options; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.PostgreSql/Core.EmailClient.PostgreSql.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.PostgreSql/EmailClientPostgreSqlModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.EmailClient.PostgreSql 7 | { 8 | [DependsOn(typeof(CoreEmailClientModule))] 9 | public class EmailClientPostgreSqlModule : CoreModuleBase 10 | { 11 | public IConfiguration Configuration { get; } 12 | 13 | public EmailClientPostgreSqlModule(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public override void ConfigureServices(ServiceCollectionContext context) 19 | { 20 | context.Services.Configure(options => 21 | { 22 | options.AddPostgreSql(Configuration.GetSection("EmailClient:Storage")); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.PostgreSql/PostgreSqlEmailStorageOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EmailClient.PostgreSql 2 | { 3 | public class PostgreSqlEmailStorageOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在schema,即创建新的schema 12 | /// 13 | public string DbSchema { get; set; } 14 | 15 | /// 16 | /// 若数据库不存在table,即创建新的table 17 | /// 18 | public string DbTable { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient.PostgreSql/PostgreSqlServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.EmailClient; 2 | using Core.EmailClient.PostgreSql; 3 | using Microsoft.Extensions.Configuration; 4 | 5 | namespace Microsoft.Extensions.DependencyInjection 6 | { 7 | public static class PostgreSqlServiceCollectionExtensions 8 | { 9 | public static EmailClientOptions AddPostgreSql(this EmailClientOptions options, Action actionOptions) 10 | { 11 | options.AddExtensions(new EmailClientOptionsExtensions(actionOptions)); 12 | return options; 13 | } 14 | 15 | public static EmailClientOptions AddPostgreSql(this EmailClientOptions options, IConfiguration configuration) 16 | { 17 | options.AddExtensions(new EmailClientOptionsExtensions(configuration)); 18 | return options; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/Core.EmailClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/CoreEmailClientModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Core.EmailClient 7 | { 8 | public class CoreEmailClientModule : CoreModuleBase 9 | { 10 | public IConfiguration Configuration { get; } 11 | 12 | public CoreEmailClientModule(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public override void ConfigureServices(ServiceCollectionContext context) 18 | { 19 | context.Services.Configure(Configuration.GetSection("EmailClient")); 20 | context.Services.AddEmailClient(_ => { }); 21 | } 22 | 23 | public override void PostConfigureServices(ServiceCollectionContext context) 24 | { 25 | var serviceProvider = context.Services.BuildServiceProvider(); 26 | var options = serviceProvider.GetRequiredService>().Value; 27 | options.Configure(context.Services); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/EmailClientBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using Core.EmailClient.Storage; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace Core.EmailClient 6 | { 7 | public class EmailClientBackgroundService : BackgroundService 8 | { 9 | private readonly IServiceScopeFactory _serviceScopeFactory; 10 | 11 | public EmailClientBackgroundService( 12 | IServiceScopeFactory serviceScopeFactory) 13 | { 14 | _serviceScopeFactory = serviceScopeFactory; 15 | } 16 | protected override Task ExecuteAsync(CancellationToken stoppingToken) 17 | { 18 | var provider = _serviceScopeFactory.CreateScope().ServiceProvider; 19 | 20 | //初始化消息存储 21 | var storage = provider.GetService(); 22 | storage?.InitializeAsync(stoppingToken); 23 | 24 | return Task.CompletedTask; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/EmailClientServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.EmailClient; 2 | using Microsoft.Extensions.DependencyInjection.Extensions; 3 | 4 | namespace Microsoft.Extensions.DependencyInjection 5 | { 6 | public static class EmailClientServiceCollectionExtensions 7 | { 8 | public static IServiceCollection AddEmailClient(this IServiceCollection services, 9 | Action configureOptions) 10 | { 11 | if (services == null) 12 | throw new ArgumentNullException(nameof(services)); 13 | 14 | if (configureOptions == null) 15 | throw new ArgumentNullException(nameof(configureOptions)); 16 | 17 | services.Configure(configureOptions); 18 | services.TryAddSingleton(); 19 | services.AddHostedService(); 20 | 21 | var options = new EmailClientOptions(); 22 | configureOptions.Invoke(options); 23 | options.Configure(services); 24 | return services; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/IEmailClient.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EmailClient 2 | { 3 | public interface IEmailClient 4 | { 5 | /// 6 | /// 发送邮件 7 | /// 8 | /// 9 | /// 10 | /// 11 | Task SendAsync(MailBodyEntity mailBodyEntity, CancellationToken cancellationToken = default); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/IEmailClientOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.EmailClient 4 | { 5 | public interface IEmailClientOptionsExtensions 6 | { 7 | void AddServices(IServiceCollection services); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/Storage/IEmailStorage.cs: -------------------------------------------------------------------------------- 1 | using Core.EmailClient.Storage.Model; 2 | 3 | namespace Core.EmailClient.Storage 4 | { 5 | public interface IEmailStorage 6 | { 7 | Task InitializeAsync(CancellationToken cancellationToken = default); 8 | 9 | Task AddAsync(AddEmailModel model, object dbTransaction = null, CancellationToken cancellationToken = default); 10 | 11 | Task UpdateAsync(UpdateEmailModel model, CancellationToken cancellationToken = default); 12 | 13 | Task> GetAsync(QueryEmailModel query, CancellationToken cancellationToken = default); 14 | 15 | Task GetAsync(string id, CancellationToken cancellationToken = default); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/Storage/Model/QueryEmailModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EmailClient.Storage.Model 2 | { 3 | public class QueryEmailModel 4 | { 5 | public bool? IsSend { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EmailClient/Storage/Model/UpdateEmailModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EmailClient.Storage.Model 2 | { 3 | public class UpdateEmailModel 4 | { 5 | public UpdateEmailModel(string id, bool isSend) 6 | { 7 | Id = id; 8 | IsSend = isSend; 9 | } 10 | public string Id { get; set; } 11 | 12 | public bool IsSend { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore.Sharding/Core.EntityFrameworkCore.Sharding.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 3.1.9.12 6 | gaobo 7 | gaobo 8 | asp net core basic framework 9 | https://github.com/Boy-boy/CoreFramework 10 | MIT 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore.Sharding/DbContextModelExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata.Internal; 2 | 3 | namespace Core.EntityFrameworkCore.Sharding 4 | { 5 | public static class DbContextModelExtensions 6 | { 7 | public static bool ValidateModelIsReadonly(this Model model) 8 | { 9 | return model.IsReadOnly; 10 | } 11 | 12 | public static void TryFinalizeModel(this Model model) 13 | { 14 | if (!model.ValidateModelIsReadonly()) 15 | { 16 | model.FinalizeModel(); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/Core.EntityFrameworkCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | asp net core basic framework 6 | gaobo 7 | 3.1.9.17 8 | https://github.com/Boy-boy/CoreFramework 9 | MIT 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/CoreEfCoreModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using System; 5 | using System.Linq; 6 | using Core.Modularity.Attribute; 7 | using Core.Uow; 8 | 9 | namespace Core.EntityFrameworkCore 10 | { 11 | [DependsOn(typeof(CoreUnitOfWorkModule))] 12 | public class CoreEfCoreModule : CoreModuleBase 13 | { 14 | public override void ConfigureServices(ServiceCollectionContext context) 15 | { 16 | var dbContextTypes = context.Items.Values 17 | .Select(value => value as Type) 18 | .Where(value => typeof(DbContext).IsAssignableFrom(value)) 19 | .Distinct() 20 | .ToList(); 21 | dbContextTypes.ForEach(dbContextType => 22 | { 23 | context.Services.AddRepositories(dbContextType); 24 | }); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/DbContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Ddd.Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.ChangeTracking; 4 | using System.Collections.Generic; 5 | 6 | namespace Core.EntityFrameworkCore 7 | { 8 | public static class DbContextExtensions 9 | { 10 | public static void TrySoftDeleted(this IEnumerable entityEntries) 11 | { 12 | foreach (var entry in entityEntries) 13 | { 14 | if (entry.State != EntityState.Deleted) continue; 15 | 16 | var entityType = entry.Entity.GetType(); 17 | if (!typeof(ISoftDeleted).IsAssignableFrom(entityType)) continue; 18 | 19 | if (entry.Entity is ISoftDeleted softDeleted) 20 | softDeleted.IsDeleted = true; 21 | entry.State = EntityState.Modified; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/DbContextNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Core.EntityFrameworkCore 5 | { 6 | public class DbContextNameAttribute:Attribute 7 | { 8 | public virtual string Name { get; } 9 | 10 | public DbContextNameAttribute(string name) 11 | { 12 | if (string.IsNullOrWhiteSpace(name)) 13 | { 14 | throw new ArgumentException($"{nameof(name)} can not be null, empty or white space!"); 15 | } 16 | Name = name; 17 | } 18 | 19 | public static string GetNameOrDefault(Type messageType) 20 | { 21 | if (messageType == null) 22 | { 23 | throw new ArgumentNullException(nameof(messageType)); 24 | } 25 | return messageType 26 | .GetCustomAttributes(true) 27 | .OfType() 28 | .FirstOrDefault() 29 | ?.Name 30 | ?? messageType.FullName; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/EntityFrameworkCore/EfCoreDatabaseApi.cs: -------------------------------------------------------------------------------- 1 | using Core.Uow; 2 | using Microsoft.EntityFrameworkCore; 3 | using System.Threading.Tasks; 4 | using System.Threading; 5 | 6 | namespace Core.EntityFrameworkCore.EntityFrameworkCore 7 | { 8 | public class EfCoreDatabaseApi : IDatabaseApi, ISupportsSavingChanges 9 | { 10 | public DbContext DbContext { get; } 11 | 12 | public EfCoreDatabaseApi(DbContext dbContext) 13 | { 14 | DbContext = dbContext; 15 | } 16 | 17 | public Task SaveChangesAsync(CancellationToken cancellationToken = default) 18 | { 19 | return DbContext.SaveChangesAsync(cancellationToken); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/EntityFrameworkCore/EfCoreTransactionApi.cs: -------------------------------------------------------------------------------- 1 | using Core.Uow; 2 | using System.Threading.Tasks; 3 | using Microsoft.EntityFrameworkCore.Storage; 4 | 5 | namespace Core.EntityFrameworkCore.EntityFrameworkCore 6 | { 7 | public class EfCoreTransactionApi : ITransactionApi 8 | { 9 | private readonly IDbContextTransaction _dbContextTransaction; 10 | 11 | public EfCoreTransactionApi(IDbContextTransaction dbContextTransaction) 12 | { 13 | _dbContextTransaction = dbContextTransaction; 14 | } 15 | 16 | public async Task CommitAsync() 17 | { 18 | await _dbContextTransaction.CommitAsync(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/EntityFrameworkCore/IDbContextProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using System.Threading.Tasks; 3 | 4 | namespace Core.EntityFrameworkCore 5 | { 6 | public interface IDbContextProvider 7 | where TDbContext : DbContext 8 | { 9 | Task GetDbContextAsync(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/Repositories/IEfCoreRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Ddd.Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.EntityFrameworkCore.Repositories 6 | { 7 | public interface IEfCoreRepository 8 | { 9 | } 10 | 11 | public interface IEfCoreRepository : IEfCoreRepository 12 | where TEntity : class, IEntity 13 | { 14 | Task GetDbContextAsync(); 15 | 16 | Task> GetDbSetAsync(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EntityFrameworkCore/Repositories/QueryableExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Ddd.Domain.Entities; 2 | using System; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace Core.EntityFrameworkCore.Repositories 7 | { 8 | public static class QueryableExtensions 9 | { 10 | public static IQueryable Where(this IQueryable queryable, Expression> predicate, bool applyPredicate) 11 | where TEntity : IEntity 12 | { 13 | return applyPredicate ? queryable.Where(predicate) : queryable; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.Mysql/Core.EventBus.Mysql.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.12 7 | gaobo 8 | asp net core basic framework 9 | MIT 10 | https://github.com/Boy-boy/CoreFramework 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.Mysql/CoreEventBusMysqlModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.EventBus.Mysql 7 | { 8 | [DependsOn(typeof(CoreEventBusModule))] 9 | public class CoreEventBusMysqlModule : CoreModuleBase 10 | { 11 | public IConfiguration Configuration { get; } 12 | 13 | public CoreEventBusMysqlModule(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | public override void ConfigureServices(ServiceCollectionContext context) 18 | { 19 | context.Services.Configure(options => 20 | { 21 | options.AddMysql(Configuration.GetSection("EventBus:Storage")); 22 | }); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.Mysql/EventBusMysqlOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Mysql 2 | { 3 | public class EventBusMysqlOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在table,即创建新的table 12 | /// 13 | public string DbTable { get; set; } = "PublishMessage"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.Mysql/MysqlServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using System; 3 | 4 | namespace Core.EventBus.Mysql 5 | { 6 | public static class MysqlServiceCollectionExtensions 7 | { 8 | public static EventBusOptions AddMysql(this EventBusOptions options, Action actionOptions) 9 | { 10 | if (actionOptions == null) 11 | throw new ArgumentNullException(nameof(actionOptions)); 12 | options.AddExtensions(new EventBusOptionsExtensions(actionOptions)); 13 | return options; 14 | } 15 | 16 | public static EventBusOptions AddMysql(this EventBusOptions options, IConfiguration configuration) 17 | { 18 | if (configuration == null) 19 | throw new ArgumentNullException(nameof(configuration)); 20 | options.AddExtensions(new EventBusOptionsExtensions(configuration)); 21 | return options; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.PostgreSql/Core.EventBus.PostgreSql.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.12 7 | gaobo 8 | gaobo 9 | asp net core basic frameworkMIT 10 | MIT 11 | https://github.com/Boy-boy/CoreFramework 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.PostgreSql/CoreEventBusPostgreSqlModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.EventBus.PostgreSql 7 | { 8 | [DependsOn(typeof(CoreEventBusModule))] 9 | public class CoreEventBusPostgreSqlModule : CoreModuleBase 10 | { 11 | public IConfiguration Configuration { get; } 12 | 13 | public CoreEventBusPostgreSqlModule(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public override void ConfigureServices(ServiceCollectionContext context) 19 | { 20 | context.Services.Configure(options => 21 | { 22 | options.AddPostgreSql(Configuration.GetSection("EventBus:Storage")); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.PostgreSql/EventBusPostgreSqlOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.PostgreSql 2 | { 3 | public class EventBusPostgreSqlOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在schema,即创建新的schema 12 | /// 13 | public string DbSchema { get; set; } = "EventBus"; 14 | 15 | /// 16 | /// 若数据库不存在table,即创建新的table 17 | /// 18 | public string DbTable { get; set; } = "PublishMessage"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.PostgreSql/PostgreSqlServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using System; 3 | 4 | namespace Core.EventBus.PostgreSql 5 | { 6 | public static class PostgreSqlServiceCollectionExtensions 7 | { 8 | public static EventBusOptions AddPostgreSql(this EventBusOptions options, Action actionOptions) 9 | { 10 | if (actionOptions == null) 11 | throw new ArgumentNullException(nameof(actionOptions)); 12 | options.AddExtensions(new EventBusOptionsExtensions(actionOptions)); 13 | return options; 14 | } 15 | 16 | public static EventBusOptions AddPostgreSql(this EventBusOptions options, IConfiguration configuration) 17 | { 18 | if (configuration == null) 19 | throw new ArgumentNullException(nameof(configuration)); 20 | options.AddExtensions(new EventBusOptionsExtensions(configuration)); 21 | return options; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.RabbitMQ/Core.EventBus.RabbitMQ.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | asp net core basic framework 6 | 3.1.9.12 7 | gaobo 8 | gaobo 9 | https://github.com/Boy-boy/CoreFramework 10 | MIT 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.RabbitMQ/CoreEventBusRabbitMqModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Core.RabbitMQ; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Core.EventBus.RabbitMQ 8 | { 9 | [DependsOn(typeof(CoreEventBusModule), 10 | typeof(CoreRabbitMqModule))] 11 | public class CoreEventBusRabbitMqModule : CoreModuleBase 12 | { 13 | public IConfiguration Configuration { get; } 14 | 15 | public CoreEventBusRabbitMqModule(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public override void ConfigureServices(ServiceCollectionContext context) 21 | { 22 | context.Services.Configure(options => 23 | { 24 | options.AddRabbitMq(Configuration.GetSection("EventBus:RabbitMq")); 25 | }); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.RabbitMQ/EventBusRabbitMqOptions.cs: -------------------------------------------------------------------------------- 1 | using Core.RabbitMQ; 2 | using System; 3 | 4 | namespace Core.EventBus.RabbitMQ 5 | { 6 | public class EventBusRabbitMqOptions 7 | { 8 | private string _defaultExchangeName = "event_bus_default_routing"; 9 | 10 | public string ExchangeName 11 | { 12 | get => _defaultExchangeName; 13 | set => _defaultExchangeName = value ?? throw new Exception("exchange is not allowed to be null"); 14 | } 15 | 16 | public EventBusRabbitMqOptions() 17 | { 18 | Connection = new RabbitMqConnectionConfigure(); 19 | } 20 | 21 | public RabbitMqConnectionConfigure Connection { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.RabbitMQ/EventBusRabbitMqServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using Core.EventBus.RabbitMQ; 3 | using Microsoft.Extensions.Configuration; 4 | using System; 5 | using EventBusOptionsExtensions = Core.EventBus.RabbitMQ.EventBusOptionsExtensions; 6 | 7 | namespace Microsoft.Extensions.DependencyInjection 8 | { 9 | public static class EventBusRabbitMqServiceCollectionExtensions 10 | { 11 | public static EventBusOptions AddRabbitMq(this EventBusOptions options, Action actionOptions) 12 | { 13 | if (actionOptions == null) 14 | throw new ArgumentNullException(nameof(actionOptions)); 15 | 16 | options.AddExtensions(new EventBusOptionsExtensions(actionOptions)); 17 | return options; 18 | } 19 | 20 | public static EventBusOptions AddRabbitMq(this EventBusOptions options, IConfiguration configuration) 21 | { 22 | if (configuration == null) 23 | throw new ArgumentNullException(nameof(configuration)); 24 | 25 | options.AddExtensions(new EventBusOptionsExtensions(configuration)); 26 | return options; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.SqlServer/Core.EventBus.SqlServer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.12 7 | 8 | gaobo 9 | gaobo 10 | asp net core basic framework 11 | MIT 12 | https://github.com/Boy-boy/CoreFramework 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.SqlServer/CoreEventBusSqlServerModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.EventBus.SqlServer 7 | { 8 | [DependsOn(typeof(CoreEventBusModule))] 9 | public class CoreEventBusSqlServerModule : CoreModuleBase 10 | { 11 | public IConfiguration Configuration { get; } 12 | 13 | public CoreEventBusSqlServerModule(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public override void ConfigureServices(ServiceCollectionContext context) 19 | { 20 | context.Services.Configure(options => 21 | { 22 | options.AddSqlServer(Configuration.GetSection("EventBus:Storage")); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.SqlServer/EventBusSqlServerOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.SqlServer 2 | { 3 | public class EventBusSqlServerOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在table,即创建新的table 12 | /// 13 | public string DbTable { get; set; } = "PublishMessage"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus.SqlServer/SqlServerServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using System; 3 | 4 | namespace Core.EventBus.SqlServer 5 | { 6 | public static class SqlServerServiceCollectionExtensions 7 | { 8 | public static EventBusOptions AddSqlServer(this EventBusOptions options, Action actionOptions) 9 | { 10 | if (actionOptions == null) 11 | throw new ArgumentNullException(nameof(actionOptions)); 12 | options.AddExtensions(new EventBusOptionsExtensions(actionOptions)); 13 | return options; 14 | } 15 | 16 | public static EventBusOptions AddSqlServer(this EventBusOptions options, IConfiguration configuration) 17 | { 18 | if (configuration == null) 19 | throw new ArgumentNullException(nameof(configuration)); 20 | options.AddExtensions(new EventBusOptionsExtensions(configuration)); 21 | return options; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Core.EventBus.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | https://github.com/Boy-boy/CoreFramework 6 | gaobo 7 | 3.1.9.12 8 | asp net core basic framework 9 | MIT 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/CoreEventBusModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Options; 4 | 5 | namespace Core.EventBus 6 | { 7 | public class CoreEventBusModule : CoreModuleBase 8 | { 9 | public override void ConfigureServices(ServiceCollectionContext context) 10 | { 11 | context.Services.AddEventBus(_ => { }); 12 | } 13 | 14 | public override void PostConfigureServices(ServiceCollectionContext context) 15 | { 16 | var serviceProvider = context.Services.BuildServiceProvider(); 17 | var options = serviceProvider.GetRequiredService>().Value; 18 | options.Configure(context.Services); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/EventBusServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using Core.EventBus.Transaction; 3 | using Microsoft.Extensions.DependencyInjection.Extensions; 4 | using System; 5 | 6 | namespace Microsoft.Extensions.DependencyInjection 7 | { 8 | public static class EventBusServiceCollectionExtensions 9 | { 10 | public static IServiceCollection AddEventBus(this IServiceCollection services, Action configureOptions) 11 | { 12 | if (services == null) 13 | throw new ArgumentNullException(nameof(services)); 14 | 15 | if (configureOptions == null) 16 | throw new ArgumentNullException(nameof(configureOptions)); 17 | 18 | services.TryAddSingleton(); 19 | services.TryAddTransient(); 20 | services.AddHostedService(); 21 | services.Configure(configureOptions); 22 | 23 | var options = new EventBusOptions(); 24 | configureOptions.Invoke(options); 25 | options.Configure(services); 26 | return services; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/IEventBusOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.EventBus 4 | { 5 | public interface IEventBusOptionsExtensions 6 | { 7 | void AddServices(IServiceCollection services); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IIntegrationMessageHandlerManager.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Integration 2 | { 3 | public interface IIntegrationMessageHandlerManager : IMessageHandlerManager 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IIntegrationMessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Integration 2 | { 3 | public interface IIntegrationMessageHandlerProvider : IMessageHandlerProvider 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IIntegrationMessagePublisher.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Integration 2 | { 3 | public interface IIntegrationMessagePublisher : IMessagePublisher 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IIntegrationMessageSubscribe.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Integration 2 | { 3 | public interface IIntegrationMessageSubscribe : IMessageSubscribe 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IOutBoxSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Core.EventBus.Integration 5 | { 6 | public interface IOutBoxSender 7 | { 8 | Task StartAsync(CancellationToken cancellationToken); 9 | 10 | Task StopAsync(CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IntegrationMessageHandlerManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.EventBus.Integration 4 | { 5 | public class IntegrationMessageHandlerManager : MessageHandlerManager, IIntegrationMessageHandlerManager 6 | { 7 | public IntegrationMessageHandlerManager(IServiceScopeFactory serviceScopeFactory) 8 | : base(serviceScopeFactory) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IntegrationMessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Integration 2 | { 3 | public class IntegrationMessageHandlerProvider : MessageHandlerProvider, IIntegrationMessageHandlerProvider 4 | { 5 | public IntegrationMessageHandlerProvider(IIntegrationMessageHandlerManager localMessageHandlerManager) 6 | : base(localMessageHandlerManager) 7 | { 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Integration/IntegrationServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.DependencyInjection.Extensions; 3 | 4 | namespace Core.EventBus.Integration 5 | { 6 | public static class IntegrationServiceCollectionExtensions 7 | { 8 | public static IServiceCollection AddIntegrationCore(this IServiceCollection services) 9 | { 10 | services.TryAddSingleton(); 11 | services.TryAddSingleton(); 12 | services.TryAddTransient(); 13 | return services; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/CoreEventBusLocalModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Modularity.Attribute; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.EventBus.Local 6 | { 7 | [DependsOn(typeof(CoreEventBusModule))] 8 | public class CoreEventBusLocalModule : CoreModuleBase 9 | { 10 | public override void ConfigureServices(ServiceCollectionContext context) 11 | { 12 | context.Services.Configure(options => 13 | { 14 | options.AddLocalMq(); 15 | }); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/EventBusLocalCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public static class EventBusLocalCollectionExtensions 4 | { 5 | public static EventBusOptions AddLocalMq(this EventBusOptions options) 6 | { 7 | options.AddExtensions(new EventBusOptionsExtensions()); 8 | return options; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/EventBusOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.DependencyInjection.Extensions; 3 | 4 | namespace Core.EventBus.Local 5 | { 6 | public class EventBusOptionsExtensions : IEventBusOptionsExtensions 7 | { 8 | public void AddServices(IServiceCollection services) 9 | { 10 | services.TryAddSingleton(); 11 | services.TryAddSingleton(); 12 | services.TryAddSingleton(); 13 | services.TryAddSingleton(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/ILocalMessageHandlerManager.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public interface ILocalMessageHandlerManager : IMessageHandlerManager 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/ILocalMessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public interface ILocalMessageHandlerProvider: IMessageHandlerProvider 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/ILocalMessagePublisher.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public interface ILocalMessagePublisher: IMessagePublisher 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/ILocalMessageSubscribe.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public interface ILocalMessageSubscribe : IMessageSubscribe 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/LocalMessageHandlerManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.EventBus.Local 4 | { 5 | public class LocalMessageHandlerManager : MessageHandlerManager, ILocalMessageHandlerManager 6 | { 7 | public LocalMessageHandlerManager(IServiceScopeFactory serviceScopeFactory) 8 | : base(serviceScopeFactory) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/LocalMessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Local 2 | { 3 | public class LocalMessageHandlerProvider : MessageHandlerProvider, ILocalMessageHandlerProvider 4 | { 5 | public LocalMessageHandlerProvider(ILocalMessageHandlerManager localMessageHandlerManager) 6 | : base(localMessageHandlerManager) 7 | { 8 | 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Local/LocalMessageSubscribe.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus.Messaging; 2 | using System; 3 | 4 | namespace Core.EventBus.Local 5 | { 6 | public class LocalMessageSubscribe : MessageSubscribeBase, ILocalMessageSubscribe 7 | { 8 | private readonly ILocalMessageHandlerManager _messageHandlerManager; 9 | 10 | public LocalMessageSubscribe(ILocalMessageHandlerManager messageHandlerManager) 11 | { 12 | _messageHandlerManager = messageHandlerManager; 13 | } 14 | 15 | protected override void Subscribe(Type messageType, Type handlerType) 16 | { 17 | _messageHandlerManager.AddHandler(messageType, handlerType); 18 | } 19 | 20 | public override void Subscribe() 21 | { 22 | Subscribe(typeof(T), typeof(TH)); 23 | } 24 | 25 | public override void UnSubscribe() 26 | { 27 | _messageHandlerManager.RemoveHandler(typeof(T), typeof(TH)); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/Attributes/MessageGroupAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Core.EventBus 6 | { 7 | [AttributeUsage(AttributeTargets.Class)] 8 | public class MessageGroupAttribute : Attribute 9 | { 10 | public virtual string Group { get; } 11 | 12 | public MessageGroupAttribute(string group) 13 | { 14 | if (string.IsNullOrWhiteSpace(group)) 15 | { 16 | throw new ArgumentException($"{nameof(group)} can not be null, empty or white space!"); 17 | } 18 | Group = group; 19 | } 20 | 21 | public static string GetGroupOrDefault(Type messageType) 22 | { 23 | if (messageType == null) 24 | { 25 | throw new ArgumentNullException(nameof(messageType)); 26 | } 27 | return messageType 28 | .GetCustomAttributes(true) 29 | .OfType() 30 | .FirstOrDefault() 31 | ?.Group 32 | ?? Assembly.GetEntryAssembly()?.GetName().Name?.ToLower(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/Attributes/MessageHandlerLifetimeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Core.EventBus 5 | { 6 | [AttributeUsage(AttributeTargets.Class)] 7 | public class MessageHandlerLifetimeAttribute : Attribute 8 | { 9 | public MessageHandlerLifetime Lifetime { get; } 10 | 11 | public MessageHandlerLifetimeAttribute(MessageHandlerLifetime lifetime) 12 | { 13 | Lifetime = lifetime; 14 | } 15 | 16 | public static MessageHandlerLifetime GetHandlerLifetime(Type handlerType) 17 | { 18 | if (handlerType == null) 19 | { 20 | throw new ArgumentNullException(nameof(handlerType)); 21 | } 22 | return handlerType 23 | .GetCustomAttributes(true) 24 | .OfType() 25 | .FirstOrDefault() 26 | ?.Lifetime 27 | ?? MessageHandlerLifetime.Transient; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/Attributes/MessageNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Core.EventBus 5 | { 6 | [AttributeUsage(AttributeTargets.Class)] 7 | public class MessageNameAttribute : Attribute 8 | { 9 | public virtual string Name { get; } 10 | 11 | public MessageNameAttribute(string name) 12 | { 13 | if (string.IsNullOrWhiteSpace(name)) 14 | { 15 | throw new ArgumentException($"{nameof(name)} can not be null, empty or white space!"); 16 | } 17 | Name = name; 18 | } 19 | 20 | public static string GetNameOrDefault(Type messageType) 21 | { 22 | if (messageType == null) 23 | { 24 | throw new ArgumentNullException(nameof(messageType)); 25 | } 26 | return messageType 27 | .GetCustomAttributes(true) 28 | .OfType() 29 | .FirstOrDefault() 30 | ?.Name 31 | ?? messageType.FullName; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/Diagnostics/DiagnosticListenerConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Diagnostics 2 | { 3 | public static class DiagnosticListenerConstants 4 | { 5 | private const string CorePrefix = "Core.EventBus."; 6 | 7 | public const string DiagnosticListenerName = CorePrefix + "DiagnosticListener"; 8 | 9 | public const string BeforePublish = CorePrefix + "PublishBefore"; 10 | public const string AfterPublish = CorePrefix + "PublishAfter"; 11 | public const string ErrorPublish = CorePrefix + "PublishError"; 12 | 13 | public const string BeforeConsume = CorePrefix + "ConsumeBefore"; 14 | public const string AfterConsume = CorePrefix + "ConsumeAfter"; 15 | public const string ErrorConsume = CorePrefix + "ConsumeError"; 16 | 17 | public const string NotSubscribed = CorePrefix + "NotSubscribed"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.EventBus 5 | { 6 | public interface IMessage 7 | { 8 | Guid Id { get; set; } 9 | 10 | DateTime Timestamp { get; set; } 11 | 12 | IDictionary Items { get; } 13 | 14 | void AddItems(IDictionary items); 15 | 16 | void RemoveItem(string itemKey); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessageHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Core.EventBus 4 | { 5 | public interface IMessageHandler 6 | { 7 | } 8 | 9 | public interface IMessageHandler : IMessageHandler 10 | where TMessage : class, IMessage 11 | { 12 | Task HandAsync(TMessage message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessageHandlerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.EventBus 5 | { 6 | public interface IMessageHandlerManager 7 | { 8 | event EventHandler OnEventRemoved; 9 | 10 | IList MessageHandlerWrappers { get; } 11 | 12 | void AddHandler(Type messageType, Type handlerType); 13 | 14 | void RemoveHandler(Type messageType, Type handlerType); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.EventBus 5 | { 6 | public interface IMessageHandlerProvider 7 | { 8 | IEnumerable GetHandlers(Type messageType); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessageHandlerWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.EventBus 4 | { 5 | public interface IMessageHandlerWrapper 6 | { 7 | IMessageHandler Handler { get; } 8 | 9 | string MessageName { get; } 10 | 11 | Type MessageType { get; } 12 | 13 | Type HandlerType { get; } 14 | 15 | int HandlerPriority { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessagePublisher.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Core.EventBus 4 | { 5 | public interface IMessagePublisher 6 | { 7 | Task PublishAsync(T message) 8 | where T : class, IMessage; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/IMessageSubscribe.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Core.EventBus 4 | { 5 | public interface IMessageSubscribe 6 | { 7 | void Initialize(params Assembly[] assemblies); 8 | 9 | void Subscribe() 10 | where T : class, IMessage 11 | where TH : IMessageHandler, new(); 12 | 13 | void UnSubscribe() 14 | where T : class, IMessage 15 | where TH : IMessageHandler, new(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/MessageHandlerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Core.EventBus 7 | { 8 | public class MessageHandlerExtensions 9 | { 10 | public static IEnumerable GetHandlerTypes(params Assembly[] assemblies) 11 | { 12 | if (assemblies == null || assemblies.Length == 0) 13 | return new List(); 14 | return assemblies.SelectMany(a => a.DefinedTypes) 15 | .Where(t => typeof(IMessageHandler).GetTypeInfo().IsAssignableFrom(t)) 16 | .ToList(); 17 | } 18 | 19 | public static IEnumerable GetBaseHandlerTypes(Type handlerType) 20 | { 21 | var baseHandlerTypes = handlerType 22 | .GetInterfaces() 23 | .Where(t => 24 | t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IMessageHandler<>)); 25 | baseHandlerTypes = baseHandlerTypes.Distinct(); 26 | return baseHandlerTypes; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/MessageHandlerLifetime.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus 2 | { 3 | public enum MessageHandlerLifetime 4 | { 5 | Transient, 6 | 7 | Singleton 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Messaging/MessageHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Core.EventBus 6 | { 7 | public class MessageHandlerProvider : IMessageHandlerProvider 8 | { 9 | private readonly IMessageHandlerManager _messageHandlerManager; 10 | 11 | public MessageHandlerProvider(IMessageHandlerManager messageHandlerManager) 12 | { 13 | _messageHandlerManager = messageHandlerManager; 14 | } 15 | 16 | public IEnumerable GetHandlers(Type messageType) 17 | { 18 | return _messageHandlerManager.MessageHandlerWrappers 19 | .Where(p => p.MessageType == messageType) 20 | .OrderByDescending(x => x.HandlerPriority) 21 | .Select(s => s.Handler) 22 | .ToList(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Storage/IStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Core.EventBus.Storage 7 | { 8 | public interface IStorage 9 | { 10 | Task InitializeAsync(CancellationToken cancellationToken); 11 | 12 | void StoreMessage(MediumMessage message, object dbTransaction = null); 13 | 14 | List GetMessages(int maxCount); 15 | 16 | void Delete(Guid id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Storage/MediumMessage.cs: -------------------------------------------------------------------------------- 1 | using Core.Json.Newtonsoft; 2 | using System; 3 | 4 | namespace Core.EventBus.Storage 5 | { 6 | public class MediumMessage 7 | { 8 | public MediumMessage() 9 | { 10 | } 11 | 12 | public MediumMessage(IMessage aggregateRootEvent) 13 | { 14 | Id = Guid.NewGuid(); 15 | Version = 1; 16 | AssemblyName = aggregateRootEvent.GetType().Assembly.GetName().Name; 17 | MessageName = aggregateRootEvent.GetType().FullName; 18 | MessageData = aggregateRootEvent.ToJson(); 19 | CreateTime = DateTime.Now; 20 | UtcTime = DateTime.UtcNow; 21 | } 22 | 23 | public Guid Id { get; set; } 24 | 25 | public int Version { get; set; } 26 | 27 | public string AssemblyName { get; set; } 28 | 29 | public string MessageName { get; set; } 30 | 31 | public string MessageData { get; set; } 32 | 33 | public DateTime CreateTime { get; set; } 34 | 35 | public DateTime UtcTime { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Storage/StorageMarkerService.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Storage 2 | { 3 | public class StorageMarkerService 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Transaction/ITransaction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.EventBus.Transaction 6 | { 7 | public interface ITransaction : IDisposable 8 | { 9 | void Commit(); 10 | 11 | Task CommitAsync(CancellationToken cancellationToken = default); 12 | 13 | void Rollback(); 14 | 15 | Task RollbackAsync(CancellationToken cancellationToken = default); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Transaction/ITransactionAccessor.cs: -------------------------------------------------------------------------------- 1 | namespace Core.EventBus.Transaction 2 | { 3 | public interface ITransactionAccessor 4 | { 5 | ITransaction Transaction { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.EventBus/Transaction/TransactionAccessor.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace Core.EventBus.Transaction 4 | { 5 | public class TransactionAccessor : ITransactionAccessor 6 | { 7 | private static readonly AsyncLocal TransactionAsyncLocal = new(); 8 | 9 | public ITransaction Transaction 10 | { 11 | get => TransactionAsyncLocal.Value?.Transaction; 12 | set 13 | { 14 | var holder = TransactionAsyncLocal.Value; 15 | if (holder != null) 16 | { 17 | holder.Transaction = null; 18 | } 19 | 20 | if (value != null) 21 | { 22 | TransactionAsyncLocal.Value = new TransactionHolder { Transaction = value }; 23 | } 24 | } 25 | } 26 | 27 | private class TransactionHolder 28 | { 29 | public ITransaction Transaction; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Excel/Core.Excel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Excel/ExcelCellStyle.cs: -------------------------------------------------------------------------------- 1 | using OfficeOpenXml.Style; 2 | 3 | namespace Core.Excel 4 | { 5 | public struct ExcelCellStyle 6 | { 7 | public ExcelCellStyle(string numberFormat) 8 | : this(numberFormat, ExcelHorizontalAlignment.Left) 9 | { 10 | } 11 | 12 | public ExcelCellStyle(string numberFormat, ExcelHorizontalAlignment horizontalAlignment) 13 | { 14 | NumberFormat = numberFormat; 15 | HorizontalAlignment = horizontalAlignment; 16 | } 17 | 18 | public ExcelHorizontalAlignment HorizontalAlignment { get; } 19 | 20 | public string NumberFormat { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Excel/ExcelColumn.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Excel 2 | { 3 | public class ExcelColumn 4 | { 5 | public ExcelColumn(string name, string displayName, int order, ExcelCellStyle cellStyle) 6 | { 7 | Name = name; 8 | DisplayName = displayName; 9 | Order = order; 10 | CellStyle = cellStyle; 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string DisplayName { get; set; } 16 | 17 | public int Order { get; set; } 18 | 19 | public ExcelCellStyle CellStyle { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Framework/Core.Framework.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.HttpClient/Core.HttpClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.12 7 | gaobo 8 | asp net core basic framework 9 | MIT 10 | https://github.com/Boy-boy/CoreFramework 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.HttpClient/HttpClientResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.HttpClient 4 | { 5 | public class HttpClientResponse 6 | { 7 | public string Result { get; set; } 8 | 9 | public Exception Error { get; set; } 10 | 11 | public HttpClientResponse(string result) 12 | { 13 | Result = result; 14 | } 15 | 16 | public HttpClientResponse(Exception error) 17 | { 18 | Error = error; 19 | } 20 | 21 | public static HttpClientResponse Success(string result) 22 | { 23 | return new HttpClientResponse(result); 24 | } 25 | 26 | public static HttpClientResponse Failed(Exception error) 27 | { 28 | return new HttpClientResponse(error); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.HttpClient/HttpClientServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace Core.HttpClient 5 | { 6 | public static class HttpClientServiceCollectionExtensions 7 | { 8 | public static IServiceCollection AddBaseHttpClient(this IServiceCollection services) 9 | { 10 | if (services == null) 11 | throw new ArgumentNullException(nameof(services)); 12 | services.AddHttpClient(); 13 | return services; 14 | } 15 | public static IServiceCollection AddBaseHttpClient(this IServiceCollection services, Action options) 16 | { 17 | if (services == null) 18 | throw new ArgumentNullException(nameof(services)); 19 | services.AddHttpClient(options); 20 | return services; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.HttpClient/IBaseHttpClient.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Core.HttpClient 7 | { 8 | public interface IBaseHttpClient 9 | { 10 | Task GetAsync(string url, Dictionary requestHeaders, CancellationToken cancellationToken = default); 11 | 12 | Task PostAsync(string url, string content, CancellationToken cancellationToken = default); 13 | 14 | Task SendAsync(HttpRequestMessage requestMessage, CancellationToken cancellationToken = default); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Core.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | https://github.com/Boy-boy/CoreFramework 7 | 3.1.9.12 8 | gaobo 9 | asp net core basic framework 10 | MIT 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Exceptions/DomainException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Infrastructure.Exceptions 4 | { 5 | public class DomainException : Exception 6 | { 7 | public DomainException(string message, int errorCode) 8 | : base(message) 9 | { 10 | ErrorCode = errorCode; 11 | } 12 | 13 | public DomainException(string message, Exception innerException, int errorCode) 14 | : base(message, innerException) 15 | { 16 | ErrorCode = errorCode; 17 | } 18 | 19 | public int ErrorCode { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Recursive/IRecursiveModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Infrastructure.Recursive 2 | { 3 | public interface IRecursiveModel 4 | { 5 | public object Id { get; set; } 6 | 7 | /// 8 | /// 若为根节点,ParentId必须为null 9 | /// 10 | public object ParentId { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Recursive/RecursiveException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Infrastructure.Recursive 4 | { 5 | public class RecursiveException : Exception 6 | { 7 | public RecursiveException(string message) 8 | : base(message) 9 | { 10 | 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Recursive/RecursiveModelDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Infrastructure.Recursive 5 | { 6 | public class RecursiveModelDescriptor 7 | where T : IRecursiveModel 8 | { 9 | public T Instance { get; set; } 10 | 11 | public IReadOnlyList> Nodes => _nodes; 12 | 13 | private readonly List> _nodes; 14 | 15 | public RecursiveModelDescriptor(T instance) 16 | { 17 | Instance = instance ?? throw new ArgumentNullException(nameof(instance)); 18 | _nodes = new List>(); 19 | } 20 | 21 | public void SetNode(RecursiveModelDescriptor model) 22 | { 23 | if (model == null) 24 | return; 25 | _nodes.Add(model); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Infrastructure/Timer/NonCapturingTimer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Core.Infrastructure.Timer 5 | { 6 | public static class NonCapturingTimer 7 | { 8 | public static System.Threading.Timer Create( 9 | TimerCallback callback, 10 | object state, 11 | TimeSpan dueTime, 12 | TimeSpan period) 13 | { 14 | if (callback == null) 15 | throw new ArgumentNullException(nameof(callback)); 16 | var flag = false; 17 | try 18 | { 19 | if (!ExecutionContext.IsFlowSuppressed()) 20 | { 21 | ExecutionContext.SuppressFlow(); 22 | flag = true; 23 | } 24 | return new System.Threading.Timer(callback, state, dueTime, period); 25 | } 26 | finally 27 | { 28 | if (flag) 29 | ExecutionContext.RestoreFlow(); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Json/Core.Json.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | asp net core basic framework 6 | 3.1.9.12 7 | gaobo 8 | https://github.com/Boy-boy/CoreFramework 9 | MIT 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Abstraction/ICoreApplicationManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.Modularity.Abstraction 6 | { 7 | public interface ICoreApplicationManager 8 | { 9 | void ConfigureConfigureServices(IServiceCollection services); 10 | void Configure(IApplicationBuilder app); 11 | void Shutdown(IServiceProvider serviceProvider); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Abstraction/ICoreModule.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Modularity.Abstraction 2 | { 3 | public interface ICoreModule 4 | { 5 | void PreConfigureServices(ServiceCollectionContext context); 6 | void ConfigureServices(ServiceCollectionContext context); 7 | void PostConfigureServices(ServiceCollectionContext context); 8 | 9 | 10 | void PreConfigure(ApplicationBuilderContext context); 11 | void Configure(ApplicationBuilderContext app); 12 | 13 | void PostConfigure(ApplicationBuilderContext context); 14 | 15 | void Shutdown(ShutdownApplicationContext context); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Abstraction/ICoreModuleDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Modularity.Abstraction 5 | { 6 | public interface ICoreModuleDescriptor 7 | { 8 | Type ModuleType { get; } 9 | 10 | ICoreModule Instance { get; } 11 | 12 | IReadOnlyList Dependencies { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Abstraction/IModuleLoader.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace Core.Modularity.Abstraction 5 | { 6 | public interface IModuleLoader 7 | { 8 | ICoreModuleDescriptor[] LoadModules( 9 | IServiceCollection services, 10 | Type startupModuleType); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/ApplicationBuilderContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | 4 | namespace Core.Modularity 5 | { 6 | public class ApplicationBuilderContext 7 | { 8 | public IApplicationBuilder ApplicationBuilder { get; } 9 | 10 | public ApplicationBuilderContext(IApplicationBuilder applicationBuilder) 11 | { 12 | ApplicationBuilder = applicationBuilder ?? throw new ArgumentNullException(nameof(applicationBuilder)); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Attribute/DependsOnAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Modularity.Attribute 4 | { 5 | 6 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 7 | public class DependsOnAttribute : System.Attribute 8 | { 9 | public Type[] DependedTypes { get; } 10 | 11 | public DependsOnAttribute(params Type[] dependedTypes) 12 | { 13 | DependedTypes = dependedTypes ?? new Type[0]; 14 | } 15 | 16 | public virtual Type[] GetDependedTypes() 17 | { 18 | return DependedTypes; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/Core.Modularity.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 3.1.9.12 6 | gaobo 7 | gaobo 8 | asp net core basic framework 9 | https://github.com/Boy-boy/CoreFramework 10 | MIT 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/CoreApplicationManagerFactory.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity.Abstraction; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | 5 | namespace Core.Modularity 6 | { 7 | public static class CoreApplicationManagerFactory 8 | { 9 | public static ICoreApplicationManager CreateCoreApplication( 10 | Type startupModuleType, 11 | IServiceCollection services) 12 | { 13 | return new CoreApplicationManager(startupModuleType, services); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/CoreFrameworkApplicationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity.Abstraction; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace Core.Modularity 7 | { 8 | public static class CoreFrameworkApplicationBuilderExtensions 9 | { 10 | public static void BuildApplicationBuilder(this IApplicationBuilder app) 11 | { 12 | var application = app.ApplicationServices.GetRequiredService(); 13 | application.Configure(app); 14 | 15 | var requiredService = app.ApplicationServices.GetRequiredService(); 16 | requiredService.ApplicationStopping.Register(() => application.Shutdown(app.ApplicationServices)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/CoreFrameworkServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity.Abstraction; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | 5 | namespace Core.Modularity 6 | { 7 | public static class CoreFrameworkServiceCollectionExtensions 8 | { 9 | public static void ConfigureServiceCollection(this IServiceCollection service) 10 | where T : ICoreModule 11 | { 12 | ConfigureServiceCollection(service, typeof(T)); 13 | } 14 | 15 | public static void ConfigureServiceCollection(this IServiceCollection service, Type startupModuleType) 16 | { 17 | CoreApplicationManagerFactory.CreateCoreApplication(startupModuleType, service); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/ServiceCollectionContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Core.Modularity 6 | { 7 | public class ServiceCollectionContext 8 | { 9 | public IServiceCollection Services { get; } 10 | public IDictionary Items { get; } 11 | 12 | public object this[string key] 13 | { 14 | get => Items[key]; 15 | set => Items[key] = value; 16 | } 17 | public ServiceCollectionContext(IServiceCollection services) 18 | { 19 | Services = services ?? throw new ArgumentNullException(nameof(services)); 20 | Items = new Dictionary(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Modularity/ShutdownApplicationContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Modularity 4 | { 5 | public class ShutdownApplicationContext 6 | { 7 | public IServiceProvider ServiceProvider { get; } 8 | 9 | public ShutdownApplicationContext(IServiceProvider serviceProvider) 10 | { 11 | ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission.PostgreSql/Core.Permission.PostgreSql.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission.PostgreSql/PermissionPostgreSqlOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Permission.PostgreSql 2 | { 3 | public class PermissionPostgreSqlOptions 4 | { 5 | /// 6 | /// 数据库连接字符串 7 | /// 8 | public string DbConnection { get; set; } 9 | 10 | /// 11 | /// 若数据库不存在schema,即创建新的schema 12 | /// 13 | public string DbSchema { get; set; } = "Permission"; 14 | 15 | /// 16 | /// 若数据库不存在table,即创建新的table 17 | /// 18 | public string DbTable { get; set; } = "AccessRole"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission.PostgreSql/PostgreSqlConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Permission.PostgreSql; 3 | 4 | namespace Core.Permission.Storage 5 | { 6 | public static class PostgreSqlBuilderExtensions 7 | { 8 | public static PermissionOptions AddPostgreSql(this PermissionOptions options,Action actionOptions) 9 | { 10 | options.AddExtensions(new PostgreSqlOptionsExtensions(actionOptions)); 11 | return options; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission.PostgreSql/PostgreSqlOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Permission.PostgreSql; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.DependencyInjection.Extensions; 5 | 6 | namespace Core.Permission.Storage 7 | { 8 | public class PostgreSqlOptionsExtensions : IPermissionOptionsExtensions 9 | { 10 | private readonly Action _actionOptions; 11 | 12 | public PostgreSqlOptionsExtensions(Action actionOptions) 13 | { 14 | _actionOptions = actionOptions ?? throw new ArgumentNullException(nameof(actionOptions)); 15 | } 16 | public void AddServices(IServiceCollection services) 17 | { 18 | services.Configure(_actionOptions); 19 | services.TryAddSingleton(typeof(IPermissionGrantsStorage), typeof(PostgreSqlPermissionGrantsStorage)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Core.Permission.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/DefaultPermissionHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.Permission 6 | { 7 | public class DefaultPermissionHandlerProvider : IPermissionHandlerProvider 8 | { 9 | private readonly IEnumerable _handlers; 10 | 11 | public DefaultPermissionHandlerProvider(IEnumerable handlers) 12 | { 13 | _handlers = handlers ?? throw new ArgumentNullException(nameof(handlers)); ; 14 | } 15 | 16 | public Task> GetHandlersAsync() 17 | { 18 | return Task.FromResult(_handlers); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/IPermissionHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Core.Permission 4 | { 5 | public interface IPermissionHandler 6 | { 7 | Task HandlerAsync(PermissionHandlerContext handlerContext); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/IPermissionHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace Core.Permission 5 | { 6 | public interface IPermissionHandlerProvider 7 | { 8 | Task> GetHandlersAsync(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/IPermissionOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Permission 4 | { 5 | public interface IPermissionOptionsExtensions 6 | { 7 | void AddServices(IServiceCollection services); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/IPermissionService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace Core.Permission 5 | { 6 | public interface IPermissionService 7 | { 8 | Task AuthorizeAsync(List permissions); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionAppBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | 4 | namespace Core.Permission 5 | { 6 | public static class PermissionAppBuilderExtensions 7 | { 8 | public static IApplicationBuilder UsePermission(this IApplicationBuilder app) 9 | { 10 | if (app == null) 11 | { 12 | throw new ArgumentNullException(nameof(app)); 13 | } 14 | return app.UseMiddleware(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Core.Permission 6 | { 7 | public class PermissionAttribute : Attribute 8 | { 9 | private readonly string _policy; 10 | 11 | public PermissionAttribute(string policy) 12 | { 13 | if (string.IsNullOrWhiteSpace(policy)) 14 | throw new ArgumentNullException(nameof(policy)); 15 | _policy = policy; 16 | } 17 | 18 | public List GetPolicies() 19 | { 20 | return _policy.Split(',').ToList(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Hosting; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Core.Permission.Storage; 6 | 7 | namespace Core.Permission 8 | { 9 | public class PermissionBackgroundService : BackgroundService 10 | { 11 | private readonly IServiceScopeFactory _serviceScopeFactory; 12 | 13 | public PermissionBackgroundService(IServiceScopeFactory serviceScopeFactory) 14 | { 15 | _serviceScopeFactory = serviceScopeFactory; 16 | } 17 | 18 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 19 | { 20 | using var scope = _serviceScopeFactory.CreateScope(); 21 | var provider = scope.ServiceProvider; 22 | 23 | var storage = provider.GetRequiredService(); 24 | await storage.InitializeAsync(stoppingToken); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionHandlerContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using System.Collections.Generic; 4 | 5 | namespace Core.Permission 6 | { 7 | public class PermissionHandlerContext 8 | { 9 | private readonly HttpContext _httpContext; 10 | private readonly List _permissions; 11 | 12 | private bool _failCalled; 13 | private bool _succeedCalled; 14 | 15 | public PermissionHandlerContext(HttpContext httpContext, List permissions) 16 | { 17 | _httpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext)); 18 | _permissions = permissions ?? throw new ArgumentNullException(nameof(permissions)); 19 | } 20 | public HttpContext HttpContext => _httpContext; 21 | 22 | public List Permissions => _permissions; 23 | 24 | public virtual bool HasSucceeded => !_failCalled && _succeedCalled; 25 | 26 | public virtual bool HasFailed => _failCalled; 27 | 28 | public virtual void Fail() => _failCalled = true; 29 | 30 | public virtual void Succeed() => _succeedCalled = true; 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Permission 5 | { 6 | public class PermissionOptions 7 | { 8 | public bool InvokeHandlersAfterFailure { get; set; } = true; 9 | public PermissionOptions() 10 | { 11 | Extensions = new List(); 12 | } 13 | public List Extensions { get; set; } 14 | } 15 | 16 | public static class EventBusOptionsExtensions 17 | { 18 | public static void AddExtensions(this PermissionOptions options, IPermissionOptionsExtensions eventBusOptionExtensions) 19 | { 20 | if (eventBusOptionExtensions == null) 21 | throw new AggregateException(nameof(eventBusOptionExtensions)); 22 | options.Extensions.Add(eventBusOptionExtensions); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/PermissionResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Permission 2 | { 3 | public class PermissionResult 4 | { 5 | public bool Forbidden { get; private init; } 6 | public bool Succeeded { get; private init; } 7 | 8 | public static PermissionResult Success() 9 | { 10 | return new PermissionResult() 11 | { 12 | Succeeded = true 13 | }; 14 | } 15 | 16 | public static PermissionResult Forbid() 17 | { 18 | return new PermissionResult() 19 | { 20 | Forbidden = true 21 | }; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/IPermissionGrantsStorage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.Permission.Storage 6 | { 7 | public interface IPermissionGrantsStorage 8 | { 9 | Task InitializeAsync(CancellationToken cancellationToken = default); 10 | 11 | Task> GetAsync(MessageQueryModel query, CancellationToken cancellationToken = default); 12 | 13 | Task> GetAllAsync(CancellationToken cancellationToken = default); 14 | 15 | Task GetCountAsync(MessageQueryModel query, CancellationToken cancellationToken); 16 | 17 | Task UpdateAsync(ModifyMessageModel message, CancellationToken cancellationToken = default); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/InMemoryConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Permission.Storage 2 | { 3 | public static class InMemoryBuilderExtensions 4 | { 5 | public static PermissionOptions AddInMemory(this PermissionOptions options) 6 | { 7 | options.AddExtensions(new InMemoryOptionsExtensions()); 8 | return options; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/InMemoryOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.DependencyInjection.Extensions; 3 | 4 | namespace Core.Permission.Storage 5 | { 6 | public class InMemoryOptionsExtensions : IPermissionOptionsExtensions 7 | { 8 | public void AddServices(IServiceCollection services) 9 | { 10 | services.TryAddSingleton(typeof(IPermissionGrantsStorage),typeof(InMemoryPermissionGrantsStorage)); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/Model/MessageQueryModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Permission.Storage 2 | { 3 | public class MessageQueryModel : PageBaseDto 4 | { 5 | public string Name { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/Model/ModifyMessageModel.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Permission.Storage 2 | { 3 | public class ModifyMessageModel 4 | { 5 | public int Id { get; set; } 6 | 7 | public string Value { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/Model/PageBaseDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Permission.Storage 4 | { 5 | public class PageBaseDto 6 | { 7 | private int _pageIndex; 8 | 9 | private int _pageSize; 10 | 11 | public virtual int PageIndex 12 | { 13 | get => _pageIndex; 14 | set 15 | { 16 | if (value - 1 < 0) 17 | throw new Exception("分页索引不能小于0"); 18 | _pageIndex = value - 1; 19 | } 20 | } 21 | 22 | public virtual int PageSize 23 | { 24 | get => _pageSize; 25 | set 26 | { 27 | if (value < 0) 28 | throw new Exception("分页大小不能小于0"); 29 | _pageSize = value == 0 ? 10 : value; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/Model/PageResultDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Core.Permission.Storage 4 | { 5 | public class PageResultDto 6 | { 7 | public int Count { get; set; } 8 | 9 | public List Items { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /CoreFramework/src/Core.Permission/Storage/PermissionGrantsEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Permission.Storage 4 | { 5 | public class PermissionGrantsEntity 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string Value { get; set; } 12 | 13 | public bool IsValid { get; set; } 14 | 15 | public DateTime CreateTime { get; set; } 16 | 17 | public DateTime UpdateTime { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/Core.Pipeline.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/DefaultPipelineBuilderFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public class DefaultPipelineBuilderFactory : IPipelineBuilderFactory 4 | { 5 | public IPipelineBuilder CreateBuilder() 6 | { 7 | return new DefaultPipelineBuilder(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IPipeline.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IPipeline 4 | { 5 | 6 | } 7 | 8 | public interface IPipeline : IPipeline where TRequest : IRequest 9 | { 10 | Task InvokeAsync(TRequest request, RequestPipelineDelegate next, CancellationToken cancellationToken = default); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IPipelineBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IPipelineBuilder 4 | { 5 | IPipelineBuilder Use(Func middleware); 6 | 7 | RequestPipelineDelegate Build(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IPipelineBuilderFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IPipelineBuilderFactory 4 | { 5 | IPipelineBuilder CreateBuilder(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IPipelineProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IPipelineProvider 4 | { 5 | RequestPipelineDelegate Get() where TRequest : IRequest; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IRequest 4 | { 5 | public IEnumerable> Features { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IRequestHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IRequestHandler 4 | { 5 | } 6 | 7 | public interface IRequestHandler : IRequestHandler 8 | where TRequest : IRequest 9 | { 10 | Task HandleAsync(TRequest request, CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IRequestPreHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IRequestPreHandler 4 | { 5 | } 6 | 7 | public interface IRequestPreHandler : IRequestPreHandler 8 | where TRequest : IRequest 9 | { 10 | Task HandleAsync(TRequest request, CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/IRequestProHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public interface IRequestProHandler 4 | { 5 | } 6 | 7 | public interface IRequestProHandler : IRequestProHandler 8 | where TRequest : IRequest 9 | { 10 | Task HandleAsync(TRequest request, CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/PipelineModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace Core.Pipeline 5 | { 6 | public class PipelineModule : CoreModuleBase 7 | { 8 | public override void ConfigureServices(ServiceCollectionContext context) 9 | { 10 | context.Services.AddPipeline(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/RequestHandlerPipeline.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | [PipelinePriority(998)] 4 | public class RequestHandlerPipeline : IPipeline 5 | where TRequest : IRequest 6 | { 7 | private readonly IEnumerable> _requestHandlers; 8 | 9 | public RequestHandlerPipeline(IEnumerable> requestHandlers) 10 | { 11 | requestHandlers ??= new List>(); 12 | _requestHandlers = requestHandlers.OrderBy(pipeline => 13 | HandlerPriorityAttribute.GetPriority(typeof(TRequest), pipeline.GetType())); 14 | } 15 | 16 | public async Task InvokeAsync(TRequest request, RequestPipelineDelegate next, CancellationToken cancellationToken = default) 17 | { 18 | foreach (var requestHandler in _requestHandlers) 19 | { 20 | await requestHandler.HandleAsync(request, cancellationToken); 21 | } 22 | await next(request, cancellationToken); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/RequestPipelineDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | public delegate Task RequestPipelineDelegate(IRequest request, CancellationToken cancellationToken); 4 | } 5 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/RequestPrePipeline.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | [PipelinePriority(-999)] 4 | public class RequestPrePipeline : IPipeline 5 | where TRequest : IRequest 6 | { 7 | private readonly IEnumerable> _preHandlers; 8 | 9 | public RequestPrePipeline(IEnumerable> preHandlers) 10 | { 11 | _preHandlers = preHandlers.OrderBy(pipeline => 12 | HandlerPriorityAttribute.GetPriority(typeof(TRequest), pipeline.GetType())); 13 | } 14 | 15 | public async Task InvokeAsync(TRequest request, RequestPipelineDelegate next, CancellationToken cancellationToken = default) 16 | { 17 | foreach (var preHandler in _preHandlers) 18 | await preHandler.HandleAsync(request, cancellationToken); 19 | await next(request, cancellationToken); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Pipeline/RequestProPipeline.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Pipeline 2 | { 3 | [PipelinePriority(999)] 4 | public class RequestProPipeline : IPipeline 5 | where TRequest : IRequest 6 | { 7 | private readonly IEnumerable> _proHandlers; 8 | 9 | public RequestProPipeline(IEnumerable> proHandlers) 10 | { 11 | _proHandlers = proHandlers.OrderBy(pipeline => 12 | HandlerPriorityAttribute.GetPriority(typeof(TRequest), pipeline.GetType())); 13 | } 14 | 15 | public async Task InvokeAsync(TRequest request, RequestPipelineDelegate next, CancellationToken cancellationToken = default) 16 | { 17 | foreach (var proHandler in _proHandlers) 18 | await proHandler.HandleAsync(request, cancellationToken); 19 | await next(request, cancellationToken); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/Core.RabbitMQ.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | https://github.com/Boy-boy/CoreFramework 6 | 3.1.9.12 7 | gaobo 8 | asp net core basic framework 9 | MIT 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/CoreRabbitMqModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.RabbitMQ 6 | { 7 | public class CoreRabbitMqModule : CoreModuleBase 8 | { 9 | public IConfiguration Configuration { get; } 10 | 11 | public CoreRabbitMqModule(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | public override void ConfigureServices(ServiceCollectionContext context) 16 | { 17 | context.Services.AddRabbitMq(Configuration.GetSection("RabbitMq")); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/IRabbitMqMessageConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using RabbitMQ.Client; 4 | using RabbitMQ.Client.Events; 5 | 6 | namespace Core.RabbitMQ 7 | { 8 | public interface IRabbitMqMessageConsumer:IDisposable 9 | { 10 | Task BindAsync(string routingKey); 11 | 12 | Task UnbindAsync(string routingKey); 13 | 14 | bool HasRoutingKeyBindingQueue(); 15 | 16 | void OnMessageReceived(Func processEvent); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/IRabbitMqMessageConsumerManager.cs: -------------------------------------------------------------------------------- 1 | namespace Core.RabbitMQ 2 | { 3 | public interface IRabbitMqMessageConsumerManager 4 | { 5 | IRabbitMqMessageConsumer TryCreate(RabbitMqExchangeDeclareConfigure exchangeDeclare, 6 | RabbitMqQueueDeclareConfigure queueDeclare); 7 | 8 | bool TryGet(string exchangeName, string queueName, out IRabbitMqMessageConsumer consumer); 9 | 10 | bool TryRemove(string exchangeName, string queueName); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/IRabbitMqPersistentConnection.cs: -------------------------------------------------------------------------------- 1 | using RabbitMQ.Client; 2 | using System; 3 | 4 | namespace Core.RabbitMQ 5 | { 6 | public interface IRabbitMqPersistentConnection 7 | : IDisposable 8 | { 9 | bool IsConnected { get; } 10 | 11 | bool TryConnect(); 12 | 13 | IModel CreateModel(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/RabbitMqConnectionConfigure.cs: -------------------------------------------------------------------------------- 1 | using RabbitMQ.Client; 2 | 3 | namespace Core.RabbitMQ 4 | { 5 | public class RabbitMqConnectionConfigure 6 | { 7 | public string HostName { get; set; } 8 | 9 | public int Port { get; set; } 10 | 11 | public string UserName { get; set; } 12 | 13 | public string Password { get; set; } 14 | 15 | public string VirtualHost { get; set; } 16 | 17 | 18 | public ConnectionFactory ConnectionFactory 19 | { 20 | get 21 | { 22 | var connectionFactory = new ConnectionFactory() 23 | { 24 | HostName = HostName, 25 | Port = Port, 26 | UserName = UserName, 27 | Password = Password, 28 | DispatchConsumersAsync = true 29 | }; 30 | if (!string.IsNullOrWhiteSpace(VirtualHost)) 31 | connectionFactory.VirtualHost = VirtualHost; 32 | return connectionFactory; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.RabbitMQ/RabbitMqOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.RabbitMQ 2 | { 3 | public class RabbitMqOptions 4 | { 5 | public RabbitMqConnectionConfigure Connection { get; set; } 6 | 7 | public RabbitMqOptions() 8 | { 9 | Connection = new RabbitMqConnectionConfigure(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Redis/Core.Redis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | 3.1.9.12 7 | gaobo 8 | asp net core basic framework 9 | MIT 10 | https://github.com/Boy-boy/CoreFramework 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Redis/CoreRedisModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Core.Redis 6 | { 7 | public class CoreRedisModule : CoreModuleBase 8 | { 9 | private readonly IConfiguration _configuration; 10 | 11 | public CoreRedisModule(IConfiguration configuration) 12 | { 13 | _configuration = configuration; 14 | } 15 | public override void ConfigureServices(ServiceCollectionContext context) 16 | { 17 | context.Services 18 | .AddRedisCache() 19 | .Configure(_configuration.GetSection("Redis")); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Redis/RedisCacheOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Redis 2 | { 3 | public class RedisCacheOptions 4 | { 5 | /// 6 | /// 连接字符串 7 | /// 8 | public string Configuration { get; set; } 9 | 10 | /// 11 | /// 连接健康检查 12 | /// 默认60秒检测一次 13 | /// 14 | public int ConnectionHealthCheck { get; set; } = 60; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Redis/RedisCacheServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.DependencyInjection.Extensions; 4 | 5 | namespace Core.Redis 6 | { 7 | public static class HttpClientServiceCollectionExtensions 8 | { 9 | public static IServiceCollection AddRedisCache(this IServiceCollection services, Action options=null) 10 | { 11 | if (services == null) 12 | throw new ArgumentNullException(nameof(services)); 13 | services.TryAddSingleton(typeof(IRedisCache), typeof(StackExchangeRedis)); 14 | if (options != null) 15 | services.Configure(options); 16 | return services; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Threading.Tasks/Concurrent/ConcurrentOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Threading.Tasks 4 | { 5 | public class ConcurrentOptions 6 | { 7 | /// 8 | /// 最小并发数 9 | /// 10 | private readonly int _minimumConcurrentCount = 1; 11 | 12 | /// 13 | /// 默认并发数 14 | /// 15 | private int _defaultConcurrentCount = 10; 16 | 17 | /// 18 | /// 最大并发量,默认为10 19 | /// 20 | public int MaxConcurrentCount 21 | { 22 | get => _defaultConcurrentCount; 23 | set 24 | { 25 | if (value < _minimumConcurrentCount) 26 | throw new ArgumentException(nameof(value)); 27 | _defaultConcurrentCount = value; 28 | } 29 | } 30 | 31 | /// 32 | /// 达到最大并发数,若在这段时间内没有接收到信号则跳过等待继续执行 33 | /// 34 | public int SecondsTimeout { get; set; } = 60; 35 | 36 | /// 37 | /// 任务结果生命周期,默认24小时 38 | /// 39 | public TimeSpan LifeTime { get; } = TimeSpan.FromHours(24); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Threading.Tasks/Concurrent/IConcurrentResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Threading.Tasks 2 | { 3 | public interface IConcurrentResult 4 | { 5 | /// 6 | /// 任务名称 7 | /// 8 | string TaskName { get; } 9 | 10 | /// 11 | /// 是否已完成 12 | /// 13 | bool IsCompleted { get; } 14 | 15 | /// 16 | /// 任务完成率 17 | /// 18 | double FinishingRate { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Threading.Tasks/Core.Threading.Tasks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/BaiDu/BaiDuTranslateOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Translate.BaiDu 2 | { 3 | public class BaiDuTranslateOptions 4 | { 5 | public string Url { get; set; } 6 | 7 | public string AppId { get; set; } 8 | 9 | public string SecretKey { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/BaiDu/BaiDuTranslateResponseDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Core.Translate.BaiDu 4 | { 5 | public class BaiDuTranslateResponseDto 6 | { 7 | /// 8 | /// 源语言 9 | /// 10 | public string From { get; set; } 11 | 12 | /// 13 | /// 目标语言 14 | /// 15 | public string To { get; set; } 16 | 17 | /// 18 | /// 翻译结果 19 | /// 20 | public List trans_result { get; set; } 21 | 22 | /// 23 | /// 错误码 24 | /// 25 | public int error_code { get; set; } 26 | 27 | /// 28 | /// 错误信息 29 | /// 30 | public string error_msg { get; set; } 31 | 32 | } 33 | 34 | public class TransDto 35 | { 36 | /// 37 | /// 原文 38 | /// 39 | public string Src { get; set; } 40 | 41 | /// 42 | /// 译文 43 | /// 44 | public string Dst { get; set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/Core.Translate.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/ITranslateProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.Translate 6 | { 7 | public interface ITranslateProvider 8 | { 9 | /// 10 | /// 翻译转换 11 | /// 12 | /// 原始数据 13 | /// 14 | /// 15 | /// 若出现错误,将以original输出 16 | Task> TranslateAsync(string original, 17 | TranslateQueryDto query, 18 | CancellationToken cancellationToken = default); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/TranslateModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Core.Translate.BaiDu; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Core.Translate 7 | { 8 | public class TranslateModule : CoreModuleBase 9 | { 10 | public IConfiguration Configuration { get; } 11 | 12 | public TranslateModule(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public override void ConfigureServices(ServiceCollectionContext context) 18 | { 19 | var services = context.Services; 20 | 21 | services.Configure(Configuration.GetSection("Translate:BaiDu")); 22 | services.AddBaiDuTranslate(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Translate/TranslateQueryDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Translate 2 | { 3 | public class TranslateQueryDto 4 | { 5 | public static TranslateQueryDto Default = new(); 6 | 7 | /// 8 | /// 翻译源语言 9 | /// 10 | public string From { get; set; } = "zh"; 11 | 12 | /// 13 | /// 翻译目标语言 14 | /// 15 | public string To { get; set; } = "en"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/Core.Uow.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 3.1.9.12 6 | gaobo 7 | asp net core basic framework 8 | https://github.com/Boy-boy/CoreFramework 9 | MIT 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/DefaultUnitOfWorkAccessor.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace Core.Uow 4 | { 5 | public class DefaultUnitOfWorkAccessor : IUnitOfWorkAccessor 6 | { 7 | private static readonly AsyncLocal UnitOfWorkAsyncLocal = new(); 8 | 9 | public IUnitOfWork UnitOfWork 10 | { 11 | get => UnitOfWorkAsyncLocal.Value; 12 | set => UnitOfWorkAsyncLocal.Value = value; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/IDatabaseApi.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Uow 2 | { 3 | public interface IDatabaseApi 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/IDatabaseApiContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Core.Uow 5 | { 6 | public interface IDatabaseApiContainer 7 | { 8 | IDatabaseApi FindDatabaseApi([NotNull] string key); 9 | 10 | void AddDatabaseApi([NotNull] string key, [NotNull] IDatabaseApi api); 11 | 12 | IDatabaseApi GetOrAddDatabaseApi([NotNull] string key, [NotNull] Func factory); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/ISupportsSavingChanges.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Core.Uow 5 | { 6 | public interface ISupportsSavingChanges 7 | { 8 | Task SaveChangesAsync(CancellationToken cancellationToken = default); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/ITransactionApi.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Core.Uow 4 | { 5 | public interface ITransactionApi 6 | { 7 | Task CommitAsync(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/ITransactionApiContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Core.Uow 5 | { 6 | public interface ITransactionApiContainer 7 | { 8 | ITransactionApi FindTransactionApi([NotNull] string key); 9 | 10 | void AddTransactionApi([NotNull] string key, [NotNull] ITransactionApi api); 11 | 12 | ITransactionApi GetOrAddTransactionApi([NotNull] string key, [NotNull] Func factory); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Core.Uow 6 | { 7 | public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer 8 | { 9 | UnitOfWorkOptions Options { get; } 10 | 11 | Task CommitAsync(CancellationToken cancellationToken = default); 12 | 13 | void AddLocalEvent(IMessage @event); 14 | 15 | void AddDistributedEvent(IMessage @event); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/IUnitOfWorkAccessor.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Uow 2 | { 3 | public interface IUnitOfWorkAccessor 4 | { 5 | IUnitOfWork UnitOfWork { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/UnitOfWorkAppBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | 4 | namespace Core.Uow 5 | { 6 | public static class UnitOfWorkAppBuilderExtensions 7 | { 8 | public static IApplicationBuilder UseUnitOfWork( 9 | this IApplicationBuilder app) 10 | { 11 | if (app == null) 12 | throw new ArgumentNullException(nameof(app)); 13 | return app.UseMiddleware(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/UnitOfWorkModule.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | 3 | namespace Core.Uow 4 | { 5 | public class CoreUnitOfWorkModule : CoreModuleBase 6 | { 7 | public override void ConfigureServices(ServiceCollectionContext context) 8 | { 9 | context.Services.AddUnitOfWork(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/UnitOfWorkOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Data; 2 | 3 | namespace Core.Uow 4 | { 5 | public class UnitOfWorkOptions 6 | { 7 | public bool IsTransactional { get; set; } 8 | 9 | public IsolationLevel? IsolationLevel { get; set; } 10 | 11 | 12 | public UnitOfWorkOptions() 13 | { 14 | } 15 | 16 | public UnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null) 17 | { 18 | IsTransactional = isTransactional; 19 | IsolationLevel = isolationLevel; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreFramework/src/Core.Uow/UnitOfWorkServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Uow 4 | { 5 | public static class UnitOfWorkServiceCollectionExtensions 6 | { 7 | public static IServiceCollection AddUnitOfWork(this IServiceCollection services) 8 | { 9 | services.AddSingleton(); 10 | services.AddTransient(provider => provider.GetRequiredService().UnitOfWork); 11 | return services; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/CustomerDbContext.cs: -------------------------------------------------------------------------------- 1 | using Core.EntityFrameworkCore; 2 | using EntityFrameworkCore.Api.Entities; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace EntityFrameworkCore.Api 6 | { 7 | public class CustomerDbContext : CoreDbContext 8 | { 9 | public CustomerDbContext(DbContextOptions options) 10 | : base(options) 11 | { 12 | } 13 | 14 | public DbSet Students { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Entities/Student.cs: -------------------------------------------------------------------------------- 1 | using Core.Ddd.Domain.Entities; 2 | using System; 3 | 4 | namespace EntityFrameworkCore.Api.Entities 5 | { 6 | public class Student : AggregateRoot 7 | { 8 | public Student(string name, int age) 9 | { 10 | Id = Guid.NewGuid().ToString(); 11 | Name = name; 12 | Age = age; 13 | } 14 | public string Id { get; set; } 15 | public string Name { get; set; } 16 | public int Age { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Events/AddStudentEvent.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | 3 | namespace EntityFrameworkCore.Api.Events 4 | { 5 | [MessageName("customer")] 6 | public class AddStudentEvent : Message 7 | { 8 | public string AggregateRootId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Events/AddStudentEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Core.Ddd.Domain.Repositories; 2 | using Core.EventBus; 3 | using EntityFrameworkCore.Api.Entities; 4 | using System.Threading.Tasks; 5 | 6 | namespace EntityFrameworkCore.Api.Events 7 | { 8 | public class AddStudentEventHandler : IMessageHandler 9 | { 10 | private readonly IRepository _repository; 11 | 12 | public AddStudentEventHandler(IRepository repository) 13 | { 14 | _repository = repository; 15 | } 16 | 17 | public async Task HandAsync(AddStudentEvent message) 18 | { 19 | var student = new Student("李四", 24); 20 | _repository.Add(student); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace EntityFrameworkCore.Api 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:54153", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "EntityFrameworkCore.Api": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/Startup.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace EntityFrameworkCore.Api 6 | { 7 | public class Startup 8 | { 9 | public void ConfigureServices(IServiceCollection services) 10 | { 11 | services.ConfigureServiceCollection(); 12 | } 13 | 14 | public void Configure(IApplicationBuilder app) 15 | { 16 | app.BuildApplicationBuilder(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EntityFrameworkCore.Api 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/test/EntityFrameworkCore.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "ConnectionStrings": { 4 | // "customer": "Server=.;Database=customer;Trusted_Connection=True;MultipleActiveResultSets=true", 5 | "customer": "Host=81.69.227.172;Port=31432;Database=customer;Username=postgres;Password=gb123456" 6 | }, 7 | "Logging": { 8 | "LogLevel": { 9 | "Default": "Information", 10 | "Microsoft": "Warning", 11 | "Microsoft.Hosting.Lifetime": "Information" 12 | } 13 | }, 14 | "AllowedHosts": "*", 15 | "EventBus": { 16 | "RabbitMq": { 17 | "ExchangeName": "exchange_name", 18 | "Connection": { 19 | "hostName": "81.69.227.172", 20 | "userName": "guest", 21 | "password": "guest", 22 | "port": "30072", 23 | "virtualHost": "/" 24 | } 25 | }, 26 | "Storage": { 27 | "DbConnection": "Host=81.69.227.172;Port=31432;Database=customer;Username=postgres;Password=gb123456", 28 | "DbSchema": "EventBus", 29 | "DbTable": "PublishMessage" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CoreFramework/test/Test/AmazonS3Test.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/test/Test/AmazonS3Test.cs -------------------------------------------------------------------------------- /CoreFramework/test/Test/PipelineTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/test/Test/PipelineTest.cs -------------------------------------------------------------------------------- /CoreFramework/test/Test/wwwroot/email_content.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 13 | 14 | 15 |
111
16 |

一个图像: Smiley face

17 | 18 | -------------------------------------------------------------------------------- /CoreFramework/test/Test/wwwroot/picture.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/test/Test/wwwroot/picture.gif -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/Event/CustomerEvent.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | 3 | namespace PublishApi.Event 4 | { 5 | [MessageName("customer")] 6 | public class CustomerEvent:Message 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/Event/CustomerHandler.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace PublishApi.Event 6 | { 7 | public class CustomerHandler : IMessageHandler 8 | { 9 | public Task HandAsync(CustomerEvent message) 10 | { 11 | Console.WriteLine(message.Id); 12 | return Task.CompletedTask; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace PublishApi 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:59889", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "PublishApi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/PublishApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boy-boy/CoreFramework/10ca3b8ec7fe8e7a658cf767fadf31097d24cb4f/CoreFramework/test/eventBus/PublishApi/Startup.cs -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PublishApi 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/PublishApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | //"customer": "Host=81.69.227.172;Port=31432;Database=customer;Username=postgres;Password=gb123456" 4 | "customer": "Data Source =.;Database =customer;Trusted_Connection =True;" 5 | }, 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*", 14 | "EventBus": { 15 | "RabbitMq": { 16 | "ExchangeName": "exchange_name", 17 | "Connection": { 18 | "hostName": "81.69.227.172", 19 | "userName": "guest", 20 | "password": "guest", 21 | "port": "30072", 22 | "virtualHost": "/" 23 | } 24 | }, 25 | "Storage": { 26 | //"DbConnection": "Host=81.69.227.172;Port=31432;Database=customer;Username=postgres;Password=gb123456", 27 | "DbConnection": "Data Source =.;Database =customer;Trusted_Connection =True;", 28 | "DbSchema": "EventBus", 29 | "DbTable": "PublishMessage" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Event/CustomerEvent.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | 3 | namespace SubscriptionApi.Event 4 | { 5 | [MessageName("customer")] 6 | public class CustomerEvent : Message 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Event/EventHandler.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace SubscriptionApi.Event 6 | { 7 | public class EventHandler : IMessageHandler 8 | { 9 | public Task HandAsync(CustomerEvent message) 10 | { 11 | Console.WriteLine("handler"+message.Id); 12 | return Task.CompletedTask; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Event/EventHandler1.cs: -------------------------------------------------------------------------------- 1 | using Core.EventBus; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace SubscriptionApi.Event 6 | { 7 | [MessageHandlerPriority(9)] 8 | public class EventHandler1 : IMessageHandler 9 | { 10 | public Task HandAsync(CustomerEvent message) 11 | { 12 | Console.WriteLine("handler1"+message.Id); 13 | return Task.CompletedTask; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace SubscriptionApi 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:59928", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "SubscriptionApi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/Startup.cs: -------------------------------------------------------------------------------- 1 | using Core.Modularity; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace SubscriptionApi 8 | { 9 | public class Startup 10 | { 11 | public Startup(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public IConfiguration Configuration { get; } 17 | 18 | public void ConfigureServices(IServiceCollection services) 19 | { 20 | //services.AddEventBus(options => 21 | //{ 22 | // options.AddConsumers(typeof(Startup).Assembly); 23 | // options.AddRabbitMq(Configuration.GetSection("EventBus:RabbitMq")); 24 | //}); 25 | 26 | services.ConfigureServiceCollection(); 27 | } 28 | 29 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 30 | { 31 | app.BuildApplicationBuilder(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/SubscriptionApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SubscriptionApi 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreFramework/test/eventBus/SubscriptionApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "EventBus": { 11 | "RabbitMq": { 12 | "ExchangeName": "exchange_name", 13 | "Connection": { 14 | "hostName": "81.69.227.172", 15 | "userName": "guest", 16 | "password": "guest", 17 | "port": "30072", 18 | "virtualHost": "/" 19 | } 20 | } 21 | } 22 | } 23 | --------------------------------------------------------------------------------