Giter Site home page Giter Site logo

dotnetcore / util Goto Github PK

View Code? Open in Web Editor NEW
4.5K 371.0 1.3K 34.49 MB

Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。

License: MIT License

C# 99.98% HTML 0.01% PowerShell 0.01%
dotnetcore aspnetcore efcore angular taghelper framework ng-zorro

util's Issues

框架能否出一个框架设计说明文档同步更新?

你好:
我们已将此框架运用到实际项目中,有一些设计思路比较困惑看起来比较吃力,能否将框架中用到的技术、设计思路、场景等编写成一个文档进行同步更新,便于大家更好的理解整个框架,将整个框架运用到更加完整

AutoMap改进

这是现在的代码
image
我觉得可以改成
image
先尝试进行map,如果失败了,才进行下面的动作

Util.Webs.Clients下 GET请求报错

private HttpRequestMessage CreateRequestMessage() 
{
    var message = new HttpRequestMessage {
        Method = _httpMethod,
        RequestUri = new Uri( _url ),
        Content = CreateHttpContent() //GET请求不能给content赋值 
    };
    foreach( var header in _headers )
        message.Headers.Add( header.Key, header.Value );
    return message;
}

动态生成组件异常没有正常得到 Context对象

环境 MacOS 10.13.5
工具 Visual Studio for mac
dotnet_2.1.301_x64

Windows 环境下是正常的。

Util.Logs 项目下 Log.cs 第89行。 var context = GetLogContext(); 动态生成组件异常没有正常得到 Context对象

ActionDescriptor: "Util.Samples.Webs.Controllers.HomeController.Index (Util.Samples.Webs)"
Exception: {AspectCore.DynamicProxy.AspectInvocationException: Exception has been thrown by the aspect of an invocation. ---> Device not configured. ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Device not configured
at System.Net.Dns.InternalGetHostByName(String hostName)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at Util.Helpers.Web.GetLanIp() in /Users/willow/Work/Work.Net/Util/src/Util/Helpers/Web.cs:line 135
at Util.Helpers.Web.get_Ip() in /Users/willow/Work/Work.Net/Util/src/Util/Helpers/Web.cs:line 126
at Util.Logs.Core.LogContext.CreateInfo() in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogContext.cs:line 77
at Util.Logs.Core.LogContext.GetInfo() in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogContext.cs:line 68
at Util.Logs.Core.LogContext.get_TraceId() in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogContext.cs:line 34
at invoker_String get_TraceId()(Object , Object[] )
at AspectCore.DynamicProxy.RuntimeAspectContext.Complete()
at AspectCore.DynamicProxy.Parameters.EnableParameterAspectInterceptor.Invoke(AspectContext context, AspectDelegate next)
--- End of inner exception stack trace ---
at AspectCore.DynamicProxy.AspectActivator.Invoke[TResult](AspectActivatorContext activatorContext)
at AspectCore.DynamicGenerated.LogContext.get_TraceId()
at Util.Logs.Core.LogBase1.Init(TContent content) in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogBase.cs:line 72 at Util.Logs.Log.Init(LogContent content) in /Users/willow/Work/Work.Net/Util/src/Util.Logs/Log.cs:line 50 at Util.Logs.Core.LogBase1.Execute(LogLevel level, TContent& content) in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogBase.cs:line 111
at Util.Logs.Core.LogBase1.Info() in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogBase.cs:line 159 at Util.Logs.Core.LogBase1.Info(String message) in /Users/willow/Work/Work.Net/Util/src/Util/Logs/Core/LogBase.cs:line 168
at Util.Samples.Webs.Controllers.HomeController.Index() in /Users/willow/Work/Work.Net/Util/sample/Util.Samples.Webs/Controllers/HomeController.cs:line 14
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()}
ExceptionDispatchInfo: {System.Runtime.ExceptionServices.ExceptionDispatchInfo}
ExceptionHandled: false
Filters: {Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata[4]}
HttpContext: {Microsoft.AspNetCore.Http.DefaultHttpContext}
ModelState: {Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary}
Result: (null)
RouteData: {Microsoft.AspNetCore.Routing.RouteData}
Non-Public members:

