From e50f7925279a4206c20230de1f5df9c309349809 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期二, 08 十月 2024 16:16:44 +0800 Subject: [PATCH] 优化API结构 --- /dev/null | 171 ------------------------------------------ Tiger.Api/Tiger.Api.csproj | 8 - Tiger.Api/Startup.cs | 5 3 files changed, 4 insertions(+), 180 deletions(-) diff --git a/Tiger.Api/Autofac/Default.json b/Tiger.Api/Autofac/Default.json deleted file mode 100644 index c21953d..0000000 --- a/Tiger.Api/Autofac/Default.json +++ /dev/null @@ -1,200 +0,0 @@ -/*鐢熷懡鍛ㄦ湡鏋氫妇 - InstanceScope锛� - InstancePerDependency锛歐hen you resolve a component that is instance per dependency, you get a new one each time. - SingleInstance锛歐hen you resolve a single instance component, you always get the same instance no matter where you request it. - InstancePerLifetimeScope锛歐hen you resolve the instance per lifetime scope component, you get a single instance per nested scope (e.g., per unit of work). - InstancePerMatchingLifetimeScope锛歐hen you create a nested lifetime scope, you have the ability to 鈥渢ag鈥� or 鈥渘ame鈥� the scope. A component with per-matching-lifetime scope will have at most a single instance per nested lifetime scope that matches a given name. This allows you to create a sort of 鈥渟coped singleton鈥� where other nested lifetime scopes can share an instance of a component without declaring a global shared instance. - InstancePerRequest锛欼nstance per request builds on top of instance per matching lifetime scope by providing a well-known lifetime scope tag, a registration convenience method, and integration for common application types. Behind the scenes, though, it鈥檚 still just instance per matching lifetime scope. - InstancePerOwned锛歍he Owned<T> implicit relationship type creates new nested lifetime scopes. It is possible to scope dependencies to the owned instance using the instance-per-owned registrations. - ThreadScope锛欵ach thread executing through ThreadStart() will then get its own instance of MyThreadScopedComponent - which is essentially a 鈥渟ingleton鈥� in the lifetime scope. Because scoped instances are never provided to outer scopes, it is easier to keep thread components separated. -*/ -{ - "components": [ - //{ - // "type": "Tiger.Business.WMS.ReceiptInfo,Tiger.Business.WMS", - // "services": [ - // { - // "type": "Tiger.IBusiness.IReceiptInfo,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - ////{ - //// "type": "Tiger.Business.UpdateMReqStatus,Tiger.Business", - //// "services": [ - //// { - //// "type": "Tiger.IBusiness.IUpdateMReqStatus,Tiger.IBusiness" - //// } - //// ], - //// "autoActivate": true, - //// "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - //// "injectProperties": true - ////}, - //{ - // "type": "Tiger.Business.Test_Z,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.ITest_Z,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.WMS.SrmToWms,Tiger.Business.WMS", - // "services": [ - // { - // "type": "Tiger.IBusiness.ISrmToWms,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.MaterialInfoBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IMaterialInfoBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.SrmDataToSiHua,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.ISrmDataToSiHua,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.OtherOutInfoBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IOtherOutInfoBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.WMS.T100ToWMS.SaleOutInfoBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.WMS.T100ToWMS.ISaleOutInfoBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.TrasferInfoBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.ITrasferInfoBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.ProductOutputBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IProductOutputBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.SplitBoxBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.ISplitBoxBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.ReworkBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IReworkBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.ProductInputBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IProductInputBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.StockInfoBusiness,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IStockInfoBusiness,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.ProdMaterialReq,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IProdMaterialReq,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //}, - //{ - // "type": "Tiger.Business.InventroyInfo,Tiger.Business", - // "services": [ - // { - // "type": "Tiger.IBusiness.IInventroyInfo,Tiger.IBusiness" - // } - // ], - // "autoActivate": true, - // "instanceScope": "per-dependency", //鐢熷懡鍛ㄦ湡 - // "injectProperties": true - //} - ] -} -/*鐢熷懡鍛ㄦ湡鏋氫妇 - InstanceScope锛� - InstancePerDependency锛歐hen you resolve a component that is instance per dependency, you get a new one each time. - SingleInstance锛歐hen you resolve a single instance component, you always get the same instance no matter where you request it. - InstancePerLifetimeScope锛歐hen you resolve the instance per lifetime scope component, you get a single instance per nested scope (e.g., per unit of work). - InstancePerMatchingLifetimeScope锛歐hen you create a nested lifetime scope, you have the ability to 鈥渢ag鈥� or 鈥渘ame鈥� the scope. A component with per-matching-lifetime scope will have at most a single instance per nested lifetime scope that matches a given name. This allows you to create a sort of 鈥渟coped singleton鈥� where other nested lifetime scopes can share an instance of a component without declaring a global shared instance. - InstancePerRequest锛欼nstance per request builds on top of instance per matching lifetime scope by providing a well-known lifetime scope tag, a registration convenience method, and integration for common application types. Behind the scenes, though, it鈥檚 still just instance per matching lifetime scope. - InstancePerOwned锛歍he Owned<T> implicit relationship type creates new nested lifetime scopes. It is possible to scope dependencies to the owned instance using the instance-per-owned registrations. - ThreadScope锛欵ach thread executing through ThreadStart() will then get its own instance of MyThreadScopedComponent - which is essentially a 鈥渟ingleton鈥� in the lifetime scope. Because scoped instances are never provided to outer scopes, it is easier to keep thread components separated. -*/ \ No newline at end of file diff --git a/Tiger.Api/Autofac/Transaction.json b/Tiger.Api/Autofac/Transaction.json deleted file mode 100644 index 0bb6456..0000000 --- a/Tiger.Api/Autofac/Transaction.json +++ /dev/null @@ -1,171 +0,0 @@ -/*鐢熷懡鍛ㄦ湡鏋氫妇 - InstanceScope锛� - InstancePerDependency锛歐hen you resolve a component that is instance per dependency, you get a new one each time. - SingleInstance锛歐hen you resolve a single instance component, you always get the same instance no matter where you request it. - InstancePerLifetimeScope锛歐hen you resolve the instance per lifetime scope component, you get a single instance per nested scope (e.g., per unit of work). - InstancePerMatchingLifetimeScope锛歐hen you create a nested lifetime scope, you have the ability to 鈥渢ag鈥� or 鈥渘ame鈥� the scope. A component with per-matching-lifetime scope will have at most a single instance per nested lifetime scope that matches a given name. This allows you to create a sort of 鈥渟coped singleton鈥� where other nested lifetime scopes can share an instance of a component without declaring a global shared instance. - InstancePerRequest锛欼nstance per request builds on top of instance per matching lifetime scope by providing a well-known lifetime scope tag, a registration convenience method, and integration for common application types. Behind the scenes, though, it鈥檚 still just instance per matching lifetime scope. - InstancePerOwned锛歍he Owned<T> implicit relationship type creates new nested lifetime scopes. It is possible to scope dependencies to the owned instance using the instance-per-owned registrations. - ThreadScope锛欵ach thread executing through ThreadStart() will then get its own instance of MyThreadScopedComponent - which is essentially a 鈥渟ingleton鈥� in the lifetime scope. Because scoped instances are never provided to outer scopes, it is easier to keep thread components separated. -*/ -{ - "components": [ -// { -// "type": "Tiger.Business.WMS.Transaction.ShelfRemote,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IShelfRemote,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.CustomerSupplyInNew,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.ICustomerSupplyInNew,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.CustSupplyCheckingNew,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.ICustSupplyCheckingNew,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.InMatStorage,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IInMatStorage,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.InProductionReturn,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IInProductionReturn,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.InFinished,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IInFinished,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OutWorkOrder,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOutWorkOrder,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.InReceipt,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IInReceipt,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.ItemQuery,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IItemQuery,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.LocationTransfer,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.ILocationTransfer,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OtherInLocation,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOtherInLocation,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OtherInLocationChecking,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOtherInLocationChecking,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OutOther,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOutOther,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OutSale,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOutSale,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OutSplit,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOutSplit,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.OutTransfer,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IOutTransfer,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.ProductionMaterialReq,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IProductionMaterialReq,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.WmsCount,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IWmsCount,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.Resell,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.IResell,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.CustomerSupplyIn,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.ICustomerSupplyIn,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// }, -// { -// "type": "Tiger.Business.WMS.Transaction.CustSupplyChecking,Tiger.Business", -// "services": [ { "type": "Tiger.IBusiness.ICustSupplyChecking,Tiger.IBusiness" } ], -// "autoActivate": true, -// "injectProperties": true, -// "instanceScope": "InstancePerDependency" //鐢熷懡鍛ㄦ湡 -// } - ] -} -/*鐢熷懡鍛ㄦ湡鏋氫妇 - InstanceScope锛� - InstancePerDependency锛歐hen you resolve a component that is instance per dependency, you get a new one each time. - SingleInstance锛歐hen you resolve a single instance component, you always get the same instance no matter where you request it. - InstancePerLifetimeScope锛歐hen you resolve the instance per lifetime scope component, you get a single instance per nested scope (e.g., per unit of work). - InstancePerMatchingLifetimeScope锛歐hen you create a nested lifetime scope, you have the ability to 鈥渢ag鈥� or 鈥渘ame鈥� the scope. A component with per-matching-lifetime scope will have at most a single instance per nested lifetime scope that matches a given name. This allows you to create a sort of 鈥渟coped singleton鈥� where other nested lifetime scopes can share an instance of a component without declaring a global shared instance. - InstancePerRequest锛欼nstance per request builds on top of instance per matching lifetime scope by providing a well-known lifetime scope tag, a registration convenience method, and integration for common application types. Behind the scenes, though, it鈥檚 still just instance per matching lifetime scope. - InstancePerOwned锛歍he Owned<T> implicit relationship type creates new nested lifetime scopes. It is possible to scope dependencies to the owned instance using the instance-per-owned registrations. - ThreadScope锛欵ach thread executing through ThreadStart() will then get its own instance of MyThreadScopedComponent - which is essentially a 鈥渟ingleton鈥� in the lifetime scope. Because scoped instances are never provided to outer scopes, it is easier to keep thread components separated. -*/ \ No newline at end of file diff --git a/Tiger.Api/Startup.cs b/Tiger.Api/Startup.cs index 98cd967..fd0f5d6 100644 --- a/Tiger.Api/Startup.cs +++ b/Tiger.Api/Startup.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; +using NLog; using Rhea.Common; using Sundial; using System; @@ -107,7 +108,7 @@ BizConfig.InitConfig(bizConfig, DI.Resolve<ILanguage>().GetDictionary()); //鍔犺浇閰嶇疆鏂囦欢 - NLog.LogManager.LoadConfiguration("nlog.config").GetCurrentClassLogger(); + NLog.LogManager.Setup().LoadConfigurationFromFile("nlog.config").GetCurrentClassLogger(); app.UseMiddleware<LogMiddleware>(); app.UseSwagger(); @@ -167,7 +168,7 @@ /// </summary> public void DeleteLogs() { - DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Logs"); + DirectoryInfo di = new (AppDomain.CurrentDomain.BaseDirectory + "\\Logs"); if(di.Exists) { var logFiles = di.GetFiles("*.log", SearchOption.AllDirectories); diff --git a/Tiger.Api/Tiger.Api.csproj b/Tiger.Api/Tiger.Api.csproj index e348f37..28e12d2 100644 --- a/Tiger.Api/Tiger.Api.csproj +++ b/Tiger.Api/Tiger.Api.csproj @@ -111,17 +111,11 @@ <Content Update="Autofac\Template.json"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> - <Content Update="Autofac\Transaction.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Update="Autofac\Default.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> </ItemGroup> <ItemGroup> <None Update="Language.db"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> </ItemGroup> - <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" autofac_4template_1json__JsonSchema="https://json.schemastore.org/appsettings.json" autofac_4transaction_1json__JsonSchema="https://json.schemastore.org/appsettings.json" /></VisualStudio></ProjectExtensions> + <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" autofac_4template_1json__JsonSchema="https://json.schemastore.org/appsettings.json" /></VisualStudio></ProjectExtensions> </Project> -- Gitblit v1.9.3