Giter Site home page Giter Site logo

anjoy8 / blog.core Goto Github PK

View Code? Open in Web Editor NEW
4.8K 160.0 1.3K 70.73 MB

💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:

Home Page: http://apk.neters.club/.doc

License: Apache License 2.0

C# 97.53% HTML 1.69% Batchfile 0.17% JavaScript 0.02% Shell 0.13% Dockerfile 0.25% CSS 0.23%
netcore automapper repository t4 netcore-webapi sqlsugarcore dto redis aop ioc

blog.core's Introduction

Blog.Core

English | 简体中文

sdk Build status Build Status codecov License MIT star this repo fork this repo 博客园

   


Blog.Core 开箱即用的企业级前后端分离【 .NET Core6.0 Api + Vue 2.x + RBAC】权限框架。
其他版本看具体分支吧🎉
官网:http://apk.neters.club/.doc/


已被近100家公司所使用(🐱‍🚀):点击查看列表 欢迎盖楼,留下公司真实名字的,可得定制化指导服务。
同时如果企业有付费咨询,欢迎联系老张(QQ:3143422472)。

核心项目组成员(排名不分先后)

hudingwenLemonNoCry、、Jamnine何拾玖

❤ 真实用户反馈 ❤

项目单体部署,并发在400~500,一切正常(不保证自己的各种错误写法)。  
如果搭配负载,效果更好。

1、A~CoderDong:
应用场景:使用Blog.Core为基础骨架开发,搭建Client监控类守护进程项目,To C 客户群,
并发情况:目前压测并发5k正常8秒处理完,并发10k可15秒处理完毕,异常不会丢失。
生产配置:一台服务器(Linux环境 + 至强8核的16G内存 + mysql数据库 + 3台Nginx负载)

 

给个星星! ⭐️

如果你喜欢这个项目或者它帮助你, 请给 Star~
如果你的项目中借鉴了本项目,请稍微说明下#75,开源不易✨。

功能与进度

企业使用高级版本

  • 包含开源版 框架模块/组件模块 中的所有功能;
  • 全部表结构主键底层架构改成string类型(默认雪花,支持guid),更方便迁移;
  • 完善部门数据权限,可以基于策略配置查看数据范围;
  • 优化权限处理器,解决多实例分布式下,权限不同步问题(必须配置Redis);
  • 增加在线用户查看功能,并实现强制用户下线功能(必须配置Redis);
  • 增加用户黑名单功能(必须配置Redis);
  • 增加岗位功能(单独建表),配合部门使用;
  • 后期优化站内通知功能,其实目前已经有SignalR来实现消息推送了,可以直接用;
  • 前端Blog.Admin.Pro使用AntDesignVue框架(设计中,未完全实现);
  • 铁粉奖励:如果参与上述功能和其他付费功能开发,可半价获取商业授权;

框架模块:

  • 采用仓储+服务+接口的形式封装框架;
  • 自定义项目模板 CreateYourProject.bat ,可以一键生成自己的项目;🎶
  • 异步 async/await 开发;
  • 接入国产数据库ORM组件 —— SqlSugar,封装数据库操作,支持级联操作;
  • 支持自由切换多种数据库,MySql/SqlServer/Sqlite/Oracle/Postgresql/达梦/人大金仓;
  • 实现项目启动,自动生成种子数据 ✨;
  • 实现数据库主键类型配置化,什么类型都可以自定义 ✨;
  • 五种日志记录,审计/异常/请求响应/服务操作/Sql记录等,并自动持久化到数据库表🎶;
  • 支持项目事务处理(若要分布式,用cap即可)✨;
  • 设计4种 AOP 切面编程,功能涵盖:日志、缓存、审计、事务 ✨;
  • 全局统一封装 Serilog 生成多种日志,并自动生成到数据库中,目前支持MySql/SqlServer/Sqlite/Oracle/Postgresql🎉;
  • 设计并支持按钮级别的RBAC权限控制,同时支持一键同步接口和菜单 🎶;
  • 支持 T4 代码模板,自动生成每层代码;
  • 或使用 DbFirst 一键创建自己项目的四层文件(支持多库);
  • 封装Blog.Core.Webapi.Template项目模板,一键重建自己的项目 ✨;
  • 搭配多个前端案例供参考和借鉴:Blog.Vue、Blog.Admin、Nuxt.tbug、Blog.Mvp.Blazor ✨;
  • 统一集成 IdentityServer4 认证 ✨;
  • 统一实现多租户;
  • 实现分表案例,支持分表的增删改查哈分页查询,具体查看SplitDemoController.cs;
  • 支持signalR对指定用户通讯;