组件过时

在还原npm时,貌似有包被标记了过时
default

sql where 表达式树里求值的疑问

sql where 表达式树里求值的疑问
如:

[Fact]
public void TestWhere_17_1()
{
        
        //执行
       _clause.Where<Sample>(t => t.Created>Datetime.Now.AddDays(-7));

 }

这种情况,如何处理?

提倡提前计算好,再进行表达式树的方法。

是否可以支持这种方式:

可通过下面这样方法来求值

Expression.Lambda(expression).Compile().DynamicInvoke();

Web.GetParam("aaa")

没传aaa这个参数,会报异常:
System.InvalidOperationException: Incorrect Content-Type:

How to scaffold new entities/features into your framework

Hello, I am trying your framework, can you share a pictures or help, for e.g. if I am adding a new PhoneBook.Cs and Person entity, which objects and layers need to be wired hookedup, subclassed etc. to benefit from your framework.

ISqlQuery 实列,被多个线程调用时疑问

一个类里,有2个方法使用ISqlQuery,ISqlQuery通过构造方法注入,并是单例。
在多钱程的情况下,
2个方法,存在同时被调用的可能。
此时,ISqlQuery 要如何来使用?

发现ISqlBuilder存在一个New方法
而ISqlQuery并没有New方法

请问这样设计是基于什么样的考虑?
感谢。

左边菜单显示不出来

ng-alain相关的包都已经通过yarn安装成功了,application的列表页面也可以正常使用。唯独就是菜单这里显示的是空白。不知道是什么情况。还有有些文本显示的英文的

centos 无法运行

使用Util.Core做了一个hello world,在windows环境下运行正常,但是发布到linux(centos7 mini)环境下运行时报错,估计是反射相关方法引起的,错误提示如下:
[root@localhost utiltest]# dotnet utiltest.dll
Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'utiltest.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

File name: 'utiltest.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.AppDomain.Load(AssemblyName assemblyRef)
at Util.Reflections.Finder.LoadAssemblies(String path)
at Util.Reflections.WebFinder.GetAssemblies()
at Util.Dependency.DependencyConfiguration.RegistServices(ContainerBuilder builder)
at Util.Dependency.Container.CreateBuilder(IServiceCollection services, Action1 actionBefore, IConfig[] configs) at Util.Dependency.Container.Register(IServiceCollection services, Action1 actionBefore, IConfig[] configs)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'utiltest.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.AppDomain.Load(AssemblyName assemblyRef)
at Util.Reflections.Finder.LoadAssemblies(String path)
at Util.Reflections.WebFinder.GetAssemblies()
at Util.Dependency.DependencyConfiguration.RegistServices(ContainerBuilder builder)
at Util.Dependency.Container.CreateBuilder(IServiceCollection services, Action1 actionBefore, IConfig[] configs) at Util.Dependency.Container.Register(IServiceCollection services, Action1 actionBefore, IConfig[] configs)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at utiltest.Program.Main(String[] args) in C:\Users\nonep\source\repos\utiltest\utiltest\Program.cs:line 17
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'utiltest.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

File name: 'utiltest.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.AppDomain.Load(AssemblyName assemblyRef)
at Util.Reflections.Finder.LoadAssemblies(String path)
at Util.Reflections.WebFinder.GetAssemblies()
at Util.Dependency.DependencyConfiguration.RegistServices(ContainerBuilder builder)
at Util.Dependency.Container.CreateBuilder(IServiceCollection services, Action1 actionBefore, IConfig[] configs) at Util.Dependency.Container.Register(IServiceCollection services, Action1 actionBefore, IConfig[] configs)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Aborted

请问IUnitOfWork是个什么概念?

很多地方看到有IUnitOfWork,这个是什么概念?用来分区?
另外,
[Model( "model" )]
public class RoleDto
Dto类属性Model又是用来标识什么的呢?会在哪里有效果?
谢谢!

Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' from assembly

