dotnetcore / util Goto Github PK
View Code? Open in Web Editor NEWUtil是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
License: MIT License
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
License: MIT License
initMaps,但原有类型会丢失,自定义设置CustomMapper
item.CustomMapper!=null
重新init
item.CustomMapper==null
你好:
我们已将此框架运用到实际项目中,有一些设计思路比较困惑看起来比较吃力,能否将框架中用到的技术、设计思路、场景等编写成一个文档进行同步更新,便于大家更好的理解整个框架,将整个框架运用到更加完整
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;
}
环境 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.LogBase
1.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.LogBase
1.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:
希望加入坐标位置方面的操作实现
实现附近的人功能
有集成第三方支付的计划吗?
在参考Util应用框架快速入门(三)- UI 快速入门时,遇到如下问题:
不知道是否有人遇到解决相关问题。
sql where 表达式树里求值的疑问
如:
[Fact]
public void TestWhere_17_1()
{
//执行
_clause.Where<Sample>(t => t.Created>Datetime.Now.AddDays(-7));
}
这种情况,如何处理?
提倡提前计算好,再进行表达式树的方法。
是否可以支持这种方式:
可通过下面这样方法来求值
Expression.Lambda(expression).Compile().DynamicInvoke();
没传aaa这个参数,会报异常:
System.InvalidOperationException: Incorrect Content-Type:
ToChineseDateString
can use format string "yyyy年MM月dd日"
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.
一个类里,有2个方法使用ISqlQuery,ISqlQuery通过构造方法注入,并是单例。
在多钱程的情况下,
2个方法,存在同时被调用的可能。
此时,ISqlQuery 要如何来使用?
发现ISqlBuilder存在一个New方法
而ISqlQuery并没有New方法
请问这样设计是基于什么样的考虑?
感谢。
ng-alain相关的包都已经通过yarn安装成功了,application的列表页面也可以正常使用。唯独就是菜单这里显示的是空白。不知道是什么情况。还有有些文本显示的英文的
09-Utili.webs 工程,缺少对包Microsoft.CSharp的引用。
使用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, Action
1 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, Action
1 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, Action
1 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,这个是什么概念?用来分区?
另外,
[Model( "model" )]
public class RoleDto
Dto类属性Model又是用来标识什么的呢?会在哪里有效果?
谢谢!
好长时间没更新了,还有在维护吗?
Angular.Material 无法安装node-sass模块
https://github.com/jbogard/MediatR
这个是微软在eShopContainer中使用的,推荐看一下,目前在项目中使用效果也比较好
我使用小程序支付的微信通知处理回调函数时,出现了异常报错
我是用的时asp.net core 3.1,猜测是否由于.net api修改,而项目未更新。
跟随DigDes/SoapCore#293的修改方式进行修改,将EnableRewind
改为了EnableBuffering
可是发现Request为null,随后追踪到Web中的Ioc.Create无法构建出IHttpContextAccessor,返回值为null
static Web() {
try {
HttpContextAccessor = Ioc.Create<IHttpContextAccessor>();
Environment = Ioc.Create<IHostingEnvironment>();
}
catch {
}
}
请问我已通过AddHttpContextAccessor
设置了DI,此处Ioc.Create无法正常构建该如何处理呢?
如题
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?
最近的Commit都是有关于SqlQuery的实现部分。
目前来看Domain层是不可能使用,只需要关注IRepository就行。
因为有Ef的存在,执行Sql语句EF也能够做到,那引入Dapper的意义又不存在了。
如果是想使用Dapper,那么常规的做法应该是再封装一套Store以及关于IDbConnection的Iqueryable的实现。目前看因为sql语句生成依赖于Ef的实体映射也不是太像。
想询问一下关于ISqlQuery这个类型的真实应用场景
我下载了之后,等待后台还原各种包,当我发现左下角提示没有后台任务时,就把"Util.Samples.Angular.AntDesign"设为启动项目,然后F5了. 然后 在Startup.cs里的
app.UseWebpackDevMiddleware( new WebpackDevMiddlewareOptions { HotModuleReplacement = true } );
就报上述错误了,这个大概是什么引起的?
在nuget更新到6.0版本,发现Util.Helpers.Encrypt这个类没有了,是取消了么
按照倒序排列有利于用户了解最新特性
Util/src/Util.Logs/03-Util.Logs.csproj
Line 39 in 87d6268
Latest official package: https://www.nuget.org/packages/NLog
See also NLog 4.5 is near! (and no NLog 5)
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);
}
Any english hermanos?
Http请求帮助类虽然是很简单,但我想应该有
老何,
麻烦更新下Util支持下preview版3.0
现在不能用返回IServiceProvider方法,官方建议在program.cs加入
builder.UseServiceProviderFactory(new AutofacServiceProviderFactory(
x =>
{
}));
然后startup.cs
加入
public void ConfigureContainer(ContainerBuilder builder)
{
}
麻烦融入下,谢谢!
Changelog template: http://keepachangelog.com/
在webapi使用中发现Util.Datas.Ef.Core.StoreBase类add/update/delete等方法都没有commit操作,导致提交失败,是否使用方式不对或者在什么地方设置统一commit?
private static TDestination MapTo( object source, TDestination destination )
这个方法里面会判断源对象和目标对象是否配置了Map,如果没有配置的话,则自动CreateMap。
针对EF的代理对象,尽管系统已经配置了Entity和Dto的Map,但是在上面方法里获取不到代理对象和Dto的Map配置,然后重新配置Map,导致自定义的Map配置条件失效了。
提个建议:建议把一些class 加上 partial, 方便扩展
比如Helpers里的帮助类,用partial class扩展几个自己要用的方法,就可以统一调用了
在Util.Datas.Ef.Core.UnitOfWorkBase中
在每次new IUnitOfWork的实例都需要调用下面方法。如果一个库有2000个表,就有两2000个IMap。每次都要重新Create这么多个Model?有没有可能只载入一次呢?或者为什么设计为每次都要重新CreateAll?
///
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.