组件模块:

  • 提供 Redis 做缓存处理;
  • 使用 Swagger 做api文档;
  • 使用 MiniProfiler 做接口性能分析 ✨;
  • 使用 Automapper 处理对象映射;
  • 使用 AutoFac 做依赖注入容器,并提供批量服务注入 ✨;
  • 支持 CORS 跨域;
  • 封装 JWT 自定义策略授权;
  • 使用 Serilog 日志框架,集成原生 ILogger 接口做日志记录;
  • 使用 SignalR 双工通讯 ✨;
  • 添加 IpRateLimiting 做 API 限流处理;
  • 使用 Quartz.net 做任务调度(目前单机多任务,集群调度暂不支持);
  • 支持 数据库读写分离和多库操作 ✨;
  • 新增 Redis 消息队列 ✨;
  • 新增 RabbitMQ 消息队列 ✨;
  • 新增 EventBus 事件总线 ✨;
  • 新增 - 统一聚合支付;
  • 新增 - Nacos注册中心配置;
  • 新增 - ES 搜索配置;
  • 新增 - Apollo 配置;
  • 新增 Kafka 消息队列,并配合实现EventBus ✨;
  • 新增 微信公众号管理,并集成到Blog.Admin后台 ✨;
  • 新增 - 数据部门权限;
  • 新增 - Serilog 集成日志数据持久化到数据库;
  • 新增 - 多租户模式(单表,多表,多库三种模式);

微服务模块:

  • 可配合 Docker 实现容器化;
  • 可配合 Jenkins 实现CI / CD;
  • 可配合 Consul 实现服务发现;
  • 可配合 Nacos 实现服务发现;
  • 可配合 apisix/Ocelot 实现网关处理;
  • 可配合 Nginx 实现负载均衡;
  • 可配合 Ids4 实现认证中心;

核心业务模块

框架采用泛型仓储模式,以下几层为核心层,不可删除

Blog.Core.ApiBlog.Core.CommonBlog.Core.IServicesBlog.Core.ModelBlog.Core.RepositoryBlog.Core.ServicesBlog.Core.TasksBlog.Core.Serilog
其他代码分层是支撑层,如果自己业务涉及不到,可以删除。

API接口层主要是基于RBAC的基于按钮级别的角色授权逻辑,以下几个Controller,不可删除

BaseApiController.cs(接口基类)、DepartmentController(部门)、ImgController(图片)、LoginController(登录)、ModuleController(接口)、PermissionController(菜单)、RoleController(角色)、TasksQzController(任务调度)、UserController(用户)、UserRoleController(用户角色关系)
其他代码部分是扩展业务,如果自己业务涉及不到,可以删除。

自定义全部日志记录图

系统架构图

自定义(中间件/服务)启动图

系统架构图

 

贡献者们

Thanks goes to these wonderful people ():(排名暂时按提交顺序)

This project follows the all-contributors specification. Contributions of any kind are welcome!

 

官方文档 📕

还在陆续整理中,不过基本操作都在,包括如何新手入门,配置数据,连接DB等等

官方文档
公众号重要文章+视频地址

 

系统架构图

系统架构图

 

 

系统压测结果报告

本项目是 .netCore 后端部分,前端部分请看我的另三个Vue工程项目

       

个人博客Vue版本 tBug项目Nuxt版本 VueAdmin权限管理后台
https://github.com/anjoy8/Blog.Vue https://github.com/anjoy8/Nuxt.tBug https://github.com/anjoy8/Blog.Admin
http://vueblog.neters.club http://tibug.neters.club http://vueadmin.neters.club

 

初始化项目

下载项目后,编译如果没问题,直接运行即可,会自动生成种子数据,数据库是Sqlite,接口文档是swagger

更多操作,点击这里:http://apk.neters.club/.doc/guide/getting-started.html

 

Nuget Packages

Package NuGet Stable Downloads
Blog.Core.Webapi.Template Blog.Core.Webapi.Template Blog.Core.Webapi.Template

关于如何使用,点击这里:https://www.cnblogs.com/laozhang-is-phi/p/10205495.html

   

其他后端框架

目前一共开源四个框架项目,感兴趣的可以看看

单层项目 简单仓储框架 仓储+服务+接口 DDD框架
CURD+Seed CURD+Seed+DI CURD+Seed+DI+AOP等 DDD+EFCore+DI+EventBus等
NetCore-Sugar-Demo Blog.SplRepository.Demo Blog.Core ChristDDD
- Blog-EFCore-Sqlite - -

 

 

售后服务与支持