我使用小程序支付的微信通知处理回调函数时,出现了异常报错
image
我是用的时asp.net core 3.1,猜测是否由于.net api修改,而项目未更新。
跟随DigDes/SoapCore#293的修改方式进行修改,将EnableRewind改为了EnableBuffering
image
可是发现Request为null,随后追踪到Web中的Ioc.Create无法构建出IHttpContextAccessor,返回值为null

        static Web() {
            try {
                HttpContextAccessor = Ioc.Create<IHttpContextAccessor>();
                Environment = Ioc.Create<IHostingEnvironment>();
            }
            catch {
            }
        }

请问我已通过AddHttpContextAccessor设置了DI,此处Ioc.Create无法正常构建该如何处理呢?

Cannot consume scoped service 'DotNetCore.CAP.ICapPublisher' from singleton 。

InvalidOperationException: Cannot consume scoped service 'DotNetCore.CAP.ICapPublisher' from singleton 'Util.Event.Messages.IMessageEventBus'.

services.AddSingleton<IMessageEventBus, MessageEventBus>();
services.AddSingleton<IEventBus, EventBus>();

需要把 AddSingleton 改成 “AddScoped”才不会报错。
是否有其他设置可以把ICapPublisher改为Singleton?

ISqlQuery的应用场景是什么?

最近的Commit都是有关于SqlQuery的实现部分。
目前来看Domain层是不可能使用,只需要关注IRepository就行。
因为有Ef的存在,执行Sql语句EF也能够做到,那引入Dapper的意义又不存在了。
如果是想使用Dapper,那么常规的做法应该是再封装一套Store以及关于IDbConnection的Iqueryable的实现。目前看因为sql语句生成依赖于Ef的实体映射也不是太像。
想询问一下关于ISqlQuery这个类型的真实应用场景

6.0类缺失

在nuget更新到6.0版本,发现Util.Helpers.Encrypt这个类没有了,是取消了么

AutoMapper 扩展不支持复杂属性、匿名对象

 static void Main(string[] args)
        {
            var source = new SourceTy
            {
                Id = 100L,
                Name = "测试",
                List = new []
                {
                    new ItemTy() {Name = "测试"}
                }
            };
            
            var dest = source.MapTo<TargetTy>();//throw exception
            Console.WriteLine(dest.Id);

            var dyn = new
            {
                Id = 100L,
                Name = "测试",
                List = new[]
                {
                    new {Name = "测试"}
                }
            };
            var dest2 = dyn.MapTo<TargetTy>();//throw exception
            Console.WriteLine(dest2.Id);
        }

HttpClient的一个小问题

image
建议 当token为空的时候不要进行BearerToken这个header的添加,因为有遇到有些接口当这个header存在时就调用不成功

.net core 3.0 preview 5+ autofac support

老何,
麻烦更新下Util支持下preview版3.0
现在不能用返回IServiceProvider方法,官方建议在program.cs加入

builder.UseServiceProviderFactory(new AutofacServiceProviderFactory(
                x =>
                {
                  
                }));

然后startup.cs
加入

  public void ConfigureContainer(ContainerBuilder builder)
        {
       
        }

麻烦融入下,谢谢!

issue of extension function MapTo

private static TDestination MapTo( object source, TDestination destination )
这个方法里面会判断源对象和目标对象是否配置了Map,如果没有配置的话,则自动CreateMap。
针对EF的代理对象,尽管系统已经配置了Entity和Dto的Map,但是在上面方法里获取不到代理对象和Dto的Map配置,然后重新配置Map,导致自定义的Map配置条件失效了。

partial class 建议

提个建议:建议把一些class 加上 partial, 方便扩展

比如Helpers里的帮助类,用partial class扩展几个自己要用的方法,就可以统一调用了

在Util.Datas.Ef.Core.UnitOfWorkBase的OnModelCreating方法

在Util.Datas.Ef.Core.UnitOfWorkBase中
在每次new IUnitOfWork的实例都需要调用下面方法。如果一个库有2000个表,就有两2000个IMap。每次都要重新Create这么多个Model?有没有可能只载入一次呢?或者为什么设计为每次都要重新CreateAll?
///


/// 配置映射
///

protected override void OnModelCreating( ModelBuilder modelBuilder ) {
foreach( IMap mapper in GetMaps() )
mapper.Map( modelBuilder );
}

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.