Giter Site home page Giter Site logo

anjoy8 / blog.core Goto Github PK

View Code? Open in Web Editor NEW
4.8K 4.8K 1.3K 70.74 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%
aop autofac automapper cors dependency-injection dto ioc jwt net7 netcore netcore-vue netcore-webapi rbac rbac-roles redis repository sqlsugar sqlsugarcore swagger t4

blog.core's Issues

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;
    }`

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

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

项目执行的时候出现错误

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

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

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

疑似发现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社区做的贡献。

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; }
就没有问题

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

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

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

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

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

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

MD5 32算法修改

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

要保证32位

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'.”

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();
    }

增加环境变量的判断

发现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记录

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";

请问 为何每个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

DbHelper.ttinclude 模板 执行报错

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

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

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 从主程序中剥离出来,单独部署

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

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

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

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

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?

跟进中

版本区别

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

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.