鼓励作者,简单打赏~~
如果你喜欢,就给作者加个鸡腿吧

赞赏码

[图片若加载不出来,点这里](http://apk.neters.club/laozhangisphigood.jpg)

文章+视频+直播

博客园:https://www.cnblogs.com/laozhang-is-phi/

Bilibili:https://space.bilibili.com/387802716

直播间:https://live.bilibili.com/21507364

 

如果你感觉看着这整个项目比较费劲,我单抽出来了几个子Demo,方便学习,项目地址 :https://github.com/anjoy8/BlogArti

blog.core's People

Contributors

317447880 avatar anewboyz avatar anjoy8 avatar binyly avatar biubiue avatar blue20171027 avatar boboyunz avatar cluyun avatar cuno92 avatar dependabot[bot] avatar flying666 avatar gkleo avatar hsxian avatar hudingwen avatar huijiongit avatar jamnine avatar jasonliuliuliuliu avatar jsonby avatar jxd728 avatar kimiding avatar lemonnocry avatar lm avatar rlei123 avatar roinbi avatar shuisen avatar skang0401 avatar weiguang3100 avatar wmchuang avatar wuare avatar www5255977 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blog.core's Issues

项目执行的时候出现错误

There is already an open DataReader associated with this Command which must be closed first.

可以尝试在连接字符串中,加上
MultipleActiveResultSets=true

具体的原因和方案,探究中

appsettings.json操作类 建议

    static Appsettings()
    {
        string Path = "appsettings.json";
        if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
        {
            Path = "appsettings.Development.json";
        }

        Configuration = new ConfigurationBuilder()
        .Add(new JsonConfigurationSource { Path = Path, ReloadOnChange = true })//请注意要把当前appsetting.json 文件->右键->属性->复制到输出目录->始终复制
        .Build();
    }

增加环境变量的判断

版本区别

master,NETcore2.2 有什么区别吗,master 是NETCore 2.2吗

git下来发布到win server2008的iis报错,查看事件日志,autofac无法实例化BlogArticleServices

Application: dotnet.exe
CoreCLR Version: 4.700.19.46205
.NET Core Version: 3.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IHostedService[] (DelegateActivator), Services = [System.Collections.Generic.IEnumerable1[[Microsoft.Extensions.Hosting.IHostedService, Microsoft.Extensions.Hosting.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = ExternallyOwned ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Job1TimedService (ReflectionActivator), Services = [Microsoft.Extensions.Hosting.IHostedService], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)
---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Job1TimedService (ReflectionActivator), Services = [Microsoft.Extensions.Hosting.IHostedService], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters: Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.)
---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.<>c__DisplayClass5_0.b__0()
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass0_0.<CanSupplyValue>b__0() at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.<>c__DisplayClass5_0.b__0()
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass0_1.<RegistrationsFor>b__2(IComponentRegistration cr) at System.Linq.Enumerable.SelectIPartitionIterator2.MoveNext()
at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass0_0.b__0(IComponentContext c, IEnumerable1 p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Blog.Core.Program.Main(String[] args) in D:\Work\Svn\Blog\Blog.Core\Blog.Core\Program.cs:line 64

DbHelper.ttinclude 模板 执行报错

DbHelper.ttinclude 下载下来的大小为 14k --博主认为是 上传文件有问题 待检查

报错如下:正在编译转换: 类、结构或接口成员声明中的标记“this”无效 Blog.Core.FrameWork
E:\Study\BlogTest\Blog.Core-master (1)\Blog.Core-master\Blog.Core.FrameWork\DbHelper.ttinclude

发现LogAop存在无法记录异常信息的问题

if (typeof(Task).IsAssignableFrom(type))
{
var resultProperty = type.GetProperty("Result");
dataIntercept += ($"【执行完成结果】:{JsonConvert.SerializeObject(resultProperty.GetValue(invocation.ReturnValue))}");
}
else
{
dataIntercept += ($"【执行完成结果】:{invocation.ReturnValue}");
}

        Parallel.For(0, 1, e =>
        {
            LogLock.OutSql2Log("AOPLog", new string[] { dataIntercept });
        });//多线程并行的for循环

方法无法执行到log记录

关于本项目在并发中出现数据库连接closed的问题。

【用sqlsugr有时候会报Invalid operation. The connection is closed】

【说明】:就是在异步多并发的时候,sugar实例偶尔会出现连接异常,并不是很常见,如果并发达不到一千以上,不用担心这个问题。

【更正】:有人提到这个问题,多半是自己没有更新SqlSugar 5.0.10+版本,请不要使用之前的版本,还一直压测说报错。

如果还不行
【最后的方案】
1、或者每次访问仓储中每一个方法的时候,都new一个实例,这样实例就不会丢失了。比如把BaseRepository的_db换成一个获取实例方法,每次都new一个,或者ISqlsugarclient注入改成services.AddTransient(o =>。
但是这样不利于事务提交,所以我不建议这么操作。

2、当然好像在同步中没有这个问题,想省事儿,改成同步也行。

bug 太多了

bug太多了。,
线上的权限分配勾选父权限。无法选中子的

更新user的角色,代码里是Add角色.

` ///


/// 更新用户与角色
///

///
///
// PUT: api/User/5
[HttpPut]
public async Task<MessageModel> Put([FromBody] sysUserInfo sysUserInfo)
{
// 这里也要做后期处理,会有用户个人中心的业务

        var data = new MessageModel<string>();
        if (sysUserInfo != null && sysUserInfo.uID > 0)
        {
            if (sysUserInfo.RID > 0)
            {
                var usrerole = await _userRoleServices.Query(d => d.UserId == sysUserInfo.uID && d.RoleId == sysUserInfo.RID);
                if (usrerole.Count == 0)
                {
                    await _userRoleServices.Add(new UserRole(sysUserInfo.uID, sysUserInfo.RID));
                }
            }

            data.success = await _sysUserInfoServices.Update(sysUserInfo);
            if (data.success)
            {
                data.msg = "更新成功";
                data.response = sysUserInfo?.uID.ObjToString();
            }
        }

        return data;
    }`

FromBody 方式 提交实体 IPLogMildd.cs 报错

楼主发现个错误,如下
测试代码
` public async Task Login([FromBody] LoginModel loginModel)
{

    return new JsonResult(new
            {
                success = false,
                message = "msg"
            });

}`
在 IPLogMildd.cs 报错 行 72
导致进不到方法中

请问 为何每个Repository(IUnitOfWork unitOfWork) 都要传递这个unitOfWork

XXXRepository通过反射加入容器,那这个 IUnitOfWork 肯定来源于容器依赖注入,IUnitOfWork 依赖于SqlSugarClient的ADO事务;这种传递是为何?也没见类内部使用啊。
如果想用跨方法事务,直接在构造方法注入即可,开启线程share,难道不传时,直接注入IUnitOfWork 会出问题?

项目在Seed Mysql 数据时候报错。

错误信息:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL

Quartz 任务是否 IsStart 问题

1,当应用程序部署在iis 中,iis应用程序池有回收机制,回收之后quartz会全部停止,此时TasksQz表里的IsStart 字段将不再准确,
建议使用以下代码判断启动状态
public async Task GetJobState(TaskJobInfo model)
{
JobKey jobKey = new JobKey(model.rowId.ToString(), model.jobGroup);
var triggers = (await _scheduler.Result.GetTriggersOfJob(jobKey)).FirstOrDefault();
if (triggers != null)
{
return await _scheduler.Result.GetTriggerState(triggers.Key);
}
return TriggerState.None;
}

2,建议将task 从主程序中剥离出来,单独部署

MD5 32算法修改

MD5Encrypt32
pwd = string.Concat(pwd, item.ToString("X"));
改成
pwd = string.Concat(pwd, item.ToString("X2"));

要保证32位

mysql +sqlsugar 时间类型的字段 SugarColumn 设置可空 c#的时间字段不是可空类型

环境:sqlsugar+mysql
[SugarColumn(ColumnName = "approval_time", ColumnDescription = "审核时间"**,IsNullable =true**)] public DateTime approval_time { get; set; }
加上特性IsNullable =true 但是 DateTime 没有加?实体查询的时候会导致程序崩溃!是奔溃!不是报错哦! 如果改成

[SugarColumn(ColumnName = "approval_time", ColumnDescription = "审核时间"**,IsNullable =true**)] public DateTime? approval_time { get; set; }
就没有问题

netcore2.2分支下Blog.Core.Model/Seed/DBSeed.cs GitJsonFileFormat和GitJsonFileForma2 url不存在

https://github.com/anjoy8/Blog.Core/blob/netcore2.2/Blog.Core.Model/Seed/DBSeed.cs
该文件下的GitJsonFileFormat和GitJsonFileForma2 url不存在(gitee和github)都如此,导致无法自动初始化表数据。估计是大牛你忘记了url吧。

改为如下。具体大牛你再看下
// 这是我的在线demo数据,比较多,且杂乱
// 国内网络不好的,可以使用这个 gitee 上的地址:https://gitee.com/laozhangIsPhi/Blog.Data.Share/raw/master/BlogCore.Data.json/{0}.tsv
// 形如https://gitee.com/laozhangIsPhi/Blog.Data.Share/raw/master/BlogCore.Data.json/BlogArticle.tsv
// private static string GitJsonFileFormat = "https://gitee.com/laozhangIsPhi/Blog.Data.Share/raw/master/BlogCore.Data.json/{0}.tsv";
private static string GitJsonFileFormat = "https://github.com/anjoy8/Blog.Data.Share/blog/master/BlogCore.Data.json.json/{0}.tsv";

    // 这里我把重要的权限数据提出来的精简版,默认一个Admin_Role + 一个管理员用户,
    // 然后就是菜单+接口+权限分配,注意没有其他博客信息了,下边seeddata 的时候,删掉即可。
    // 国内网络不好的,可以使用这个 gitee 上的地址:https://gitee.com/laozhangIsPhi/Blog.Data.Share/tree/master/Student.Achieve.json/{0}.tsv
    private static string GitJsonFileFormat2 = "https://github.com/anjoy8/Blog.Data.Share/blob/master/Student.Achieve.json/{0}.tsv";

git下来发布到win server2008的iis报错,查看事件日志,autofac无法实例化BlogArticleServices

Application: dotnet.exe
CoreCLR Version: 4.700.19.46205
.NET Core Version: 3.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IHostedService[] (DelegateActivator), Services = [System.Collections.Generic.IEnumerable1[[Microsoft.Extensions.Hosting.IHostedService, Microsoft.Extensions.Hosting.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = ExternallyOwned ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Job1TimedService (ReflectionActivator), Services = [Microsoft.Extensions.Hosting.IHostedService], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)
---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Job1TimedService (ReflectionActivator), Services = [Microsoft.Extensions.Hosting.IHostedService], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters: Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = BlogArticleServices (ReflectionActivator), Services = [Blog.Core.IServices.BASE.IBaseServices1[[Blog.Core.Model.Models.BlogArticle, Blog.Core.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Blog.Core.IServices.IBlogArticleServices], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'. (See inner exception for details.)
---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Blog.Core.Services.BlogArticleServices' can be invoked with the available services and parameters:
Cannot resolve parameter 'Blog.Core.IRepository.IBlogArticleRepository dal' of constructor 'Void .ctor(Blog.Core.IRepository.IBlogArticleRepository, AutoMapper.IMapper)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.<>c__DisplayClass5_0.b__0()
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass0_0.<CanSupplyValue>b__0() at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.<>c__DisplayClass5_0.b__0()
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass0_1.<RegistrationsFor>b__2(IComponentRegistration cr) at System.Linq.Enumerable.SelectIPartitionIterator2.MoveNext()
at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass0_0.b__0(IComponentContext c, IEnumerable1 p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Blog.Core.Program.Main(String[] args) in D:\Work\Svn\Blog\Blog.Core\Blog.Core\Program.cs:line 64

Exception middle ware with serilog

I am not using Log4 dot net.insted of lo4.net i am using serilog

private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(typeof(ExceptionHandlerMidd));

so please help me How to Configure serilog in Exception middleware

我在用JWT这步时报了一个错误

System.ArgumentException:“IDX12709: CanReadToken() returned false. JWT is not well formed: '[PII is hidden]'.
The token needs to be in JWS or JWE Compact Serialization Format. (JWS): 'EncodedHeader.EndcodedPayload.EncodedSignature'. (JWE): 'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'.”

疑似发现aop事务存在问题

起初是在自己的项目里,使用aop事务出现了This SqlTransaction has completed; it is no longer usable.的问题,后发现是在services层调用多个Repository层方法时,可能在services方法未执行完成的情况下,提交了事务。
后下载了博主的源码。也发现了类似的问题。
1
这里访问第一个数据访问层方法
2
然后就进了aop,接着断点就开始乱跳
3
4
在访问第三个数据访问层方法之前,工作单元就会提交事务(实际上也可能直接跟着图2继续执行下去)
5
6
接着就会报This SqlTransaction has completed; it is no longer usable.的问题
但是在我的项目里数据库操作是会成功的,用的是mssql
怀疑是否有可能是拦截器和service层并行了导致的,因为都是异步方法。
感谢群主开源,对.Net社区做的贡献。

autofac 组件在6.0版本出现注入失败问题

Castle.DynamicProxy.ProxyGenerationException: This is a DynamicProxy2 error: Target type for the proxy implements Castle.DynamicProxy.IProxyTargetAccessor which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to proxy an existing proxy?

跟进中

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.