chore: 构建稳定版本
This commit is contained in:
201
Yi.Abp.Net8/Yi.Abp.sln
Normal file
201
Yi.Abp.Net8/Yi.Abp.sln
Normal file
@@ -0,0 +1,201 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34202.233
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.Web", "src\Yi.Abp.Web\Yi.Abp.Web.csproj", "{15913E44-DA92-44B9-9AC5-E9457EA34BF5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.SqlSugarCore", "framework\Yi.Framework.SqlSugarCore\Yi.Framework.SqlSugarCore.csproj", "{DC431ECC-C75D-4B01-8B79-4861948179BB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B782C78B-6C17-49E6-A237-3383BA720766}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0D10EEF2-FBAE-4C72-B816-A52823FC299B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework", "framework", "{77B949E9-530E-45A5-9657-20F7D5C6875C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "module", "module", "{2317227D-7796-4E7B-BEDB-7CD1CAE7B853}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.SqlSugarCore", "src\Yi.Abp.SqlSugarCore\Yi.Abp.SqlSugarCore.csproj", "{9A7BBA40-28D6-4900-9E1D-D627A516EE72}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.Application", "src\Yi.Abp.Application\Yi.Abp.Application.csproj", "{746DBBD6-23E8-4D5D-9D23-E2902BE338BD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.Application.Contracts", "src\Yi.Abp.Application.Contracts\Yi.Abp.Application.Contracts.csproj", "{51EEBF59-3D37-4681-981D-56F8D8F8968D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.Domain", "src\Yi.Abp.Domain\Yi.Abp.Domain.csproj", "{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Abp.Domain.Shared", "src\Yi.Abp.Domain.Shared\Yi.Abp.Domain.Shared.csproj", "{F4D5A496-BFBE-470B-A05B-CB5823B47E72}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A5375C6-1D55-4E93-9B19-736F1C68CBC3}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
common.props = common.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.SqlSugarCore.Abstractions", "framework\Yi.Framework.SqlSugarCore.Abstractions\Yi.Framework.SqlSugarCore.Abstractions.csproj", "{FD6D6860-3753-4747-8A26-977E4A3001F9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Core", "framework\Yi.Framework.Core\Yi.Framework.Core.csproj", "{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Mapster", "framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj", "{1995A019-C8AE-467E-B427-ED57D6CBF44F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.AspNetCore", "framework\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj", "{F5011C0D-209B-4A98-BBE3-68157503EEF8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Ddd.Application.Contracts", "framework\Yi.Framework.Ddd.Application.Contracts\Yi.Framework.Ddd.Application.Contracts.csproj", "{0A8296A3-C11F-4F13-8E49-6BC8188D4804}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Ddd.Application", "framework\Yi.Framework.Ddd.Application\Yi.Framework.Ddd.Application.csproj", "{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rbac", "rbac", "{9CC7A457-1236-40BA-B47B-E7B710A3F061}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Rbac.Application.Contracts", "module\rbac\Yi.Framework.Rbac.Application.Contracts\Yi.Framework.Rbac.Application.Contracts.csproj", "{1C360956-8CD8-407E-B87F-D0BD57068EB9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Rbac.Application", "module\rbac\Yi.Framework.Rbac.Application\Yi.Framework.Rbac.Application.csproj", "{4F02B08D-5FE2-460D-BCA5-DA565151AE30}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Rbac.Domain", "module\rbac\Yi.Framework.Rbac.Domain\Yi.Framework.Rbac.Domain.csproj", "{C04D3F71-1557-46D0-B810-97B1FBB6AB73}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Rbac.Domain.Shared", "module\rbac\Yi.Framework.Rbac.Domain.Shared\Yi.Framework.Rbac.Domain.Shared.csproj", "{A2BB899D-4F9A-4184-81BD-94B938E2AB03}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Rbac.SqlSugarCore", "module\rbac\Yi.Framework.Rbac.SqlSugarCore\Yi.Framework.Rbac.SqlSugarCore.csproj", "{4503A2F9-139D-4CBC-AF11-689C34F0D77B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bbs", "bbs", "{E902A945-4F41-4E96-A0DA-9F66CDA22261}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Bbs.Domain.Shared", "module\bbs\Yi.Framework.Bbs.Domain.Shared\Yi.Framework.Bbs.Domain.Shared.csproj", "{EB9349E2-256D-41EB-A345-21635A1361B3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Bbs.Domain", "module\bbs\Yi.Framework.Bbs.Domain\Yi.Framework.Bbs.Domain.csproj", "{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Bbs.Application.Contracts", "module\bbs\Yi.Framework.Bbs.Application.Contracts\Yi.Framework.Bbs.Application.Contracts.csproj", "{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Bbs.Application", "module\bbs\Yi.Framework.Bbs.Application\Yi.Framework.Bbs.Application.csproj", "{AD4EE9E6-F4A3-4139-AF05-71388167DE5B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Bbs.SqlSugarCore", "module\bbs\Yi.Framework.Bbs.SqlSugarCore\Yi.Framework.Bbs.SqlSugarCore.csproj", "{6C86BA71-9F87-4E2C-B467-2950D77DCDFA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{15913E44-DA92-44B9-9AC5-E9457EA34BF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{15913E44-DA92-44B9-9AC5-E9457EA34BF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{15913E44-DA92-44B9-9AC5-E9457EA34BF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{15913E44-DA92-44B9-9AC5-E9457EA34BF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DC431ECC-C75D-4B01-8B79-4861948179BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DC431ECC-C75D-4B01-8B79-4861948179BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DC431ECC-C75D-4B01-8B79-4861948179BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DC431ECC-C75D-4B01-8B79-4861948179BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9A7BBA40-28D6-4900-9E1D-D627A516EE72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9A7BBA40-28D6-4900-9E1D-D627A516EE72}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9A7BBA40-28D6-4900-9E1D-D627A516EE72}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9A7BBA40-28D6-4900-9E1D-D627A516EE72}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{746DBBD6-23E8-4D5D-9D23-E2902BE338BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{746DBBD6-23E8-4D5D-9D23-E2902BE338BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{746DBBD6-23E8-4D5D-9D23-E2902BE338BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{746DBBD6-23E8-4D5D-9D23-E2902BE338BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{51EEBF59-3D37-4681-981D-56F8D8F8968D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{51EEBF59-3D37-4681-981D-56F8D8F8968D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{51EEBF59-3D37-4681-981D-56F8D8F8968D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{51EEBF59-3D37-4681-981D-56F8D8F8968D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F4D5A496-BFBE-470B-A05B-CB5823B47E72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F4D5A496-BFBE-470B-A05B-CB5823B47E72}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F4D5A496-BFBE-470B-A05B-CB5823B47E72}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F4D5A496-BFBE-470B-A05B-CB5823B47E72}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FD6D6860-3753-4747-8A26-977E4A3001F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FD6D6860-3753-4747-8A26-977E4A3001F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FD6D6860-3753-4747-8A26-977E4A3001F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FD6D6860-3753-4747-8A26-977E4A3001F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1995A019-C8AE-467E-B427-ED57D6CBF44F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1995A019-C8AE-467E-B427-ED57D6CBF44F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1995A019-C8AE-467E-B427-ED57D6CBF44F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1995A019-C8AE-467E-B427-ED57D6CBF44F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F5011C0D-209B-4A98-BBE3-68157503EEF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5011C0D-209B-4A98-BBE3-68157503EEF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5011C0D-209B-4A98-BBE3-68157503EEF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5011C0D-209B-4A98-BBE3-68157503EEF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0A8296A3-C11F-4F13-8E49-6BC8188D4804}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A8296A3-C11F-4F13-8E49-6BC8188D4804}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A8296A3-C11F-4F13-8E49-6BC8188D4804}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A8296A3-C11F-4F13-8E49-6BC8188D4804}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1C360956-8CD8-407E-B87F-D0BD57068EB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1C360956-8CD8-407E-B87F-D0BD57068EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1C360956-8CD8-407E-B87F-D0BD57068EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1C360956-8CD8-407E-B87F-D0BD57068EB9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F02B08D-5FE2-460D-BCA5-DA565151AE30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F02B08D-5FE2-460D-BCA5-DA565151AE30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F02B08D-5FE2-460D-BCA5-DA565151AE30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F02B08D-5FE2-460D-BCA5-DA565151AE30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C04D3F71-1557-46D0-B810-97B1FBB6AB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C04D3F71-1557-46D0-B810-97B1FBB6AB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C04D3F71-1557-46D0-B810-97B1FBB6AB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C04D3F71-1557-46D0-B810-97B1FBB6AB73}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2BB899D-4F9A-4184-81BD-94B938E2AB03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2BB899D-4F9A-4184-81BD-94B938E2AB03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2BB899D-4F9A-4184-81BD-94B938E2AB03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2BB899D-4F9A-4184-81BD-94B938E2AB03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4503A2F9-139D-4CBC-AF11-689C34F0D77B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4503A2F9-139D-4CBC-AF11-689C34F0D77B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4503A2F9-139D-4CBC-AF11-689C34F0D77B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4503A2F9-139D-4CBC-AF11-689C34F0D77B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EB9349E2-256D-41EB-A345-21635A1361B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EB9349E2-256D-41EB-A345-21635A1361B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB9349E2-256D-41EB-A345-21635A1361B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EB9349E2-256D-41EB-A345-21635A1361B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AD4EE9E6-F4A3-4139-AF05-71388167DE5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AD4EE9E6-F4A3-4139-AF05-71388167DE5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AD4EE9E6-F4A3-4139-AF05-71388167DE5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AD4EE9E6-F4A3-4139-AF05-71388167DE5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C86BA71-9F87-4E2C-B467-2950D77DCDFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C86BA71-9F87-4E2C-B467-2950D77DCDFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C86BA71-9F87-4E2C-B467-2950D77DCDFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C86BA71-9F87-4E2C-B467-2950D77DCDFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{15913E44-DA92-44B9-9AC5-E9457EA34BF5} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{DC431ECC-C75D-4B01-8B79-4861948179BB} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{9A7BBA40-28D6-4900-9E1D-D627A516EE72} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{746DBBD6-23E8-4D5D-9D23-E2902BE338BD} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{51EEBF59-3D37-4681-981D-56F8D8F8968D} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{7B15C198-538A-44ED-A6AA-3A0FEAA1D2BD} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{F4D5A496-BFBE-470B-A05B-CB5823B47E72} = {B782C78B-6C17-49E6-A237-3383BA720766}
|
||||
{FD6D6860-3753-4747-8A26-977E4A3001F9} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{ECE874D4-F882-4EF4-84A6-A842D9B8FBC5} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{1995A019-C8AE-467E-B427-ED57D6CBF44F} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{F5011C0D-209B-4A98-BBE3-68157503EEF8} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{0A8296A3-C11F-4F13-8E49-6BC8188D4804} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{F0141C17-0EBD-4261-98D5-1C5B7BC1DFEE} = {77B949E9-530E-45A5-9657-20F7D5C6875C}
|
||||
{9CC7A457-1236-40BA-B47B-E7B710A3F061} = {2317227D-7796-4E7B-BEDB-7CD1CAE7B853}
|
||||
{1C360956-8CD8-407E-B87F-D0BD57068EB9} = {9CC7A457-1236-40BA-B47B-E7B710A3F061}
|
||||
{4F02B08D-5FE2-460D-BCA5-DA565151AE30} = {9CC7A457-1236-40BA-B47B-E7B710A3F061}
|
||||
{C04D3F71-1557-46D0-B810-97B1FBB6AB73} = {9CC7A457-1236-40BA-B47B-E7B710A3F061}
|
||||
{A2BB899D-4F9A-4184-81BD-94B938E2AB03} = {9CC7A457-1236-40BA-B47B-E7B710A3F061}
|
||||
{4503A2F9-139D-4CBC-AF11-689C34F0D77B} = {9CC7A457-1236-40BA-B47B-E7B710A3F061}
|
||||
{E902A945-4F41-4E96-A0DA-9F66CDA22261} = {2317227D-7796-4E7B-BEDB-7CD1CAE7B853}
|
||||
{EB9349E2-256D-41EB-A345-21635A1361B3} = {E902A945-4F41-4E96-A0DA-9F66CDA22261}
|
||||
{4EABBC84-BCED-46C1-8CF1-62A7B8081ED7} = {E902A945-4F41-4E96-A0DA-9F66CDA22261}
|
||||
{7E569FD9-B1AB-4848-8AB7-FD9EFA1DBA20} = {E902A945-4F41-4E96-A0DA-9F66CDA22261}
|
||||
{AD4EE9E6-F4A3-4139-AF05-71388167DE5B} = {E902A945-4F41-4E96-A0DA-9F66CDA22261}
|
||||
{6C86BA71-9F87-4E2C-B467-2950D77DCDFA} = {E902A945-4F41-4E96-A0DA-9F66CDA22261}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {23D6FBC9-C970-4641-BC1E-2AEA59F51C18}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
20
Yi.Abp.Net8/common.props
Normal file
20
Yi.Abp.Net8/common.props
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>1.0.0</Version>
|
||||
<NoWarn>$(NoWarn);CS1591;CS8618;CS1998;CS8604;CS8620;CS8600;CS8602</NoWarn>
|
||||
<AbpProjectType>app</AbpProjectType>
|
||||
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="NoWarnOnRazorViewImportedTypeConflicts" BeforeTargets="RazorCoreCompile">
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn);0436</NoWarn>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Middlewares;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder
|
||||
{
|
||||
public static class ApiInfoBuilderExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseYiApiHandlinge([NotNull] this IApplicationBuilder app)
|
||||
{
|
||||
app.UseMiddleware<ApiInfoMiddleware>();
|
||||
return app;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder
|
||||
{
|
||||
public static class SwaggerBuilderExtensons
|
||||
{
|
||||
public static IApplicationBuilder UseYiSwagger(this IApplicationBuilder app, params SwaggerModel[] swaggerModels)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
if (swaggerModels.Length == 0)
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var k in swaggerModels)
|
||||
{
|
||||
|
||||
c.SwaggerEndpoint(k.Url, k.Name);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return app;
|
||||
}
|
||||
|
||||
}
|
||||
public class SwaggerModel
|
||||
{
|
||||
public SwaggerModel(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Url = "/swagger/v1/swagger.json";
|
||||
}
|
||||
public SwaggerModel(string url, string name)
|
||||
{
|
||||
this.Url = url;
|
||||
this.Name = name;
|
||||
}
|
||||
public string Url { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Json;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Microsoft.AspNetCore.Middlewares
|
||||
{
|
||||
public class ApiInfoMiddleware : IMiddleware, ITransientDependency
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
|
||||
{
|
||||
await next(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static class SwaggerAddExtensions
|
||||
{
|
||||
public static IServiceCollection AddYiSwaggerGen<Program>(this IServiceCollection services, Action<SwaggerGenOptions>? action)
|
||||
{
|
||||
services.AddAbpSwaggerGen(
|
||||
options =>
|
||||
{
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
||||
if (basePath is not null)
|
||||
{
|
||||
foreach (var item in Directory.GetFiles(basePath, "*.xml"))
|
||||
{
|
||||
options.IncludeXmlComments(item, true);
|
||||
}
|
||||
}
|
||||
|
||||
options.AddSecurityDefinition("JwtBearer", new OpenApiSecurityScheme()
|
||||
{
|
||||
Description = "直接输入Token即可",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.Http,
|
||||
Scheme = "bearer"
|
||||
});
|
||||
var scheme = new OpenApiSecurityScheme()
|
||||
{
|
||||
Reference = new OpenApiReference() { Type = ReferenceType.SecurityScheme, Id = "JwtBearer" }
|
||||
};
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
||||
{
|
||||
[scheme] = new string[0]
|
||||
});
|
||||
|
||||
|
||||
if (action is not null)
|
||||
{
|
||||
action.Invoke(options);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp.AspNetCore.Mvc.Conventions;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Reflection;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Mvc
|
||||
{
|
||||
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
|
||||
[ExposeServices(typeof(IConventionalRouteBuilder))]
|
||||
public class YiConventionalRouteBuilder : ConventionalRouteBuilder
|
||||
{
|
||||
public YiConventionalRouteBuilder(IOptions<AbpConventionalControllerOptions> options) : base(options)
|
||||
{
|
||||
}
|
||||
public override string Build(
|
||||
string rootPath,
|
||||
string controllerName,
|
||||
ActionModel action,
|
||||
string httpMethod,
|
||||
[CanBeNull] ConventionalControllerSetting configuration)
|
||||
{
|
||||
|
||||
var apiRoutePrefix = GetApiRoutePrefix(action, configuration);
|
||||
var controllerNameInUrl =
|
||||
NormalizeUrlControllerName(rootPath, controllerName, action, httpMethod, configuration);
|
||||
|
||||
var url = $"{apiRoutePrefix}/{rootPath}/{NormalizeControllerNameCase(controllerNameInUrl, configuration)}";
|
||||
|
||||
//Add {id} path if needed
|
||||
var idParameterModel = action.Parameters.FirstOrDefault(p => p.ParameterName == "id");
|
||||
if (idParameterModel != null)
|
||||
{
|
||||
if (TypeHelper.IsPrimitiveExtended(idParameterModel.ParameterType, includeEnums: true))
|
||||
{
|
||||
url += "/{id}";
|
||||
}
|
||||
else
|
||||
{
|
||||
var properties = idParameterModel
|
||||
.ParameterType
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
url += "/{" + NormalizeIdPropertyNameCase(property, configuration) + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add action name if needed
|
||||
var actionNameInUrl = NormalizeUrlActionName(rootPath, controllerName, action, httpMethod, configuration);
|
||||
if (!actionNameInUrl.IsNullOrEmpty())
|
||||
{
|
||||
url += $"/{NormalizeActionNameCase(actionNameInUrl, configuration)}";
|
||||
|
||||
//Add secondary Id
|
||||
var secondaryIds = action.Parameters
|
||||
.Where(p => p.ParameterName.EndsWith("Id", StringComparison.Ordinal)).ToList();
|
||||
if (secondaryIds.Count == 1)
|
||||
{
|
||||
url += $"/{{{NormalizeSecondaryIdNameCase(secondaryIds[0], configuration)}}}";
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ActionConstraints;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.Conventions;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Reflection;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Mvc
|
||||
{
|
||||
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
|
||||
[ExposeServices(typeof(IAbpServiceConvention))]
|
||||
public class YiServiceConvention : AbpServiceConvention
|
||||
{
|
||||
public YiServiceConvention(IOptions<AbpAspNetCoreMvcOptions> options, IConventionalRouteBuilder conventionalRouteBuilder) : base(options, conventionalRouteBuilder)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ConfigureSelector(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration)
|
||||
{
|
||||
RemoveEmptySelectors(action.Selectors);
|
||||
|
||||
var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault<RemoteServiceAttribute>(action.ActionMethod);
|
||||
if (remoteServiceAtt != null && !remoteServiceAtt.IsEnabledFor(action.ActionMethod))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!action.Selectors.Any())
|
||||
{
|
||||
AddAbpServiceSelector(rootPath, controllerName, action, configuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalizeSelectorRoutes(rootPath, controllerName, action, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration)
|
||||
{
|
||||
if (action.ActionName.ToLower().Contains("vue"))
|
||||
{
|
||||
}
|
||||
base.AddAbpServiceSelector(rootPath, controllerName, action, configuration);
|
||||
}
|
||||
|
||||
protected override void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration)
|
||||
{
|
||||
foreach (var selector in action.Selectors)
|
||||
{
|
||||
var httpMethod = selector.ActionConstraints
|
||||
.OfType<HttpMethodActionConstraint>()
|
||||
.FirstOrDefault()?
|
||||
.HttpMethods?
|
||||
.FirstOrDefault();
|
||||
|
||||
if (httpMethod == null)
|
||||
{
|
||||
httpMethod = SelectHttpMethod(action, configuration);
|
||||
}
|
||||
|
||||
if (selector.AttributeRouteModel == null)
|
||||
{
|
||||
selector.AttributeRouteModel = CreateAbpServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod, configuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var template = selector.AttributeRouteModel.Template;
|
||||
if (!template.StartsWith("/"))
|
||||
{
|
||||
var route = $"{AbpAspNetCoreConsts.DefaultApiPrefix}/{rootPath}/{template}";
|
||||
selector.AttributeRouteModel.Template = route;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!selector.ActionConstraints.OfType<HttpMethodActionConstraint>().Any())
|
||||
{
|
||||
selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod }));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.AspNetCore
|
||||
{
|
||||
[Serializable]
|
||||
public class RemoteServiceSuccessInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="RemoteServiceSuccessInfo"/>.
|
||||
/// </summary>
|
||||
public RemoteServiceSuccessInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="RemoteServiceSuccessInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="code">Error code</param>
|
||||
/// <param name="details">Error details</param>
|
||||
/// <param name="message">Error message</param>
|
||||
/// <param name="data">Error data</param>
|
||||
public RemoteServiceSuccessInfo(string message, string? details = null, string? code = null, object? data = null)
|
||||
{
|
||||
Message = message;
|
||||
Details = details;
|
||||
Code = code;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// code.
|
||||
/// </summary>
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// message.
|
||||
/// </summary>
|
||||
public string? Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// details.
|
||||
/// </summary>
|
||||
public string? Details { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// data.
|
||||
/// </summary>
|
||||
public object? Data { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Json" Version="7.4.2" />
|
||||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="7.4.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Cors\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.AspNetCore</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of <see cref="T:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.#ctor(System.String,System.String,System.String,System.Object)">
|
||||
<summary>
|
||||
Creates a new instance of <see cref="T:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo"/>.
|
||||
</summary>
|
||||
<param name="code">Error code</param>
|
||||
<param name="details">Error details</param>
|
||||
<param name="message">Error message</param>
|
||||
<param name="data">Error data</param>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.Code">
|
||||
<summary>
|
||||
code.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.Message">
|
||||
<summary>
|
||||
message.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.Details">
|
||||
<summary>
|
||||
details.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.AspNetCore.RemoteServiceSuccessInfo.Data">
|
||||
<summary>
|
||||
data.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.AspNetCore.Mvc;
|
||||
using Yi.Framework.Core;
|
||||
|
||||
namespace Yi.Framework.AspNetCore
|
||||
{
|
||||
[DependsOn(typeof(YiFrameworkCoreModule)
|
||||
)]
|
||||
public class YiFrameworkAspNetCoreModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 定义公共文件路径
|
||||
/// </summary>
|
||||
public enum FileTypeEnum
|
||||
{
|
||||
File,
|
||||
Image,
|
||||
Thumbnail,
|
||||
Excel,
|
||||
Temp
|
||||
}
|
||||
}
|
||||
14
Yi.Abp.Net8/framework/Yi.Framework.Core/Enums/OrderByEnum.cs
Normal file
14
Yi.Abp.Net8/framework/Yi.Framework.Core/Enums/OrderByEnum.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Enums
|
||||
{
|
||||
public enum OrderByEnum
|
||||
{
|
||||
Asc,
|
||||
Desc
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Enums
|
||||
{
|
||||
public enum QueryOperatorEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 相等
|
||||
/// </summary>
|
||||
Equal,
|
||||
/// <summary>
|
||||
/// 匹配
|
||||
/// </summary>
|
||||
Like,
|
||||
/// <summary>
|
||||
/// 大于
|
||||
/// </summary>
|
||||
GreaterThan,
|
||||
/// <summary>
|
||||
/// 大于或等于
|
||||
/// </summary>
|
||||
GreaterThanOrEqual,
|
||||
/// <summary>
|
||||
/// 小于
|
||||
/// </summary>
|
||||
LessThan,
|
||||
/// <summary>
|
||||
/// 小于或等于
|
||||
/// </summary>
|
||||
LessThanOrEqual,
|
||||
/// <summary>
|
||||
/// 等于集合
|
||||
/// </summary>
|
||||
In,
|
||||
/// <summary>
|
||||
/// 不等于集合
|
||||
/// </summary>
|
||||
NotIn,
|
||||
/// <summary>
|
||||
/// 左边匹配
|
||||
/// </summary>
|
||||
LikeLeft,
|
||||
/// <summary>
|
||||
/// 右边匹配
|
||||
/// </summary>
|
||||
LikeRight,
|
||||
/// <summary>
|
||||
/// 不相等
|
||||
/// </summary>
|
||||
NoEqual,
|
||||
/// <summary>
|
||||
/// 为空或空
|
||||
/// </summary>
|
||||
IsNullOrEmpty,
|
||||
/// <summary>
|
||||
/// 不为空
|
||||
/// </summary>
|
||||
IsNot,
|
||||
/// <summary>
|
||||
/// 不匹配
|
||||
/// </summary>
|
||||
NoLike,
|
||||
/// <summary>
|
||||
/// 时间段 值用 "|" 隔开
|
||||
/// </summary>
|
||||
DateRange
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Enums
|
||||
{
|
||||
public enum ResultCodeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作成功。
|
||||
/// </summary>
|
||||
Success = 200,
|
||||
|
||||
/// <summary>
|
||||
/// 操作不成功
|
||||
/// </summary>
|
||||
NotSuccess = 500,
|
||||
|
||||
/// <summary>
|
||||
/// 无权限
|
||||
/// </summary>
|
||||
NoPermission = 401,
|
||||
|
||||
/// <summary>
|
||||
/// 被拒绝
|
||||
/// </summary>
|
||||
Denied = 403
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Yi.Framework.Core.Extensions
|
||||
{
|
||||
public static class HttpContextExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置文件下载名称
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static void FileInlineHandle(this HttpContext httpContext, string fileName)
|
||||
{
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
||||
httpContext.Response.Headers.Add("Content-Disposition", "inline;filename=" + encodeFilename);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置文件附件名称
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static void FileAttachmentHandle(this HttpContext httpContext, string fileName)
|
||||
{
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
||||
httpContext.Response.Headers.Add("Content-Disposition", "attachment;filename=" + encodeFilename);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取语言种类
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetLanguage(this HttpContext httpContext)
|
||||
{
|
||||
string res = "zh-CN";
|
||||
var str = httpContext.Request.Headers["Accept-Language"].FirstOrDefault();
|
||||
if (str is not null)
|
||||
{
|
||||
res = str.Split(",")[0];
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为异步请求
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsAjaxRequest(this HttpRequest request)
|
||||
{
|
||||
string header = request.Headers["X-Requested-With"];
|
||||
return "XMLHttpRequest".Equals(header);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取客户端IP
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetClientIp(this HttpContext context)
|
||||
{
|
||||
if (context == null) return "";
|
||||
var result = context.Request.Headers["X-Forwarded-For"].FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
result = context.Connection.RemoteIpAddress?.ToString();
|
||||
}
|
||||
if (string.IsNullOrEmpty(result) || result.Contains("::1"))
|
||||
result = "127.0.0.1";
|
||||
|
||||
result = result.Replace("::ffff:", "127.0.0.1");
|
||||
|
||||
//Ip规则效验
|
||||
var regResult = Regex.IsMatch(result, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
|
||||
|
||||
result = regResult ? result : "127.0.0.1";
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取浏览器标识
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUserAgent(this HttpContext context)
|
||||
{
|
||||
return context.Request.Headers["User-Agent"];
|
||||
}
|
||||
|
||||
public static string[]? GetUserPermissions(this HttpContext context, string permissionsName)
|
||||
{
|
||||
return context.User.Claims.Where(x => x.Type == permissionsName).Select(x => x.Value).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class AssemblyHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 此处统一获取程序集,排除微软内部相关
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Assembly[] GetAllLoadAssembly()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies();
|
||||
}
|
||||
|
||||
public static List<Assembly> GetReferanceAssemblies(this AppDomain domain)
|
||||
{
|
||||
var list = new List<Assembly>();
|
||||
domain.GetAssemblies().ToList().ForEach(i =>
|
||||
{
|
||||
GetReferanceAssemblies(i, list);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
private static void GetReferanceAssemblies(Assembly assembly, List<Assembly> list)
|
||||
{
|
||||
assembly.GetReferencedAssemblies().ToList().ForEach(i =>
|
||||
{
|
||||
var ass = Assembly.Load(i);
|
||||
if (!list.Contains(ass))
|
||||
{
|
||||
list.Add(ass);
|
||||
GetReferanceAssemblies(ass, list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<Type> GetClass(string assemblyFile, string? className = null, string? spaceName = null)
|
||||
{
|
||||
Assembly assembly = Assembly.Load(assemblyFile);
|
||||
return assembly.GetTypes().Where(m => m.IsClass
|
||||
&& className == null ? true : m.Name == className
|
||||
&& spaceName == null ? true : m.Namespace == spaceName
|
||||
&& !m.Name.StartsWith("<>")
|
||||
).ToList();
|
||||
}
|
||||
|
||||
public static List<Type> GetClassByParentClass(string assemblyFile, Type type)
|
||||
{
|
||||
Assembly assembly = Assembly.Load(assemblyFile);
|
||||
|
||||
List<Type> resList = new List<Type>();
|
||||
|
||||
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
|
||||
foreach (var t in typeList)
|
||||
{
|
||||
var data = t.BaseType;
|
||||
if (data == type)
|
||||
{
|
||||
resList.Add(t);
|
||||
}
|
||||
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
public static List<Type> GetClassByInterfaces(string assemblyFile, Type type)
|
||||
{
|
||||
Assembly assembly = Assembly.Load(assemblyFile);
|
||||
|
||||
List<Type> resList = new List<Type>();
|
||||
|
||||
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
|
||||
foreach (var t in typeList)
|
||||
{
|
||||
var data = t.GetInterfaces();
|
||||
if (data.Contains(type))
|
||||
{
|
||||
resList.Add(t);
|
||||
}
|
||||
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
101
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/Base32Helper.cs
Normal file
101
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/Base32Helper.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public sealed class Base32Helper
|
||||
{
|
||||
|
||||
// the valid chars for the encoding
|
||||
private static string ValidChars = "QAZ2WSX3" + "EDC4RFV5" + "TGB6YHN7" + "UJM8K9LP";
|
||||
|
||||
/// <summary>
|
||||
/// Converts an array of bytes to a Base32-k string.
|
||||
/// </summary>
|
||||
public static string ToString(byte[] bytes)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(); // holds the base32 chars
|
||||
byte index;
|
||||
int hi = 5;
|
||||
int currentByte = 0;
|
||||
|
||||
while (currentByte < bytes.Length)
|
||||
{
|
||||
// do we need to use the next byte?
|
||||
if (hi > 8)
|
||||
{
|
||||
// get the last piece from the current byte, shift it to the right
|
||||
// and increment the byte counter
|
||||
index = (byte)(bytes[currentByte++] >> hi - 5);
|
||||
if (currentByte != bytes.Length)
|
||||
{
|
||||
// if we are not at the end, get the first piece from
|
||||
// the next byte, clear it and shift it to the left
|
||||
index = (byte)((byte)(bytes[currentByte] << 16 - hi) >> 3 | index);
|
||||
}
|
||||
|
||||
hi -= 3;
|
||||
}
|
||||
else if (hi == 8)
|
||||
{
|
||||
index = (byte)(bytes[currentByte++] >> 3);
|
||||
hi -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// simply get the stuff from the current byte
|
||||
index = (byte)((byte)(bytes[currentByte] << 8 - hi) >> 3);
|
||||
hi += 5;
|
||||
}
|
||||
|
||||
sb.Append(ValidChars[index]);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Base32-k string into an array of bytes.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Input string <paramref name="s">s</paramref> contains invalid Base32-k characters.
|
||||
/// </exception>
|
||||
public static byte[] FromBase32String(string str)
|
||||
{
|
||||
int numBytes = str.Length * 5 / 8;
|
||||
byte[] bytes = new byte[numBytes];
|
||||
|
||||
// all UPPERCASE chars
|
||||
str = str.ToUpper();
|
||||
|
||||
int bit_buffer;
|
||||
int currentCharIndex;
|
||||
int bits_in_buffer;
|
||||
|
||||
if (str.Length < 3)
|
||||
{
|
||||
bytes[0] = (byte)(ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bit_buffer = ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5;
|
||||
bits_in_buffer = 10;
|
||||
currentCharIndex = 2;
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
bytes[i] = (byte)bit_buffer;
|
||||
bit_buffer >>= 8;
|
||||
bits_in_buffer -= 8;
|
||||
while (bits_in_buffer < 8 && currentCharIndex < str.Length)
|
||||
{
|
||||
bit_buffer |= ValidChars.IndexOf(str[currentCharIndex++]) << bits_in_buffer;
|
||||
bits_in_buffer += 5;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
329
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/ComputerHelper.cs
Normal file
329
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/ComputerHelper.cs
Normal file
@@ -0,0 +1,329 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class ComputerHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 将object转换为long,若转换失败,则返回0。不抛出异常。
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
private static long ParseToLong( object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return long.Parse(obj.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将string转换为DateTime,若转换失败,则返回日期最小值。不抛出异常。
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
private static DateTime ParseToDateTime( string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
if (str.Contains("-") || str.Contains("/"))
|
||||
{
|
||||
return DateTime.Parse(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
int length = str.Length;
|
||||
switch (length)
|
||||
{
|
||||
case 4:
|
||||
return DateTime.ParseExact(str, "yyyy", System.Globalization.CultureInfo.CurrentCulture);
|
||||
case 6:
|
||||
return DateTime.ParseExact(str, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
|
||||
case 8:
|
||||
return DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
|
||||
case 10:
|
||||
return DateTime.ParseExact(str, "yyyyMMddHH", System.Globalization.CultureInfo.CurrentCulture);
|
||||
case 12:
|
||||
return DateTime.ParseExact(str, "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);
|
||||
case 14:
|
||||
return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
|
||||
default:
|
||||
return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
private static double ParseToDouble(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return double.Parse(obj.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内存使用情况
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static MemoryMetrics GetComputerInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
MemoryMetricsClient client = new();
|
||||
MemoryMetrics memoryMetrics = IsUnix() ? client.GetUnixMetrics() : client.GetWindowsMetrics();
|
||||
|
||||
memoryMetrics.FreeRam = Math.Round(memoryMetrics.Free / 1024, 2) + "GB";
|
||||
memoryMetrics.UsedRam = Math.Round(memoryMetrics.Used / 1024, 2) + "GB";
|
||||
memoryMetrics.TotalRAM = Math.Round(memoryMetrics.Total / 1024, 2) + "GB";
|
||||
memoryMetrics.RAMRate = Math.Ceiling(100 * memoryMetrics.Used / memoryMetrics.Total).ToString() + "%";
|
||||
memoryMetrics.CPURate = Math.Ceiling(ParseToDouble(GetCPURate())) + "%";
|
||||
return memoryMetrics;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("获取内存使用出错,msg=" + ex.Message + "," + ex.StackTrace);
|
||||
}
|
||||
return new MemoryMetrics();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内存大小
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<DiskInfo> GetDiskInfos()
|
||||
{
|
||||
List<DiskInfo> diskInfos = new();
|
||||
|
||||
if (IsUnix())
|
||||
{
|
||||
try
|
||||
{
|
||||
string output = ShellHelper.Bash("df -m / | awk '{print $2,$3,$4,$5,$6}'");
|
||||
var arr = output.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (arr.Length == 0) return diskInfos;
|
||||
|
||||
var rootDisk = arr[1].Split(' ', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
if (rootDisk == null || rootDisk.Length == 0)
|
||||
{
|
||||
return diskInfos;
|
||||
}
|
||||
DiskInfo diskInfo = new()
|
||||
{
|
||||
DiskName = "/",
|
||||
TotalSize = long.Parse(rootDisk[0]) / 1024,
|
||||
Used = long.Parse(rootDisk[1]) / 1024,
|
||||
AvailableFreeSpace = long.Parse(rootDisk[2]) / 1024,
|
||||
AvailablePercent = decimal.Parse(rootDisk[3].Replace("%", ""))
|
||||
};
|
||||
diskInfos.Add(diskInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("获取磁盘信息出错了" + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var driv = DriveInfo.GetDrives();
|
||||
foreach (var item in driv)
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = new DiskInfo()
|
||||
{
|
||||
DiskName = item.Name,
|
||||
TypeName = item.DriveType.ToString(),
|
||||
TotalSize = item.TotalSize / 1024 / 1024 / 1024,
|
||||
AvailableFreeSpace = item.AvailableFreeSpace / 1024 / 1024 / 1024,
|
||||
};
|
||||
obj.Used = obj.TotalSize - obj.AvailableFreeSpace;
|
||||
obj.AvailablePercent = decimal.Ceiling(obj.Used / (decimal)obj.TotalSize * 100);
|
||||
diskInfos.Add(obj);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("获取磁盘信息出错了" + ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return diskInfos;
|
||||
}
|
||||
|
||||
public static bool IsUnix()
|
||||
{
|
||||
var isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
return isUnix;
|
||||
}
|
||||
|
||||
public static string GetCPURate()
|
||||
{
|
||||
string cpuRate;
|
||||
if (IsUnix())
|
||||
{
|
||||
string output = ShellHelper.Bash("top -b -n1 | grep \"Cpu(s)\" | awk '{print $2 + $4}'");
|
||||
cpuRate = output.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
string output = ShellHelper.Cmd("wmic", "cpu get LoadPercentage");
|
||||
cpuRate = output.Replace("LoadPercentage", string.Empty).Trim();
|
||||
}
|
||||
return cpuRate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取系统运行时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetRunTime()
|
||||
{
|
||||
string runTime = string.Empty;
|
||||
try
|
||||
{
|
||||
if (IsUnix())
|
||||
{
|
||||
string output = ShellHelper.Bash("uptime -s").Trim();
|
||||
runTime = DateTimeHelper.FormatTime(ParseToLong((DateTime.Now - ParseToDateTime(output)).TotalMilliseconds.ToString().Split('.')[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
string output = ShellHelper.Cmd("wmic", "OS get LastBootUpTime/Value");
|
||||
string[] outputArr = output.Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
if (outputArr.Length == 2)
|
||||
{
|
||||
runTime = DateTimeHelper.FormatTime(ParseToLong((DateTime.Now - ParseToDateTime( outputArr[1].Split('.')[0])).TotalMilliseconds.ToString().Split('.')[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("获取runTime出错" + ex.Message);
|
||||
}
|
||||
return runTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内存信息
|
||||
/// </summary>
|
||||
public class MemoryMetrics
|
||||
{
|
||||
[JsonIgnore]
|
||||
public double Total { get; set; }
|
||||
[JsonIgnore]
|
||||
public double Used { get; set; }
|
||||
[JsonIgnore]
|
||||
public double Free { get; set; }
|
||||
|
||||
public string UsedRam { get; set; }
|
||||
/// <summary>
|
||||
/// CPU使用率%
|
||||
/// </summary>
|
||||
public string CPURate { get; set; }
|
||||
/// <summary>
|
||||
/// 总内存 GB
|
||||
/// </summary>
|
||||
public string TotalRAM { get; set; }
|
||||
/// <summary>
|
||||
/// 内存使用率 %
|
||||
/// </summary>
|
||||
public string RAMRate { get; set; }
|
||||
/// <summary>
|
||||
/// 空闲内存
|
||||
/// </summary>
|
||||
public string FreeRam { get; set; }
|
||||
}
|
||||
|
||||
public class DiskInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 磁盘名
|
||||
/// </summary>
|
||||
public string DiskName { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public long TotalFree { get; set; }
|
||||
public long TotalSize { get; set; }
|
||||
/// <summary>
|
||||
/// 已使用
|
||||
/// </summary>
|
||||
public long Used { get; set; }
|
||||
/// <summary>
|
||||
/// 可使用
|
||||
/// </summary>
|
||||
public long AvailableFreeSpace { get; set; }
|
||||
public decimal AvailablePercent { get; set; }
|
||||
}
|
||||
|
||||
public class MemoryMetricsClient
|
||||
{
|
||||
#region 获取内存信息
|
||||
|
||||
/// <summary>
|
||||
/// windows系统获取内存信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MemoryMetrics GetWindowsMetrics()
|
||||
{
|
||||
string output = ShellHelper.Cmd("wmic", "OS get FreePhysicalMemory,TotalVisibleMemorySize /Value");
|
||||
var metrics = new MemoryMetrics();
|
||||
var lines = output.Trim().Split('\n', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (lines.Length <= 0) return metrics;
|
||||
|
||||
var freeMemoryParts = lines[0].Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
var totalMemoryParts = lines[1].Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
metrics.Total = Math.Round(double.Parse(totalMemoryParts[1]) / 1024, 0);
|
||||
metrics.Free = Math.Round(double.Parse(freeMemoryParts[1]) / 1024, 0);//m
|
||||
metrics.Used = metrics.Total - metrics.Free;
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unix系统获取
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MemoryMetrics GetUnixMetrics()
|
||||
{
|
||||
string output = ShellHelper.Bash("free -m | awk '{print $2,$3,$4,$5,$6}'");
|
||||
var metrics = new MemoryMetrics();
|
||||
var lines = output.Split('\n', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (lines.Length <= 0) return metrics;
|
||||
|
||||
if (lines != null && lines.Length > 0)
|
||||
{
|
||||
var memory = lines[1].Split(' ', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
if (memory.Length >= 3)
|
||||
{
|
||||
metrics.Total = double.Parse(memory[0]);
|
||||
metrics.Used = double.Parse(memory[1]);
|
||||
metrics.Free = double.Parse(memory[2]);//m
|
||||
}
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class ConsoleHelper
|
||||
{
|
||||
public static void WriteColorLine(string str, ConsoleColor color)
|
||||
{
|
||||
ConsoleColor currentForeColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
Console.WriteLine(str);
|
||||
Console.ForegroundColor = currentForeColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印错误信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteErrorLine(this string str, ConsoleColor color = ConsoleColor.Red)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印警告信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteWarningLine(this string str, ConsoleColor color = ConsoleColor.Yellow)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印正常信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteInfoLine(this string str, ConsoleColor color = ConsoleColor.White)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印成功的信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteSuccessLine(this string str, ConsoleColor color = ConsoleColor.Green)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
58
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateHelper.cs
Normal file
58
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateHelper.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class DateHelper
|
||||
{
|
||||
public static DateTime StampToDateTime(string time)
|
||||
{
|
||||
time = time.Substring(0, 10);
|
||||
double timestamp = Convert.ToInt64(time);
|
||||
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
dateTime = dateTime.AddSeconds(timestamp).ToLocalTime();
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static string TimeSubTract(DateTime time1, DateTime time2)
|
||||
{
|
||||
TimeSpan subTract = time1.Subtract(time2);
|
||||
return $"{subTract.Days} 天 {subTract.Hours} 时 {subTract.Minutes} 分 ";
|
||||
}
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateBySeconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeSeconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampBySeconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateByMilliseconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeMilliseconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampByMilliseconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeMilliseconds();
|
||||
}
|
||||
}
|
||||
}
|
||||
139
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateTimeHelper.cs
Normal file
139
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateTimeHelper.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class DateTimeHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetBeginTime(DateTime? dateTime, int days = 0)
|
||||
{
|
||||
if (dateTime == DateTime.MinValue || dateTime == null)
|
||||
{
|
||||
return DateTime.Now.AddDays(days);
|
||||
}
|
||||
return dateTime ?? DateTime.Now;
|
||||
}
|
||||
#region 时间戳转换
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateBySeconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeSeconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampBySeconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateByMilliseconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeMilliseconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampByMilliseconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeMilliseconds();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 毫秒转天时分秒
|
||||
/// <summary>
|
||||
/// 毫秒转天时分秒
|
||||
/// </summary>
|
||||
/// <param name="ms"></param>
|
||||
/// <returns></returns>
|
||||
public static string FormatTime(long ms)
|
||||
{
|
||||
int ss = 1000;
|
||||
int mi = ss * 60;
|
||||
int hh = mi * 60;
|
||||
int dd = hh * 24;
|
||||
|
||||
long day = ms / dd;
|
||||
long hour = (ms - day * dd) / hh;
|
||||
long minute = (ms - day * dd - hour * hh) / mi;
|
||||
long second = (ms - day * dd - hour * hh - minute * mi) / ss;
|
||||
long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
|
||||
|
||||
string sDay = day < 10 ? "0" + day : "" + day; //天
|
||||
string sHour = hour < 10 ? "0" + hour : "" + hour;//小时
|
||||
string sMinute = minute < 10 ? "0" + minute : "" + minute;//分钟
|
||||
string sSecond = second < 10 ? "0" + second : "" + second;//秒
|
||||
string sMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒
|
||||
sMilliSecond = milliSecond < 100 ? "0" + sMilliSecond : "" + sMilliSecond;
|
||||
|
||||
return string.Format("{0} 天 {1} 小时 {2} 分 {3} 秒", sDay, sHour, sMinute, sSecond);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取unix时间戳
|
||||
/// <summary>
|
||||
/// 获取unix时间戳
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static long GetUnixTimeStamp(DateTime dt)
|
||||
{
|
||||
long unixTime = ((DateTimeOffset)dt).ToUnixTimeMilliseconds();
|
||||
return unixTime;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取日期天的最小时间
|
||||
public static DateTime GetDayMinDate(DateTime dt)
|
||||
{
|
||||
DateTime min = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);
|
||||
return min;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取日期天的最大时间
|
||||
public static DateTime GetDayMaxDate(DateTime dt)
|
||||
{
|
||||
DateTime max = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
|
||||
return max;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取日期天的最大时间
|
||||
public static string FormatDateTime(DateTime? dt)
|
||||
{
|
||||
if (dt != null)
|
||||
{
|
||||
if (dt.Value.Year == DateTime.Now.Year)
|
||||
{
|
||||
return dt.Value.ToString("MM-dd HH:mm");
|
||||
}
|
||||
else
|
||||
{
|
||||
return dt.Value.ToString("yyyy-MM-dd HH:mm");
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class Compare<T, C> : IEqualityComparer<T>
|
||||
{
|
||||
private Func<T, C> _getField;
|
||||
public Compare(Func<T, C> getfield)
|
||||
{
|
||||
_getField = getfield;
|
||||
}
|
||||
public bool Equals(T? x, T? y)
|
||||
{
|
||||
return EqualityComparer<C>.Default.Equals(_getField(x!), _getField(y!));
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
{
|
||||
return EqualityComparer<C>.Default.GetHashCode(_getField(obj)!);
|
||||
}
|
||||
}
|
||||
public static class DistinctHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义Distinct扩展方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要去重的对象类</typeparam>
|
||||
/// <typeparam name="C">自定义去重的字段类型</typeparam>
|
||||
/// <param name="source">要去重的对象</param>
|
||||
/// <param name="getfield">获取自定义去重字段的委托</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> DistinctNew<T, C>(this IEnumerable<T> source, Func<T, C> getfield)
|
||||
{
|
||||
return source.Distinct(new Compare<T, C>(getfield));
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/EnumHelper.cs
Normal file
25
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/EnumHelper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class EnumHelper
|
||||
{
|
||||
public static New EnumToEnum<New>(this object oldEnum)
|
||||
{
|
||||
if (oldEnum is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(oldEnum));
|
||||
}
|
||||
return (New)Enum.ToObject(typeof(New), oldEnum.GetHashCode());
|
||||
}
|
||||
|
||||
public static TEnum StringToEnum<TEnum>(this string str)
|
||||
{
|
||||
return (TEnum)Enum.Parse(typeof(TEnum), str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class ExpressionHelper
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Expression表达式树lambda参数拼接组合
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="merge"></param>
|
||||
/// <returns></returns>
|
||||
public static Expression<T> Compose<T>(this Expression<T> first, Expression<T> second, Func<Expression, Expression, Expression> merge)
|
||||
{
|
||||
var parameterMap = first.Parameters.Select((f, i) => new { f, s = second.Parameters[i] }).ToDictionary(p => p.s, p => p.f);
|
||||
var secondBody = LambdaParameteRebinder.ReplaceParameter(parameterMap, second.Body);
|
||||
return Expression.Lambda<T>(merge(first.Body, secondBody), first.Parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expression表达式树lambda参数拼接--false
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static Expression<Func<T, bool>> False<T>() => f => false;
|
||||
|
||||
/// <summary>
|
||||
/// Expression表达式树lambda参数拼接-true
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static Expression<Func<T, bool>> True<T>() => f => true;
|
||||
|
||||
/// <summary>
|
||||
/// Expression表达式树lambda参数拼接--and
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <returns></returns>
|
||||
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second) => first.Compose(second, Expression.And);
|
||||
|
||||
/// <summary>
|
||||
/// Expression表达式树lambda参数拼接--or
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <returns></returns>
|
||||
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second) => first.Compose(second, Expression.Or);
|
||||
}
|
||||
|
||||
public class LambdaParameteRebinder : ExpressionVisitor
|
||||
{
|
||||
/// <summary>
|
||||
/// 存放表达式树的参数的字典
|
||||
/// </summary>
|
||||
private readonly Dictionary<ParameterExpression, ParameterExpression> map;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
public LambdaParameteRebinder(Dictionary<ParameterExpression, ParameterExpression> map)
|
||||
{
|
||||
this.map = map ?? new Dictionary<ParameterExpression, ParameterExpression>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重载参数访问的方法,访问表达式树参数,如果字典中包含,则取出
|
||||
/// </summary>
|
||||
/// <param name="node">表达式树参数</param>
|
||||
/// <returns></returns>
|
||||
protected override Expression VisitParameter(ParameterExpression node)
|
||||
{
|
||||
if (map.TryGetValue(node, out ParameterExpression expression))
|
||||
{
|
||||
node = expression;
|
||||
}
|
||||
return base.VisitParameter(node);
|
||||
}
|
||||
|
||||
public static Expression ReplaceParameter(Dictionary<ParameterExpression, ParameterExpression> map, Expression exp)
|
||||
{
|
||||
return new LambdaParameteRebinder(map).Visit(exp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
490
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/FileHelper.cs
Normal file
490
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/FileHelper.cs
Normal file
@@ -0,0 +1,490 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class FileHelper : IDisposable
|
||||
{
|
||||
|
||||
private bool _alreadyDispose = false;
|
||||
|
||||
|
||||
|
||||
#region 构造函数
|
||||
public FileHelper()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
~FileHelper()
|
||||
{
|
||||
Dispose(); ;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool isDisposing)
|
||||
{
|
||||
if (_alreadyDispose) return;
|
||||
_alreadyDispose = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable 成员
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 取得文件后缀名
|
||||
/****************************************
|
||||
* 函数名称:GetPostfixStr
|
||||
* 功能说明:取得文件后缀名
|
||||
* 参 数:filename:文件名称
|
||||
* 调用示列:
|
||||
* string filename = "aaa.aspx";
|
||||
* string s = EC.FileObj.GetPostfixStr(filename);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 取后缀名
|
||||
/// </summary>
|
||||
/// <param name="filename">文件名</param>
|
||||
/// <returns>.gif|.html格式</returns>
|
||||
public static string GetPostfixStr(string filename)
|
||||
{
|
||||
int start = filename.LastIndexOf(".");
|
||||
int length = filename.Length;
|
||||
string postfix = filename.Substring(start, length - start);
|
||||
return postfix;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据文件大小获取指定前缀的可用文件名
|
||||
/// <summary>
|
||||
/// 根据文件大小获取指定前缀的可用文件名
|
||||
/// </summary>
|
||||
/// <param name="folderPath">文件夹</param>
|
||||
/// <param name="prefix">文件前缀</param>
|
||||
/// <param name="size">文件大小(1m)</param>
|
||||
/// <param name="ext">文件后缀(.log)</param>
|
||||
/// <returns>可用文件名</returns>
|
||||
//public static string GetAvailableFileWithPrefixOrderSize(string folderPath, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
|
||||
//{
|
||||
// var allFiles = new DirectoryInfo(folderPath);
|
||||
// var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d=>d.Name).ToList();
|
||||
|
||||
// if (selectFiles.Count > 0)
|
||||
// {
|
||||
// return selectFiles.FirstOrDefault().FullName;
|
||||
// }
|
||||
|
||||
// return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.DateToTimeStamp()}.log");
|
||||
//}
|
||||
//public static string GetAvailableFileNameWithPrefixOrderSize(string _contentRoot, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
|
||||
//{
|
||||
// var folderPath = Path.Combine(_contentRoot, "Log");
|
||||
// if (!Directory.Exists(folderPath))
|
||||
// {
|
||||
// Directory.CreateDirectory(folderPath);
|
||||
// }
|
||||
|
||||
// var allFiles = new DirectoryInfo(folderPath);
|
||||
// var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d => d.Name).ToList();
|
||||
|
||||
// if (selectFiles.Count > 0)
|
||||
// {
|
||||
// return selectFiles.FirstOrDefault().Name.Replace(".log","");
|
||||
// }
|
||||
|
||||
// return $@"{prefix}_{DateTime.Now.DateToTimeStamp()}";
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 写文件
|
||||
/****************************************
|
||||
* 函数名称:WriteFile
|
||||
* 功能说明:写文件,会覆盖掉以前的内容
|
||||
* 参 数:Path:文件路径,Strings:文本内容
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string Strings = "这是我写的内容啊";
|
||||
* EC.FileObj.WriteFile(Path,Strings);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 写文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="Strings">文件内容</param>
|
||||
public static void WriteFile(string Path, string Strings)
|
||||
{
|
||||
if (!File.Exists(Path))
|
||||
{
|
||||
FileStream f = File.Create(Path);
|
||||
f.Close();
|
||||
}
|
||||
StreamWriter f2 = new StreamWriter(Path, false, Encoding.GetEncoding("gb2312"));
|
||||
f2.Write(Strings);
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="Strings">文件内容</param>
|
||||
/// <param name="encode">编码格式</param>
|
||||
public static void WriteFile(string Path, string Strings, Encoding encode)
|
||||
{
|
||||
if (!File.Exists(Path))
|
||||
{
|
||||
FileStream f = File.Create(Path);
|
||||
f.Close();
|
||||
}
|
||||
StreamWriter f2 = new StreamWriter(Path, false, encode);
|
||||
f2.Write(Strings);
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 读文件
|
||||
/****************************************
|
||||
* 函数名称:ReadFile
|
||||
* 功能说明:读取文本内容
|
||||
* 参 数:Path:文件路径
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string s = EC.FileObj.ReadFile(Path);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 读文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadFile(string Path)
|
||||
{
|
||||
string s = "";
|
||||
if (!File.Exists(Path))
|
||||
s = "不存在相应的目录";
|
||||
else
|
||||
{
|
||||
StreamReader f2 = new StreamReader(Path, Encoding.GetEncoding("gb2312"));
|
||||
s = f2.ReadToEnd();
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="encode">编码格式</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadFile(string Path, Encoding encode)
|
||||
{
|
||||
string s = "";
|
||||
if (!File.Exists(Path))
|
||||
s = "不存在相应的目录";
|
||||
else
|
||||
{
|
||||
StreamReader f2 = new StreamReader(Path, encode);
|
||||
s = f2.ReadToEnd();
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 追加文件
|
||||
/****************************************
|
||||
* 函数名称:FileAdd
|
||||
* 功能说明:追加文件内容
|
||||
* 参 数:Path:文件路径,strings:内容
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string Strings = "新追加内容";
|
||||
* EC.FileObj.FileAdd(Path, Strings);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 追加文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="strings">内容</param>
|
||||
public static void FileAdd(string Path, string strings)
|
||||
{
|
||||
StreamWriter sw = File.AppendText(Path);
|
||||
sw.Write(strings);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 拷贝文件
|
||||
/****************************************
|
||||
* 函数名称:FileCoppy
|
||||
* 功能说明:拷贝文件
|
||||
* 参 数:OrignFile:原始文件,NewFile:新文件路径
|
||||
* 调用示列:
|
||||
* string orignFile = Server.MapPath("Default2.aspx");
|
||||
* string NewFile = Server.MapPath("Default3.aspx");
|
||||
* EC.FileObj.FileCoppy(OrignFile, NewFile);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 拷贝文件
|
||||
/// </summary>
|
||||
/// <param name="OrignFile">原始文件</param>
|
||||
/// <param name="NewFile">新文件路径</param>
|
||||
public static void FileCoppy(string orignFile, string NewFile)
|
||||
{
|
||||
File.Copy(orignFile, NewFile, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 删除文件
|
||||
/****************************************
|
||||
* 函数名称:FileDel
|
||||
* 功能说明:删除文件
|
||||
* 参 数:Path:文件路径
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default3.aspx");
|
||||
* EC.FileObj.FileDel(Path);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 删除文件
|
||||
/// </summary>
|
||||
/// <param name="Path">路径</param>
|
||||
public static void FileDel(string Path)
|
||||
{
|
||||
File.Delete(Path);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 移动文件
|
||||
/****************************************
|
||||
* 函数名称:FileMove
|
||||
* 功能说明:移动文件
|
||||
* 参 数:OrignFile:原始路径,NewFile:新文件路径
|
||||
* 调用示列:
|
||||
* string orignFile = Server.MapPath("../说明.txt");
|
||||
* string NewFile = Server.MapPath("http://www.cnblogs.com/说明.txt");
|
||||
* EC.FileObj.FileMove(OrignFile, NewFile);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 移动文件
|
||||
/// </summary>
|
||||
/// <param name="OrignFile">原始路径</param>
|
||||
/// <param name="NewFile">新路径</param>
|
||||
public static void FileMove(string orignFile, string NewFile)
|
||||
{
|
||||
File.Move(orignFile, NewFile);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 在当前目录下创建目录
|
||||
/****************************************
|
||||
* 函数名称:FolderCreate
|
||||
* 功能说明:在当前目录下创建目录
|
||||
* 参 数:OrignFolder:当前目录,NewFloder:新目录
|
||||
* 调用示列:
|
||||
* string orignFolder = Server.MapPath("test/");
|
||||
* string NewFloder = "new";
|
||||
* EC.FileObj.FolderCreate(OrignFolder, NewFloder);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 在当前目录下创建目录
|
||||
/// </summary>
|
||||
/// <param name="OrignFolder">当前目录</param>
|
||||
/// <param name="NewFloder">新目录</param>
|
||||
public static void FolderCreate(string orignFolder, string NewFloder)
|
||||
{
|
||||
Directory.SetCurrentDirectory(orignFolder);
|
||||
Directory.CreateDirectory(NewFloder);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 递归删除文件夹目录及文件
|
||||
/****************************************
|
||||
* 函数名称:DeleteFolder
|
||||
* 功能说明:递归删除文件夹目录及文件
|
||||
* 参 数:dir:文件夹路径
|
||||
* 调用示列:
|
||||
* string dir = Server.MapPath("test/");
|
||||
* EC.FileObj.DeleteFolder(dir);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 递归删除文件夹目录及文件
|
||||
/// </summary>
|
||||
/// <param name="dir"></param>
|
||||
/// <returns></returns>
|
||||
public static void DeleteFolder(string dir)
|
||||
{
|
||||
if (Directory.Exists(dir)) //如果存在这个文件夹删除之
|
||||
{
|
||||
foreach (string d in Directory.GetFileSystemEntries(dir))
|
||||
{
|
||||
if (File.Exists(d))
|
||||
File.Delete(d); //直接删除其中的文件
|
||||
else
|
||||
DeleteFolder(d); //递归删除子文件夹
|
||||
}
|
||||
Directory.Delete(dir); //删除已空文件夹
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。
|
||||
/****************************************
|
||||
* 函数名称:CopyDir
|
||||
* 功能说明:将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。
|
||||
* 参 数:srcPath:原始路径,aimPath:目标文件夹
|
||||
* 调用示列:
|
||||
* string srcPath = Server.MapPath("test/");
|
||||
* string aimPath = Server.MapPath("test1/");
|
||||
* EC.FileObj.CopyDir(srcPath,aimPath);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 指定文件夹下面的所有内容copy到目标文件夹下面
|
||||
/// </summary>
|
||||
/// <param name="srcPath">原始路径</param>
|
||||
/// <param name="aimPath">目标文件夹</param>
|
||||
public static void CopyDir(string srcPath, string aimPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查目标目录是否以目录分割字符结束如果不是则添加之
|
||||
if (aimPath[aimPath.Length - 1] != Path.DirectorySeparatorChar)
|
||||
aimPath += Path.DirectorySeparatorChar;
|
||||
// 判断目标目录是否存在如果不存在则新建之
|
||||
if (!Directory.Exists(aimPath))
|
||||
Directory.CreateDirectory(aimPath);
|
||||
// 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组
|
||||
//如果你指向copy目标文件下面的文件而不包含目录请使用下面的方法
|
||||
//string[] fileList = Directory.GetFiles(srcPath);
|
||||
string[] fileList = Directory.GetFileSystemEntries(srcPath);
|
||||
//遍历所有的文件和目录
|
||||
foreach (string file in fileList)
|
||||
{
|
||||
//先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
|
||||
|
||||
if (Directory.Exists(file))
|
||||
CopyDir(file, aimPath + Path.GetFileName(file));
|
||||
//否则直接Copy文件
|
||||
else
|
||||
File.Copy(file, aimPath + Path.GetFileName(file), true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
throw new Exception(ee.ToString());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取目录下全部文件名
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetAllFileNames(string path, string pattern = "*")
|
||||
{
|
||||
List<FileInfo> folder = new DirectoryInfo(path).GetFiles(pattern).ToList();
|
||||
|
||||
return folder.Select(x => x.Name).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件内容替换
|
||||
/// </summary>
|
||||
public static string FileContentReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
var content = File.ReadAllText(path);
|
||||
|
||||
if (content.Contains(oldStr))
|
||||
{
|
||||
File.Delete(path);
|
||||
File.WriteAllText(path, content.Replace(oldStr, newStr));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public static string FileNameReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
string fileName = Path.GetFileName(path);
|
||||
if (!fileName.Contains(oldStr))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
string? directoryName = Path.GetDirectoryName(path);
|
||||
string newFileName = fileName.Replace(oldStr, newStr);
|
||||
string newPath = Path.Combine(directoryName ?? "", newFileName);
|
||||
File.Move(path, newPath);
|
||||
|
||||
return newPath;
|
||||
}
|
||||
/// <summary>
|
||||
/// 目录名替换
|
||||
/// </summary>
|
||||
public static string DirectoryNameReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
string fileName = Path.GetFileName(path);
|
||||
if (!fileName.Contains(oldStr))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
string? directoryName = Path.GetDirectoryName(path);
|
||||
string newFileName = fileName.Replace(oldStr, newStr);
|
||||
string newPath = Path.Combine(directoryName ?? "", newFileName);
|
||||
Directory.Move(path, newPath);
|
||||
return newPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部信息递归替换
|
||||
/// </summary>
|
||||
/// <param name="dirPath"></param>
|
||||
/// <param name="oldStr"></param>
|
||||
/// <param name="newStr"></param>
|
||||
public static void AllInfoReplace(string dirPath, string oldStr, string newStr)
|
||||
{
|
||||
var path = DirectoryNameReplace(dirPath, oldStr, newStr);
|
||||
var dirInfo = new DirectoryInfo(path);
|
||||
var files = dirInfo.GetFiles();
|
||||
var dirs = dirInfo.GetDirectories();
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (var f in files)
|
||||
{
|
||||
FileContentReplace(f.FullName, oldStr, newStr);
|
||||
FileNameReplace(f.FullName, oldStr, newStr);
|
||||
}
|
||||
}
|
||||
if (dirs.Length > 0)
|
||||
{
|
||||
foreach (var d in dirs)
|
||||
{
|
||||
AllInfoReplace(d.FullName, oldStr, newStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/HtmlHelper.cs
Normal file
24
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/HtmlHelper.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class HtmlHelper
|
||||
{
|
||||
#region 去除富文本中的HTML标签
|
||||
/// <summary>
|
||||
/// 去除富文本中的HTML标签
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReplaceHtmlTag(string html, int length = 0)
|
||||
{
|
||||
string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
|
||||
strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
|
||||
|
||||
if (length > 0 && strText.Length > length)
|
||||
return strText.Substring(0, length);
|
||||
|
||||
return strText;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
122
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/HttpHelper.cs
Normal file
122
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/HttpHelper.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
|
||||
public static HttpClient Client { get; set; } = new HttpClient();
|
||||
|
||||
public static async Task<string> Get(string url)
|
||||
{
|
||||
return await Client.GetStringAsync(url);
|
||||
}
|
||||
|
||||
public static async Task<Stream> GetIO(string url)
|
||||
{
|
||||
return await Client.GetStreamAsync(url);
|
||||
}
|
||||
|
||||
|
||||
public static async Task<string> Post(string url, object? item = null, Dictionary<string, string>? head = null)
|
||||
{
|
||||
|
||||
using StringContent json = new(JsonSerializer.Serialize(item), Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
|
||||
|
||||
if (head is not null)
|
||||
{
|
||||
foreach (var d in head)
|
||||
{
|
||||
json.Headers.Add(d.Key, d.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var httpResponse = await Client.PostAsync(url, json);
|
||||
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var content = httpResponse.Content;
|
||||
|
||||
return await content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
||||
// public static string HttpGet(string Url, string postDataStr="")
|
||||
// {
|
||||
//#pragma warning disable SYSLIB0014 // 类型或成员已过时
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||
//#pragma warning restore SYSLIB0014 // 类型或成员已过时
|
||||
// request.Method = "GET";
|
||||
// request.ContentType = "text/html;charset=UTF-8";
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||||
// string retString = myStreamReader.ReadToEnd();
|
||||
// myStreamReader.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return retString;
|
||||
// }
|
||||
|
||||
// public static bool HttpIOGet(string Url, string file, string postDataStr="")
|
||||
// {
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||
// request.Method = "GET";
|
||||
// request.ContentType = "text/html;charset=UTF-8";
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// FileStream writer = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int c;
|
||||
// while ((c = myResponseStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
// {
|
||||
// writer.Write(buffer, 0, c);
|
||||
// }
|
||||
// writer.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public static string HttpPost(string Url, string postDataStr="")
|
||||
// {
|
||||
// CookieContainer cookie = new CookieContainer();
|
||||
//#pragma warning disable SYSLIB0014 // 类型或成员已过时
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
||||
//#pragma warning restore SYSLIB0014 // 类型或成员已过时
|
||||
// request.Method = "POST";
|
||||
// request.ContentType = "application/x-www-form-urlencoded";
|
||||
// request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
|
||||
// request.CookieContainer = cookie;
|
||||
|
||||
// Stream myRequestStream = request.GetRequestStream();
|
||||
// StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
|
||||
// myStreamWriter.Write(postDataStr);
|
||||
// myStreamWriter.Close();
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
// response.Cookies = cookie.GetCookies(response.ResponseUri);
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||||
// string retString = myStreamReader.ReadToEnd();
|
||||
// myStreamReader.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return retString;
|
||||
// }
|
||||
}
|
||||
}
|
||||
16
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/IdHelper.cs
Normal file
16
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/IdHelper.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class IdHelper
|
||||
{
|
||||
public static dynamic[] ToDynamicArray(this IEnumerable<long> ids)
|
||||
{
|
||||
return ids.Select(id => (dynamic)id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/IpHelper.cs
Normal file
56
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/IpHelper.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class IpHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前IP地址
|
||||
/// </summary>
|
||||
/// <param name="preferredNetworks"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCurrentIp(string preferredNetworks)
|
||||
{
|
||||
var instanceIp = "127.0.0.1";
|
||||
|
||||
try
|
||||
{
|
||||
// 获取可用网卡
|
||||
var nics = NetworkInterface.GetAllNetworkInterfaces()?.Where(network => network.OperationalStatus == OperationalStatus.Up);
|
||||
|
||||
// 获取所有可用网卡IP信息
|
||||
var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses);
|
||||
|
||||
if (ipCollection is null)
|
||||
{
|
||||
return instanceIp;
|
||||
}
|
||||
|
||||
foreach (var ipadd in ipCollection)
|
||||
{
|
||||
if (!IPAddress.IsLoopback(ipadd.Address) && ipadd.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
if (string.IsNullOrEmpty(preferredNetworks))
|
||||
{
|
||||
instanceIp = ipadd.Address.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ipadd.Address.ToString().StartsWith(preferredNetworks)) continue;
|
||||
instanceIp = ipadd.Address.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return instanceIp;
|
||||
}
|
||||
}
|
||||
}
|
||||
514
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/JsonHelper.cs
Normal file
514
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/JsonHelper.cs
Normal file
@@ -0,0 +1,514 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class JsonHelper
|
||||
{
|
||||
public static string ObjToStr<T>(T obj, string dateTimeFormat)
|
||||
{
|
||||
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter()
|
||||
{
|
||||
DateTimeFormat = dateTimeFormat
|
||||
};
|
||||
return JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
|
||||
}
|
||||
|
||||
public static string ObjToStr<T>(T obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj);
|
||||
}
|
||||
|
||||
public static T StrToObj<T>(string str)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(str)!;
|
||||
}
|
||||
/// <summary>
|
||||
/// 转换对象为JSON格式数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类</typeparam>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns>字符格式的JSON数据</returns>
|
||||
public static string GetJSON<T>(object obj)
|
||||
{
|
||||
string result = string.Empty;
|
||||
try
|
||||
{
|
||||
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer =
|
||||
new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
serializer.WriteObject(ms, obj);
|
||||
result = System.Text.Encoding.UTF8.GetString(ms.ToArray());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 转换List<T>的数据为JSON格式
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类</typeparam>
|
||||
/// <param name="vals">列表值</param>
|
||||
/// <returns>JSON格式数据</returns>
|
||||
public string JSON<T>(List<T> vals)
|
||||
{
|
||||
System.Text.StringBuilder st = new System.Text.StringBuilder();
|
||||
try
|
||||
{
|
||||
System.Runtime.Serialization.Json.DataContractJsonSerializer s = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
|
||||
|
||||
foreach (T city in vals)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
s.WriteObject(ms, city);
|
||||
st.Append(System.Text.Encoding.UTF8.GetString(ms.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
return st.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// JSON格式字符转换为T类型的对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="jsonStr"></param>
|
||||
/// <returns></returns>
|
||||
public static T ParseFormByJson<T>(string jsonStr)
|
||||
{
|
||||
T obj = Activator.CreateInstance<T>();
|
||||
using (MemoryStream ms =
|
||||
new MemoryStream(System.Text.Encoding.UTF8.GetBytes(jsonStr)))
|
||||
{
|
||||
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer =
|
||||
new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
|
||||
return (T)serializer.ReadObject(ms)!;
|
||||
}
|
||||
}
|
||||
|
||||
public string JSON1<SendData>(List<SendData> vals)
|
||||
{
|
||||
System.Text.StringBuilder st = new System.Text.StringBuilder();
|
||||
try
|
||||
{
|
||||
System.Runtime.Serialization.Json.DataContractJsonSerializer s = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(SendData));
|
||||
|
||||
foreach (SendData city in vals)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
s.WriteObject(ms, city);
|
||||
st.Append(System.Text.Encoding.UTF8.GetString(ms.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
return st.ToString();
|
||||
}
|
||||
|
||||
private static bool IsJsonStart(ref string json)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
json = json.Trim('\r', '\n', ' ');
|
||||
if (json.Length > 1)
|
||||
{
|
||||
char s = json[0];
|
||||
char e = json[json.Length - 1];
|
||||
return s == '{' && e == '}' || s == '[' && e == ']';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsJson(string json)
|
||||
{
|
||||
int errIndex;
|
||||
return IsJson(json, out errIndex);
|
||||
}
|
||||
public static bool IsJson(string json, out int errIndex)
|
||||
{
|
||||
errIndex = 0;
|
||||
if (IsJsonStart(ref json))
|
||||
{
|
||||
CharState cs = new CharState();
|
||||
char c;
|
||||
for (int i = 0; i < json.Length; i++)
|
||||
{
|
||||
c = json[i];
|
||||
if (SetCharState(c, ref cs) && cs.childrenStart)//设置关键符号状态。
|
||||
{
|
||||
string item = json.Substring(i);
|
||||
int err;
|
||||
int length = GetValueLength(item, true, out err);
|
||||
cs.childrenStart = false;
|
||||
if (err > 0)
|
||||
{
|
||||
errIndex = i + err;
|
||||
return false;
|
||||
}
|
||||
i = i + length - 1;
|
||||
}
|
||||
if (cs.isError)
|
||||
{
|
||||
errIndex = i;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !cs.arrayStart && !cs.jsonStart;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取值的长度(当Json值嵌套以"{"或"["开头时)
|
||||
/// </summary>
|
||||
private static int GetValueLength(string json, bool breakOnErr, out int errIndex)
|
||||
{
|
||||
errIndex = 0;
|
||||
int len = 0;
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
CharState cs = new CharState();
|
||||
char c;
|
||||
for (int i = 0; i < json.Length; i++)
|
||||
{
|
||||
c = json[i];
|
||||
if (!SetCharState(c, ref cs))//设置关键符号状态。
|
||||
{
|
||||
if (!cs.jsonStart && !cs.arrayStart)//json结束,又不是数组,则退出。
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (cs.childrenStart)//正常字符,值状态下。
|
||||
{
|
||||
int length = GetValueLength(json.Substring(i), breakOnErr, out errIndex);//递归子值,返回一个长度。。。
|
||||
cs.childrenStart = false;
|
||||
cs.valueStart = 0;
|
||||
//cs.state = 0;
|
||||
i = i + length - 1;
|
||||
}
|
||||
if (breakOnErr && cs.isError)
|
||||
{
|
||||
errIndex = i;
|
||||
return i;
|
||||
}
|
||||
if (!cs.jsonStart && !cs.arrayStart)//记录当前结束位置。
|
||||
{
|
||||
len = i + 1;//长度比索引+1
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置字符状态(返回true则为关键词,返回false则当为普通字符处理)
|
||||
/// </summary>
|
||||
private static bool SetCharState(char c, ref CharState cs)
|
||||
{
|
||||
cs.CheckIsError(c);
|
||||
switch (c)
|
||||
{
|
||||
case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}]
|
||||
#region 大括号
|
||||
if (cs.keyStart <= 0 && cs.valueStart <= 0)
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
if (cs.jsonStart && cs.state == 1)
|
||||
{
|
||||
cs.childrenStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.state = 0;
|
||||
}
|
||||
cs.jsonStart = true;//开始。
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case '}':
|
||||
#region 大括号结束
|
||||
if (cs.keyStart <= 0 && cs.valueStart < 2 && cs.jsonStart)
|
||||
{
|
||||
cs.jsonStart = false;//正常结束。
|
||||
cs.state = 0;
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
cs.setDicValue = true;
|
||||
return true;
|
||||
}
|
||||
// cs.isError = !cs.jsonStart && cs.state == 0;
|
||||
#endregion
|
||||
break;
|
||||
case '[':
|
||||
#region 中括号开始
|
||||
if (!cs.jsonStart)
|
||||
{
|
||||
cs.arrayStart = true;
|
||||
return true;
|
||||
}
|
||||
else if (cs.jsonStart && cs.state == 1)
|
||||
{
|
||||
cs.childrenStart = true;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ']':
|
||||
#region 中括号结束
|
||||
if (cs.arrayStart && !cs.jsonStart && cs.keyStart <= 2 && cs.valueStart <= 0)//[{},333]//这样结束。
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
cs.arrayStart = false;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
#region 引号
|
||||
if (cs.jsonStart || cs.arrayStart)
|
||||
{
|
||||
if (cs.state == 0)//key阶段,有可能是数组["aa",{}]
|
||||
{
|
||||
if (cs.keyStart <= 0)
|
||||
{
|
||||
cs.keyStart = c == '"' ? 3 : 2;
|
||||
return true;
|
||||
}
|
||||
else if (cs.keyStart == 2 && c == '\'' || cs.keyStart == 3 && c == '"')
|
||||
{
|
||||
if (!cs.escapeChar)
|
||||
{
|
||||
cs.keyStart = -1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cs.state == 1 && cs.jsonStart)//值阶段必须是Json开始了。
|
||||
{
|
||||
if (cs.valueStart <= 0)
|
||||
{
|
||||
cs.valueStart = c == '"' ? 3 : 2;
|
||||
return true;
|
||||
}
|
||||
else if (cs.valueStart == 2 && c == '\'' || cs.valueStart == 3 && c == '"')
|
||||
{
|
||||
if (!cs.escapeChar)
|
||||
{
|
||||
cs.valueStart = -1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ':':
|
||||
#region 冒号
|
||||
if (cs.jsonStart && cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 0)
|
||||
{
|
||||
if (cs.keyStart == 1)
|
||||
{
|
||||
cs.keyStart = -1;
|
||||
}
|
||||
cs.state = 1;
|
||||
return true;
|
||||
}
|
||||
// cs.isError = !cs.jsonStart || (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1);
|
||||
#endregion
|
||||
break;
|
||||
case ',':
|
||||
#region 逗号 //["aa",{aa:12,}]
|
||||
|
||||
if (cs.jsonStart)
|
||||
{
|
||||
if (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1)
|
||||
{
|
||||
cs.state = 0;
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
//if (cs.valueStart == 1)
|
||||
//{
|
||||
// cs.valueStart = 0;
|
||||
//}
|
||||
cs.setDicValue = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (cs.arrayStart && cs.keyStart <= 2)
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
//if (cs.keyStart == 1)
|
||||
//{
|
||||
// cs.keyStart = -1;
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ' ':
|
||||
case '\r':
|
||||
case '\n'://[ "a",\r\n{} ]
|
||||
case '\0':
|
||||
case '\t':
|
||||
if (cs.keyStart <= 0 && cs.valueStart <= 0) //cs.jsonStart &&
|
||||
{
|
||||
return true;//跳过空格。
|
||||
}
|
||||
break;
|
||||
default: //值开头。。
|
||||
if (c == '\\') //转义符号
|
||||
{
|
||||
if (cs.escapeChar)
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
if (cs.jsonStart || cs.arrayStart) // Json 或数组开始了。
|
||||
{
|
||||
if (cs.keyStart <= 0 && cs.state == 0)
|
||||
{
|
||||
cs.keyStart = 1;//无引号的
|
||||
}
|
||||
else if (cs.valueStart <= 0 && cs.state == 1 && cs.jsonStart)//只有Json开始才有值。
|
||||
{
|
||||
cs.valueStart = 1;//无引号的
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 字符状态
|
||||
/// </summary>
|
||||
public class CharState
|
||||
{
|
||||
internal bool jsonStart = false;//以 "{"开始了...
|
||||
internal bool setDicValue = false;// 可以设置字典值了。
|
||||
internal bool escapeChar = false;//以"\"转义符号开始了
|
||||
/// <summary>
|
||||
/// 数组开始【仅第一开头才算】,值嵌套的以【childrenStart】来标识。
|
||||
/// </summary>
|
||||
internal bool arrayStart = false;//以"[" 符号开始了
|
||||
internal bool childrenStart = false;//子级嵌套开始了。
|
||||
/// <summary>
|
||||
/// 【0 初始状态,或 遇到“,”逗号】;【1 遇到“:”冒号】
|
||||
/// </summary>
|
||||
internal int state = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
/// </summary>
|
||||
internal int keyStart = 0;
|
||||
/// <summary>
|
||||
/// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
/// </summary>
|
||||
internal int valueStart = 0;
|
||||
internal bool isError = false;//是否语法错误。
|
||||
|
||||
internal void CheckIsError(char c)//只当成一级处理(因为GetLength会递归到每一个子项处理)
|
||||
{
|
||||
if (keyStart > 1 || valueStart > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//示例 ["aa",{"bbbb":123,"fff","Ddd"}]
|
||||
switch (c)
|
||||
{
|
||||
case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}]
|
||||
isError = jsonStart && state == 0;//重复开始错误 同时不是值处理。
|
||||
break;
|
||||
case '}':
|
||||
isError = !jsonStart || keyStart != 0 && state == 0;//重复结束错误 或者 提前结束{"aa"}。正常的有{}
|
||||
break;
|
||||
case '[':
|
||||
isError = arrayStart && state == 0;//重复开始错误
|
||||
break;
|
||||
case ']':
|
||||
isError = !arrayStart || jsonStart;//重复开始错误 或者 Json 未结束
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
isError = !(jsonStart || arrayStart); //json 或数组开始。
|
||||
if (!isError)
|
||||
{
|
||||
//重复开始 [""",{"" "}]
|
||||
isError = state == 0 && keyStart == -1 || state == 1 && valueStart == -1;
|
||||
}
|
||||
if (!isError && arrayStart && !jsonStart && c == '\'')//['aa',{}]
|
||||
{
|
||||
isError = true;
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
isError = !jsonStart || state == 1;//重复出现。
|
||||
break;
|
||||
case ',':
|
||||
isError = !(jsonStart || arrayStart); //json 或数组开始。
|
||||
if (!isError)
|
||||
{
|
||||
if (jsonStart)
|
||||
{
|
||||
isError = state == 0 || state == 1 && valueStart > 1;//重复出现。
|
||||
}
|
||||
else if (arrayStart)//["aa,] [,] [{},{}]
|
||||
{
|
||||
isError = keyStart == 0 && !setDicValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
case '\r':
|
||||
case '\n'://[ "a",\r\n{} ]
|
||||
case '\0':
|
||||
case '\t':
|
||||
break;
|
||||
default: //值开头。。
|
||||
isError = !jsonStart && !arrayStart || state == 0 && keyStart == -1 || valueStart == -1 && state == 1;//
|
||||
break;
|
||||
}
|
||||
//if (isError)
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
132
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/MD5Hepler.cs
Normal file
132
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/MD5Hepler.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class MD5Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成PasswordSalt
|
||||
/// </summary>
|
||||
/// <returns>返回string</returns>
|
||||
public static string GenerateSalt()
|
||||
{
|
||||
byte[] buf = new byte[16];
|
||||
#pragma warning disable SYSLIB0023 // 类型或成员已过时
|
||||
new RNGCryptoServiceProvider().GetBytes(buf);
|
||||
#pragma warning restore SYSLIB0023 // 类型或成员已过时
|
||||
return Convert.ToBase64String(buf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加密密码
|
||||
/// </summary>
|
||||
/// <param name="pass">密码</param>
|
||||
/// <param name="passwordFormat">加密类型</param>
|
||||
/// <param name="salt">PasswordSalt</param>
|
||||
/// <returns>加密后的密码</returns>
|
||||
public static string SHA2Encode(string pass, string salt, int passwordFormat = 1)
|
||||
{
|
||||
if (passwordFormat == 0) // MembershipPasswordFormat.Clear
|
||||
return pass;
|
||||
|
||||
byte[] bIn = Encoding.Unicode.GetBytes(pass);
|
||||
byte[] bSalt = Convert.FromBase64String(salt);
|
||||
byte[] bAll = new byte[bSalt.Length + bIn.Length];
|
||||
byte[]? bRet = null;
|
||||
|
||||
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
|
||||
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
|
||||
|
||||
#pragma warning disable SYSLIB0021 // 类型或成员已过时
|
||||
var s = SHA512.Create();
|
||||
#pragma warning restore SYSLIB0021 // 类型或成员已过时
|
||||
bRet = s.ComputeHash(bAll);
|
||||
|
||||
return ConvertEx.ToUrlBase64String(bRet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 16位MD5加密
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public static string MD5Encrypt16(string password)
|
||||
{
|
||||
var md5 = MD5.Create();
|
||||
string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)), 4, 8);
|
||||
t2 = t2.Replace("-", string.Empty);
|
||||
return t2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 32位MD5加密
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public static string MD5Encrypt32(string password = "")
|
||||
{
|
||||
string pwd = string.Empty;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
MD5 md5 = MD5.Create(); //实例化一个md5对像
|
||||
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择
|
||||
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
|
||||
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
|
||||
foreach (var item in s)
|
||||
{
|
||||
// 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
|
||||
pwd = string.Concat(pwd, item.ToString("X2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new Exception($"错误的 password 字符串:【{password}】");
|
||||
}
|
||||
return pwd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 64位MD5加密
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public static string MD5Encrypt64(string password)
|
||||
{
|
||||
// 实例化一个md5对像
|
||||
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择
|
||||
MD5 md5 = MD5.Create();
|
||||
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
|
||||
return Convert.ToBase64String(s);
|
||||
}
|
||||
}
|
||||
public class ConvertEx
|
||||
{
|
||||
static readonly char[] padding = { '=' };
|
||||
public static string ToUrlBase64String(byte[] inArray)
|
||||
{
|
||||
var str = Convert.ToBase64String(inArray);
|
||||
str = str.TrimEnd(padding).Replace('+', '-').Replace('/', '_');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static byte[] FromUrlBase64String(string s)
|
||||
{
|
||||
string incoming = s.Replace('_', '/').Replace('-', '+');
|
||||
switch (s.Length % 4)
|
||||
{
|
||||
case 2: incoming += "=="; break;
|
||||
case 3: incoming += "="; break;
|
||||
}
|
||||
byte[] bytes = Convert.FromBase64String(incoming);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
260
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/MimeHelper.cs
Normal file
260
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/MimeHelper.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core.Enums;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class MimeHelper
|
||||
{
|
||||
// 通过自己定义一个静态类
|
||||
// 将所有的Content Type都扔进去吧
|
||||
// 调用的时候直接调用静态方法即可。
|
||||
|
||||
public static List<string> ImageType { get; set; } = new List<string>
|
||||
{
|
||||
".jpg",".png",".jpge"
|
||||
};
|
||||
|
||||
private static Hashtable _mimeMappingTable;
|
||||
|
||||
private static void AddMimeMapping(string extension, string MimeType)
|
||||
{
|
||||
_mimeMappingTable.Add(extension, MimeType);
|
||||
}
|
||||
|
||||
public static string GetMimeMapping(string FileName)
|
||||
{
|
||||
string text = null!;
|
||||
int num = FileName.LastIndexOf('.');
|
||||
if (0 < num && num > FileName.LastIndexOf('\\'))
|
||||
{
|
||||
text = (string)_mimeMappingTable[FileName.Substring(num)]!;
|
||||
}
|
||||
if (text == null)
|
||||
{
|
||||
text = (string)_mimeMappingTable[".*"]!;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static FileTypeEnum GetFileType(string fileName)
|
||||
{
|
||||
var extension = Path.GetExtension(fileName);
|
||||
if (ImageType.Contains(extension.ToLower()))
|
||||
return FileTypeEnum.Image;
|
||||
return FileTypeEnum.File;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static MimeHelper()
|
||||
{
|
||||
_mimeMappingTable = new Hashtable(190, StringComparer.CurrentCultureIgnoreCase);
|
||||
AddMimeMapping(".323", "text/h323");
|
||||
AddMimeMapping(".asx", "video/x-ms-asf");
|
||||
AddMimeMapping(".acx", "application/internet-property-stream");
|
||||
AddMimeMapping(".ai", "application/postscript");
|
||||
AddMimeMapping(".aif", "audio/x-aiff");
|
||||
AddMimeMapping(".aiff", "audio/aiff");
|
||||
AddMimeMapping(".axs", "application/olescript");
|
||||
AddMimeMapping(".aifc", "audio/aiff");
|
||||
AddMimeMapping(".asr", "video/x-ms-asf");
|
||||
AddMimeMapping(".avi", "video/x-msvideo");
|
||||
AddMimeMapping(".asf", "video/x-ms-asf");
|
||||
AddMimeMapping(".au", "audio/basic");
|
||||
AddMimeMapping(".application", "application/x-ms-application");
|
||||
AddMimeMapping(".bin", "application/octet-stream");
|
||||
AddMimeMapping(".bas", "text/plain");
|
||||
AddMimeMapping(".bcpio", "application/x-bcpio");
|
||||
AddMimeMapping(".bmp", "image/bmp");
|
||||
AddMimeMapping(".cdf", "application/x-cdf");
|
||||
AddMimeMapping(".cat", "application/vndms-pkiseccat");
|
||||
AddMimeMapping(".crt", "application/x-x509-ca-cert");
|
||||
AddMimeMapping(".c", "text/plain");
|
||||
AddMimeMapping(".css", "text/css");
|
||||
AddMimeMapping(".cer", "application/x-x509-ca-cert");
|
||||
AddMimeMapping(".crl", "application/pkix-crl");
|
||||
AddMimeMapping(".cmx", "image/x-cmx");
|
||||
AddMimeMapping(".csh", "application/x-csh");
|
||||
AddMimeMapping(".cod", "image/cis-cod");
|
||||
AddMimeMapping(".cpio", "application/x-cpio");
|
||||
AddMimeMapping(".clp", "application/x-msclip");
|
||||
AddMimeMapping(".crd", "application/x-mscardfile");
|
||||
AddMimeMapping(".deploy", "application/octet-stream");
|
||||
AddMimeMapping(".dll", "application/x-msdownload");
|
||||
AddMimeMapping(".dot", "application/msword");
|
||||
AddMimeMapping(".doc", "application/msword");
|
||||
AddMimeMapping(".dvi", "application/x-dvi");
|
||||
AddMimeMapping(".dir", "application/x-director");
|
||||
AddMimeMapping(".dxr", "application/x-director");
|
||||
AddMimeMapping(".der", "application/x-x509-ca-cert");
|
||||
AddMimeMapping(".dib", "image/bmp");
|
||||
AddMimeMapping(".dcr", "application/x-director");
|
||||
AddMimeMapping(".disco", "text/xml");
|
||||
AddMimeMapping(".exe", "application/octet-stream");
|
||||
AddMimeMapping(".etx", "text/x-setext");
|
||||
AddMimeMapping(".evy", "application/envoy");
|
||||
AddMimeMapping(".eml", "message/rfc822");
|
||||
AddMimeMapping(".eps", "application/postscript");
|
||||
AddMimeMapping(".flr", "x-world/x-vrml");
|
||||
AddMimeMapping(".fif", "application/fractals");
|
||||
AddMimeMapping(".gtar", "application/x-gtar");
|
||||
AddMimeMapping(".gif", "image/gif");
|
||||
AddMimeMapping(".gz", "application/x-gzip");
|
||||
AddMimeMapping(".hta", "application/hta");
|
||||
AddMimeMapping(".htc", "text/x-component");
|
||||
AddMimeMapping(".htt", "text/webviewhtml");
|
||||
AddMimeMapping(".h", "text/plain");
|
||||
AddMimeMapping(".hdf", "application/x-hdf");
|
||||
AddMimeMapping(".hlp", "application/winhlp");
|
||||
AddMimeMapping(".html", "text/html");
|
||||
AddMimeMapping(".htm", "text/html");
|
||||
AddMimeMapping(".hqx", "application/mac-binhex40");
|
||||
AddMimeMapping(".isp", "application/x-internet-signup");
|
||||
AddMimeMapping(".iii", "application/x-iphone");
|
||||
AddMimeMapping(".ief", "image/ief");
|
||||
AddMimeMapping(".ivf", "video/x-ivf");
|
||||
AddMimeMapping(".ins", "application/x-internet-signup");
|
||||
AddMimeMapping(".ico", "image/x-icon");
|
||||
AddMimeMapping(".jpg", "image/jpeg");
|
||||
AddMimeMapping(".jfif", "image/pjpeg");
|
||||
AddMimeMapping(".jpe", "image/jpeg");
|
||||
AddMimeMapping(".jpeg", "image/jpeg");
|
||||
AddMimeMapping(".js", "application/x-javascript");
|
||||
AddMimeMapping(".lsx", "video/x-la-asf");
|
||||
AddMimeMapping(".latex", "application/x-latex");
|
||||
AddMimeMapping(".lsf", "video/x-la-asf");
|
||||
AddMimeMapping(".manifest", "application/x-ms-manifest");
|
||||
AddMimeMapping(".mhtml", "message/rfc822");
|
||||
AddMimeMapping(".mny", "application/x-msmoney");
|
||||
AddMimeMapping(".mht", "message/rfc822");
|
||||
AddMimeMapping(".mid", "audio/mid");
|
||||
AddMimeMapping(".mpv2", "video/mpeg");
|
||||
AddMimeMapping(".man", "application/x-troff-man");
|
||||
AddMimeMapping(".mvb", "application/x-msmediaview");
|
||||
AddMimeMapping(".mpeg", "video/mpeg");
|
||||
AddMimeMapping(".m3u", "audio/x-mpegurl");
|
||||
AddMimeMapping(".mdb", "application/x-msaccess");
|
||||
AddMimeMapping(".mpp", "application/vnd.ms-project");
|
||||
AddMimeMapping(".m1v", "video/mpeg");
|
||||
AddMimeMapping(".mpa", "video/mpeg");
|
||||
AddMimeMapping(".me", "application/x-troff-me");
|
||||
AddMimeMapping(".m13", "application/x-msmediaview");
|
||||
AddMimeMapping(".movie", "video/x-sgi-movie");
|
||||
AddMimeMapping(".m14", "application/x-msmediaview");
|
||||
AddMimeMapping(".mpe", "video/mpeg");
|
||||
AddMimeMapping(".mp2", "video/mpeg");
|
||||
AddMimeMapping(".mov", "video/quicktime");
|
||||
AddMimeMapping(".mp3", "audio/mpeg");
|
||||
AddMimeMapping(".mpg", "video/mpeg");
|
||||
AddMimeMapping(".ms", "application/x-troff-ms");
|
||||
AddMimeMapping(".nc", "application/x-netcdf");
|
||||
AddMimeMapping(".nws", "message/rfc822");
|
||||
AddMimeMapping(".oda", "application/oda");
|
||||
AddMimeMapping(".ods", "application/oleobject");
|
||||
AddMimeMapping(".pmc", "application/x-perfmon");
|
||||
AddMimeMapping(".p7r", "application/x-pkcs7-certreqresp");
|
||||
AddMimeMapping(".p7b", "application/x-pkcs7-certificates");
|
||||
AddMimeMapping(".p7s", "application/pkcs7-signature");
|
||||
AddMimeMapping(".pmw", "application/x-perfmon");
|
||||
AddMimeMapping(".ps", "application/postscript");
|
||||
AddMimeMapping(".p7c", "application/pkcs7-mime");
|
||||
AddMimeMapping(".pbm", "image/x-portable-bitmap");
|
||||
AddMimeMapping(".ppm", "image/x-portable-pixmap");
|
||||
AddMimeMapping(".pub", "application/x-mspublisher");
|
||||
AddMimeMapping(".pnm", "image/x-portable-anymap");
|
||||
AddMimeMapping(".png", "image/png");
|
||||
AddMimeMapping(".pml", "application/x-perfmon");
|
||||
AddMimeMapping(".p10", "application/pkcs10");
|
||||
AddMimeMapping(".pfx", "application/x-pkcs12");
|
||||
AddMimeMapping(".p12", "application/x-pkcs12");
|
||||
AddMimeMapping(".pdf", "application/pdf");
|
||||
AddMimeMapping(".pps", "application/vnd.ms-powerpoint");
|
||||
AddMimeMapping(".p7m", "application/pkcs7-mime");
|
||||
AddMimeMapping(".pko", "application/vndms-pkipko");
|
||||
AddMimeMapping(".ppt", "application/vnd.ms-powerpoint");
|
||||
AddMimeMapping(".pmr", "application/x-perfmon");
|
||||
AddMimeMapping(".pma", "application/x-perfmon");
|
||||
AddMimeMapping(".pot", "application/vnd.ms-powerpoint");
|
||||
AddMimeMapping(".prf", "application/pics-rules");
|
||||
AddMimeMapping(".pgm", "image/x-portable-graymap");
|
||||
AddMimeMapping(".qt", "video/quicktime");
|
||||
AddMimeMapping(".ra", "audio/x-pn-realaudio");
|
||||
AddMimeMapping(".rgb", "image/x-rgb");
|
||||
AddMimeMapping(".ram", "audio/x-pn-realaudio");
|
||||
AddMimeMapping(".rmi", "audio/mid");
|
||||
AddMimeMapping(".ras", "image/x-cmu-raster");
|
||||
AddMimeMapping(".roff", "application/x-troff");
|
||||
AddMimeMapping(".rtf", "application/rtf");
|
||||
AddMimeMapping(".rtx", "text/richtext");
|
||||
AddMimeMapping(".sv4crc", "application/x-sv4crc");
|
||||
AddMimeMapping(".spc", "application/x-pkcs7-certificates");
|
||||
AddMimeMapping(".setreg", "application/set-registration-initiation");
|
||||
AddMimeMapping(".snd", "audio/basic");
|
||||
AddMimeMapping(".stl", "application/vndms-pkistl");
|
||||
AddMimeMapping(".setpay", "application/set-payment-initiation");
|
||||
AddMimeMapping(".stm", "text/html");
|
||||
AddMimeMapping(".shar", "application/x-shar");
|
||||
AddMimeMapping(".sh", "application/x-sh");
|
||||
AddMimeMapping(".sit", "application/x-stuffit");
|
||||
AddMimeMapping(".spl", "application/futuresplash");
|
||||
AddMimeMapping(".sct", "text/scriptlet");
|
||||
AddMimeMapping(".scd", "application/x-msschedule");
|
||||
AddMimeMapping(".sst", "application/vndms-pkicertstore");
|
||||
AddMimeMapping(".src", "application/x-wais-source");
|
||||
AddMimeMapping(".sv4cpio", "application/x-sv4cpio");
|
||||
AddMimeMapping(".tex", "application/x-tex");
|
||||
AddMimeMapping(".tgz", "application/x-compressed");
|
||||
AddMimeMapping(".t", "application/x-troff");
|
||||
AddMimeMapping(".tar", "application/x-tar");
|
||||
AddMimeMapping(".tr", "application/x-troff");
|
||||
AddMimeMapping(".tif", "image/tiff");
|
||||
AddMimeMapping(".txt", "text/plain");
|
||||
AddMimeMapping(".texinfo", "application/x-texinfo");
|
||||
AddMimeMapping(".trm", "application/x-msterminal");
|
||||
AddMimeMapping(".tiff", "image/tiff");
|
||||
AddMimeMapping(".tcl", "application/x-tcl");
|
||||
AddMimeMapping(".texi", "application/x-texinfo");
|
||||
AddMimeMapping(".tsv", "text/tab-separated-values");
|
||||
AddMimeMapping(".ustar", "application/x-ustar");
|
||||
AddMimeMapping(".uls", "text/iuls");
|
||||
AddMimeMapping(".vcf", "text/x-vcard");
|
||||
AddMimeMapping(".wps", "application/vnd.ms-works");
|
||||
AddMimeMapping(".wav", "audio/wav");
|
||||
AddMimeMapping(".wrz", "x-world/x-vrml");
|
||||
AddMimeMapping(".wri", "application/x-mswrite");
|
||||
AddMimeMapping(".wks", "application/vnd.ms-works");
|
||||
AddMimeMapping(".wmf", "application/x-msmetafile");
|
||||
AddMimeMapping(".wcm", "application/vnd.ms-works");
|
||||
AddMimeMapping(".wrl", "x-world/x-vrml");
|
||||
AddMimeMapping(".wdb", "application/vnd.ms-works");
|
||||
AddMimeMapping(".wsdl", "text/xml");
|
||||
AddMimeMapping(".xap", "application/x-silverlight-app");
|
||||
AddMimeMapping(".xml", "text/xml");
|
||||
AddMimeMapping(".xlm", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xaf", "x-world/x-vrml");
|
||||
AddMimeMapping(".xla", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xls", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xlsx", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xof", "x-world/x-vrml");
|
||||
AddMimeMapping(".xlt", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xlc", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xsl", "text/xml");
|
||||
AddMimeMapping(".xbm", "image/x-xbitmap");
|
||||
AddMimeMapping(".xlw", "application/vnd.ms-excel");
|
||||
AddMimeMapping(".xpm", "image/x-xpixmap");
|
||||
AddMimeMapping(".xwd", "image/x-xwindowdump");
|
||||
AddMimeMapping(".xsd", "text/xml");
|
||||
AddMimeMapping(".z", "application/x-compress");
|
||||
AddMimeMapping(".zip", "application/x-zip-compressed");
|
||||
AddMimeMapping(".*", "application/octet-stream");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class RSAFileHelper
|
||||
{
|
||||
public static RSA GetKey()
|
||||
{
|
||||
return GetRSA("key.pem");
|
||||
}
|
||||
public static RSA GetPublicKey()
|
||||
{
|
||||
return GetRSA("public.pem");
|
||||
}
|
||||
|
||||
private static RSA GetRSA(string fileName)
|
||||
{
|
||||
string rootPath = Directory.GetCurrentDirectory();
|
||||
string filePath = Path.Combine(rootPath, fileName);
|
||||
if (!File.Exists(filePath))
|
||||
throw new Exception("文件不存在");
|
||||
string key = File.ReadAllText(filePath);
|
||||
var rsa = RSA.Create();
|
||||
rsa.ImportFromPem(key.AsSpan());
|
||||
return rsa;
|
||||
}
|
||||
}
|
||||
}
|
||||
390
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/RSAHelper.cs
Normal file
390
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/RSAHelper.cs
Normal file
@@ -0,0 +1,390 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// RSA加解密 使用OpenSSL的公钥加密/私钥解密
|
||||
/// 公私钥请使用openssl生成
|
||||
/// </summary>
|
||||
public class RSAHelper
|
||||
{
|
||||
public readonly RSA? _privateKeyRsaProvider;
|
||||
public readonly RSA? _publicKeyRsaProvider;
|
||||
private readonly HashAlgorithmName _hashAlgorithmName;
|
||||
private readonly Encoding _encoding;
|
||||
|
||||
/// <summary>
|
||||
/// 实例化RSAHelper
|
||||
/// </summary>
|
||||
/// <param name="rsaType">加密算法类型 RSA SHA1;RSA2 SHA256 密钥长度至少为2048</param>
|
||||
/// <param name="encoding">编码类型</param>
|
||||
/// <param name="privateKey">私钥</param>
|
||||
/// <param name="publicKey">公钥</param>
|
||||
public RSAHelper(RSAType rsaType, Encoding encoding, string privateKey, string? publicKey = null)
|
||||
{
|
||||
_encoding = encoding;
|
||||
if (!string.IsNullOrEmpty(privateKey))
|
||||
{
|
||||
_privateKeyRsaProvider = CreateRsaProviderFromPrivateKey(privateKey);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(publicKey))
|
||||
{
|
||||
_publicKeyRsaProvider = CreateRsaProviderFromPublicKey(publicKey);
|
||||
}
|
||||
|
||||
_hashAlgorithmName = rsaType == RSAType.RSA ? HashAlgorithmName.SHA1 : HashAlgorithmName.SHA256;
|
||||
}
|
||||
|
||||
#region 使用私钥签名
|
||||
|
||||
/// <summary>
|
||||
/// 使用私钥签名
|
||||
/// </summary>
|
||||
/// <param name="data">原始数据</param>
|
||||
/// <returns></returns>
|
||||
public string Sign(string data)
|
||||
{
|
||||
byte[] dataBytes = _encoding.GetBytes(data);
|
||||
|
||||
var signatureBytes = _privateKeyRsaProvider!.SignData(dataBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1);
|
||||
|
||||
return Convert.ToBase64String(signatureBytes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 使用公钥验签
|
||||
|
||||
/// <summary>
|
||||
/// 使用公钥验签
|
||||
/// </summary>
|
||||
/// <param name="data">原始数据</param>
|
||||
/// <param name="sign">签名</param>
|
||||
/// <returns></returns>
|
||||
public bool Verify(string data, string sign)
|
||||
{
|
||||
byte[] dataBytes = _encoding.GetBytes(data);
|
||||
byte[] signBytes = Convert.FromBase64String(sign);
|
||||
|
||||
var verify = _publicKeyRsaProvider!.VerifyData(dataBytes, signBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1);
|
||||
|
||||
return verify;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 解密
|
||||
/// <summary>
|
||||
/// 私钥解密(原)
|
||||
/// </summary>
|
||||
/// <param name="cipherText">解密字符串(base64)</param>
|
||||
/// <returns></returns>
|
||||
|
||||
//public string Decrypt(string cipherText)
|
||||
//{
|
||||
// if (_privateKeyRsaProvider == null)
|
||||
// {
|
||||
// throw new Exception("_privateKeyRsaProvider is null");
|
||||
// }
|
||||
// return _encoding.GetString(_privateKeyRsaProvider.Decrypt(Convert.FromBase64String(cipherText), RSAEncryptionPadding.Pkcs1));
|
||||
//}
|
||||
/// <summary>
|
||||
/// 私钥解密(支持大量数据)
|
||||
/// </summary>
|
||||
/// <param name="cipherText"></param>
|
||||
/// <returns></returns>
|
||||
public string Decrypt(string cipherText)
|
||||
{
|
||||
if (_privateKeyRsaProvider == null)
|
||||
{
|
||||
throw new Exception("_privateKeyRsaProvider is null");
|
||||
}
|
||||
var bufferSize = _privateKeyRsaProvider.KeySize / 8;
|
||||
byte[] buffer = new byte[bufferSize];//待解密块
|
||||
using (MemoryStream msInput = new MemoryStream(Convert.FromBase64String(cipherText)))
|
||||
{
|
||||
using (MemoryStream msOutput = new MemoryStream())
|
||||
{
|
||||
int readLen; while ((readLen = msInput.Read(buffer, 0, bufferSize)) > 0)
|
||||
{
|
||||
byte[] dataToEnc = new byte[readLen];
|
||||
Array.Copy(buffer, 0, dataToEnc, 0, readLen); byte[] encData = _privateKeyRsaProvider.Decrypt(dataToEnc, RSAEncryptionPadding.Pkcs1);
|
||||
msOutput.Write(encData, 0, encData.Length);
|
||||
}
|
||||
byte[] result = msOutput.ToArray();
|
||||
return _encoding.GetString(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加密
|
||||
|
||||
/// <summary>
|
||||
/// 公钥加密(原)
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
//public string Encrypt(string text)
|
||||
//{
|
||||
// if (_publicKeyRsaProvider == null)
|
||||
// {
|
||||
// throw new Exception("_publicKeyRsaProvider is null");
|
||||
// }
|
||||
// return Convert.ToBase64String(_publicKeyRsaProvider.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.Pkcs1));
|
||||
//}
|
||||
/// <summary>
|
||||
/// 公钥加密(支持大量数据)
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public string Encrypt(string text)
|
||||
{
|
||||
if (_publicKeyRsaProvider == null)
|
||||
{
|
||||
throw new Exception("_publicKeyRsaProvider is null");
|
||||
}
|
||||
var bufferSize = _publicKeyRsaProvider.KeySize / 8 - 11;
|
||||
byte[] buffer = new byte[bufferSize];//待加密块
|
||||
|
||||
using (MemoryStream msInput = new MemoryStream(_encoding.GetBytes(text)))
|
||||
{
|
||||
using (MemoryStream msOutput = new MemoryStream())
|
||||
{
|
||||
int readLen; while ((readLen = msInput.Read(buffer, 0, bufferSize)) > 0)
|
||||
{
|
||||
byte[] dataToEnc = new byte[readLen];
|
||||
Array.Copy(buffer, 0, dataToEnc, 0, readLen); byte[] encData = _publicKeyRsaProvider.Encrypt(dataToEnc, RSAEncryptionPadding.Pkcs1);
|
||||
msOutput.Write(encData, 0, encData.Length);
|
||||
}
|
||||
byte[] result = msOutput.ToArray();
|
||||
return Convert.ToBase64String(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 使用私钥创建RSA实例
|
||||
/// <summary>
|
||||
/// 使用私钥创建RSA实例
|
||||
/// </summary>
|
||||
/// <param name="privateKey"></param>
|
||||
/// <returns></returns>
|
||||
private RSA CreateRsaProviderFromPrivateKey(string privateKey)
|
||||
{
|
||||
var privateKeyBits = Convert.FromBase64String(privateKey);
|
||||
|
||||
var rsa = RSA.Create();
|
||||
var rsaParameters = new RSAParameters();
|
||||
|
||||
using (BinaryReader binr = new BinaryReader(new MemoryStream(privateKeyBits)))
|
||||
{
|
||||
byte bt = 0;
|
||||
ushort twobytes = 0;
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes == 0x8130)
|
||||
binr.ReadByte();
|
||||
else if (twobytes == 0x8230)
|
||||
binr.ReadInt16();
|
||||
else
|
||||
throw new Exception("Unexpected value read binr.ReadUInt16()");
|
||||
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes != 0x0102)
|
||||
throw new Exception("Unexpected version");
|
||||
|
||||
bt = binr.ReadByte();
|
||||
if (bt != 0x00)
|
||||
throw new Exception("Unexpected value read binr.ReadByte()");
|
||||
|
||||
rsaParameters.Modulus = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.Exponent = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.D = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.P = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.Q = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.DP = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.DQ = binr.ReadBytes(GetIntegerSize(binr));
|
||||
rsaParameters.InverseQ = binr.ReadBytes(GetIntegerSize(binr));
|
||||
}
|
||||
|
||||
rsa.ImportParameters(rsaParameters);
|
||||
return rsa;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 使用公钥创建RSA实例
|
||||
/// <summary>
|
||||
/// 使用公钥创建RSA实例
|
||||
/// </summary>
|
||||
/// <param name="publicKeyString"></param>
|
||||
/// <returns></returns>
|
||||
public RSA? CreateRsaProviderFromPublicKey(string publicKeyString)
|
||||
{
|
||||
// encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1"
|
||||
byte[] seqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };
|
||||
byte[] seq = new byte[15];
|
||||
|
||||
var x509Key = Convert.FromBase64String(publicKeyString);
|
||||
|
||||
// --------- Set up stream to read the asn.1 encoded SubjectPublicKeyInfo blob ------
|
||||
using (MemoryStream mem = new MemoryStream(x509Key))
|
||||
{
|
||||
using (BinaryReader binr = new BinaryReader(mem)) //wrap Memory Stream with BinaryReader for easy reading
|
||||
{
|
||||
byte bt = 0;
|
||||
ushort twobytes = 0;
|
||||
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)
|
||||
binr.ReadByte(); //advance 1 byte
|
||||
else if (twobytes == 0x8230)
|
||||
binr.ReadInt16(); //advance 2 bytes
|
||||
else
|
||||
return null;
|
||||
|
||||
seq = binr.ReadBytes(15); //read the Sequence OID
|
||||
if (!CompareBytearrays(seq, seqOid)) //make sure Sequence for OID is correct
|
||||
return null;
|
||||
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes == 0x8103) //data read as little endian order (actual data order for Bit String is 03 81)
|
||||
binr.ReadByte(); //advance 1 byte
|
||||
else if (twobytes == 0x8203)
|
||||
binr.ReadInt16(); //advance 2 bytes
|
||||
else
|
||||
return null;
|
||||
|
||||
bt = binr.ReadByte();
|
||||
if (bt != 0x00) //expect null byte next
|
||||
return null;
|
||||
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)
|
||||
binr.ReadByte(); //advance 1 byte
|
||||
else if (twobytes == 0x8230)
|
||||
binr.ReadInt16(); //advance 2 bytes
|
||||
else
|
||||
return null;
|
||||
|
||||
twobytes = binr.ReadUInt16();
|
||||
byte lowbyte = 0x00;
|
||||
byte highbyte = 0x00;
|
||||
|
||||
if (twobytes == 0x8102) //data read as little endian order (actual data order for Integer is 02 81)
|
||||
lowbyte = binr.ReadByte(); // read next bytes which is bytes in modulus
|
||||
else if (twobytes == 0x8202)
|
||||
{
|
||||
highbyte = binr.ReadByte(); //advance 2 bytes
|
||||
lowbyte = binr.ReadByte();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; //reverse byte order since asn.1 key uses big endian order
|
||||
int modsize = BitConverter.ToInt32(modint, 0);
|
||||
|
||||
int firstbyte = binr.PeekChar();
|
||||
if (firstbyte == 0x00)
|
||||
{ //if first byte (highest order) of modulus is zero, don't include it
|
||||
binr.ReadByte(); //skip this null byte
|
||||
modsize -= 1; //reduce modulus buffer size by 1
|
||||
}
|
||||
|
||||
byte[] modulus = binr.ReadBytes(modsize); //read the modulus bytes
|
||||
|
||||
if (binr.ReadByte() != 0x02) //expect an Integer for the exponent data
|
||||
return null;
|
||||
int expbytes = binr.ReadByte(); // should only need one byte for actual exponent data (for all useful values)
|
||||
byte[] exponent = binr.ReadBytes(expbytes);
|
||||
|
||||
// ------- create RSACryptoServiceProvider instance and initialize with public key -----
|
||||
var rsa = RSA.Create();
|
||||
RSAParameters rsaKeyInfo = new RSAParameters
|
||||
{
|
||||
Modulus = modulus,
|
||||
Exponent = exponent
|
||||
};
|
||||
rsa.ImportParameters(rsaKeyInfo);
|
||||
|
||||
return rsa;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 导入密钥算法
|
||||
|
||||
private int GetIntegerSize(BinaryReader binr)
|
||||
{
|
||||
byte bt = 0;
|
||||
int count = 0;
|
||||
bt = binr.ReadByte();
|
||||
if (bt != 0x02)
|
||||
return 0;
|
||||
bt = binr.ReadByte();
|
||||
|
||||
if (bt == 0x81)
|
||||
count = binr.ReadByte();
|
||||
else
|
||||
if (bt == 0x82)
|
||||
{
|
||||
var highbyte = binr.ReadByte();
|
||||
var lowbyte = binr.ReadByte();
|
||||
byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };
|
||||
count = BitConverter.ToInt32(modint, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = bt;
|
||||
}
|
||||
|
||||
while (binr.ReadByte() == 0x00)
|
||||
{
|
||||
count -= 1;
|
||||
}
|
||||
binr.BaseStream.Seek(-1, SeekOrigin.Current);
|
||||
return count;
|
||||
}
|
||||
|
||||
private bool CompareBytearrays(byte[] a, byte[] b)
|
||||
{
|
||||
if (a.Length != b.Length)
|
||||
return false;
|
||||
int i = 0;
|
||||
foreach (byte c in a)
|
||||
{
|
||||
if (c != b[i])
|
||||
return false;
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RSA算法类型
|
||||
/// </summary>
|
||||
public enum RSAType
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA1
|
||||
/// </summary>
|
||||
RSA = 0,
|
||||
/// <summary>
|
||||
/// RSA2 密钥长度至少为2048
|
||||
/// SHA256
|
||||
/// </summary>
|
||||
RSA2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class RandomHelper
|
||||
{
|
||||
public static string replaceBianLiang(string content)
|
||||
{
|
||||
content = content.Replace("{当前时间}", DateTime.Now.TimeOfDay.ToString());
|
||||
string[] bianliang = new string[] { "{随机字母}", "{随机数字}", "{随机汉字}" };
|
||||
Regex r;
|
||||
int count;
|
||||
string readstr = "";
|
||||
foreach (string str in bianliang)
|
||||
{
|
||||
count = (content.Length - content.Replace(str, "").Length) / str.Length;
|
||||
if (str == "{随机汉字}") readstr = RandChina(count);
|
||||
if (str == "{随机数字}") readstr = GenerateCheckCodeNum(count);
|
||||
if (str == "{随机字母}") readstr = GenerateRandomLetter(count);
|
||||
if (count > readstr.Length) count = readstr.Length;
|
||||
r = new Regex(str.Replace("{", "\\{").Replace("}", "\\}"));
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
content = r.Replace(content, readstr.Substring(i, 1), 1);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 随机生成字母
|
||||
/// </summary>
|
||||
/// <param name="Length"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateRandomLetter(int Length)
|
||||
{
|
||||
char[] Pattern = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||
string result = "";
|
||||
int n = Pattern.Length;
|
||||
Random random = new Random(~unchecked((int)DateTime.Now.Ticks));
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
int rnd = random.Next(0, n);
|
||||
result += Pattern[rnd];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机生成数字
|
||||
/// </summary>
|
||||
/// <param name="codeCount"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateCheckCodeNum(int codeCount)
|
||||
{
|
||||
int rep = 0;
|
||||
string str = string.Empty;
|
||||
long num2 = DateTime.Now.Ticks + rep;
|
||||
rep++;
|
||||
Random random = new Random((int)((ulong)num2 & 0xffffffffL) | (int)(num2 >> rep));
|
||||
for (int i = 0; i < codeCount; i++)
|
||||
{
|
||||
int num = random.Next();
|
||||
str = str + ((char)(0x30 + (ushort)(num % 10))).ToString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 此函数为生成指定数目的汉字
|
||||
/// </summary>
|
||||
/// <param name="charLen">汉字数目</param>
|
||||
/// <returns>所有汉字</returns>
|
||||
public static string RandChina(int charLen)
|
||||
{
|
||||
int area, code;//汉字由区位和码位组成(都为0-94,其中区位16-55为一级汉字区,56-87为二级汉字区,1-9为特殊字符区)
|
||||
StringBuilder strtem = new StringBuilder();
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < charLen; i++)
|
||||
{
|
||||
area = rand.Next(16, 88);
|
||||
if (area == 55)//第55区只有89个字符
|
||||
{
|
||||
code = rand.Next(1, 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = rand.Next(1, 94);
|
||||
}
|
||||
strtem.Append(Encoding.GetEncoding("GB2312").GetString(new byte[] { Convert.ToByte(area + 160), Convert.ToByte(code + 160) }));
|
||||
}
|
||||
return strtem.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class ReflexHelper
|
||||
{
|
||||
|
||||
#region 对象相关
|
||||
/// <summary>
|
||||
/// 取对象属性值
|
||||
/// </summary>
|
||||
/// <param name="FieldName"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetModelValue(string FieldName, object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Type Ts = obj.GetType();
|
||||
object o = Ts.GetProperty(FieldName).GetValue(obj, null);
|
||||
if (null == o)
|
||||
return null;
|
||||
string Value = Convert.ToString(o);
|
||||
if (string.IsNullOrEmpty(Value))
|
||||
return null;
|
||||
return Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置对象属性值
|
||||
/// </summary>
|
||||
/// <param name="FieldName"></param>
|
||||
/// <param name="Value"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetModelValue(string FieldName, object Value, object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Type Ts = obj.GetType();
|
||||
Ts.GetProperty(FieldName).SetValue(obj, Value, null);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class ShellHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// linux 系统命令
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public static string Bash(string command)
|
||||
{
|
||||
var escapedArgs = command.Replace("\"", "\\\"");
|
||||
var process = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "/bin/bash",
|
||||
Arguments = $"-c \"{escapedArgs}\"",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
string result = process.StandardOutput.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
process.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// windows系统命令
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static string Cmd(string fileName, string args)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
var info = new ProcessStartInfo();
|
||||
info.FileName = fileName;
|
||||
info.Arguments = args;
|
||||
info.RedirectStandardOutput = true;
|
||||
|
||||
using (var process = Process.Start(info))
|
||||
{
|
||||
output = process.StandardOutput.ReadToEnd();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/StringHelper.cs
Normal file
113
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/StringHelper.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class StringHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据分隔符返回前n条数据
|
||||
/// </summary>
|
||||
/// <param name="content">数据内容</param>
|
||||
/// <param name="separator">分隔符</param>
|
||||
/// <param name="top">前n条</param>
|
||||
/// <param name="isDesc">是否倒序(默认false)</param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetTopDataBySeparator(string content, string separator, int top, bool isDesc = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
return new List<string>() { };
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(separator))
|
||||
{
|
||||
throw new ArgumentException("message", nameof(separator));
|
||||
}
|
||||
|
||||
var dataArray = content.Split(separator).Where(d => !string.IsNullOrEmpty(d)).ToArray();
|
||||
if (isDesc)
|
||||
{
|
||||
Array.Reverse(dataArray);
|
||||
}
|
||||
|
||||
if (top > 0)
|
||||
{
|
||||
dataArray = dataArray.Take(top).ToArray();
|
||||
}
|
||||
|
||||
return dataArray.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据字段拼接get参数
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetPars(Dictionary<string, object> dic)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string? urlPars = null;
|
||||
bool isEnter = false;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
sb.Append($"{(isEnter ? "&" : "")}{item.Key}={item.Value}");
|
||||
isEnter = true;
|
||||
}
|
||||
urlPars = sb.ToString();
|
||||
return urlPars;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据字段拼接get参数
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetPars(Dictionary<string, string> dic)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string? urlPars = null;
|
||||
bool isEnter = false;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
sb.Append($"{(isEnter ? "&" : "")}{item.Key}={item.Value}");
|
||||
isEnter = true;
|
||||
}
|
||||
urlPars = sb.ToString();
|
||||
return urlPars;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取一个GUID
|
||||
/// </summary>
|
||||
/// <param name="format">格式-默认为N</param>
|
||||
/// <returns></returns>
|
||||
public static string GetGUID(string format = "N")
|
||||
{
|
||||
return Guid.NewGuid().ToString(format);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据GUID获取19位的唯一数字序列
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static long GetGuidToLongID()
|
||||
{
|
||||
byte[] buffer = Guid.NewGuid().ToByteArray();
|
||||
return BitConverter.ToInt64(buffer, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取字符串最后X行
|
||||
/// </summary>
|
||||
/// <param name="resourceStr"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCusLine(string resourceStr, int length)
|
||||
{
|
||||
string[] arrStr = resourceStr.Split("\r\n");
|
||||
return string.Join("", (from q in arrStr select q).Skip(arrStr.Length - length + 1).Take(length).ToArray());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
68
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/TreeHelper.cs
Normal file
68
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/TreeHelper.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class TreeHelper
|
||||
{
|
||||
public static List<T> SetTree<T>(List<T> list, Action<T> action = null!)
|
||||
{
|
||||
if (list is not null && list.Count > 0)
|
||||
{
|
||||
IList<T> result = new List<T>();
|
||||
Guid pid = list.Min(m => (m as ITreeModel<T>)!.ParentId);
|
||||
IList<T> t = list.Where(m => (m as ITreeModel<T>)!.ParentId == pid).ToList();
|
||||
foreach (T model in t)
|
||||
{
|
||||
if (action is not null)
|
||||
{
|
||||
action(model);
|
||||
}
|
||||
result.Add(model);
|
||||
var item = model as ITreeModel<T>;
|
||||
IList<T> children = list.Where(m => (m as ITreeModel<T>)!.ParentId == item!.Id).ToList();
|
||||
if (children.Count > 0)
|
||||
{
|
||||
SetTreeChildren(list, children, model, action!);
|
||||
}
|
||||
}
|
||||
return result.OrderByDescending(m => (m as ITreeModel<T>)!.OrderNum).ToList();
|
||||
}
|
||||
return null!;
|
||||
}
|
||||
private static void SetTreeChildren<T>(IList<T> list, IList<T> children, T model, Action<T> action = null!)
|
||||
{
|
||||
var mm = model as ITreeModel<T>;
|
||||
mm!.Children = new List<T>();
|
||||
foreach (T item in children)
|
||||
{
|
||||
if (action is not null)
|
||||
{
|
||||
action(item);
|
||||
}
|
||||
mm.Children.Add(item);
|
||||
var _item = item as ITreeModel<T>;
|
||||
IList<T> _children = list.Where(m => (m as ITreeModel<T>)!.ParentId == _item!.Id).ToList();
|
||||
if (_children.Count > 0)
|
||||
{
|
||||
SetTreeChildren(list, _children, item, action!);
|
||||
}
|
||||
}
|
||||
mm.Children = mm.Children.OrderByDescending(m => (m as ITreeModel<T>)!.OrderNum).ToList();
|
||||
}
|
||||
|
||||
|
||||
public interface ITreeModel<T>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public List<T>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public static class UnicodeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 字符串转Unicode码
|
||||
/// </summary>
|
||||
/// <returns>The to unicode.</returns>
|
||||
/// <param name="value">Value.</param>
|
||||
public static string StringToUnicode(string value)
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(value);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < bytes.Length; i += 2)
|
||||
{
|
||||
// 取两个字符,每个字符都是右对齐。
|
||||
stringBuilder.AppendFormat("u{0}{1}", bytes[i + 1].ToString("x").PadLeft(2, '0'), bytes[i].ToString("x").PadLeft(2, '0'));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unicode转字符串
|
||||
/// </summary>
|
||||
/// <returns>The to string.</returns>
|
||||
/// <param name="unicode">Unicode.</param>
|
||||
public static string UnicodeToString(string unicode)
|
||||
{
|
||||
unicode = unicode.Replace("%", "\\");
|
||||
|
||||
return new Regex(@"\\u([0-9A-F]{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled).Replace(
|
||||
unicode, x => string.Empty + Convert.ToChar(Convert.ToUInt16(x.Result("$1"), 16)));
|
||||
|
||||
//string resultStr = "";
|
||||
//string[] strList = unicode.Split('u');
|
||||
//for (int i = 1; i < strList.Length; i++)
|
||||
//{
|
||||
// resultStr += (char)int.Parse(strList[i], System.Globalization.NumberStyles.HexNumber);
|
||||
//}
|
||||
//return resultStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/UrlHelper.cs
Normal file
24
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/UrlHelper.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class UrlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// UrlEncode编码
|
||||
/// </summary>
|
||||
/// <param name="url">url</param>
|
||||
/// <returns></returns>
|
||||
public static string UrlEncode(string url)
|
||||
{
|
||||
return System.Web.HttpUtility.UrlEncode(url, System.Text.Encoding.UTF8);
|
||||
}
|
||||
/// <summary>
|
||||
/// UrlEncode解码
|
||||
/// </summary>
|
||||
/// <param name="data">数据</param>
|
||||
/// <returns></returns>
|
||||
public static string UrlDecode(string data)
|
||||
{
|
||||
return System.Web.HttpUtility.UrlDecode(data, System.Text.Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/XmlHelper.cs
Normal file
51
Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/XmlHelper.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Yi.Framework.Core.Helper
|
||||
{
|
||||
public class XmlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 转换对象为JSON格式数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类</typeparam>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns>字符格式的JSON数据</returns>
|
||||
public static string? GetXML<T>(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof(T));
|
||||
|
||||
using (TextWriter tw = new StringWriter())
|
||||
{
|
||||
xs.Serialize(tw, obj);
|
||||
return tw.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xml格式字符转换为T类型的对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="xml"></param>
|
||||
/// <returns></returns>
|
||||
public static T ParseFormByXml<T>(string xml, string rootName = "root")
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T), new XmlRootAttribute(rootName));
|
||||
StringReader reader = new StringReader(xml);
|
||||
|
||||
T res = (T)serializer.Deserialize(reader)!;
|
||||
reader.Close();
|
||||
reader.Dispose();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Yi.Abp.Net8/framework/Yi.Framework.Core/IOrderNum.cs
Normal file
13
Yi.Abp.Net8/framework/Yi.Framework.Core/IOrderNum.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public interface IOrderNum
|
||||
{
|
||||
int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
13
Yi.Abp.Net8/framework/Yi.Framework.Core/IState.cs
Normal file
13
Yi.Abp.Net8/framework/Yi.Framework.Core/IState.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public interface IState
|
||||
{
|
||||
public bool State { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Volo.Abp.Core" Version="7.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
847
Yi.Abp.Net8/framework/Yi.Framework.Core/Yi.Framework.Core.xml
Normal file
847
Yi.Abp.Net8/framework/Yi.Framework.Core/Yi.Framework.Core.xml
Normal file
@@ -0,0 +1,847 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Core</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Framework.Core.Enums.FileTypeEnum">
|
||||
<summary>
|
||||
定义公共文件路径
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.Equal">
|
||||
<summary>
|
||||
相等
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.Like">
|
||||
<summary>
|
||||
匹配
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.GreaterThan">
|
||||
<summary>
|
||||
大于
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.GreaterThanOrEqual">
|
||||
<summary>
|
||||
大于或等于
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.LessThan">
|
||||
<summary>
|
||||
小于
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.LessThanOrEqual">
|
||||
<summary>
|
||||
小于或等于
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.In">
|
||||
<summary>
|
||||
等于集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.NotIn">
|
||||
<summary>
|
||||
不等于集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.LikeLeft">
|
||||
<summary>
|
||||
左边匹配
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.LikeRight">
|
||||
<summary>
|
||||
右边匹配
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.NoEqual">
|
||||
<summary>
|
||||
不相等
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.IsNullOrEmpty">
|
||||
<summary>
|
||||
为空或空
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.IsNot">
|
||||
<summary>
|
||||
不为空
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.NoLike">
|
||||
<summary>
|
||||
不匹配
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.QueryOperatorEnum.DateRange">
|
||||
<summary>
|
||||
时间段 值用 "|" 隔开
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.ResultCodeEnum.Success">
|
||||
<summary>
|
||||
操作成功。
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.ResultCodeEnum.NotSuccess">
|
||||
<summary>
|
||||
操作不成功
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.ResultCodeEnum.NoPermission">
|
||||
<summary>
|
||||
无权限
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Enums.ResultCodeEnum.Denied">
|
||||
<summary>
|
||||
被拒绝
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.FileInlineHandle(Microsoft.AspNetCore.Http.HttpContext,System.String)">
|
||||
<summary>
|
||||
设置文件下载名称
|
||||
</summary>
|
||||
<param name="httpContext"></param>
|
||||
<param name="fileName"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.FileAttachmentHandle(Microsoft.AspNetCore.Http.HttpContext,System.String)">
|
||||
<summary>
|
||||
设置文件附件名称
|
||||
</summary>
|
||||
<param name="httpContext"></param>
|
||||
<param name="fileName"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.GetLanguage(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
获取语言种类
|
||||
</summary>
|
||||
<param name="httpContext"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.IsAjaxRequest(Microsoft.AspNetCore.Http.HttpRequest)">
|
||||
<summary>
|
||||
判断是否为异步请求
|
||||
</summary>
|
||||
<param name="request"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.GetClientIp(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
获取客户端IP
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Extensions.HttpContextExtensions.GetUserAgent(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
获取浏览器标识
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.AssemblyHelper.GetAllLoadAssembly">
|
||||
<summary>
|
||||
此处统一获取程序集,排除微软内部相关
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.Base32Helper.ToString(System.Byte[])">
|
||||
<summary>
|
||||
Converts an array of bytes to a Base32-k string.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.Base32Helper.FromBase32String(System.String)">
|
||||
<summary>
|
||||
Converts a Base32-k string into an array of bytes.
|
||||
</summary>
|
||||
<exception cref="T:System.ArgumentException">
|
||||
Input string <paramref name="s">s</paramref> contains invalid Base32-k characters.
|
||||
</exception>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ComputerHelper.ParseToLong(System.Object)">
|
||||
<summary>
|
||||
将object转换为long,若转换失败,则返回0。不抛出异常。
|
||||
</summary>
|
||||
<param name="str"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ComputerHelper.ParseToDateTime(System.String)">
|
||||
<summary>
|
||||
将string转换为DateTime,若转换失败,则返回日期最小值。不抛出异常。
|
||||
</summary>
|
||||
<param name="str"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ComputerHelper.GetComputerInfo">
|
||||
<summary>
|
||||
内存使用情况
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ComputerHelper.GetDiskInfos">
|
||||
<summary>
|
||||
获取内存大小
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ComputerHelper.GetRunTime">
|
||||
<summary>
|
||||
获取系统运行时间
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Core.Helper.MemoryMetrics">
|
||||
<summary>
|
||||
内存信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.MemoryMetrics.CPURate">
|
||||
<summary>
|
||||
CPU使用率%
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.MemoryMetrics.TotalRAM">
|
||||
<summary>
|
||||
总内存 GB
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.MemoryMetrics.RAMRate">
|
||||
<summary>
|
||||
内存使用率 %
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.MemoryMetrics.FreeRam">
|
||||
<summary>
|
||||
空闲内存
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.DiskInfo.DiskName">
|
||||
<summary>
|
||||
磁盘名
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.DiskInfo.Used">
|
||||
<summary>
|
||||
已使用
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Core.Helper.DiskInfo.AvailableFreeSpace">
|
||||
<summary>
|
||||
可使用
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MemoryMetricsClient.GetWindowsMetrics">
|
||||
<summary>
|
||||
windows系统获取内存信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MemoryMetricsClient.GetUnixMetrics">
|
||||
<summary>
|
||||
Unix系统获取
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ConsoleHelper.WriteErrorLine(System.String,System.ConsoleColor)">
|
||||
<summary>
|
||||
打印错误信息
|
||||
</summary>
|
||||
<param name="str">待打印的字符串</param>
|
||||
<param name="color">想要打印的颜色</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ConsoleHelper.WriteWarningLine(System.String,System.ConsoleColor)">
|
||||
<summary>
|
||||
打印警告信息
|
||||
</summary>
|
||||
<param name="str">待打印的字符串</param>
|
||||
<param name="color">想要打印的颜色</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ConsoleHelper.WriteInfoLine(System.String,System.ConsoleColor)">
|
||||
<summary>
|
||||
打印正常信息
|
||||
</summary>
|
||||
<param name="str">待打印的字符串</param>
|
||||
<param name="color">想要打印的颜色</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ConsoleHelper.WriteSuccessLine(System.String,System.ConsoleColor)">
|
||||
<summary>
|
||||
打印成功的信息
|
||||
</summary>
|
||||
<param name="str">待打印的字符串</param>
|
||||
<param name="color">想要打印的颜色</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateHelper.ToLocalTimeDateBySeconds(System.Int64)">
|
||||
<summary>
|
||||
时间戳转本地时间-时间戳精确到秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateHelper.ToUnixTimestampBySeconds(System.DateTime)">
|
||||
<summary>
|
||||
时间转时间戳Unix-时间戳精确到秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateHelper.ToLocalTimeDateByMilliseconds(System.Int64)">
|
||||
<summary>
|
||||
时间戳转本地时间-时间戳精确到毫秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateHelper.ToUnixTimestampByMilliseconds(System.DateTime)">
|
||||
<summary>
|
||||
时间转时间戳Unix-时间戳精确到毫秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.GetBeginTime(System.Nullable{System.DateTime},System.Int32)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="dateTime"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.ToLocalTimeDateBySeconds(System.Int64)">
|
||||
<summary>
|
||||
时间戳转本地时间-时间戳精确到秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.ToUnixTimestampBySeconds(System.DateTime)">
|
||||
<summary>
|
||||
时间转时间戳Unix-时间戳精确到秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.ToLocalTimeDateByMilliseconds(System.Int64)">
|
||||
<summary>
|
||||
时间戳转本地时间-时间戳精确到毫秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.ToUnixTimestampByMilliseconds(System.DateTime)">
|
||||
<summary>
|
||||
时间转时间戳Unix-时间戳精确到毫秒
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.FormatTime(System.Int64)">
|
||||
<summary>
|
||||
毫秒转天时分秒
|
||||
</summary>
|
||||
<param name="ms"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DateTimeHelper.GetUnixTimeStamp(System.DateTime)">
|
||||
<summary>
|
||||
获取unix时间戳
|
||||
</summary>
|
||||
<param name="dt"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.DistinctHelper.DistinctNew``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})">
|
||||
<summary>
|
||||
自定义Distinct扩展方法
|
||||
</summary>
|
||||
<typeparam name="T">要去重的对象类</typeparam>
|
||||
<typeparam name="C">自定义去重的字段类型</typeparam>
|
||||
<param name="source">要去重的对象</param>
|
||||
<param name="getfield">获取自定义去重字段的委托</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ExpressionHelper.Compose``1(System.Linq.Expressions.Expression{``0},System.Linq.Expressions.Expression{``0},System.Func{System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression})">
|
||||
<summary>
|
||||
Expression表达式树lambda参数拼接组合
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<param name="merge"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ExpressionHelper.False``1">
|
||||
<summary>
|
||||
Expression表达式树lambda参数拼接--false
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ExpressionHelper.True``1">
|
||||
<summary>
|
||||
Expression表达式树lambda参数拼接-true
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ExpressionHelper.And``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
||||
<summary>
|
||||
Expression表达式树lambda参数拼接--and
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ExpressionHelper.Or``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
||||
<summary>
|
||||
Expression表达式树lambda参数拼接--or
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.LambdaParameteRebinder.map">
|
||||
<summary>
|
||||
存放表达式树的参数的字典
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.LambdaParameteRebinder.#ctor(System.Collections.Generic.Dictionary{System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.ParameterExpression})">
|
||||
<summary>
|
||||
构造函数
|
||||
</summary>
|
||||
<param name="map"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.LambdaParameteRebinder.VisitParameter(System.Linq.Expressions.ParameterExpression)">
|
||||
<summary>
|
||||
重载参数访问的方法,访问表达式树参数,如果字典中包含,则取出
|
||||
</summary>
|
||||
<param name="node">表达式树参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.GetPostfixStr(System.String)">
|
||||
<summary>
|
||||
取后缀名
|
||||
</summary>
|
||||
<param name="filename">文件名</param>
|
||||
<returns>.gif|.html格式</returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.WriteFile(System.String,System.String)">
|
||||
<summary>
|
||||
写文件
|
||||
</summary>
|
||||
<param name="Path">文件路径</param>
|
||||
<param name="Strings">文件内容</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.WriteFile(System.String,System.String,System.Text.Encoding)">
|
||||
<summary>
|
||||
写文件
|
||||
</summary>
|
||||
<param name="Path">文件路径</param>
|
||||
<param name="Strings">文件内容</param>
|
||||
<param name="encode">编码格式</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.ReadFile(System.String)">
|
||||
<summary>
|
||||
读文件
|
||||
</summary>
|
||||
<param name="Path">文件路径</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.ReadFile(System.String,System.Text.Encoding)">
|
||||
<summary>
|
||||
读文件
|
||||
</summary>
|
||||
<param name="Path">文件路径</param>
|
||||
<param name="encode">编码格式</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileAdd(System.String,System.String)">
|
||||
<summary>
|
||||
追加文件
|
||||
</summary>
|
||||
<param name="Path">文件路径</param>
|
||||
<param name="strings">内容</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileCoppy(System.String,System.String)">
|
||||
<summary>
|
||||
拷贝文件
|
||||
</summary>
|
||||
<param name="OrignFile">原始文件</param>
|
||||
<param name="NewFile">新文件路径</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileDel(System.String)">
|
||||
<summary>
|
||||
删除文件
|
||||
</summary>
|
||||
<param name="Path">路径</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileMove(System.String,System.String)">
|
||||
<summary>
|
||||
移动文件
|
||||
</summary>
|
||||
<param name="OrignFile">原始路径</param>
|
||||
<param name="NewFile">新路径</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FolderCreate(System.String,System.String)">
|
||||
<summary>
|
||||
在当前目录下创建目录
|
||||
</summary>
|
||||
<param name="OrignFolder">当前目录</param>
|
||||
<param name="NewFloder">新目录</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.DeleteFolder(System.String)">
|
||||
<summary>
|
||||
递归删除文件夹目录及文件
|
||||
</summary>
|
||||
<param name="dir"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.CopyDir(System.String,System.String)">
|
||||
<summary>
|
||||
指定文件夹下面的所有内容copy到目标文件夹下面
|
||||
</summary>
|
||||
<param name="srcPath">原始路径</param>
|
||||
<param name="aimPath">目标文件夹</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.GetAllFileNames(System.String,System.String)">
|
||||
<summary>
|
||||
获取目录下全部文件名
|
||||
</summary>
|
||||
<param name="path"></param>
|
||||
<param name="pattern"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileContentReplace(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
文件内容替换
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.FileNameReplace(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
文件名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.DirectoryNameReplace(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
目录名替换
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.FileHelper.AllInfoReplace(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
全部信息递归替换
|
||||
</summary>
|
||||
<param name="dirPath"></param>
|
||||
<param name="oldStr"></param>
|
||||
<param name="newStr"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.HtmlHelper.ReplaceHtmlTag(System.String,System.Int32)">
|
||||
<summary>
|
||||
去除富文本中的HTML标签
|
||||
</summary>
|
||||
<param name="html"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.IpHelper.GetCurrentIp(System.String)">
|
||||
<summary>
|
||||
获取当前IP地址
|
||||
</summary>
|
||||
<param name="preferredNetworks"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.JsonHelper.GetJSON``1(System.Object)">
|
||||
<summary>
|
||||
转换对象为JSON格式数据
|
||||
</summary>
|
||||
<typeparam name="T">类</typeparam>
|
||||
<param name="obj">对象</param>
|
||||
<returns>字符格式的JSON数据</returns>
|
||||
</member>
|
||||
<!-- Badly formed XML comment ignored for member "M:Yi.Framework.Core.Helper.JsonHelper.JSON``1(System.Collections.Generic.List{``0})" -->
|
||||
<member name="M:Yi.Framework.Core.Helper.JsonHelper.ParseFormByJson``1(System.String)">
|
||||
<summary>
|
||||
JSON格式字符转换为T类型的对象
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="jsonStr"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.JsonHelper.GetValueLength(System.String,System.Boolean,System.Int32@)">
|
||||
<summary>
|
||||
获取值的长度(当Json值嵌套以"{"或"["开头时)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.JsonHelper.SetCharState(System.Char,Yi.Framework.Core.Helper.CharState@)">
|
||||
<summary>
|
||||
设置字符状态(返回true则为关键词,返回false则当为普通字符处理)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Core.Helper.CharState">
|
||||
<summary>
|
||||
字符状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.CharState.arrayStart">
|
||||
<summary>
|
||||
数组开始【仅第一开头才算】,值嵌套的以【childrenStart】来标识。
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.CharState.state">
|
||||
<summary>
|
||||
【0 初始状态,或 遇到“,”逗号】;【1 遇到“:”冒号】
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.CharState.keyStart">
|
||||
<summary>
|
||||
【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.CharState.valueStart">
|
||||
<summary>
|
||||
【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MD5Helper.GenerateSalt">
|
||||
<summary>
|
||||
生成PasswordSalt
|
||||
</summary>
|
||||
<returns>返回string</returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MD5Helper.SHA2Encode(System.String,System.String,System.Int32)">
|
||||
<summary>
|
||||
加密密码
|
||||
</summary>
|
||||
<param name="pass">密码</param>
|
||||
<param name="passwordFormat">加密类型</param>
|
||||
<param name="salt">PasswordSalt</param>
|
||||
<returns>加密后的密码</returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MD5Helper.MD5Encrypt16(System.String)">
|
||||
<summary>
|
||||
16位MD5加密
|
||||
</summary>
|
||||
<param name="password"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MD5Helper.MD5Encrypt32(System.String)">
|
||||
<summary>
|
||||
32位MD5加密
|
||||
</summary>
|
||||
<param name="password"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.MD5Helper.MD5Encrypt64(System.String)">
|
||||
<summary>
|
||||
64位MD5加密
|
||||
</summary>
|
||||
<param name="password"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RandomHelper.GenerateRandomLetter(System.Int32)">
|
||||
<summary>
|
||||
随机生成字母
|
||||
</summary>
|
||||
<param name="Length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RandomHelper.GenerateCheckCodeNum(System.Int32)">
|
||||
<summary>
|
||||
随机生成数字
|
||||
</summary>
|
||||
<param name="codeCount"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RandomHelper.RandChina(System.Int32)">
|
||||
<summary>
|
||||
此函数为生成指定数目的汉字
|
||||
</summary>
|
||||
<param name="charLen">汉字数目</param>
|
||||
<returns>所有汉字</returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ReflexHelper.GetModelValue(System.String,System.Object)">
|
||||
<summary>
|
||||
取对象属性值
|
||||
</summary>
|
||||
<param name="FieldName"></param>
|
||||
<param name="obj"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ReflexHelper.SetModelValue(System.String,System.Object,System.Object)">
|
||||
<summary>
|
||||
设置对象属性值
|
||||
</summary>
|
||||
<param name="FieldName"></param>
|
||||
<param name="Value"></param>
|
||||
<param name="obj"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Core.Helper.RSAHelper">
|
||||
<summary>
|
||||
RSA加解密 使用OpenSSL的公钥加密/私钥解密
|
||||
公私钥请使用openssl生成
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.#ctor(Yi.Framework.Core.Helper.RSAType,System.Text.Encoding,System.String,System.String)">
|
||||
<summary>
|
||||
实例化RSAHelper
|
||||
</summary>
|
||||
<param name="rsaType">加密算法类型 RSA SHA1;RSA2 SHA256 密钥长度至少为2048</param>
|
||||
<param name="encoding">编码类型</param>
|
||||
<param name="privateKey">私钥</param>
|
||||
<param name="publicKey">公钥</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.Sign(System.String)">
|
||||
<summary>
|
||||
使用私钥签名
|
||||
</summary>
|
||||
<param name="data">原始数据</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.Verify(System.String,System.String)">
|
||||
<summary>
|
||||
使用公钥验签
|
||||
</summary>
|
||||
<param name="data">原始数据</param>
|
||||
<param name="sign">签名</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.Decrypt(System.String)">
|
||||
<summary>
|
||||
私钥解密(支持大量数据)
|
||||
</summary>
|
||||
<param name="cipherText"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.Encrypt(System.String)">
|
||||
<summary>
|
||||
公钥加密(支持大量数据)
|
||||
</summary>
|
||||
<param name="text"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.CreateRsaProviderFromPrivateKey(System.String)">
|
||||
<summary>
|
||||
使用私钥创建RSA实例
|
||||
</summary>
|
||||
<param name="privateKey"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.RSAHelper.CreateRsaProviderFromPublicKey(System.String)">
|
||||
<summary>
|
||||
使用公钥创建RSA实例
|
||||
</summary>
|
||||
<param name="publicKeyString"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.Core.Helper.RSAType">
|
||||
<summary>
|
||||
RSA算法类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.RSAType.RSA">
|
||||
<summary>
|
||||
SHA1
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Yi.Framework.Core.Helper.RSAType.RSA2">
|
||||
<summary>
|
||||
RSA2 密钥长度至少为2048
|
||||
SHA256
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ShellHelper.Bash(System.String)">
|
||||
<summary>
|
||||
linux 系统命令
|
||||
</summary>
|
||||
<param name="command"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.ShellHelper.Cmd(System.String,System.String)">
|
||||
<summary>
|
||||
windows系统命令
|
||||
</summary>
|
||||
<param name="fileName"></param>
|
||||
<param name="args"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetTopDataBySeparator(System.String,System.String,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
根据分隔符返回前n条数据
|
||||
</summary>
|
||||
<param name="content">数据内容</param>
|
||||
<param name="separator">分隔符</param>
|
||||
<param name="top">前n条</param>
|
||||
<param name="isDesc">是否倒序(默认false)</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetPars(System.Collections.Generic.Dictionary{System.String,System.Object})">
|
||||
<summary>
|
||||
根据字段拼接get参数
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetPars(System.Collections.Generic.Dictionary{System.String,System.String})">
|
||||
<summary>
|
||||
根据字段拼接get参数
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetGUID(System.String)">
|
||||
<summary>
|
||||
获取一个GUID
|
||||
</summary>
|
||||
<param name="format">格式-默认为N</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetGuidToLongID">
|
||||
<summary>
|
||||
根据GUID获取19位的唯一数字序列
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.StringHelper.GetCusLine(System.String,System.Int32)">
|
||||
<summary>
|
||||
获取字符串最后X行
|
||||
</summary>
|
||||
<param name="resourceStr"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.UnicodeHelper.StringToUnicode(System.String)">
|
||||
<summary>
|
||||
字符串转Unicode码
|
||||
</summary>
|
||||
<returns>The to unicode.</returns>
|
||||
<param name="value">Value.</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.UnicodeHelper.UnicodeToString(System.String)">
|
||||
<summary>
|
||||
Unicode转字符串
|
||||
</summary>
|
||||
<returns>The to string.</returns>
|
||||
<param name="unicode">Unicode.</param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.UrlHelper.UrlEncode(System.String)">
|
||||
<summary>
|
||||
UrlEncode编码
|
||||
</summary>
|
||||
<param name="url">url</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.UrlHelper.UrlDecode(System.String)">
|
||||
<summary>
|
||||
UrlEncode解码
|
||||
</summary>
|
||||
<param name="data">数据</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.XmlHelper.GetXML``1(System.Object)">
|
||||
<summary>
|
||||
转换对象为JSON格式数据
|
||||
</summary>
|
||||
<typeparam name="T">类</typeparam>
|
||||
<param name="obj">对象</param>
|
||||
<returns>字符格式的JSON数据</returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Core.Helper.XmlHelper.ParseFormByXml``1(System.String,System.String)">
|
||||
<summary>
|
||||
Xml格式字符转换为T类型的对象
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="xml"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public class YiFrameworkCoreModule:AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
public interface IDeletesAppService<in TKey> : IDeleteAppService< TKey> , IApplicationService, IRemoteService
|
||||
{
|
||||
Task DeleteAsync(IEnumerable<TKey> ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
public interface IPageTimeResultRequestDto : IPagedAndSortedResultRequest
|
||||
{
|
||||
DateTime? StartTime { get; set; }
|
||||
DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
public interface IPagedAllResultRequestDto : IPageTimeResultRequestDto, IPagedAndSortedResultRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
public interface IYiCrudAppService<TEntityDto, in TKey> : ICrudAppService<TEntityDto, TKey>
|
||||
{
|
||||
}
|
||||
|
||||
public interface IYiCrudAppService<TEntityDto, in TKey, in TGetListInput> : ICrudAppService<TEntityDto, TKey, TGetListInput>
|
||||
{
|
||||
}
|
||||
|
||||
public interface IYiCrudAppService<TEntityDto, in TKey, in TGetListInput, in TCreateInput> : ICrudAppService<TEntityDto, TKey, TGetListInput, TCreateInput>
|
||||
{
|
||||
}
|
||||
|
||||
public interface IYiCrudAppService<TEntityDto, in TKey, in TGetListInput, in TCreateInput, in TUpdateInput> : ICrudAppService<TEntityDto, TKey, TGetListInput, TCreateInput, TUpdateInput>
|
||||
{
|
||||
}
|
||||
|
||||
public interface IYiCrudAppService<TGetOutputDto, TGetListOutputDto, in TKey, in TGetListInput, in TCreateInput, in TUpdateInput> : ICrudAppService<TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>, IDeletesAppService<TKey>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
public class PagedAllResultRequestDto : PagedAndSortedResultRequestDto, IPagedAllResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询开始时间条件
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 查询结束时间条件
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="7.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Ddd.Application.Contracts</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="P:Yi.Framework.Ddd.Application.Contracts.PagedAllResultRequestDto.StartTime">
|
||||
<summary>
|
||||
查询开始时间条件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.Ddd.Application.Contracts.PagedAllResultRequestDto.EndTime">
|
||||
<summary>
|
||||
查询结束时间条件
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application.Contracts
|
||||
{
|
||||
[DependsOn(typeof(AbpDddApplicationContractsModule))]
|
||||
public class YiFrameworkDddApplicationContractsModule : AbpModule
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application" Version="7.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Ddd.Application.Contracts\Yi.Framework.Ddd.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Ddd.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Yi.Framework.Ddd.Application.YiCrudAppService`7.DeleteAsync(System.Collections.Generic.IEnumerable{`3})">
|
||||
<summary>
|
||||
偷梁换柱
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application
|
||||
{
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey> : YiCrudAppService<TEntity, TEntityDto, TKey, PagedAndSortedResultRequestDto>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey, TGetListInput>
|
||||
: YiCrudAppService<TEntity, TEntityDto, TKey, TGetListInput, TEntityDto>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey, TGetListInput, TCreateInput>
|
||||
: YiCrudAppService<TEntity, TEntityDto, TKey, TGetListInput, TCreateInput, TCreateInput>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey, TGetListInput, TCreateInput, TUpdateInput>
|
||||
: YiCrudAppService<TEntity, TEntityDto, TEntityDto, TKey, TGetListInput, TCreateInput, TUpdateInput>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class YiCrudAppService<TEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>
|
||||
: CrudAppService<TEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TGetOutputDto : IEntityDto<TKey>
|
||||
where TGetListOutputDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偷梁换柱
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[RemoteService(isEnabled: true)]
|
||||
public async Task DeleteAsync(IEnumerable<TKey> id)
|
||||
{
|
||||
await Repository.DeleteManyAsync(id);
|
||||
}
|
||||
[RemoteService(isEnabled:false)]
|
||||
public override Task DeleteAsync(TKey id)
|
||||
{
|
||||
return base.DeleteAsync(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.Ddd.Application.Contracts;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application
|
||||
{
|
||||
[DependsOn(typeof(AbpDddApplicationModule),
|
||||
typeof(YiFrameworkDddApplicationContractsModule))]
|
||||
public class YiFrameworkDddApplicationModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Mapster;
|
||||
using Volo.Abp.ObjectMapping;
|
||||
|
||||
namespace Yi.Framework.Mapster
|
||||
{
|
||||
public class MapsterAutoObjectMappingProvider : IAutoObjectMappingProvider
|
||||
{
|
||||
public TDestination Map<TSource, TDestination>(object source)
|
||||
{
|
||||
var sss = typeof(TDestination).Name;
|
||||
return source.Adapt<TDestination>();
|
||||
}
|
||||
|
||||
public TDestination Map<TSource, TDestination>(TSource source, TDestination destination)
|
||||
{
|
||||
return source.Adapt<TSource, TDestination>(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.ObjectMapping;
|
||||
|
||||
namespace Yi.Framework.Mapster
|
||||
{
|
||||
public class MapsterObjectMapper : IObjectMapper
|
||||
{
|
||||
public IAutoObjectMappingProvider AutoObjectMappingProvider => throw new NotImplementedException();
|
||||
|
||||
public TDestination Map<TSource, TDestination>(TSource source)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TDestination Map<TSource, TDestination>(TSource source, TDestination destination)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
<PackageReference Include="Volo.Abp.ObjectMapping" Version="7.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.Mapster</name>
|
||||
</assembly>
|
||||
<members>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,21 @@
|
||||
using MapsterMapper;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.ObjectMapping;
|
||||
using Yi.Framework.Core;
|
||||
|
||||
namespace Yi.Framework.Mapster
|
||||
{
|
||||
[DependsOn(typeof(YiFrameworkCoreModule),
|
||||
|
||||
typeof(AbpObjectMappingModule)
|
||||
)]
|
||||
public class YiFrameworkMapsterModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Abstractions
|
||||
{
|
||||
public interface ISqlSugarDbContext
|
||||
{
|
||||
// IAbpLazyServiceProvider LazyServiceProvider { get; set; }
|
||||
ISqlSugarClient SqlSugarClient { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Linq.Expressions;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Abstractions
|
||||
{
|
||||
|
||||
public interface ISqlSugarRepository<TEntity>:IRepository<TEntity> where TEntity : class, IEntity,new ()
|
||||
{
|
||||
ISqlSugarClient _Db { get; }
|
||||
ISugarQueryable<TEntity> _DbQueryable { get; }
|
||||
|
||||
Task<ISqlSugarClient> GetDbContextAsync();
|
||||
Task<IDeleteable<TEntity>> AsDeleteable();
|
||||
Task<IInsertable<TEntity>> AsInsertable(List<TEntity> insertObjs);
|
||||
Task<IInsertable<TEntity>> AsInsertable(TEntity insertObj);
|
||||
Task<IInsertable<TEntity>> AsInsertable(TEntity[] insertObjs);
|
||||
Task<ISugarQueryable<TEntity>> AsQueryable();
|
||||
Task<ISqlSugarClient> AsSugarClient();
|
||||
Task<ITenant> AsTenant();
|
||||
Task<IUpdateable<TEntity>> AsUpdateable(List<TEntity> updateObjs);
|
||||
Task<IUpdateable<TEntity>> AsUpdateable(TEntity updateObj);
|
||||
Task<IUpdateable<TEntity>> AsUpdateable();
|
||||
Task<IUpdateable<TEntity>> AsUpdateable(TEntity[] updateObjs);
|
||||
|
||||
#region 单查
|
||||
//单查
|
||||
Task<TEntity> GetByIdAsync(dynamic id);
|
||||
Task<TEntity> GetSingleAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
Task<TEntity> GetFirstAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
Task<bool> IsAnyAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
Task<int> CountAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 多查
|
||||
//多查
|
||||
Task<List<TEntity>> GetListAsync();
|
||||
Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
#endregion
|
||||
|
||||
|
||||
#region 分页查
|
||||
//分页查
|
||||
Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize);
|
||||
Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<TEntity, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
|
||||
#endregion
|
||||
|
||||
#region 插入
|
||||
//插入
|
||||
Task<bool> InsertAsync(TEntity insertObj);
|
||||
Task<bool> InsertOrUpdateAsync(TEntity data);
|
||||
Task<bool> InsertOrUpdateAsync(List<TEntity> datas);
|
||||
Task<int> InsertReturnIdentityAsync(TEntity insertObj);
|
||||
Task<long> InsertReturnBigIdentityAsync(TEntity insertObj);
|
||||
Task<long> InsertReturnSnowflakeIdAsync(TEntity insertObj);
|
||||
Task<TEntity> InsertReturnEntityAsync(TEntity insertObj);
|
||||
Task<bool> InsertRangeAsync(List<TEntity> insertObjs);
|
||||
#endregion
|
||||
|
||||
|
||||
#region 更新
|
||||
//更新
|
||||
Task<bool> UpdateAsync(TEntity updateObj);
|
||||
Task<bool> UpdateRangeAsync(List<TEntity> updateObjs);
|
||||
Task<bool> UpdateAsync(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> whereExpression);
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
//删除
|
||||
Task<bool> DeleteAsync(TEntity deleteObj);
|
||||
Task<bool> DeleteAsync(List<TEntity> deleteObjs);
|
||||
Task<bool> DeleteAsync(Expression<Func<TEntity, bool>> whereExpression);
|
||||
Task<bool> DeleteByIdAsync(dynamic id);
|
||||
Task<bool> DeleteByIdsAsync(dynamic[] ids);
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
public interface ISqlSugarRepository<TEntity, TKey> : ISqlSugarRepository<TEntity>,IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>, new()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Abstractions
|
||||
{
|
||||
public interface ISugarDbContextProvider<TDbContext>
|
||||
where TDbContext : ISqlSugarDbContext
|
||||
{
|
||||
|
||||
Task<TDbContext> GetDbContextAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.124" />
|
||||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="7.4.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.SqlSugarCore.Abstractions</name>
|
||||
</assembly>
|
||||
<members>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.Core;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Abstractions
|
||||
{
|
||||
[DependsOn(typeof(YiFrameworkCoreModule))]
|
||||
public class YiFrameworkSqlSugarCoreAbstractionsModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
public class DbConnOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接字符串,必填
|
||||
/// </summary>
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public DbType? DbType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开启种子数据
|
||||
/// </summary>
|
||||
public bool EnabledDbSeed { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 开启读写分离
|
||||
/// </summary>
|
||||
public bool EnabledReadWrite { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 开启codefirst
|
||||
/// </summary>
|
||||
public bool EnabledCodeFirst { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 开启sql日志
|
||||
/// </summary>
|
||||
public bool EnabledSqlLog { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 实体程序集
|
||||
/// </summary>
|
||||
public List<string>? EntityAssembly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 读写分离
|
||||
/// </summary>
|
||||
public List<string>? ReadUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
using System.Linq.Expressions;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Linq;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Repositories
|
||||
{
|
||||
public class SqlSugarRepository<TEntity> : ISqlSugarRepository<TEntity>, IRepository<TEntity> where TEntity : class, IEntity, new()
|
||||
{
|
||||
public ISqlSugarClient _Db => GetDbContextAsync().Result;
|
||||
|
||||
public ISugarQueryable<TEntity> _DbQueryable => GetDbContextAsync().Result.Queryable<TEntity>();
|
||||
|
||||
private ISugarDbContextProvider<ISqlSugarDbContext> _sugarDbContextProvider;
|
||||
public IAsyncQueryableExecuter AsyncExecuter { get; }
|
||||
|
||||
public SqlSugarRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider)
|
||||
{
|
||||
_sugarDbContextProvider = sugarDbContextProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取DB
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ISqlSugarClient> GetDbContextAsync()
|
||||
{
|
||||
|
||||
var db = (await _sugarDbContextProvider.GetDbContextAsync()).SqlSugarClient;
|
||||
await Console.Out.WriteLineAsync("获取的id:" + db.ContextID);
|
||||
return db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取简单Db
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<SimpleClient<TEntity>> GetDbSimpleClientAsync()
|
||||
{
|
||||
var db = await GetDbContextAsync();
|
||||
return new SimpleClient<TEntity>(db);
|
||||
}
|
||||
|
||||
#region Abp模块
|
||||
|
||||
public async Task<TEntity?> FindAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetFirstAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetFirstAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task DeleteDirectAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteAsync(predicate);
|
||||
}
|
||||
|
||||
public IQueryable<TEntity> WithDetails()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IQueryable<TEntity> WithDetails(params Expression<Func<TEntity, object>>[] propertySelectors)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IQueryable<TEntity>> WithDetailsAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IQueryable<TEntity>> WithDetailsAsync(params Expression<Func<TEntity, object>>[] propertySelectors)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IQueryable<TEntity>> GetQueryableAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetListAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await InsertReturnEntityAsync(entity);
|
||||
}
|
||||
|
||||
public async Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await InsertRangeAsync(entities.ToList());
|
||||
}
|
||||
|
||||
public async Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await UpdateAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await UpdateRangeAsync(entities.ToList());
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteAsync(entity);
|
||||
}
|
||||
|
||||
public async Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteAsync(entities.ToList());
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await this.CountAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPageListAsync(_ => true, skipCount, maxResultCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 内置DB快捷操作
|
||||
public async Task<IDeleteable<TEntity>> AsDeleteable()
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsDeleteable();
|
||||
}
|
||||
|
||||
public async Task<IInsertable<TEntity>> AsInsertable(List<TEntity> insertObjs)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsInsertable(insertObjs);
|
||||
}
|
||||
|
||||
public async Task<IInsertable<TEntity>> AsInsertable(TEntity insertObj)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsInsertable(insertObj);
|
||||
}
|
||||
|
||||
public async Task<IInsertable<TEntity>> AsInsertable(TEntity[] insertObjs)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsInsertable(insertObjs);
|
||||
}
|
||||
|
||||
public async Task<ISugarQueryable<TEntity>> AsQueryable()
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsQueryable();
|
||||
}
|
||||
|
||||
public async Task<ISqlSugarClient> AsSugarClient()
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsSugarClient();
|
||||
}
|
||||
|
||||
public async Task<ITenant> AsTenant()
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsTenant();
|
||||
}
|
||||
|
||||
public async Task<IUpdateable<TEntity>> AsUpdateable(List<TEntity> updateObjs)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsUpdateable(updateObjs);
|
||||
}
|
||||
|
||||
public async Task<IUpdateable<TEntity>> AsUpdateable(TEntity updateObj)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsUpdateable(updateObj);
|
||||
}
|
||||
|
||||
public async Task<IUpdateable<TEntity>> AsUpdateable()
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsUpdateable();
|
||||
}
|
||||
|
||||
public async Task<IUpdateable<TEntity>> AsUpdateable(TEntity[] updateObjs)
|
||||
{
|
||||
return (await GetDbSimpleClientAsync()).AsUpdateable(updateObjs);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SimpleClient模块
|
||||
public async Task<int> CountAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).CountAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(TEntity deleteObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).DeleteAsync(deleteObj);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(List<TEntity> deleteObjs)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).DeleteAsync(deleteObjs);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).DeleteAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteByIdAsync(dynamic id)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).DeleteByIdAsync(id);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteByIdsAsync(dynamic[] ids)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).DeleteByIdAsync(ids);
|
||||
}
|
||||
|
||||
public async Task<TEntity> GetByIdAsync(dynamic id)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetByIdAsync(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<TEntity> GetFirstAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetFirstAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetListAsync()
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetListAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel() { PageIndex = pageNum, PageSize = pageSize });
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<TEntity, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType);
|
||||
}
|
||||
|
||||
public async Task<TEntity> GetSingleAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetSingleAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<bool> InsertAsync(TEntity insertObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertAsync(insertObj);
|
||||
}
|
||||
|
||||
public async Task<bool> InsertOrUpdateAsync(TEntity data)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertOrUpdateAsync(data);
|
||||
}
|
||||
|
||||
public async Task<bool> InsertOrUpdateAsync(List<TEntity> datas)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertOrUpdateAsync(datas);
|
||||
}
|
||||
|
||||
public async Task<bool> InsertRangeAsync(List<TEntity> insertObjs)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertRangeAsync(insertObjs);
|
||||
}
|
||||
|
||||
public async Task<long> InsertReturnBigIdentityAsync(TEntity insertObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertReturnBigIdentityAsync(insertObj);
|
||||
}
|
||||
|
||||
public async Task<TEntity> InsertReturnEntityAsync(TEntity insertObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertReturnEntityAsync(insertObj);
|
||||
}
|
||||
|
||||
public async Task<int> InsertReturnIdentityAsync(TEntity insertObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertReturnIdentityAsync(insertObj);
|
||||
}
|
||||
|
||||
public async Task<long> InsertReturnSnowflakeIdAsync(TEntity insertObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).InsertReturnSnowflakeIdAsync(insertObj);
|
||||
}
|
||||
|
||||
public async Task<bool> IsAnyAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).IsAnyAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(TEntity updateObj)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).UpdateAsync(updateObj);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> whereExpression)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).UpdateAsync(columns, whereExpression);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> UpdateRangeAsync(List<TEntity> updateObjs)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).UpdateRangeAsync(updateObjs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SqlSugarRepository<TEntity, TKey> : SqlSugarRepository<TEntity>, ISqlSugarRepository<TEntity,TKey>, IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>, new()
|
||||
{
|
||||
public SqlSugarRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteByIdAsync(id);
|
||||
}
|
||||
|
||||
public async Task DeleteManyAsync(IEnumerable<TKey> ids, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await DeleteByIdsAsync(ids.Select(x => (object)x).ToArray());
|
||||
}
|
||||
|
||||
public async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetByIdAsync(id);
|
||||
}
|
||||
|
||||
public async Task<TEntity> GetAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetByIdAsync(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Entities.Events;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
public class SqlSugarDbContext : ISqlSugarDbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// SqlSugar 客户端
|
||||
/// </summary>
|
||||
public ISqlSugarClient SqlSugarClient { get; }
|
||||
public ICurrentUser CurrentUser => LazyServiceProvider.GetRequiredService<ICurrentUser>();
|
||||
|
||||
private IAbpLazyServiceProvider LazyServiceProvider { get; }
|
||||
|
||||
private IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetRequiredService<IGuidGenerator>();
|
||||
protected ILoggerFactory Logger => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();
|
||||
private ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService<ICurrentTenant>();
|
||||
public IDataFilter DataFilter => LazyServiceProvider.LazyGetRequiredService<IDataFilter>();
|
||||
protected virtual bool IsMultiTenantFilterEnabled => DataFilter?.IsEnabled<IMultiTenant>() ?? false;
|
||||
|
||||
protected virtual bool IsSoftDeleteFilterEnabled => DataFilter?.IsEnabled<ISoftDelete>() ?? false;
|
||||
|
||||
public IEntityChangeEventHelper EntityChangeEventHelper => LazyServiceProvider.LazyGetService<IEntityChangeEventHelper>(NullEntityChangeEventHelper.Instance);
|
||||
protected DbConnOptions Options => LazyServiceProvider.LazyGetRequiredService<IOptions<DbConnOptions>>().Value;
|
||||
|
||||
public SqlSugarDbContext(IAbpLazyServiceProvider lazyServiceProvider)
|
||||
{
|
||||
LazyServiceProvider = lazyServiceProvider;
|
||||
var dbConnOptions = Options;
|
||||
#region 组装options
|
||||
if (dbConnOptions.DbType is null)
|
||||
{
|
||||
throw new ArgumentException("DbType配置为空");
|
||||
}
|
||||
var slavaConFig = new List<SlaveConnectionConfig>();
|
||||
if (dbConnOptions.EnabledReadWrite)
|
||||
{
|
||||
if (dbConnOptions.ReadUrl is null)
|
||||
{
|
||||
throw new ArgumentException("读写分离为空");
|
||||
}
|
||||
|
||||
var readCon = dbConnOptions.ReadUrl;
|
||||
|
||||
readCon.ForEach(s =>
|
||||
{
|
||||
//如果是动态saas分库,这里的连接串都不能写死,需要动态添加,这里只配置共享库的连接
|
||||
slavaConFig.Add(new SlaveConnectionConfig() { ConnectionString = s });
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
SqlSugarClient = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
//准备添加分表分库
|
||||
DbType = dbConnOptions.DbType ?? DbType.Sqlite,
|
||||
ConnectionString = dbConnOptions.Url,
|
||||
IsAutoCloseConnection = true,
|
||||
SlaveConnectionConfigs = slavaConFig,
|
||||
//设置codefirst非空值判断
|
||||
ConfigureExternalServices = new ConfigureExternalServices
|
||||
{
|
||||
EntityService = (c, p) =>
|
||||
{
|
||||
|
||||
if (new NullabilityInfoContext()
|
||||
.Create(c).WriteState is NullabilityState.Nullable)
|
||||
{
|
||||
p.IsNullable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
db =>
|
||||
{
|
||||
|
||||
db.Aop.DataExecuting = DataExecuting;
|
||||
db.Aop.DataExecuted = DataExecuted;
|
||||
db.Aop.OnLogExecuting = OnLogExecuting;
|
||||
db.Aop.OnLogExecuted = OnLogExecuted;
|
||||
//扩展
|
||||
OnSqlSugarClientConfig(db);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上下文对象扩展
|
||||
/// </summary>
|
||||
/// <param name="sqlSugarClient"></param>
|
||||
protected virtual void OnSqlSugarClientConfig(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
//需自定义扩展
|
||||
if (IsSoftDeleteFilterEnabled)
|
||||
{
|
||||
sqlSugarClient.QueryFilter.AddTableFilter<ISoftDelete>(u => u.IsDeleted == false);
|
||||
}
|
||||
if (IsMultiTenantFilterEnabled)
|
||||
{
|
||||
sqlSugarClient.QueryFilter.AddTableFilter<IMultiTenant>(u => u.TenantId == GuidGenerator.Create());
|
||||
}
|
||||
CustomDataFilter();
|
||||
}
|
||||
protected virtual void CustomDataFilter()
|
||||
{
|
||||
|
||||
}
|
||||
protected virtual void DataExecuted(object oldValue, DataAfterModel entityInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <param name="entityInfo"></param>
|
||||
protected virtual void DataExecuting(object oldValue, DataFilterModel entityInfo)
|
||||
{
|
||||
//审计日志
|
||||
switch (entityInfo.OperationType)
|
||||
{
|
||||
case DataFilterType.UpdateByObject:
|
||||
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
|
||||
{
|
||||
if (!DateTime.MinValue.Equals(oldValue))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
}
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
|
||||
{
|
||||
if (CurrentUser != null)
|
||||
{
|
||||
entityInfo.SetValue(CurrentUser.Id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DataFilterType.InsertByObject:
|
||||
if (entityInfo.PropertyName.Equals(nameof(IEntity<Guid>.Id)))
|
||||
{
|
||||
//主键为空或者为默认最小值
|
||||
if (Guid.Empty.Equals(oldValue))
|
||||
{
|
||||
entityInfo.SetValue(GuidGenerator.Create());
|
||||
}
|
||||
}
|
||||
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
|
||||
{
|
||||
//为空或者为默认最小值
|
||||
if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
}
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
|
||||
{
|
||||
if (CurrentUser != null)
|
||||
{
|
||||
entityInfo.SetValue(CurrentUser.Id);
|
||||
}
|
||||
}
|
||||
|
||||
//插入时,需要租户id,先预留
|
||||
if (entityInfo.PropertyName.Equals(nameof(IMultiTenant.TenantId)))
|
||||
{
|
||||
if (CurrentTenant is not null)
|
||||
{
|
||||
entityInfo.SetValue(CurrentTenant.Id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//领域事件
|
||||
switch (entityInfo.OperationType)
|
||||
{
|
||||
case DataFilterType.InsertByObject:
|
||||
if (entityInfo.PropertyName == nameof(IEntity<object>.Id))
|
||||
{
|
||||
EntityChangeEventHelper.PublishEntityCreatedEvent(entityInfo.EntityValue);
|
||||
}
|
||||
break;
|
||||
case DataFilterType.UpdateByObject:
|
||||
if (entityInfo.PropertyName == nameof(IEntity<object>.Id))
|
||||
{
|
||||
EntityChangeEventHelper.PublishEntityUpdatedEvent(entityInfo.EntityValue);
|
||||
}
|
||||
break;
|
||||
case DataFilterType.DeleteByObject:
|
||||
if (entityInfo.PropertyName == nameof(IEntity<object>.Id))
|
||||
{
|
||||
EntityChangeEventHelper.PublishEntityDeletedEvent(entityInfo.EntityValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="pars"></param>
|
||||
protected virtual void OnLogExecuting(string sql , SugarParameter[] pars)
|
||||
{
|
||||
if (Options.EnabledSqlLog)
|
||||
{
|
||||
Logger.CreateLogger<SqlSugarDbContext>().LogDebug(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="pars"></param>
|
||||
protected virtual void OnLogExecuted(string sql, SugarParameter[] pars)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
public class SqlSugarLogAuditingStore : IAuditingStore, ISingletonDependency
|
||||
{
|
||||
public Task SaveAsync(AuditLogInfo auditInfo)
|
||||
{
|
||||
Console.WriteLine(auditInfo.ExecutionTime);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
public static class SqlsugarCoreExtensions
|
||||
{
|
||||
public static IServiceCollection AddYiDbContext<DbContext>(this IServiceCollection service) where DbContext : class, ISqlSugarDbContext
|
||||
{
|
||||
service.Replace(new ServiceDescriptor(typeof(ISqlSugarDbContext), typeof(DbContext), ServiceLifetime.Scoped));
|
||||
return service;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddYiDbContext<DbContext>(this IServiceCollection service,Action<DbConnOptions> options) where DbContext : class, ISqlSugarDbContext
|
||||
{
|
||||
|
||||
service.Configure<DbConnOptions>(ops => {
|
||||
options.Invoke(ops);
|
||||
});
|
||||
service.AddYiDbContext<DbContext>();
|
||||
return service;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Uow;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Uow
|
||||
{
|
||||
public class SqlSugarDatabaseApi : IDatabaseApi
|
||||
{
|
||||
public ISqlSugarDbContext DbContext { get; }
|
||||
|
||||
public SqlSugarDatabaseApi(ISqlSugarDbContext dbContext)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Volo.Abp.Uow;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Uow
|
||||
{
|
||||
public class SqlSugarTransactionApi : ITransactionApi, ISupportsRollback
|
||||
{
|
||||
private ISqlSugarDbContext _sqlsugarDbContext;
|
||||
|
||||
public SqlSugarTransactionApi(ISqlSugarDbContext sqlsugarDbContext)
|
||||
{
|
||||
_sqlsugarDbContext = sqlsugarDbContext;
|
||||
|
||||
}
|
||||
|
||||
public async Task CommitAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
||||
|
||||
await Console.Out.WriteLineAsync("事务提交");
|
||||
|
||||
Console.WriteLine(_sqlsugarDbContext.SqlSugarClient.ContextID + "---------------");
|
||||
await _sqlsugarDbContext.SqlSugarClient.Ado.CommitTranAsync();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Console.WriteLine("Dispose");
|
||||
}
|
||||
|
||||
public async Task RollbackAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("事务回滚");
|
||||
Console.WriteLine(_sqlsugarDbContext.SqlSugarClient.ContextID);
|
||||
await _sqlsugarDbContext.SqlSugarClient.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.Threading;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore.Uow
|
||||
{
|
||||
public class UnitOfWorkSqlsugarDbContextProvider<TDbContext> : ISugarDbContextProvider<TDbContext> where TDbContext : ISqlSugarDbContext
|
||||
{
|
||||
|
||||
public ILogger<UnitOfWorkSqlsugarDbContextProvider<TDbContext>> Logger { get; set; }
|
||||
|
||||
protected readonly IUnitOfWorkManager UnitOfWorkManager;
|
||||
protected readonly IConnectionStringResolver ConnectionStringResolver;
|
||||
protected readonly ICancellationTokenProvider CancellationTokenProvider;
|
||||
protected readonly ICurrentTenant CurrentTenant;
|
||||
|
||||
public UnitOfWorkSqlsugarDbContextProvider(
|
||||
IUnitOfWorkManager unitOfWorkManager,
|
||||
IConnectionStringResolver connectionStringResolver,
|
||||
ICancellationTokenProvider cancellationTokenProvider,
|
||||
ICurrentTenant currentTenant
|
||||
)
|
||||
{
|
||||
UnitOfWorkManager = unitOfWorkManager;
|
||||
ConnectionStringResolver = connectionStringResolver;
|
||||
CancellationTokenProvider = cancellationTokenProvider;
|
||||
CurrentTenant = currentTenant;
|
||||
Logger = NullLogger<UnitOfWorkSqlsugarDbContextProvider<TDbContext>>.Instance;
|
||||
}
|
||||
|
||||
public virtual async Task<TDbContext> GetDbContextAsync()
|
||||
{
|
||||
|
||||
var unitOfWork = UnitOfWorkManager.Current;
|
||||
if (unitOfWork == null)
|
||||
{
|
||||
throw new AbpException("A DbContext can only be created inside a unit of work!");
|
||||
}
|
||||
//var sss= unitOfWork.ServiceProvider.GetRequiredService<TDbContext>();
|
||||
//Console.WriteLine("反户的:"+sss.SqlSugarClient.ContextID);
|
||||
//return sss;
|
||||
|
||||
|
||||
var connectionStringName = "Default";
|
||||
var connectionString = await ResolveConnectionStringAsync(connectionStringName);
|
||||
// var dbContextKey = $"{this.GetType().FullName}_{connectionString}";
|
||||
var dbContextKey = "Default";
|
||||
var databaseApi = unitOfWork.FindDatabaseApi(dbContextKey);
|
||||
|
||||
if (databaseApi == null)
|
||||
{
|
||||
databaseApi = new SqlSugarDatabaseApi(
|
||||
await CreateDbContextAsync(unitOfWork, connectionStringName, connectionString)
|
||||
);
|
||||
unitOfWork.AddDatabaseApi(dbContextKey, databaseApi);
|
||||
|
||||
}
|
||||
return (TDbContext)((SqlSugarDatabaseApi)databaseApi).DbContext; ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual async Task<TDbContext> CreateDbContextAsync(IUnitOfWork unitOfWork, string connectionStringName, string connectionString)
|
||||
{
|
||||
|
||||
var dbContext = await CreateDbContextAsync(unitOfWork);
|
||||
Console.WriteLine("111111:" + dbContext.SqlSugarClient.ContextID);
|
||||
return dbContext;
|
||||
}
|
||||
|
||||
protected virtual async Task<TDbContext> CreateDbContextAsync(IUnitOfWork unitOfWork)
|
||||
{
|
||||
return unitOfWork.Options.IsTransactional
|
||||
? await CreateDbContextWithTransactionAsync(unitOfWork)
|
||||
: unitOfWork.ServiceProvider.GetRequiredService<TDbContext>();
|
||||
}
|
||||
protected virtual async Task<TDbContext> CreateDbContextWithTransactionAsync(IUnitOfWork unitOfWork)
|
||||
{
|
||||
var transactionApiKey = $"Sqlsugar_Default".ToString();
|
||||
|
||||
var activeTransaction = unitOfWork.FindTransactionApi(transactionApiKey) as SqlSugarDatabaseApi;
|
||||
if (activeTransaction == null)
|
||||
{
|
||||
|
||||
var dbContext = unitOfWork.ServiceProvider.GetRequiredService<TDbContext>();
|
||||
var transaction = new SqlSugarTransactionApi(
|
||||
dbContext
|
||||
);
|
||||
unitOfWork.AddTransactionApi(transactionApiKey, transaction);
|
||||
|
||||
|
||||
await Console.Out.WriteLineAsync("开始新的事务");
|
||||
Console.WriteLine(dbContext.SqlSugarClient.ContextID);
|
||||
await dbContext.SqlSugarClient.Ado.BeginTranAsync();
|
||||
return dbContext;
|
||||
}
|
||||
else
|
||||
{
|
||||
await Console.Out.WriteLineAsync("继续老的事务");
|
||||
Console.WriteLine(activeTransaction.DbContext.SqlSugarClient);
|
||||
await activeTransaction.DbContext.SqlSugarClient.Ado.BeginTranAsync();
|
||||
return (TDbContext)activeTransaction.DbContext;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected virtual async Task<string> ResolveConnectionStringAsync(string connectionStringName)
|
||||
{
|
||||
if (typeof(TDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
|
||||
{
|
||||
using (CurrentTenant.Change(null))
|
||||
{
|
||||
return await ConnectionStringResolver.ResolveAsync(connectionStringName);
|
||||
}
|
||||
}
|
||||
|
||||
return await ConnectionStringResolver.ResolveAsync(connectionStringName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.124" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.SqlSugarCore.Abstractions\Yi.Framework.SqlSugarCore.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.SqlSugarCore</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.Url">
|
||||
<summary>
|
||||
连接字符串,必填
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.DbType">
|
||||
<summary>
|
||||
数据库类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.EnabledDbSeed">
|
||||
<summary>
|
||||
开启种子数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.EnabledReadWrite">
|
||||
<summary>
|
||||
开启读写分离
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.EnabledCodeFirst">
|
||||
<summary>
|
||||
开启codefirst
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.EnabledSqlLog">
|
||||
<summary>
|
||||
开启sql日志
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.EntityAssembly">
|
||||
<summary>
|
||||
实体程序集
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.DbConnOptions.ReadUrl">
|
||||
<summary>
|
||||
读写分离
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.Repositories.SqlSugarRepository`1.GetDbContextAsync">
|
||||
<summary>
|
||||
获取DB
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.Repositories.SqlSugarRepository`1.GetDbSimpleClientAsync">
|
||||
<summary>
|
||||
获取简单Db
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:Yi.Framework.SqlSugarCore.SqlSugarDbContext.SqlSugarClient">
|
||||
<summary>
|
||||
SqlSugar 客户端
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.SqlSugarDbContext.OnSqlSugarClientConfig(SqlSugar.ISqlSugarClient)">
|
||||
<summary>
|
||||
上下文对象扩展
|
||||
</summary>
|
||||
<param name="sqlSugarClient"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.SqlSugarDbContext.DataExecuting(System.Object,SqlSugar.DataFilterModel)">
|
||||
<summary>
|
||||
数据
|
||||
</summary>
|
||||
<param name="oldValue"></param>
|
||||
<param name="entityInfo"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.SqlSugarDbContext.OnLogExecuting(System.String,SqlSugar.SugarParameter[])">
|
||||
<summary>
|
||||
日志
|
||||
</summary>
|
||||
<param name="sql"></param>
|
||||
<param name="pars"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.SqlSugarCore.SqlSugarDbContext.OnLogExecuted(System.String,SqlSugar.SugarParameter[])">
|
||||
<summary>
|
||||
日志
|
||||
</summary>
|
||||
<param name="sql"></param>
|
||||
<param name="pars"></param>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Domain;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
using Yi.Framework.SqlSugarCore.Repositories;
|
||||
using Yi.Framework.SqlSugarCore.Uow;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
[DependsOn(typeof(AbpDddDomainModule))]
|
||||
public class YiFrameworkSqlSugarCoreModule : AbpModule
|
||||
{
|
||||
public override Task ConfigureServicesAsync(ServiceConfigurationContext context)
|
||||
{
|
||||
var service = context.Services;
|
||||
var configuration = service.GetConfiguration();
|
||||
Configure<DbConnOptions>(configuration.GetSection("DbConnOptions"));
|
||||
|
||||
|
||||
service.TryAddScoped<ISqlSugarDbContext, SqlSugarDbContext>();
|
||||
|
||||
//不开放sqlsugarClient
|
||||
//service.AddTransient<ISqlSugarClient>(x => x.GetRequiredService<ISqlsugarDbContext>().SqlSugarClient);
|
||||
|
||||
|
||||
service.AddTransient(typeof(IRepository<>), typeof(SqlSugarRepository<>));
|
||||
service.AddTransient(typeof(IRepository<,>), typeof(SqlSugarRepository<,>));
|
||||
service.AddTransient(typeof(ISqlSugarRepository<>), typeof(SqlSugarRepository<>));
|
||||
service.AddTransient(typeof(ISqlSugarRepository<,>), typeof(SqlSugarRepository<,>));
|
||||
|
||||
service.AddTransient<IAuditingStore, SqlSugarLogAuditingStore>();
|
||||
|
||||
service.AddTransient(typeof(ISugarDbContextProvider<>), typeof(UnitOfWorkSqlsugarDbContextProvider<>));
|
||||
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
|
||||
{
|
||||
var service = context.ServiceProvider;
|
||||
return base.OnApplicationInitializationAsync(context);
|
||||
}
|
||||
|
||||
|
||||
public override async void OnPreApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
//进行CodeFirst
|
||||
var service = context.ServiceProvider;
|
||||
var options = service.GetRequiredService<IOptions<DbConnOptions>>().Value;
|
||||
|
||||
if (options.EnabledCodeFirst)
|
||||
{
|
||||
CodeFirst(service);
|
||||
}
|
||||
if (options.EnabledCodeFirst)
|
||||
{
|
||||
await DataSeedAsync(service);
|
||||
}
|
||||
}
|
||||
|
||||
private void CodeFirst(IServiceProvider service)
|
||||
{
|
||||
|
||||
var options = service.GetRequiredService<IOptions<DbConnOptions>>().Value;
|
||||
if (options.EnabledCodeFirst)
|
||||
{
|
||||
var moduleContainer = service.GetRequiredService<IModuleContainer>();
|
||||
var db = service.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient;
|
||||
|
||||
List<Type> types = new List<Type>();
|
||||
foreach (var module in moduleContainer.Modules)
|
||||
{
|
||||
types.AddRange(module.Assembly.GetTypes().Where(x => x.GetCustomAttribute<SugarTable>() != null).Where(x => x.GetCustomAttribute<SplitTableAttribute>() is null));
|
||||
}
|
||||
if (types.Count > 0)
|
||||
{
|
||||
db.CodeFirst.InitTables(types.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DataSeedAsync(IServiceProvider service)
|
||||
{
|
||||
var dataSeeder = service.GetRequiredService<IDataSeeder>();
|
||||
await dataSeeder.SeedAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.AccessLog
|
||||
{
|
||||
public class AccessLogDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public long Number { get; set; }
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Argee
|
||||
{
|
||||
public class AgreeDto
|
||||
{
|
||||
public AgreeDto(bool isAgree)
|
||||
{
|
||||
IsAgree = isAgree;
|
||||
if (isAgree)
|
||||
{
|
||||
|
||||
Message = "点赞成功,点赞+1";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Message = "取消点赞,点赞-1";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsAgree { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleAllOutputDto : EntityDto<Guid>
|
||||
{
|
||||
|
||||
//批量查询,不给内容,性能考虑
|
||||
//public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<ArticleAllOutputDto>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
/// <summary>
|
||||
/// Article输入创建对象
|
||||
/// </summary>
|
||||
public class ArticleCreateInputVo
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public string? Content { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public Guid? DiscussId { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleGetListOutputDto : EntityDto<Guid>
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
//public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
public List<ArticleGetListOutputDto>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleGetOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleUpdateInputVo
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Banner
|
||||
{
|
||||
/// <summary>
|
||||
/// Banner输入创建对象
|
||||
/// </summary>
|
||||
public class BannerCreateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
public string? Color { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Banner
|
||||
{
|
||||
public class BannerGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Banner
|
||||
{
|
||||
public class BannerGetListOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Banner
|
||||
{
|
||||
public class BannerGetOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Banner
|
||||
{
|
||||
public class BannerUpdateInputVo
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
public string? Color { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
|
||||
{
|
||||
/// <summary>
|
||||
/// Comment输入创建对象
|
||||
/// </summary>
|
||||
public class CommentCreateInputVo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 评论id
|
||||
/// </summary>
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主题id
|
||||
/// </summary>
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第一层评论id,第一层为0
|
||||
/// </summary>
|
||||
public Guid RootId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 被回复的CommentId,第一层为0
|
||||
/// </summary>
|
||||
public Guid ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
|
||||
{
|
||||
public class CommentGetListInputVo
|
||||
{
|
||||
public DateTime? creationTime { get; set; }
|
||||
public string? Content { get; set; }
|
||||
|
||||
//Ӧ<><D3A6>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ī<EFBFBD><C4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ
|
||||
public Guid? DiscussId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>۶෴
|
||||
/// </summary>
|
||||
public class CommentGetListOutputDto : EntityDto<Guid>
|
||||
{
|
||||
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>id
|
||||
/// </summary>
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public Guid RootId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
|
||||
/// </summary>
|
||||
public UserGetOutputDto CreateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><DBB5>û<EFBFBD><C3BB><EFBFBD>Ϣ
|
||||
/// </summary>
|
||||
public UserGetOutputDto CommentedUser { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD>飬<EFBFBD><E9A3AC>Childrenֻ<6E><D6BB><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>
|
||||
/// </summary>
|
||||
public List<CommentGetListOutputDto> Children { get; set; } = new List<CommentGetListOutputDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD><DBBC><EFBFBD>
|
||||
/// </summary>
|
||||
public class CommentGetOutputDto : EntityDto<Guid>
|
||||
{
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD>id<69><64><EFBFBD><EFBFBD>Ϊ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
|
||||
public UserGetOutputDto User { get; set; }
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id
|
||||
/// </summary>
|
||||
public Guid RootId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>CommentId
|
||||
/// </summary>
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user