commit
91080ee029
62 changed files with 5748 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||||
|
**/.classpath |
||||||
|
**/.dockerignore |
||||||
|
**/.env |
||||||
|
**/.git |
||||||
|
**/.gitignore |
||||||
|
**/.project |
||||||
|
**/.settings |
||||||
|
**/.toolstarget |
||||||
|
**/.vs |
||||||
|
**/.vscode |
||||||
|
**/*.*proj.user |
||||||
|
**/*.dbmdl |
||||||
|
**/*.jfm |
||||||
|
**/azds.yaml |
||||||
|
**/bin |
||||||
|
**/charts |
||||||
|
**/docker-compose* |
||||||
|
**/Dockerfile* |
||||||
|
**/node_modules |
||||||
|
**/npm-debug.log |
||||||
|
**/obj |
||||||
|
**/secrets.dev.yaml |
||||||
|
**/values.dev.yaml |
||||||
|
LICENSE |
||||||
|
README.md |
@ -0,0 +1,3 @@ |
|||||||
|
{ |
||||||
|
"help":"https://go.microsoft.com/fwlink/?linkid=866610" |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
# ---> C |
||||||
|
# Prerequisites |
||||||
|
*.d |
||||||
|
|
||||||
|
# Object files |
||||||
|
*.o |
||||||
|
*.ko |
||||||
|
*.obj |
||||||
|
*.elf |
||||||
|
|
||||||
|
# Linker output |
||||||
|
*.ilk |
||||||
|
*.map |
||||||
|
*.exp |
||||||
|
|
||||||
|
# Precompiled Headers |
||||||
|
*.gch |
||||||
|
*.pch |
||||||
|
|
||||||
|
# Libraries |
||||||
|
*.lib |
||||||
|
*.a |
||||||
|
*.la |
||||||
|
*.lo |
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs) |
||||||
|
*.dll |
||||||
|
*.so |
||||||
|
*.so.* |
||||||
|
*.dylib |
||||||
|
|
||||||
|
# Executables |
||||||
|
*.exe |
||||||
|
*.out |
||||||
|
*.app |
||||||
|
*.i*86 |
||||||
|
*.x86_64 |
||||||
|
*.hex |
||||||
|
|
||||||
|
# Debug files |
||||||
|
*.dSYM/ |
||||||
|
*.su |
||||||
|
*.idb |
||||||
|
*.pdb |
||||||
|
|
||||||
|
# Kernel Module Compile Results |
||||||
|
*.mod* |
||||||
|
*.cmd |
||||||
|
.tmp_versions/ |
||||||
|
modules.order |
||||||
|
Module.symvers |
||||||
|
Mkfile.old |
||||||
|
dkms.conf |
||||||
|
|
||||||
|
/.vs |
||||||
|
/24Hour/bin |
||||||
|
/24Hour/obj |
||||||
|
/Elight.Entity/bin |
||||||
|
/Elight.Entity/obj |
||||||
|
/Elight.Logic/bin |
||||||
|
/Elight.Logic/obj |
||||||
|
/Elight.Utility/bin |
||||||
|
/Elight.Utility/obj |
||||||
|
/Elight.Utility/Extension/ServiceConverter.cs |
||||||
|
/24Hour/wwwroot/File |
||||||
|
/24Hour/wwwroot/CaseFile/User |
||||||
|
/24Hour/wwwroot/CaseFile/Detectionscheme/~$230301193901426.docx |
||||||
|
/24Hour/wwwroot/CaseFile/Detectionscheme/20230301195021869.docx |
||||||
|
/24Hour/wwwroot/CaseFile/Detectionscheme/20230301194942291.docx |
||||||
|
/24Hour/wwwroot/CaseFile/Detectionscheme/20230301193901426.docx |
||||||
|
/24Hour/24Hour.xml |
@ -0,0 +1,43 @@ |
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||||
|
# Visual Studio Version 17 |
||||||
|
VisualStudioVersion = 17.3.32901.215 |
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1 |
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "24Hour", "24Hour\24Hour.csproj", "{9CC60D58-CC75-4BF7-A854-3220E725CD8C}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Entity", "Elight.Entity\Elight.Entity.csproj", "{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Logic", "Elight.Logic\Elight.Logic.csproj", "{DE4F1117-9E0E-4570-885A-3E852CB96CB9}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Utility", "Elight.Utility\Elight.Utility.csproj", "{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}" |
||||||
|
EndProject |
||||||
|
Global |
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||||
|
Debug|Any CPU = Debug|Any CPU |
||||||
|
Release|Any CPU = Release|Any CPU |
||||||
|
EndGlobalSection |
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||||
|
{9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||||
|
{9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||||
|
{9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||||
|
{9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Release|Any CPU.Build.0 = Release|Any CPU |
||||||
|
{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||||
|
{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||||
|
{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||||
|
{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Release|Any CPU.Build.0 = Release|Any CPU |
||||||
|
{DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||||
|
{DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||||
|
{DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||||
|
{DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Release|Any CPU.Build.0 = Release|Any CPU |
||||||
|
{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||||
|
{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||||
|
{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||||
|
{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Release|Any CPU.Build.0 = Release|Any CPU |
||||||
|
EndGlobalSection |
||||||
|
GlobalSection(SolutionProperties) = preSolution |
||||||
|
HideSolutionNode = FALSE |
||||||
|
EndGlobalSection |
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution |
||||||
|
SolutionGuid = {DF93D9CD-387C-4698-B374-B03D65624202} |
||||||
|
EndGlobalSection |
||||||
|
EndGlobal |
@ -0,0 +1,22 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net6.0</TargetFramework> |
||||||
|
<Nullable>enable</Nullable> |
||||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||||
|
<RootNamespace>_24Hour</RootNamespace> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.16" /> |
||||||
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.83" /> |
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\Elight.Entity\Elight.Entity.csproj" /> |
||||||
|
<ProjectReference Include="..\Elight.Logic\Elight.Logic.csproj" /> |
||||||
|
<ProjectReference Include="..\Elight.Utility\Elight.Utility.csproj" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID> |
||||||
|
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> |
||||||
|
</PropertyGroup> |
||||||
|
</Project> |
@ -0,0 +1,200 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Logic; |
||||||
|
using Elight.Utility; |
||||||
|
using Elight.Utility.Code; |
||||||
|
using Elight.Utility.Extensions; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using SqlSugar; |
||||||
|
|
||||||
|
namespace _24Hour.Controllers.Common |
||||||
|
{ |
||||||
|
[Authorize] |
||||||
|
[ApiController] |
||||||
|
[Route("api/reception")] |
||||||
|
public class ReservationController : Controller |
||||||
|
{ |
||||||
|
#region Identity |
||||||
|
private readonly SqlSugarClient _db;//数据库 |
||||||
|
private readonly WriteSysLog _logs;//操作日志 |
||||||
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
||||||
|
private readonly ILogger<LoginController> _logger;//日志 |
||||||
|
Result result = new Result(); |
||||||
|
public ReservationController(ILogger<LoginController> logger, SqlSugarClient db, WriteSysLog logs, User user) |
||||||
|
{ |
||||||
|
_logger = logger; |
||||||
|
_db = db; |
||||||
|
_logs = logs; |
||||||
|
_userdata = user.Userdata(); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
|
||||||
|
#region 预约接待管理 |
||||||
|
/// <summary> |
||||||
|
/// 预约接待分页查询 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("QueryReception")] |
||||||
|
public async Task<Result> QueryReception(App_ReceptionInput Reception) |
||||||
|
{ |
||||||
|
var Receptionlist = new List<App_ReceptionModel>(); |
||||||
|
//获取工作台信息 |
||||||
|
var app_staging = await _db.Queryable<StagingModel>().Where(w => w.IsDelete == 0).ToListAsync(); |
||||||
|
//查询预约接待记录 |
||||||
|
var list = await _db.Queryable<App_ReceptionModel>() |
||||||
|
.WhereIF(!string.IsNullOrEmpty(Reception.depart), q => q.depart.Contains(Reception.depart)) |
||||||
|
.WhereIF(!string.IsNullOrEmpty(Reception.createusername), q => q.createusername.Contains(Reception.createusername)) |
||||||
|
.WhereIF(!string.IsNullOrEmpty(Reception.receptionId), q => q.receptionId.Contains(Reception.receptionId)) |
||||||
|
.WhereIF(Reception.state != null, q => q.state == Reception.state) |
||||||
|
.Where(q => q.IsDelete == 0).ToPageListAsync(Reception.PageIndex, Reception.PageSize); |
||||||
|
list.ForEach(q => |
||||||
|
{ |
||||||
|
var data = app_staging.Where(a => a.Id == q.receptionId).First(); |
||||||
|
if (data != null) |
||||||
|
{ |
||||||
|
q.receptionId = data.title; |
||||||
|
Receptionlist.Add(q); |
||||||
|
} |
||||||
|
}); |
||||||
|
var data = new QueryResult<App_ReceptionModel>(Reception, Receptionlist.OrderByDescending(q => q.creationtime).ToList()); |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = data; |
||||||
|
return result; |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// 添加预约接待 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("AddReception")] |
||||||
|
public async Task<Result> AddReception(App_ReceptionModel Receptiondata) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
Receptiondata.Id = Guid.NewGuid().ToString(); |
||||||
|
Receptiondata.createuserId = _userdata.Id.ToString(); |
||||||
|
Receptiondata.createusername = _userdata.name; |
||||||
|
var num = await _db.Insertable(Receptiondata).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "添加成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("预约管理", "添加预约接待信息", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 修改预约接待 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("UpdateReception")] |
||||||
|
public async Task<Result> UpdateReception(App_ReceptionModel Receptiondata) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
var num = await _db.Updateable(Receptiondata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "修改成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("预约管理", "修改预约接待", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 删除预约接待 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("DeleteReception")] |
||||||
|
public async Task<Result> DeleteReception(CurrencyDelete Currency) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
var Receptionlist = await _db.Queryable<App_ReceptionModel>().In(q => q.Id, Currency.id).ToListAsync(); |
||||||
|
Receptionlist.ForEach(q => |
||||||
|
{ |
||||||
|
q.IsDelete = 1; |
||||||
|
}); |
||||||
|
var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "删除成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("预约管理", "删除预约接待", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 办理预约接待 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("UpdateReception_state")] |
||||||
|
public async Task<Result> UpdateReception_state(CurrencyDelete Currency) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
var Receptionlist = await _db.Queryable<App_ReceptionModel>().Where(q => Currency.id.Contains(q.Id)).ToListAsync(); |
||||||
|
Receptionlist.ForEach(q => { q.state = 1; }); |
||||||
|
_db.BeginTran(); |
||||||
|
var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "办理成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("预约管理", "办理预约接待", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,243 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Logic; |
||||||
|
using Elight.Utility; |
||||||
|
using Elight.Utility.Code; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using SqlSugar; |
||||||
|
|
||||||
|
namespace _24Hour.Controllers.Common |
||||||
|
{ |
||||||
|
[Authorize] |
||||||
|
[ApiController] |
||||||
|
[Route("api/Staging")] |
||||||
|
public class StagingController : Controller |
||||||
|
{ |
||||||
|
#region Identity |
||||||
|
private readonly SqlSugarClient _db;//数据库 |
||||||
|
private readonly WriteSysLog _logs;//操作日志 |
||||||
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
||||||
|
private readonly ILogger<LoginController> _logger;//日志 |
||||||
|
Result result = new Result(); |
||||||
|
public StagingController(ILogger<LoginController> logger, SqlSugarClient db, WriteSysLog logs, User user) |
||||||
|
{ |
||||||
|
_logger = logger; |
||||||
|
_db = db; |
||||||
|
_logs = logs; |
||||||
|
_userdata = user.Userdata(); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region 工作台管理 |
||||||
|
/// <summary> |
||||||
|
/// 工作台分页查询 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("QueryStaging")] |
||||||
|
public async Task<Result> QueryStaging(StagingInput Staging) |
||||||
|
{ |
||||||
|
var list = await _db.Queryable<StagingModel>() |
||||||
|
.WhereIF(!string.IsNullOrEmpty(Staging.title), q => q.title.Contains(Staging.title)) |
||||||
|
.WhereIF(!string.IsNullOrEmpty(Staging.titletype), q => q.titletype.Contains(Staging.titletype)) |
||||||
|
.Where(q => q.IsDelete == 0).ToPageListAsync(Staging.PageIndex, Staging.PageSize); |
||||||
|
var data = new QueryResult<StagingModel>(Staging, list); |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = data; |
||||||
|
return result; |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// 添加工作台 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("AddStaging")] |
||||||
|
public async Task<Result> AddStaging(StagingModel Stagingdata) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
Stagingdata.Id = Guid.NewGuid().ToString(); |
||||||
|
Stagingdata.userId = _userdata.Id.ToString(); |
||||||
|
Stagingdata.username = _userdata.name; |
||||||
|
var num = await _db.Insertable(Stagingdata).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "添加成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("工作台添加", "添加工作台", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 修改工作台 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("UpdateStaging")] |
||||||
|
public async Task<Result> UpdateStaging(StagingModel Stagingdata) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
var num = await _db.Updateable(Stagingdata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "修改成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("工作台", "修改工作台信息", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 删除工作台 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpPost] |
||||||
|
[Route("DeleteStaging")] |
||||||
|
public async Task<Result> DeleteStaging(CurrencyDelete Currency) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
var Staginglist = await _db.Queryable<StagingModel>().In(q => q.Id, Currency.id).ToListAsync(); |
||||||
|
Staginglist.ForEach(q => |
||||||
|
{ |
||||||
|
q.IsDelete = 1; |
||||||
|
}); |
||||||
|
var num = await _db.Updateable(Staginglist).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = "删除成功"; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("工作台", "删除工作台信息", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 添加工作台使用次数 |
||||||
|
/// </summary> |
||||||
|
/// <param name="info"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpGet] |
||||||
|
[Route("AddStagingnum")] |
||||||
|
public async Task<Result> AddStagingnum(string id) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
var Stagingdata = await _db.Queryable<StagingModel>().Where(q => q.Id == id).FirstAsync(); |
||||||
|
if (Stagingdata != null) |
||||||
|
{ |
||||||
|
var Stagingnumdata = await _db.Queryable<StagingNumModel>().Where(q => q.userId == _userdata.Id.ToString() && q.stagingId == id).FirstAsync(); |
||||||
|
if (Stagingnumdata != null) |
||||||
|
{ |
||||||
|
Stagingnumdata.num++; |
||||||
|
Stagingnumdata.creationtime = DateTime.Now; |
||||||
|
_db.BeginTran(); |
||||||
|
var num = await _db.Updateable(Stagingnumdata).UpdateColumns(it => new { it.num }).ExecuteCommandAsync(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = ""; |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
_db.BeginTran(); |
||||||
|
var da = new StagingNumModel(); |
||||||
|
da.Id = Guid.NewGuid().ToString(); |
||||||
|
da.stagingId = id; |
||||||
|
da.num = 1; |
||||||
|
da.userId = _userdata.Id; |
||||||
|
da.username = _userdata.name; |
||||||
|
var num = _db.Insertable(da).ExecuteCommand(); |
||||||
|
_db.CommitTran(); |
||||||
|
if (num > 0) |
||||||
|
{ |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = ""; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
catch (System.Exception ex) |
||||||
|
{ |
||||||
|
_db.RollbackTran(); |
||||||
|
result.IsSucceed = false; |
||||||
|
result.Message = ex.Message; |
||||||
|
} |
||||||
|
_logs.WriteSysLogadd("工作台_使用数据", "更新或则添加使用次数", result,_db); |
||||||
|
return result; |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// 获取工作台信息 |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpGet] |
||||||
|
[Route("GetStaginglist")] |
||||||
|
public async Task<Result> GetStaginglist() |
||||||
|
{ |
||||||
|
var nulist = new List<StagingModel>(); |
||||||
|
var Staginglist = await _db.Queryable<StagingModel>().Where(q => q.IsDelete == 0).ToListAsync(); |
||||||
|
var Staginggrlist = Staginglist.GroupBy(q => q.titletype).Select(x => new { type = x.Key, data = x.ToList() }).ToList(); |
||||||
|
var Numlist = await _db.Queryable<StagingNumModel>().Where(q => q.IsDelete == 0 && q.userId == _userdata.Id).ToListAsync(); |
||||||
|
if (Numlist.Count > 0) |
||||||
|
{ |
||||||
|
//获取常用工作台菜单 |
||||||
|
var da = Numlist.OrderByDescending(q => q.creationtime).Take(10).Select(q => q.stagingId); |
||||||
|
var dalist = Staginglist.Where(q => da.Contains(q.Id)).ToList(); |
||||||
|
Staginggrlist.Insert(0, new { type = "我的", data = dalist }); |
||||||
|
|
||||||
|
//获取使用次数最多4个常用工作台菜单 |
||||||
|
var Numda = Numlist.OrderByDescending(q => q.num).Take(4).Select(q => q.stagingId); |
||||||
|
nulist = Staginglist.Where(q => Numda.Contains(q.Id)).ToList(); |
||||||
|
nulist.AddRange(Staginglist.Where(q => !Numda.Contains(q.Id)).Take(4 - nulist.Count()).ToList()); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
nulist = Staginglist.Take(4).ToList(); |
||||||
|
} |
||||||
|
result.IsSucceed = true; |
||||||
|
result.result = new { typelist = Staginggrlist, numlist = nulist }; |
||||||
|
return result; |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
|
||||||
|
namespace _24Hour.Controllers.Common |
||||||
|
{ |
||||||
|
[Authorize] |
||||||
|
public class WebSocketController : Controller |
||||||
|
{ |
||||||
|
[HttpGet("/ws")] |
||||||
|
public async Task WebSocketServer() |
||||||
|
{ |
||||||
|
if (HttpContext.WebSockets.IsWebSocketRequest) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
var socket = await HttpContext.WebSockets.AcceptWebSocketAsync(); |
||||||
|
} |
||||||
|
catch (Exception ex) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,189 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Utility.Code; |
||||||
|
using Elight.Utility.Encrypt; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.Extensions.Configuration; |
||||||
|
using Microsoft.IdentityModel.Tokens; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using SqlSugar; |
||||||
|
using System.IdentityModel.Tokens.Jwt; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Security.Claims; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace _24Hour.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 登录 |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
[Route("api/Login")] |
||||||
|
public class LoginController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly IConfiguration _configuration; |
||||||
|
private readonly SqlSugarClient _db;//数据库 |
||||||
|
private readonly ILogger<LoginController> _logger;//日志 |
||||||
|
Result ret = new Result(); |
||||||
|
public LoginController(ILogger<LoginController> logger, SqlSugarClient db, IConfiguration configuration) |
||||||
|
{ |
||||||
|
_logger = logger; |
||||||
|
_db = db; |
||||||
|
_configuration = configuration; |
||||||
|
} |
||||||
|
[HttpPost] |
||||||
|
[Route("Login")] |
||||||
|
public async Task<Result> Login(UserLogin login) |
||||||
|
{ |
||||||
|
var Passmd5 = Md5.Encrypt32(login.Password).ToLower(); |
||||||
|
var date = await _db.Queryable<App_Sys_UserModel>().Where(q => q.IsDeleted == 0 && q.isdeactivate == 0 && q.phone == login.phone).FirstAsync(); |
||||||
|
if (date != null) |
||||||
|
{ |
||||||
|
if (Passmd5 != date.Password) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = "账号或则密码错误!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
else if (date.usertype == 1 && date.audit == null) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = "账号审核中!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
else if (date.usertype == 1 && date.audit == 1) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = $"账号审核未通过,原因:{date.describe}!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
else if (date.usertype == 0 && date.becurrent == 1) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = $"账号未授权无法登录,请联系管理员!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
#region jwt生成token |
||||||
|
var tokenHandler = new JwtSecurityTokenHandler(); |
||||||
|
var claims =new Claim[] |
||||||
|
{ |
||||||
|
new Claim(ClaimTypes.UserData,JsonConvert.SerializeObject(date)), |
||||||
|
}; |
||||||
|
|
||||||
|
var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_configuration.GetSection("JwtConfiguration:Jwtkey").Value)); |
||||||
|
var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); |
||||||
|
//Token |
||||||
|
var jwttoken = new JwtSecurityToken( |
||||||
|
issuer: "https://127.0.0.1:7246", |
||||||
|
audience: "https://127.0.0.1:7246", |
||||||
|
claims: claims, |
||||||
|
notBefore: DateTime.Now, |
||||||
|
expires: DateTime.Now.AddDays(1), |
||||||
|
signingCredentials: signingCredentials |
||||||
|
); |
||||||
|
//var token = new JwtSecurityTokenHandler().CreateToken(jwttoken); |
||||||
|
var tokenString = new JwtSecurityTokenHandler().WriteToken(jwttoken); |
||||||
|
ret.result = new |
||||||
|
{ |
||||||
|
name = date.name, |
||||||
|
sex = date.sex, |
||||||
|
phone = date.phone, |
||||||
|
photo = date.photo, |
||||||
|
duties = date.duties, |
||||||
|
unitCode = "", |
||||||
|
department = "", |
||||||
|
token = tokenString |
||||||
|
}; |
||||||
|
#endregion |
||||||
|
ret.IsSucceed = true; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = "账号不存在!"; |
||||||
|
} |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 微信授权登录 |
||||||
|
/// </summary> |
||||||
|
/// <param name="openId"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpGet] |
||||||
|
[Route("WeChatLogin")] |
||||||
|
public async Task<Result> WeChatLogin(string openId) |
||||||
|
{ |
||||||
|
var date = await _db.Queryable<App_Sys_UserModel>().Where(q => q.IsDeleted == 0 && q.isdeactivate == 0 && q.wechatId == openId).FirstAsync(); |
||||||
|
if (date != null) |
||||||
|
{ |
||||||
|
if (date.usertype == 1 && date.audit == null) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = "账号审核中!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
else if (date.usertype == 1 && date.audit == 1) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = $"账号审核未通过,原因:{date.describe}!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
else if (date.usertype == 0 && date.becurrent == 1) |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = $"账号未授权无法登录,请联系管理员!"; |
||||||
|
return ret; |
||||||
|
} |
||||||
|
#region jwt生成token |
||||||
|
var tokenHandler = new JwtSecurityTokenHandler(); |
||||||
|
var claims = new Claim[] |
||||||
|
{ |
||||||
|
new Claim(ClaimTypes.UserData,JsonConvert.SerializeObject(date)), |
||||||
|
}; |
||||||
|
|
||||||
|
var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_configuration.GetSection("JwtConfiguration:Jwtkey").Value)); |
||||||
|
var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); |
||||||
|
//Token |
||||||
|
var jwttoken = new JwtSecurityToken( |
||||||
|
issuer: "https://127.0.0.1:7246", |
||||||
|
audience: "https://127.0.0.1:7246", |
||||||
|
claims: claims, |
||||||
|
notBefore: DateTime.Now, |
||||||
|
expires: DateTime.Now.AddDays(1), |
||||||
|
signingCredentials: signingCredentials |
||||||
|
); |
||||||
|
//var token = new JwtSecurityTokenHandler().CreateToken(jwttoken); |
||||||
|
var tokenString = new JwtSecurityTokenHandler().WriteToken(jwttoken); |
||||||
|
ret.result = new |
||||||
|
{ |
||||||
|
name = date.name, |
||||||
|
sex = date.sex, |
||||||
|
phone = date.phone, |
||||||
|
photo = date.photo, |
||||||
|
duties = date.duties, |
||||||
|
unitCode = "", |
||||||
|
department = "", |
||||||
|
token = tokenString |
||||||
|
}; |
||||||
|
#endregion |
||||||
|
ret.IsSucceed = true; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
ret.IsSucceed = false; |
||||||
|
ret.Message = "微信未授权!"; |
||||||
|
} |
||||||
|
return ret; |
||||||
|
} |
||||||
|
} |
||||||
|
public class UserLogin |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
public string phone { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 登录密码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Password { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Utility; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using SqlSugar; |
||||||
|
|
||||||
|
namespace _24Hour.Controllers |
||||||
|
{ |
||||||
|
[Authorize] |
||||||
|
[ApiController] |
||||||
|
[Route("api/WeatherForecast")] |
||||||
|
public class WeatherForecastController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly SqlSugarClient _db; |
||||||
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//µ±Ç°Óû§ |
||||||
|
private static readonly string[] Summaries = new[] |
||||||
|
{ |
||||||
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" |
||||||
|
}; |
||||||
|
|
||||||
|
private readonly ILogger<WeatherForecastController> _logger; |
||||||
|
|
||||||
|
public WeatherForecastController(ILogger<WeatherForecastController> logger, SqlSugarClient db,User user) |
||||||
|
{ |
||||||
|
_logger = logger; |
||||||
|
_db = db; |
||||||
|
_userdata = user.Userdata(); |
||||||
|
} |
||||||
|
|
||||||
|
[HttpGet(Name = "GetWeatherForecast")] |
||||||
|
public IEnumerable<WeatherForecast> Get() |
||||||
|
{ |
||||||
|
var ss = _userdata; |
||||||
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast |
||||||
|
{ |
||||||
|
Date = DateTime.Now.AddDays(index), |
||||||
|
TemperatureC = Random.Shared.Next(-20, 55), |
||||||
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)] |
||||||
|
}) |
||||||
|
.ToArray(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<ShowAllFiles>true</ShowAllFiles> |
||||||
|
</PropertyGroup> |
||||||
|
</Project> |
@ -0,0 +1,169 @@ |
|||||||
|
using Elight.Logic; |
||||||
|
using Elight.Utility; |
||||||
|
using Microsoft.AspNetCore.Authentication; |
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||||
|
using Microsoft.Extensions.Configuration; |
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
||||||
|
using Microsoft.IdentityModel.Tokens; |
||||||
|
using Microsoft.OpenApi.Models; |
||||||
|
using SqlSugar; |
||||||
|
using System.Data; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
#region builder |
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args); |
||||||
|
|
||||||
|
var Configuration = builder.Configuration; |
||||||
|
|
||||||
|
// Add services to the container. |
||||||
|
|
||||||
|
builder.Services.AddControllers(); |
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
||||||
|
builder.Services.AddEndpointsApiExplorer(); |
||||||
|
builder.Services.AddSwaggerGen(c => |
||||||
|
{ |
||||||
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); |
||||||
|
|
||||||
|
//添加Jwt验证设置 |
||||||
|
c.AddSecurityRequirement(new OpenApiSecurityRequirement() |
||||||
|
{ |
||||||
|
{ |
||||||
|
new OpenApiSecurityScheme |
||||||
|
{ |
||||||
|
Reference = new OpenApiReference |
||||||
|
{ |
||||||
|
Id = "Bearer", |
||||||
|
Type = ReferenceType.SecurityScheme |
||||||
|
} |
||||||
|
}, |
||||||
|
new List<string>() |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||||
|
{ |
||||||
|
Description = "Value: Bearer {token}", |
||||||
|
Name = "Authorization", |
||||||
|
In = ParameterLocation.Header, |
||||||
|
Type = SecuritySchemeType.ApiKey |
||||||
|
}); |
||||||
|
}); |
||||||
|
// 添加身份验证服务 |
||||||
|
builder.Services.AddAuthentication(options => |
||||||
|
{ |
||||||
|
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; |
||||||
|
options.DefaultChallengeScheme = nameof(ResponseAuthenticationHandler); //401 |
||||||
|
options.DefaultForbidScheme = nameof(ResponseAuthenticationHandler); //403 |
||||||
|
}) |
||||||
|
.AddJwtBearer(options => |
||||||
|
{ |
||||||
|
// 配置JWT身份验证选项 |
||||||
|
options.TokenValidationParameters = new TokenValidationParameters |
||||||
|
{ |
||||||
|
ValidateIssuer = true, |
||||||
|
ValidateAudience = true, |
||||||
|
ValidateLifetime = true, |
||||||
|
ValidateIssuerSigningKey = true, |
||||||
|
ValidIssuer = Configuration.GetSection("JwtConfiguration:Issuer").Value, |
||||||
|
ValidAudience = Configuration.GetSection("JwtConfiguration:Audience").Value, |
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("JwtConfiguration:Jwtkey").Value)), |
||||||
|
ClockSkew = TimeSpan.Zero |
||||||
|
}; |
||||||
|
|
||||||
|
////重点在于这里;判断是SignalR的路径(https://www.cnblogs.com/fger/p/11811190.html) |
||||||
|
options.Events = new JwtBearerEvents |
||||||
|
{ |
||||||
|
OnMessageReceived = (context) => |
||||||
|
{ |
||||||
|
if (!context.HttpContext.Request.Path.HasValue) return Task.CompletedTask; |
||||||
|
//重点在于这里;判断是SignalR的路径 |
||||||
|
var accessToken = context.HttpContext.Request.Query["access_token"]; |
||||||
|
var path = context.HttpContext.Request.Path; |
||||||
|
if (string.IsNullOrWhiteSpace(accessToken) || !path.StartsWithSegments("/ws")) return Task.CompletedTask; |
||||||
|
|
||||||
|
context.Token = accessToken; |
||||||
|
return Task.CompletedTask; |
||||||
|
}, |
||||||
|
|
||||||
|
//此处为权限验证失败后触发的事件 |
||||||
|
OnChallenge = context => |
||||||
|
{ |
||||||
|
//此处代码为终止.Net Core默认的返回类型和数据结果,这个很重要哦,必须 |
||||||
|
context.HandleResponse(); |
||||||
|
//自定义自己想要返回的数据结果,我这里要返回的是Json对象,通过引用Newtonsoft.Json库进行转换 |
||||||
|
var payload = new { StatusCode = 0, Message = "身份认证失败!" }; |
||||||
|
//自定义返回的数据类型 |
||||||
|
context.Response.ContentType = "application/json"; |
||||||
|
//自定义返回状态码,默认为401 我这里改成 200 |
||||||
|
context.Response.StatusCode = StatusCodes.Status200OK; |
||||||
|
//context.Response.StatusCode = StatusCodes.Status401Unauthorized; |
||||||
|
//输出Json数据结果 |
||||||
|
context.Response.WriteAsync(Convert.ToString(payload)); |
||||||
|
return Task.FromResult(0); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
}).AddScheme<AuthenticationSchemeOptions, ResponseAuthenticationHandler>(nameof(ResponseAuthenticationHandler), o => { }); |
||||||
|
|
||||||
|
builder.Services.AddAuthorization(); |
||||||
|
builder.Services.AddHttpContextAccessor(); |
||||||
|
builder.Services.TryAddSingleton<User, User>(); //jwt |
||||||
|
builder.Services.TryAddSingleton<WriteSysLog, WriteSysLog>(); //WriteSysLog |
||||||
|
builder.Services.AddScoped<SqlSugarClient>(sp => |
||||||
|
{ |
||||||
|
var connectionString = Configuration.GetSection("ConnectionStrings:MySQLConnString").Value; |
||||||
|
var db = new SqlSugarClient(new ConnectionConfig |
||||||
|
{ |
||||||
|
ConnectionString = connectionString, |
||||||
|
DbType = SqlSugar.DbType.MySql, |
||||||
|
IsAutoCloseConnection = true, |
||||||
|
InitKeyType = InitKeyType.Attribute |
||||||
|
}); |
||||||
|
return db; |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region APP |
||||||
|
var app = builder.Build(); |
||||||
|
|
||||||
|
// Configure the HTTP request pipeline. |
||||||
|
if (app.Environment.IsDevelopment()) |
||||||
|
{ |
||||||
|
app.UseSwagger(); |
||||||
|
app.UseSwaggerUI(); |
||||||
|
} |
||||||
|
|
||||||
|
app.UseHttpsRedirection(); |
||||||
|
//路由 |
||||||
|
app.UseRouting(); |
||||||
|
app.UseAuthentication(); // 启用身份验证中间件 |
||||||
|
app.UseAuthorization(); // 启用授权中间件 |
||||||
|
//app.MapControllers(); |
||||||
|
app.UseEndpoints(endpoints => |
||||||
|
{ |
||||||
|
endpoints.MapControllers(); |
||||||
|
}); |
||||||
|
#region swagger |
||||||
|
app.UseSwagger();// 启用Swagger中间件 |
||||||
|
app.UseSwaggerUI(c => |
||||||
|
{ |
||||||
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); |
||||||
|
c.RoutePrefix = string.Empty; |
||||||
|
}); |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region websockets配置 |
||||||
|
app.UseWebSockets(new WebSocketOptions |
||||||
|
{ |
||||||
|
KeepAliveInterval = TimeSpan.FromMinutes(120) |
||||||
|
}); |
||||||
|
//app.UseMiddleware<WebSocketMiddleware>(); |
||||||
|
#endregion |
||||||
|
|
||||||
|
|
||||||
|
app.Run(); |
||||||
|
#endregion |
@ -0,0 +1,31 @@ |
|||||||
|
{ |
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json", |
||||||
|
"iisSettings": { |
||||||
|
"windowsAuthentication": false, |
||||||
|
"anonymousAuthentication": true, |
||||||
|
"iisExpress": { |
||||||
|
"applicationUrl": "http://localhost:54036", |
||||||
|
"sslPort": 44381 |
||||||
|
} |
||||||
|
}, |
||||||
|
"profiles": { |
||||||
|
"_24Hour": { |
||||||
|
"commandName": "Project", |
||||||
|
"dotnetRunMessages": true, |
||||||
|
"launchBrowser": true, |
||||||
|
"launchUrl": "swagger", |
||||||
|
"applicationUrl": "https://localhost:7246", |
||||||
|
"environmentVariables": { |
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||||
|
} |
||||||
|
}, |
||||||
|
"IIS Express": { |
||||||
|
"commandName": "IISExpress", |
||||||
|
"launchBrowser": true, |
||||||
|
"launchUrl": "swagger", |
||||||
|
"environmentVariables": { |
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
namespace _24Hour |
||||||
|
{ |
||||||
|
public class WeatherForecast |
||||||
|
{ |
||||||
|
public DateTime Date { get; set; } |
||||||
|
|
||||||
|
public int TemperatureC { get; set; } |
||||||
|
|
||||||
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); |
||||||
|
|
||||||
|
public string? Summary { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
{ |
||||||
|
"Logging": { |
||||||
|
"LogLevel": { |
||||||
|
"Default": "Information", |
||||||
|
"Microsoft.AspNetCore": "Warning" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
{ |
||||||
|
"Logging": { |
||||||
|
"LogLevel": { |
||||||
|
"Default": "Information", |
||||||
|
"Microsoft.AspNetCore": "Warning" |
||||||
|
} |
||||||
|
}, |
||||||
|
"AllowedHosts": "*", |
||||||
|
"ConnectionStrings": { |
||||||
|
"DBType": "MySQL", |
||||||
|
"MySQLConnString": "server=192.168.0.251;Database=equipmentrearend;Uid=root;Pwd=sa@admin;Allow User Variables=True;", |
||||||
|
}, |
||||||
|
//JwtConfig |
||||||
|
"JwtConfiguration": { |
||||||
|
/*JwtConfig Issuer=http://127.0.0.1:api本地端口*/ |
||||||
|
//发行者 |
||||||
|
"Issuer": "https://127.0.0.1:7246", |
||||||
|
/* JwtConfig Audience=http://127.0.0.1:api本地端口*/ |
||||||
|
//订阅者 |
||||||
|
"Audience": "https://127.0.0.1:7246", |
||||||
|
//RefreshToken受众 |
||||||
|
"RefreshTokenAudience": null, |
||||||
|
//加密Key |
||||||
|
"Jwtkey": "ertJKl#521*a@790asD&1#", |
||||||
|
//有效期(分钟) 120 = 24小时 |
||||||
|
"Expires": 1440, |
||||||
|
//RefreshToken过期时间(分钟) 1440 = 1天 |
||||||
|
"RefreshTokenExpires": 1440, |
||||||
|
//时间歪斜,单位秒 |
||||||
|
"ClockSkew": 1 |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
日志时间:2023-06-13 10:49:46 |
||||||
|
************************Exception Start******************************** |
||||||
|
Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 |
||||||
|
Exception Date:2023/6/13 10:49:46 |
||||||
|
Exception Type:MySqlConnector.MySqlException |
||||||
|
Exception Message:Unknown column 'SerialNumber' in 'field list' |
||||||
|
Exception Source:SqlSugar |
||||||
|
Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) |
||||||
|
at SqlSugar.InsertableProvider`1.ExecuteCommand() |
||||||
|
at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in C:\Users\Administrator\Desktop\24Hour\Elight.Logic\WriteSysLog.cs:line 51 |
||||||
|
************************Exception End************************************ |
||||||
|
|
@ -0,0 +1,78 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 预约接待 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_reception")] |
||||||
|
public class App_ReceptionModel |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string? Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 预约时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? receptiontime { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string? depart { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 接待人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string? receptionuser { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 事由 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string? matter { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 预约接待类型 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string? receptionId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 0:代办,1已完成 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int state { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
|
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建日期 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除:0:未删除、1:删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 工作台 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_staging")] |
||||||
|
public class StagingModel |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 跳转地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string path { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 图标地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string icon { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 颜色 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string color { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string title { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 类型 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string titletype { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
|
||||||
|
[DataMember] |
||||||
|
public string userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建日期 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除:0:未删除、1:删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 工作台使用数据 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_staging_num")] |
||||||
|
public class StagingNumModel |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 工作台Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string stagingId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 使用数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int num { get; set; } |
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建日期 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除:0:未删除、1:删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net6.0</TargetFramework> |
||||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||||
|
<Nullable>enable</Nullable> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.83" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,68 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 部门信息 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_depart")] |
||||||
|
public class App_Sys_DepartModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 单位Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departCode { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 部门名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departname { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门简称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departjc { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 0否,1是 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? createtime { get; set; } = DateTime.Now; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,113 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 菜单管理 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_menu")] |
||||||
|
public class App_Sys_MenuModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 父级 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string pid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string path { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 菜单名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页面组件路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string component { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 直接跳转路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string redirect { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页面标题 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string title { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏子菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideChildrenInMenu { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 图标 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string icon { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 当前菜单在列表中显示时 激活的菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool currentActiveMenu { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏面包眉 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideBreadcrumb { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏当前菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideMenu { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 排序 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int sortnum { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 0否,1是 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? createtime { get; set; } = DateTime.Now; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,60 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色菜单表 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_rolemenu")] |
||||||
|
public class App_Sys_RoleMenuModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 菜单Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string menuId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDeleted { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,60 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色表 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_role")] |
||||||
|
public class App_Sys_RoleModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDeleted { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,60 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色用户表 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_roleuser")] |
||||||
|
public class App_Sys_RoleUserModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 用户名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDeleted { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,69 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 单位信息 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_unit")] |
||||||
|
public class App_Sys_UnitModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 父级 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string pid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 单位名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitname { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位简称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitjc { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 0否,1是 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? createtime { get; set; } = DateTime.Now; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,138 @@ |
|||||||
|
|
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Entity |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 用户信息表(app_sys_user) |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_user")] |
||||||
|
public class App_Sys_UserModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string department { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 密码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Password { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 职务 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string duties { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 电话号码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string phone { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 身份证号码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string cardId { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 身份(检察官,律师,当事人) |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string identity { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 微信Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string wechatId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 账号类型0:系统,1:APP |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int usertype { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否停用 0:启用,1禁用 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int isdeactivate { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否App通用:0:通用,1:不通用 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int becurrent { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 头像地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string photo { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 性别 0:女 1:男 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int sex { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDeleted { get; set; } = 0; |
||||||
|
/// <summary> |
||||||
|
/// 审核状态 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? audit { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 审核描述 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string describe { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? createtime { get; set; } = DateTime.Now; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,107 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Entity.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 日志记录表(Func_Dossier_LogRecord) |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
[Serializable] |
||||||
|
[SugarTable("app_sys_depart")] |
||||||
|
public class Func_Dossier_LogRecordModel |
||||||
|
{ |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 序号 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string SerialNumber { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string UnitCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string NameEntity { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string DepartmentCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string DepartmentName { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作人工号 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string OperatingManual { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Operation { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string OperatingTime { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作IP |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string OperationIp { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作类型 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string OperationType { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 日志内容 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string LogContents { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作案件部门受案号 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string OpeCasDepAccCas { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 分区列 创建时间取年份,触发器完成 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string ParColCreTimTakYeaTri { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDeleted { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
/*CodeAutoBuilderArea*/ |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Logic |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 通用id删除 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class CurrencyDelete |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string tyId { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 集合Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public List<string> id { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net6.0</TargetFramework> |
||||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||||
|
<Nullable>enable</Nullable> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="IKVM" Version="8.5.2" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\Elight.Entity\Elight.Entity.csproj" /> |
||||||
|
<ProjectReference Include="..\Elight.Utility\Elight.Utility.csproj" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,68 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Logic |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 预约接待--分页 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_ReceptionInput : Paging |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 预约时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? receptiontime { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string depart { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 接待人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string receptionuser { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 事由 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string matter { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 预约接待类型 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string receptionId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 0:代办,1已完成 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? state { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Logic |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 工作台 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class StagingInput:Paging |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 跳转地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string path { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 图标地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string icon { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 颜色 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string color { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string title { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 类型 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string titletype { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Logic |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 工作台使用数据 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class StagingNumInput |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
[SugarColumn(IsPrimaryKey = true)] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 工作台Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string stagingId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 使用数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string num { get; set; } |
||||||
|
[DataMember] |
||||||
|
public string username { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int userId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建日期 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? creationtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除:0:未删除、1:删除 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } = 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 部门信息--分页 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_DepartInput : Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 单位Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departCode { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 部门名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departname { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门简称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string departjc { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,87 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 菜单管理 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_MenuInput:Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 父级 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string pid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string path { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 菜单名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页面组件路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string component { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 直接跳转路径 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string redirect { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页面标题 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string title { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏子菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideChildrenInMenu { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 图标 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string icon { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 当前菜单在列表中显示时 激活的菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool currentActiveMenu { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏面包眉 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideBreadcrum { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 是否隐藏当前菜单 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool hideMenu { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 排序 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int sortnum { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,34 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色表 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_RoleInput: Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,31 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色菜单表 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_RoleMenuInput : Paging |
||||||
|
{ |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 菜单Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string menuId { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,34 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 角色用户表 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_RoleUserInput : Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 角色用户Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string roleuserId { get; set; } |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,43 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 单位信息--分页 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_UnitInput : Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 父级 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string pid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 单位名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitname { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位简称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitjc { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,73 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 单位信息--树型查询 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
[SugarTable("app_sys_unit")] |
||||||
|
public class App_Sys_UnitTree |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)] |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 父级 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string pid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 单位名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitname { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位简称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitjc { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否删除 0否,1是 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int IsDelete { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createuserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建人 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string createusername { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 创建时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? createtime { get; set; } = DateTime.Now; |
||||||
|
|
||||||
|
[SqlSugar.SugarColumn(IsIgnore = true)] |
||||||
|
public List<App_Sys_UnitTree> Child { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,105 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Logic.SystemModel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 用户信息表 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public class App_Sys_UserInput:Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 表里用户唯一标识符,自增长Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Id { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 单位编码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string unitCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 部门 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string department { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 密码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Password { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 名称 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string name { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 职务 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string duties { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 电话号码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string phone { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 身份 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string identity { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 身份证号码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string cardId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 微信Id |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string wechatId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 账号类型0:系统,1:APP |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? usertype { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否停用 0:启用,1禁用 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? isdeactivate { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否App通用:0:通用,1:不通用 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? becurrent { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 头像地址 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string photo { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 性别 0:女 1:男 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int? sex { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,59 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Entity.SystemModel; |
||||||
|
using Elight.Utility; |
||||||
|
using Elight.Utility.Code; |
||||||
|
using Elight.Utility.logs; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.Extensions.Configuration; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using SqlSugar; |
||||||
|
using sun.nio.ch; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Security.Claims; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Logic |
||||||
|
{ |
||||||
|
public class WriteSysLog |
||||||
|
{ |
||||||
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
||||||
|
Result ret = new Result(); |
||||||
|
public WriteSysLog(User user) |
||||||
|
{ |
||||||
|
_userdata = user.Userdata(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 添加数据库日志信息 |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
public void WriteSysLogadd(string operationType, string content, Result result, SqlSugarClient _db=null, string opeCasDepAccCas = null) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
Func_Dossier_LogRecordModel model = new Func_Dossier_LogRecordModel |
||||||
|
{ |
||||||
|
UnitCode = _userdata.unitCode, |
||||||
|
OperationType = operationType, |
||||||
|
NameEntity = "", |
||||||
|
LogContents = result.IsSucceed ? $"{content}成功" : $"{content}失败:{result.Message}", |
||||||
|
ParColCreTimTakYeaTri = DateTime.Now.Year.ToString(), |
||||||
|
OperationIp = "", |
||||||
|
Operation = _userdata.name, |
||||||
|
OperatingTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
||||||
|
OperatingManual = _userdata.Id, |
||||||
|
OpeCasDepAccCas = opeCasDepAccCas ?? string.Empty |
||||||
|
}; |
||||||
|
var sss= _db.Insertable(model).ExecuteCommand(); |
||||||
|
} |
||||||
|
catch (Exception ex) |
||||||
|
{ |
||||||
|
LogService.WriteLog(ex, "添加数据库日志信息_WriteSysLog_1 发生异常"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,101 @@ |
|||||||
|
using Elight.Utility.Enum; |
||||||
|
using Microsoft.AspNetCore.Authentication; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Options; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using Newtonsoft.Json.Serialization; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Net.Http.Headers; |
||||||
|
using System.Security.Claims; |
||||||
|
using System.Text; |
||||||
|
using System.Text.Encodings.Web; |
||||||
|
|
||||||
|
namespace Elight.Utility |
||||||
|
{ /// <summary> |
||||||
|
/// 响应认证处理器 |
||||||
|
/// </summary> |
||||||
|
/// Author:mxg |
||||||
|
/// CreatedTimed:2022-05-15 10:08 PM |
||||||
|
public class ResponseAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> |
||||||
|
{ |
||||||
|
#region Identity |
||||||
|
|
||||||
|
public ResponseAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, |
||||||
|
ILoggerFactory logger, |
||||||
|
UrlEncoder encoder, |
||||||
|
ISystemClock clock |
||||||
|
) : base(options, logger, encoder, clock) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
#endregion Identity |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
/// <exception cref="NotImplementedException"></exception> |
||||||
|
protected override Task<AuthenticateResult> HandleAuthenticateAsync() => throw new NotImplementedException(); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// HandleChallengeAsync |
||||||
|
/// </summary> |
||||||
|
/// <param name="properties"></param> |
||||||
|
/// <returns></returns> |
||||||
|
protected override async Task HandleChallengeAsync(AuthenticationProperties properties) |
||||||
|
{ |
||||||
|
Response.ContentType = "application/json"; |
||||||
|
Response.StatusCode = StatusCodes.Status401Unauthorized; |
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject( |
||||||
|
new ResponseStatusData |
||||||
|
{ |
||||||
|
Code = CustomizedStatusCodeEnum.Status401Unauthorized, |
||||||
|
Msg = CustomizedStatusCodeEnum.Status401Unauthorized.ToDescription() |
||||||
|
}, |
||||||
|
new JsonSerializerSettings() |
||||||
|
{ |
||||||
|
ContractResolver = new CamelCasePropertyNamesContractResolver() |
||||||
|
} |
||||||
|
)); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// HandleForbiddenAsync |
||||||
|
/// </summary> |
||||||
|
/// <param name="properties"></param> |
||||||
|
/// <returns></returns> |
||||||
|
protected override async Task HandleForbiddenAsync(AuthenticationProperties properties) |
||||||
|
{ |
||||||
|
Response.ContentType = "application/json"; |
||||||
|
Response.StatusCode = StatusCodes.Status403Forbidden; |
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject( |
||||||
|
new ResponseStatusData |
||||||
|
{ |
||||||
|
Code = CustomizedStatusCodeEnum.Status403Forbidden, |
||||||
|
Msg = CustomizedStatusCodeEnum.Status403Forbidden.ToDescription() |
||||||
|
}, |
||||||
|
new JsonSerializerSettings() |
||||||
|
{ |
||||||
|
ContractResolver = new CamelCasePropertyNamesContractResolver() |
||||||
|
} |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
public class ResponseStatusData |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 状态码枚举 (0:操作失败 1:操作成功 401:未登录 403:权限不足 404:资源不存在 500:系统内部错误) |
||||||
|
/// <see cref="CustomizedStatusCodeEnum"/> |
||||||
|
/// </summary> |
||||||
|
public CustomizedStatusCodeEnum Code { get; set; } = CustomizedStatusCodeEnum.Status1Ok; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
public string? Msg { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net6.0</TargetFramework> |
||||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||||
|
<Nullable>enable</Nullable> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" /> |
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.16" /> |
||||||
|
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.5" /> |
||||||
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.5" /> |
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\Elight.Entity\Elight.Entity.csproj" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,58 @@ |
|||||||
|
using System; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace Elight.Utility.Encrypt |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// AES |
||||||
|
/// </summary> |
||||||
|
public class AES |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 加密 |
||||||
|
/// </summary> |
||||||
|
/// <param name="toEncrypt">数据字符</param> |
||||||
|
/// <returns>密文</returns> |
||||||
|
public static string Encrypt(string toEncrypt) |
||||||
|
{ |
||||||
|
byte[] keyArray = Encoding.UTF8.GetBytes("12345678901234567890123456789012"); |
||||||
|
byte[] toEncryptArray = Encoding.UTF8.GetBytes(toEncrypt); |
||||||
|
|
||||||
|
RijndaelManaged rDel = new RijndaelManaged |
||||||
|
{ |
||||||
|
Key = keyArray, |
||||||
|
Mode = CipherMode.ECB, |
||||||
|
Padding = PaddingMode.PKCS7 |
||||||
|
}; |
||||||
|
|
||||||
|
ICryptoTransform cTransform = rDel.CreateEncryptor(); |
||||||
|
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
||||||
|
|
||||||
|
return Convert.ToBase64String(resultArray, 0, resultArray.Length); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 解密 |
||||||
|
/// </summary> |
||||||
|
/// <param name="toDecrypt">密文</param> |
||||||
|
/// <returns>结果</returns> |
||||||
|
public static string Decrypt(string toDecrypt) |
||||||
|
{ |
||||||
|
byte[] keyArray = Encoding.UTF8.GetBytes("12345678901234567890123456789012"); |
||||||
|
byte[] toEncryptArray = Convert.FromBase64String(toDecrypt); |
||||||
|
|
||||||
|
RijndaelManaged rDel = new RijndaelManaged |
||||||
|
{ |
||||||
|
Key = keyArray, |
||||||
|
Mode = CipherMode.ECB, |
||||||
|
Padding = PaddingMode.PKCS7 |
||||||
|
}; |
||||||
|
|
||||||
|
ICryptoTransform cTransform = rDel.CreateDecryptor(); |
||||||
|
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
||||||
|
|
||||||
|
return Encoding.UTF8.GetString(resultArray); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
using System; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Text; |
||||||
|
namespace Elight.Utility.Encrypt |
||||||
|
{/// <summary> |
||||||
|
/// Md5 |
||||||
|
/// </summary> |
||||||
|
public class Md5 |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 加密32 |
||||||
|
/// </summary> |
||||||
|
/// <param name="source">数据</param> |
||||||
|
/// <returns>密文</returns> |
||||||
|
public static string Encrypt32(string source) |
||||||
|
{ |
||||||
|
MD5 md5 = new MD5CryptoServiceProvider(); |
||||||
|
byte[] t = md5.ComputeHash(Encoding.UTF8.GetBytes(source)); |
||||||
|
StringBuilder sb = new StringBuilder(32); |
||||||
|
foreach (byte item in t) |
||||||
|
{ |
||||||
|
sb.Append(item.ToString("x").PadLeft(2, '0')); |
||||||
|
} |
||||||
|
return sb.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 加密16 |
||||||
|
/// </summary> |
||||||
|
/// <param name="source">数据</param> |
||||||
|
/// <returns>密文</returns> |
||||||
|
public static string Encrypt16(string source) |
||||||
|
{ |
||||||
|
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); |
||||||
|
string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(source)), 4, 8); |
||||||
|
t2 = t2.Replace("-", ""); |
||||||
|
return t2; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// MD5 加密字符串 |
||||||
|
/// </summary> |
||||||
|
/// <param name="rawPass">源字符串</param> |
||||||
|
/// <returns>加密后字符串</returns> |
||||||
|
public static string MD5Encoding(string rawPass) |
||||||
|
{ |
||||||
|
// 创建MD5类的默认实例:MD5CryptoServiceProvider |
||||||
|
MD5 md5 = MD5.Create(); |
||||||
|
byte[] bs = Encoding.UTF8.GetBytes(rawPass); |
||||||
|
byte[] hs = md5.ComputeHash(bs); |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
foreach (byte b in hs) |
||||||
|
{ |
||||||
|
// 以十六进制格式格式化 |
||||||
|
sb.Append(b.ToString("x2")); |
||||||
|
} |
||||||
|
return sb.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// MD5盐值加密 |
||||||
|
/// </summary> |
||||||
|
/// <param name="rawPass">源字符串</param> |
||||||
|
/// <param name="salt">盐值</param> |
||||||
|
/// <returns>加密后字符串</returns> |
||||||
|
public static string MD5Encoding(string rawPass, object salt) |
||||||
|
{ |
||||||
|
if (salt == null) return rawPass; |
||||||
|
return MD5Encoding(rawPass + "{" + salt.ToString() + "}"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility.Enum |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 状态码枚举 (0:操作失败 1:操作成功 401:未登录 403:权限不足 404:资源不存在 500:系统内部错误) |
||||||
|
/// </summary> |
||||||
|
/// Author:mxg |
||||||
|
/// CreatedTimed:2022-05-15 10:31 PM |
||||||
|
public enum CustomizedStatusCodeEnum |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 操作失败 |
||||||
|
/// </summary> |
||||||
|
[Description("操作失败")] |
||||||
|
Status0NotOk = 0, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 操作成功 |
||||||
|
/// </summary> |
||||||
|
[Description("操作成功")] |
||||||
|
Status1Ok = 1, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 未登录(需要重新登录) |
||||||
|
/// </summary> |
||||||
|
[Description("未登录")] |
||||||
|
Status401Unauthorized = 401, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 权限不足 |
||||||
|
/// </summary> |
||||||
|
[Description("权限不足")] |
||||||
|
Status403Forbidden = 403, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 资源不存在 |
||||||
|
/// </summary> |
||||||
|
[Description("资源不存在")] |
||||||
|
Status404NotFound = 404, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 系统内部错误(非业务代码里显式抛出的异常,例如由于数据不正确导致空指针异常、数据库异常等等) |
||||||
|
/// </summary> |
||||||
|
[Description("系统内部错误")] |
||||||
|
Status500InternalServerError = 500 |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Reflection; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility.Enum |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// Author:mxg |
||||||
|
/// CreatedTimed:2022-05-13 06:00 PM |
||||||
|
public static class EnumExtension |
||||||
|
{ |
||||||
|
public static string? ToDescription(this System.Enum item) |
||||||
|
{ |
||||||
|
string? name = item.ToString(); |
||||||
|
var desc = item.GetType().GetField(name)?.GetCustomAttribute<DescriptionAttribute>(); |
||||||
|
return desc?.Description ?? name; |
||||||
|
} |
||||||
|
|
||||||
|
public static long ToInt64(this System.Enum item) |
||||||
|
{ |
||||||
|
return Convert.ToInt64(item); |
||||||
|
} |
||||||
|
|
||||||
|
public static List<Dictionary<string, object>> ToList(this System.Enum value, bool ignoreNull = false) |
||||||
|
{ |
||||||
|
var enumType = value.GetType(); |
||||||
|
|
||||||
|
if (!enumType.IsEnum) |
||||||
|
return null; |
||||||
|
|
||||||
|
return System.Enum.GetValues(enumType).Cast<System.Enum>() |
||||||
|
.Where(m => !ignoreNull || !m.ToString().Equals("Null")).Select(x => new Dictionary<string, object?> |
||||||
|
{ |
||||||
|
["Label"] = x.ToDescription(), |
||||||
|
["Value"] = x |
||||||
|
}).ToList(); |
||||||
|
} |
||||||
|
|
||||||
|
public static List<Dictionary<string, object>> ToList<T>(bool ignoreNull = false) |
||||||
|
{ |
||||||
|
var enumType = typeof(T); |
||||||
|
|
||||||
|
if (!enumType.IsEnum) |
||||||
|
return null; |
||||||
|
|
||||||
|
return System.Enum.GetValues(enumType).Cast<System.Enum>() |
||||||
|
.Where(m => !ignoreNull || !m.ToString().Equals("Null")).Select(x => new Dictionary<string, object?> |
||||||
|
{ |
||||||
|
["Label"] = x.ToDescription(), |
||||||
|
["Value"] = x |
||||||
|
}).ToList(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility.Enum |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 系统日志等级,按照Syslog的标准,将日志等级分为八个等级 |
||||||
|
/// </summary> |
||||||
|
[DataContract] |
||||||
|
public enum LogLevel |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// A系统不可用 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
A系统不可用 = 0, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// B紧急事件 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
B紧急事件 = 1, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// C关键事件 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
C关键事件 = 2, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// D错误事件 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
D错误事件 = 3, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// E警告事件 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
E警告事件 = 4, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// F重要事件 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
F重要事件 = 5, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// G有用信息 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
G有用信息 = 6, |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// H调试信息 |
||||||
|
/// </summary> |
||||||
|
[EnumMember] |
||||||
|
H调试信息 = 7 |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,655 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics.CodeAnalysis; |
||||||
|
using System.Globalization; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Text; |
||||||
|
using System.Text.RegularExpressions; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility.Extensions |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// Author:mxg |
||||||
|
/// CreatedTimed:2022-05-13 06:00 PM |
||||||
|
public static class StringExtension |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 判断字符串是否为Null、空 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsNull(this string? s) => string.IsNullOrWhiteSpace(s); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 判断字符串是否不为Null、空 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool NotNull(this string? s) => !string.IsNullOrWhiteSpace(s); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="thisValue"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsNotEmptyOrNull(this object? thisValue) |
||||||
|
{ |
||||||
|
var val = thisValue as string; |
||||||
|
return val != "" && val != "undefined" && val != "null"; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 与字符串进行比较,忽略大小写 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <param name="value"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool EqualsIgnoreCase(this string s, string? value) => s.Equals(value, StringComparison.OrdinalIgnoreCase); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 首字母转小写 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string FirstCharToLower(this string s) |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(s)) return s; |
||||||
|
string str = string.Concat(s.First().ToString().ToLower(), s.AsSpan(1)); |
||||||
|
return str; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 首字母转大写 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string FirstCharToUpper(this string s) |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(s)) return s; |
||||||
|
|
||||||
|
string str = string.Concat(s.First().ToString().ToUpper(), s.AsSpan(1)); |
||||||
|
return str; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 转为Base64,UTF-8格式 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string ToBase64(this string s) => s.ToBase64(Encoding.UTF8); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 转为Base64 |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <param name="encoding">编码</param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string ToBase64(this string s, Encoding encoding) |
||||||
|
{ |
||||||
|
if (s.IsNull()) return string.Empty; |
||||||
|
|
||||||
|
var bytes = encoding.GetBytes(s); |
||||||
|
if (bytes == null) |
||||||
|
return null; |
||||||
|
else |
||||||
|
return Convert.ToBase64String(bytes); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="s"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string ToPath(this string s) => s.IsNull() ? string.Empty : s.Replace(@"\", "/"); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="str"></param> |
||||||
|
/// <param name="obj"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string Format(this string str, object obj) |
||||||
|
{ |
||||||
|
if (str.IsNull()) return str; |
||||||
|
|
||||||
|
string s = str; |
||||||
|
if (obj.GetType().Name == "JObject") |
||||||
|
{ |
||||||
|
foreach (var item in (Newtonsoft.Json.Linq.JObject)obj) |
||||||
|
{ |
||||||
|
var k = item.Key.ToString(); |
||||||
|
string? v = item.Value?.ToString(); |
||||||
|
s = Regex.Replace(s, "\\{" + k + "\\}", v, RegexOptions.IgnoreCase); |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
foreach (System.Reflection.PropertyInfo p in obj.GetType().GetProperties()) |
||||||
|
{ |
||||||
|
var xx = p.Name; |
||||||
|
var yy = p.GetValue(obj)?.ToString(); |
||||||
|
s = Regex.Replace(s, "\\{" + xx + "\\}", yy, RegexOptions.IgnoreCase); |
||||||
|
} |
||||||
|
} |
||||||
|
return s; |
||||||
|
} |
||||||
|
|
||||||
|
#region IsXXXX |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="guid"></param> |
||||||
|
/// <param name="outId"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool GetGuid(this string guid, out Guid outId) => Guid.TryParse(guid, out outId); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="guid"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsGuid(this string guid) => GetGuid(guid, out _); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="obj"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsInt(this object? obj) |
||||||
|
{ |
||||||
|
if (obj == null) return false; |
||||||
|
bool result = Int32.TryParse(obj.ToString(), out int number); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="str"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsDate(this object? str) => IsDate(str, out _); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <param name="str"></param> |
||||||
|
/// <param name="dateTime"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsDate(this object? str, out DateTime dateTime) |
||||||
|
{ |
||||||
|
dateTime = DateTime.Now; |
||||||
|
if (str == null || str.ToString() == "") return false; |
||||||
|
return DateTime.TryParse(str.ToString(), out dateTime); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 根据传入格式判断是否为小数 |
||||||
|
/// </summary> |
||||||
|
/// <param name="str"></param> |
||||||
|
/// <param name="formatString">18,5</param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsNumber(this string str, string? formatString) |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(str)) return false; |
||||||
|
int precision = 32; |
||||||
|
int scale = 5; |
||||||
|
try |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(formatString)) |
||||||
|
{ |
||||||
|
precision = 10; |
||||||
|
scale = 2; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
string[] numbers = formatString.Split(','); |
||||||
|
precision = Convert.ToInt32(numbers[0]); |
||||||
|
scale = numbers.Length == 0 ? 2 : Convert.ToInt32(numbers[1]); |
||||||
|
} |
||||||
|
} |
||||||
|
catch |
||||||
|
{ |
||||||
|
// ignored |
||||||
|
} |
||||||
|
return IsNumber(str, precision, scale); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 判断一个字符串是否为合法数字(指定整数位数和小数位数) |
||||||
|
/// </summary> |
||||||
|
/// <param name="str">字符串</param> |
||||||
|
/// <param name="precision">整数位数</param> |
||||||
|
/// <param name="scale">小数位数</param> |
||||||
|
/// <returns></returns> |
||||||
|
public static bool IsNumber(this string str, int precision, int scale) |
||||||
|
{ |
||||||
|
if ((precision == 0) && (scale == 0)) return false; |
||||||
|
string pattern = @"(^\d{1," + precision + "}"; |
||||||
|
if (scale > 0) pattern += @"\.\d{0," + scale + "}$)|" + pattern; |
||||||
|
pattern += "$)"; |
||||||
|
return Regex.IsMatch(str, pattern); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion IsXXXX |
||||||
|
|
||||||
|
// |
||||||
|
// Summary: |
||||||
|
// Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1 |
||||||
|
// collection of type System.String, using the specified separator between each |
||||||
|
// member. This is a shortcut for string.Join(...) |
||||||
|
// |
||||||
|
// Parameters: |
||||||
|
// source: |
||||||
|
// A collection that contains the strings to concatenate. |
||||||
|
// |
||||||
|
// separator: |
||||||
|
// The string to use as a separator. separator is included in the returned string |
||||||
|
// only if values has more than one element. |
||||||
|
// |
||||||
|
// Returns: |
||||||
|
// A string that consists of the members of values delimited by the separator string. |
||||||
|
// If values has no members, the method returns System.String.Empty. |
||||||
|
public static string? JoinAsString(this IEnumerable<string> source, string separator) => string.Join(separator, source); |
||||||
|
|
||||||
|
// |
||||||
|
// Summary: |
||||||
|
// Concatenates the members of a collection, using the specified separator between |
||||||
|
// each member. This is a shortcut for string.Join(...) |
||||||
|
// |
||||||
|
// Parameters: |
||||||
|
// source: |
||||||
|
// A collection that contains the objects to concatenate. |
||||||
|
// |
||||||
|
// separator: |
||||||
|
// The string to use as a separator. separator is included in the returned string |
||||||
|
// only if values has more than one element. |
||||||
|
// |
||||||
|
// Type parameters: |
||||||
|
// T: |
||||||
|
// The type of the members of values. |
||||||
|
// |
||||||
|
// Returns: |
||||||
|
// A string that consists of the members of values delimited by the separator string. |
||||||
|
// If values has no members, the method returns System.String.Empty. |
||||||
|
public static string JoinAsString<T>(this IEnumerable<T> source, string separator) => string.Join(separator, source); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if '@this' is null or empty. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>true if null or empty, false if not.</returns> |
||||||
|
public static bool IsNullOrEmpty(this string @this) => string.IsNullOrEmpty(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if '@this' is not null and not empty. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>false if null or empty, true if not.</returns> |
||||||
|
public static bool IsNotNullOrEmpty(this string? @this) => !string.IsNullOrEmpty(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if '@this' is null or whiteSpace. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>true if null or whiteSpace, false if not.</returns> |
||||||
|
public static bool IsNullOrWhiteSpace(this string? @this) => string.IsNullOrWhiteSpace(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if '@this' is not null and not whiteSpace. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>false if null or whiteSpace, true if not.</returns> |
||||||
|
public static bool IsNotNullOrWhiteSpace(this string? @this) => !string.IsNullOrWhiteSpace(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Concatenates the elements of an object array, using the specified separator between each element. |
||||||
|
/// </summary> |
||||||
|
/// <param name="separator"> |
||||||
|
/// The string to use as a separator. is included in the returned string only if has more |
||||||
|
/// than one element. |
||||||
|
/// </param> |
||||||
|
/// <param name="values">An array that contains the elements to concatenate.</param> |
||||||
|
/// <returns> |
||||||
|
/// A string that consists of the elements of delimited by the string. If is an empty array, the method |
||||||
|
/// returns . |
||||||
|
/// </returns> |
||||||
|
public static string Join<T>([NotNull] this string separator, IEnumerable<T> values) => string.Join(separator, values); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Indicates whether the specified regular expression finds a match in the specified input string. |
||||||
|
/// </summary> |
||||||
|
/// <param name="input">The string to search for a match.</param> |
||||||
|
/// <param name="pattern">The regular expression pattern to match.</param> |
||||||
|
/// <returns>true if the regular expression finds a match; otherwise, false.</returns> |
||||||
|
public static bool IsMatch([NotNull] this string input, string pattern) => Regex.IsMatch(input, pattern); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Indicates whether the specified regular expression finds a match in the specified input string, using the |
||||||
|
/// specified matching options. |
||||||
|
/// </summary> |
||||||
|
/// <param name="input">The string to search for a match.</param> |
||||||
|
/// <param name="pattern">The regular expression pattern to match.</param> |
||||||
|
/// <param name="options">A bitwise combination of the enumeration values that provide options for matching.</param> |
||||||
|
/// <returns>true if the regular expression finds a match; otherwise, false.</returns> |
||||||
|
public static bool IsMatch([NotNull] this string input, string pattern, RegexOptions options) => Regex.IsMatch(input, pattern, options); |
||||||
|
|
||||||
|
/// <summary>An IEnumerable<string> extension method that concatenates the given this.</summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string Concatenate([NotNull] this IEnumerable<string> @this) |
||||||
|
{ |
||||||
|
var sb = new StringBuilder(); |
||||||
|
|
||||||
|
foreach (var s in @this) |
||||||
|
{ |
||||||
|
sb.Append(s); |
||||||
|
} |
||||||
|
|
||||||
|
return sb.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>An IEnumerable<T> extension method that concatenates.</summary> |
||||||
|
/// <typeparam name="T">Generic type parameter.</typeparam> |
||||||
|
/// <param name="source">The source to act on.</param> |
||||||
|
/// <param name="func">The function.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string Concatenate<T>([NotNull] this IEnumerable<T> source, Func<T, string> func) |
||||||
|
{ |
||||||
|
var sb = new StringBuilder(); |
||||||
|
foreach (var item in source) |
||||||
|
{ |
||||||
|
sb.Append(func(item)); |
||||||
|
} |
||||||
|
|
||||||
|
return sb.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if this object contains the given value. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="value">The value.</param> |
||||||
|
/// <returns>true if the value is in the string, false if not.</returns> |
||||||
|
public static bool Contains([NotNull] this string @this, string value) => @this.IndexOf(value, StringComparison.Ordinal) != -1; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if this object contains the given value. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="value">The value.</param> |
||||||
|
/// <param name="comparisonType">Type of the comparison.</param> |
||||||
|
/// <returns>true if the value is in the string, false if not.</returns> |
||||||
|
public static bool Contains([NotNull] this string @this, string value, StringComparison comparisonType) => @this.IndexOf(value, comparisonType) != -1; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that extracts this object. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="predicate">The predicate.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string Extract([NotNull] this string @this, Func<char, bool> predicate) => new string(@this.ToCharArray().Where(predicate).ToArray()); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that removes the letter. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="predicate">The predicate.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string RemoveWhere([NotNull] this string @this, Func<char, bool> predicate) => new string(@this.ToCharArray().Where(x => !predicate(x)).ToArray()); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Replaces the format item in a specified String with the text equivalent of the value of a corresponding |
||||||
|
/// Object instance in a specified array. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">A String containing zero or more format items.</param> |
||||||
|
/// <param name="values">An Object array containing zero or more objects to format.</param> |
||||||
|
/// <returns> |
||||||
|
/// A copy of format in which the format items have been replaced by the String equivalent of the corresponding |
||||||
|
/// instances of Object in args. |
||||||
|
/// </returns> |
||||||
|
public static string FormatWith([NotNull] this string @this, params object[] values) => string.Format(@this, values); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that query if '@this' satisfy the specified pattern. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="pattern">The pattern to use. Use '*' as wildcard string.</param> |
||||||
|
/// <returns>true if '@this' satisfy the specified pattern, false if not.</returns> |
||||||
|
public static bool IsLike([NotNull] this string @this, string pattern) |
||||||
|
{ |
||||||
|
// Turn the pattern into regex pattern, and match the whole string with ^$ |
||||||
|
var regexPattern = "^" + Regex.Escape(pattern) + "$"; |
||||||
|
|
||||||
|
// Escape special character ?, #, *, [], and [!] |
||||||
|
regexPattern = regexPattern.Replace(@"\[!", "[^") |
||||||
|
.Replace(@"\[", "[") |
||||||
|
.Replace(@"\]", "]") |
||||||
|
.Replace(@"\?", ".") |
||||||
|
.Replace(@"\*", ".*") |
||||||
|
.Replace(@"\#", @"\d"); |
||||||
|
|
||||||
|
return Regex.IsMatch(@this, regexPattern); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// SafeSubstring |
||||||
|
/// </summary> |
||||||
|
/// <param name="this"></param> |
||||||
|
/// <param name="startIndex"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string SafeSubstring([NotNull] this string @this, int startIndex) |
||||||
|
{ |
||||||
|
if (startIndex < 0 || startIndex > @this.Length) |
||||||
|
{ |
||||||
|
return string.Empty; |
||||||
|
} |
||||||
|
return @this[startIndex..]; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// SafeSubstring |
||||||
|
/// </summary> |
||||||
|
/// <param name="str"></param> |
||||||
|
/// <param name="startIndex"></param> |
||||||
|
/// <param name="length"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string SafeSubstring([NotNull] this string str, int startIndex, int length) |
||||||
|
{ |
||||||
|
if (startIndex < 0 || startIndex >= str.Length || length < 0) |
||||||
|
{ |
||||||
|
return string.Empty; |
||||||
|
} |
||||||
|
return str.Substring(startIndex, Math.Min(str.Length - startIndex, length)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Sub, not only substring but support for negative numbers |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">string to be handled</param> |
||||||
|
/// <param name="startIndex">startIndex to substract</param> |
||||||
|
/// <returns>substring</returns> |
||||||
|
public static string Sub([NotNull] this string @this, int startIndex) |
||||||
|
{ |
||||||
|
if (startIndex >= 0) |
||||||
|
{ |
||||||
|
return @this.SafeSubstring(startIndex); |
||||||
|
} |
||||||
|
if (Math.Abs(startIndex) > @this.Length) |
||||||
|
{ |
||||||
|
return string.Empty; |
||||||
|
} |
||||||
|
return @this[(@this.Length + startIndex)..]; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that repeats the string a specified number of times. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="repeatCount">Number of repeats.</param> |
||||||
|
/// <returns>The repeated string.</returns> |
||||||
|
public static string Repeat([NotNull] this string @this, int repeatCount) |
||||||
|
{ |
||||||
|
if (@this.Length == 1) |
||||||
|
{ |
||||||
|
return new string(@this[0], repeatCount); |
||||||
|
} |
||||||
|
|
||||||
|
var sb = new StringBuilder(repeatCount * @this.Length); |
||||||
|
while (repeatCount-- > 0) |
||||||
|
{ |
||||||
|
sb.Append(@this); |
||||||
|
} |
||||||
|
|
||||||
|
return sb.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that reverses the given string. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>The string reversed.</returns> |
||||||
|
public static string Reverse([NotNull] this string @this) |
||||||
|
{ |
||||||
|
if (@this.Length <= 1) |
||||||
|
{ |
||||||
|
return @this; |
||||||
|
} |
||||||
|
|
||||||
|
var chars = @this.ToCharArray(); |
||||||
|
Array.Reverse(chars); |
||||||
|
return new string(chars); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Returns a String array containing the substrings in this string that are delimited by elements of a specified |
||||||
|
/// String array. A parameter specifies whether to return empty array elements. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="separator">A string that delimit the substrings in this string.</param> |
||||||
|
/// <param name="option"> |
||||||
|
/// (Optional) Specify RemoveEmptyEntries to omit empty array elements from the array returned, |
||||||
|
/// or None to include empty array elements in the array returned. |
||||||
|
/// </param> |
||||||
|
/// <returns> |
||||||
|
/// An array whose elements contain the substrings in this string that are delimited by the separator. |
||||||
|
/// </returns> |
||||||
|
public static string[] Split([NotNull] this string @this, string separator, StringSplitOptions option = StringSplitOptions.None) => @this.Split(new[] { separator }, option); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that converts the @this to a byte array. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>@this as a byte[].</returns> |
||||||
|
public static byte[] ToByteArray([NotNull] this string @this) => Encoding.UTF8.GetBytes(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that converts the @this to a byte array. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="encoding">encoding</param> |
||||||
|
/// <returns>@this as a byte[].</returns> |
||||||
|
public static byte[] ToByteArray([NotNull] this string @this, Encoding encoding) => encoding.GetBytes(@this); |
||||||
|
|
||||||
|
public static byte[] GetBytes([NotNull] this string str) => str.GetBytes(Encoding.UTF8); |
||||||
|
|
||||||
|
public static byte[] GetBytes([NotNull] this string? str, Encoding encoding) => encoding.GetBytes(str); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that converts the @this to an enum. |
||||||
|
/// </summary> |
||||||
|
/// <typeparam name="T">Generic type parameter.</typeparam> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>@this as a T.</returns> |
||||||
|
public static T ToEnum<T>([NotNull] this string @this) => (T)System.Enum.Parse(typeof(T), @this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that converts the @this to a title case. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <returns>@this as a string.</returns> |
||||||
|
public static string ToTitleCase([NotNull] this string @this) => new CultureInfo("en-US").TextInfo.ToTitleCase(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that converts the @this to a title case. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="cultureInfo">Information describing the culture.</param> |
||||||
|
/// <returns>@this as a string.</returns> |
||||||
|
public static string ToTitleCase([NotNull] this string @this, CultureInfo cultureInfo) => cultureInfo.TextInfo.ToTitleCase(@this); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that truncates. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="maxLength">The maximum length.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string Truncate(this string @this, int maxLength) => @this.Truncate(maxLength, "..."); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// A string extension method that truncates. |
||||||
|
/// </summary> |
||||||
|
/// <param name="this">The @this to act on.</param> |
||||||
|
/// <param name="maxLength">The maximum length.</param> |
||||||
|
/// <param name="suffix">The suffix.</param> |
||||||
|
/// <returns>A string.</returns> |
||||||
|
public static string Truncate(this string @this, int maxLength, string suffix) |
||||||
|
{ |
||||||
|
if (@this == null || @this.Length <= maxLength) |
||||||
|
{ |
||||||
|
return @this; |
||||||
|
} |
||||||
|
return @this.Substring(0, maxLength - suffix.Length) + suffix; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// string=>long |
||||||
|
/// </summary> |
||||||
|
/// <param name="txt"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static long? ToLong(this string? @this) |
||||||
|
{ |
||||||
|
bool status = long.TryParse(@this, out long result); |
||||||
|
|
||||||
|
if (status) |
||||||
|
return result; |
||||||
|
else |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
#region 处理Windows和Linux 系统下文件路径 处理方法 |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 处理Windows和Linux 系统下文件路径 |
||||||
|
/// </summary> |
||||||
|
/// <param name="path"></param> |
||||||
|
/// <returns></returns> |
||||||
|
public static string GetRuntimeDirectory(this string path) |
||||||
|
{ |
||||||
|
if (IsLinuxRunTime()) return GetLinuxDirectory(path); |
||||||
|
return IsWindowRunTime() ? GetWindowDirectory(path) : path; |
||||||
|
} |
||||||
|
|
||||||
|
public static bool IsWindowRunTime() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); |
||||||
|
|
||||||
|
public static bool IsLinuxRunTime() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); |
||||||
|
|
||||||
|
private static string GetLinuxDirectory(string path) |
||||||
|
{ |
||||||
|
var pathTemp = Path.Combine(path); |
||||||
|
return pathTemp.Replace("\\", "/"); |
||||||
|
} |
||||||
|
|
||||||
|
private static string GetWindowDirectory(string path) |
||||||
|
{ |
||||||
|
var pathTemp = Path.Combine(path); |
||||||
|
return pathTemp.Replace("/", "\\"); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion 处理Windows和Linux 系统下文件路径 处理方法 |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,166 @@ |
|||||||
|
using System; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
|
||||||
|
namespace Elight.Utility.Code |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 分页类 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class Paging |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 页码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
private int pageIndex = 1; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页码 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int PageIndex |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return this.pageIndex; |
||||||
|
} |
||||||
|
|
||||||
|
set |
||||||
|
{ |
||||||
|
this.pageIndex = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页大小 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
private int pageSize = 10; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 页大小(默认10页) |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int PageSize |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return this.pageSize; |
||||||
|
} |
||||||
|
|
||||||
|
set |
||||||
|
{ |
||||||
|
this.pageSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 总条数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int RowsCount { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 总页数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
private int pageCount; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 总页数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int PageCount |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
if (PageSize == 0) |
||||||
|
{ |
||||||
|
return 0; |
||||||
|
} |
||||||
|
this.pageCount = (this.RowsCount % this.PageSize) == 0 |
||||||
|
? this.RowsCount / this.PageSize |
||||||
|
: (this.RowsCount / this.PageSize) + 1; |
||||||
|
return this.pageCount; |
||||||
|
} |
||||||
|
|
||||||
|
set |
||||||
|
{ |
||||||
|
this.pageCount = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否获取总条数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
private bool getRowsCount = true; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 排序名 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string SortName { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 排序方式 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string SortType { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 实名数量 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int RealNameCount { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 匿名数量 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public int AnonymousCount { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 开始时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? StartTime { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 结束时间 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public DateTime? EndTime { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 是否获取总条数 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool GetRowsCount |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return this.getRowsCount; |
||||||
|
} |
||||||
|
|
||||||
|
set |
||||||
|
{ |
||||||
|
this.getRowsCount = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 开始索引 |
||||||
|
/// </summary> |
||||||
|
public int StratRows => PageSize * ((PageIndex <= 0 ? 1 : PageIndex) - 1) + 1; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 开始索引 |
||||||
|
/// </summary> |
||||||
|
public int EndRows => (PageIndex <= 0 ? 1 : PageIndex) * PageSize; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
using Elight.Utility.Code; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// The query result. |
||||||
|
/// </summary> |
||||||
|
/// <typeparam name="T"> |
||||||
|
/// T |
||||||
|
/// </typeparam> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class QueryResult<T> |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Initializes a new instance of the <see cref="QueryResult{T}"/> class. |
||||||
|
/// </summary> |
||||||
|
/// <param name="paging"> |
||||||
|
/// The paging. |
||||||
|
/// </param> |
||||||
|
/// <param name="data"> |
||||||
|
/// The data. |
||||||
|
/// </param> |
||||||
|
public QueryResult(Paging paging, IList<T> data) |
||||||
|
{ |
||||||
|
this.Paging = paging; |
||||||
|
this.Data = data; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 分页信息 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public Paging Paging { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 数据 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public IList<T> Data { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Runtime.Serialization; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace Elight.Utility.Code |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 消息 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class Result |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 成功/失败 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public bool IsSucceed { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 消息 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Message { get; set; } |
||||||
|
/// <summary> |
||||||
|
/// 消息 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public dynamic result { get; set; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 消息 |
||||||
|
/// </summary> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class ResultData:Result |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 数据 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public string Data { get; set; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 处理结果 |
||||||
|
/// </summary> |
||||||
|
/// <typeparam name="T">扩展数据</typeparam> |
||||||
|
[Serializable] |
||||||
|
[DataContract] |
||||||
|
public class Result<T> : Result |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 扩展数据 |
||||||
|
/// </summary> |
||||||
|
[DataMember] |
||||||
|
public T Data { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,188 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 写入文本 |
||||||
|
/// </summary> |
||||||
|
internal class TextWriter |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 写入文件路径 |
||||||
|
/// </summary> |
||||||
|
private readonly string fileName; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Initializes a new instance of the <see cref="TextWriter"/> class. |
||||||
|
/// </summary> |
||||||
|
public TextWriter() |
||||||
|
: this(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs")) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Initializes a new instance of the <see cref="TextWriter"/> class. |
||||||
|
/// </summary> |
||||||
|
/// <param name="fileName"> |
||||||
|
/// The file name. |
||||||
|
/// </param> |
||||||
|
public TextWriter(string fileName) |
||||||
|
{ |
||||||
|
this.fileName = fileName; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 写入日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="logInfo">内容 </param> |
||||||
|
/// <returns>结果</returns> |
||||||
|
internal bool WriteLog(string logInfo) |
||||||
|
{ |
||||||
|
if (string.IsNullOrWhiteSpace(logInfo)) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
DateTime timeStamp = DateTime.Now; |
||||||
|
string path = this.GetFileMainPath(timeStamp); |
||||||
|
FileInfo lastFile = GetLastAccessFile(path, timeStamp); |
||||||
|
FileStream fileStream = GetFileStream(lastFile, path, timeStamp); |
||||||
|
if (fileStream == null) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
StreamWriter sw = new StreamWriter(fileStream); |
||||||
|
sw.BaseStream.Seek(0, SeekOrigin.End); |
||||||
|
sw.Write(logInfo); |
||||||
|
sw.Flush(); |
||||||
|
sw.Close(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
finally |
||||||
|
{ |
||||||
|
fileStream.Close(); |
||||||
|
fileStream.Dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 获取文件路径 |
||||||
|
/// </summary> |
||||||
|
/// <param name="timeStamp">timeStamp</param> |
||||||
|
/// <returns>path</returns> |
||||||
|
private string GetFileMainPath(DateTime timeStamp) |
||||||
|
{ |
||||||
|
return Path.Combine(this.fileName, timeStamp.ToString("yyyyMMdd")); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 获取最后写入日志的文件 |
||||||
|
/// </summary> |
||||||
|
/// <param name="path">路径</param> |
||||||
|
/// <param name="timeStamp">timeStamp</param> |
||||||
|
/// <returns>FileInfo</returns> |
||||||
|
private static FileInfo GetLastAccessFile(string path, DateTime timeStamp) |
||||||
|
{ |
||||||
|
FileInfo result = null; |
||||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(path); |
||||||
|
if (directoryInfo.Exists) |
||||||
|
{ |
||||||
|
FileInfo[] fileInfos = directoryInfo.GetFiles(); |
||||||
|
foreach (FileInfo fileInfo in fileInfos) |
||||||
|
{ |
||||||
|
if (timeStamp.Hour == fileInfo.CreationTime.Hour) |
||||||
|
{ |
||||||
|
result = fileInfo; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
directoryInfo.Create(); |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 获取文件流 |
||||||
|
/// </summary> |
||||||
|
/// <param name="fileInfo">lastFile</param> |
||||||
|
/// <param name="path">path</param> |
||||||
|
/// <param name="timeStamp">timeStamp</param> |
||||||
|
/// <returns>FileStream</returns> |
||||||
|
private static FileStream GetFileStream(FileInfo fileInfo, string path, DateTime timeStamp) |
||||||
|
{ |
||||||
|
FileStream result; |
||||||
|
if (fileInfo == null) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
result = CreateFile(path, GetFileMainName(timeStamp)); |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
else if (IsOutOfTimeMaxLength(fileInfo.CreationTime, timeStamp)) |
||||||
|
{ |
||||||
|
result = CreateFile(path, GetFileMainName(timeStamp)); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
result = fileInfo.OpenWrite(); |
||||||
|
} |
||||||
|
catch |
||||||
|
{ |
||||||
|
result = CreateFile(path, GetFileMainName(timeStamp)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建文件 |
||||||
|
/// </summary> |
||||||
|
/// <param name="path">路径</param> |
||||||
|
/// <param name="fileName1">名称</param> |
||||||
|
/// <returns>FileStream</returns> |
||||||
|
private static FileStream CreateFile(string path, string fileName1) |
||||||
|
{ |
||||||
|
//return File.Create(@"" + path + "\"" + fileName1 + ".log"); |
||||||
|
return File.Create(path + @"\" + fileName1 + ".log"); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 获取文件名称 |
||||||
|
/// </summary> |
||||||
|
/// <param name="timeStamp">timeStamp</param> |
||||||
|
/// <returns>HHmmssfff</returns> |
||||||
|
private static string GetFileMainName(DateTime timeStamp) |
||||||
|
{ |
||||||
|
return timeStamp.ToString("HH"); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// IsOutOfTimeMaxLength |
||||||
|
/// </summary> |
||||||
|
/// <param name="creationTime">creationTime</param> |
||||||
|
/// <param name="timeStamp">timeStamp</param> |
||||||
|
/// <returns>bool</returns> |
||||||
|
private static bool IsOutOfTimeMaxLength(DateTime creationTime, DateTime timeStamp) |
||||||
|
{ |
||||||
|
return Math.Abs((creationTime - timeStamp).TotalHours) >= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Utility.Extensions; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IdentityModel.Tokens.Jwt; |
||||||
|
using System.Linq; |
||||||
|
using System.Security.Claims; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 用户信息 |
||||||
|
/// </summary> |
||||||
|
/// Author:mxg |
||||||
|
/// CreatedTimed:2022-05-15 10:08 PM |
||||||
|
public class User |
||||||
|
{ |
||||||
|
#region Identity |
||||||
|
|
||||||
|
private readonly IHttpContextAccessor _accessor; |
||||||
|
|
||||||
|
public User(IHttpContextAccessor accessor) |
||||||
|
{ |
||||||
|
_accessor = accessor; |
||||||
|
} |
||||||
|
|
||||||
|
#endregion Identity |
||||||
|
|
||||||
|
|
||||||
|
public App_Sys_UserModel Userdata() |
||||||
|
{ |
||||||
|
var data = _accessor?.HttpContext?.User?.FindFirst(ClaimTypes.UserData); |
||||||
|
var da = JsonConvert.DeserializeObject<App_Sys_UserModel>(data.Value); |
||||||
|
return da; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
using Elight.Entity; |
||||||
|
using Elight.Utility.Code; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using SqlSugar; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Net.WebSockets; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace Elight.Utility |
||||||
|
{ /// <summary> |
||||||
|
/// webSocket |
||||||
|
/// </summary> |
||||||
|
public class WebSocketMiddleware |
||||||
|
{ |
||||||
|
#region Identity |
||||||
|
private static Dictionary<string, WebSocket> CONNECT_POOL = new Dictionary<string, WebSocket>();//用户连接池 |
||||||
|
private readonly RequestDelegate _next; |
||||||
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
||||||
|
Result result = new Result(); |
||||||
|
public WebSocketMiddleware(User user) |
||||||
|
{ |
||||||
|
_userdata = user.Userdata(); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
/// <summary> |
||||||
|
/// 构造 |
||||||
|
/// </summary> |
||||||
|
/// <param name="next"></param> |
||||||
|
/// <param name="actionPathName">目标路径</param> |
||||||
|
public WebSocketMiddleware(RequestDelegate next) |
||||||
|
{ |
||||||
|
_next = next; |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// 中间件调用 |
||||||
|
/// </summary> |
||||||
|
/// <param name="httpContext"></param> |
||||||
|
/// <returns></returns> |
||||||
|
[HttpGet("/ws")] |
||||||
|
public async Task Invoke(HttpContext httpContext) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
var socket = await httpContext.WebSockets.AcceptWebSocketAsync(); |
||||||
|
string user = _userdata.Id; |
||||||
|
#region 用户添加连接池 |
||||||
|
//第一次open时,添加到连接池中 |
||||||
|
if (!CONNECT_POOL.ContainsKey(user)) |
||||||
|
CONNECT_POOL.Add(user, socket);//不存在,添加 |
||||||
|
else |
||||||
|
if (socket != CONNECT_POOL[user])//当前对象不一致,更新 |
||||||
|
CONNECT_POOL[user] = socket; |
||||||
|
#endregion |
||||||
|
} |
||||||
|
catch (Exception ex) |
||||||
|
{ |
||||||
|
var ss = ex.Message; |
||||||
|
} |
||||||
|
await _next(httpContext); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,258 @@ |
|||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using LogLevel = Elight.Utility.Enum.LogLevel; |
||||||
|
|
||||||
|
namespace Elight.Utility.logs |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// 写入文本日志 |
||||||
|
/// </summary> |
||||||
|
public static class LogService |
||||||
|
{ |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 写日志的等级 默认int最小值 |
||||||
|
/// </summary> |
||||||
|
private static readonly int _logWriteLevel =3; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// The obj. |
||||||
|
/// </summary> |
||||||
|
private static readonly object obj = new object(); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 写日志等级设置,默认只写全部日志 |
||||||
|
/// </summary> |
||||||
|
private static LogLevel LogWriteLevel |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
if (_logWriteLevel < 0 || _logWriteLevel > 7) |
||||||
|
{ |
||||||
|
return LogLevel.H调试信息; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return (LogLevel)_logWriteLevel; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录异常文本日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="ex">异常</param> |
||||||
|
/// <param name="remark">备注</param> |
||||||
|
public static void WriteLog(Exception ex, string remark) |
||||||
|
{ |
||||||
|
WriteLog(ex, null, remark); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Writes the log. |
||||||
|
/// </summary> |
||||||
|
/// <param name="ex">The ex.</param> |
||||||
|
/// <param name="remark">The remark.</param> |
||||||
|
/// <param name="logLevel">The log level.</param> |
||||||
|
public static void WriteLog(Exception ex, string remark, LogLevel logLevel = LogLevel.D错误事件) |
||||||
|
{ |
||||||
|
if (logLevel > LogWriteLevel) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
WriteLog(ex, null, remark); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录异常文本日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="ex">异常</param> |
||||||
|
/// <param name="path">日志路径</param> |
||||||
|
/// <param name="remark">备注</param> |
||||||
|
public static void WriteLog(Exception ex, string path, string remark) |
||||||
|
{ |
||||||
|
var errormessage = CreateErrorMessage(ex, remark); |
||||||
|
WriteLog(errormessage.ToString(), path ?? Path.Combine(GetLogPath(), "Logs/ExceptionLog")); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录异常文本日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="describe">错误描述</param> |
||||||
|
/// <param name="ex">异常</param> |
||||||
|
/// <param name="path">日志路径</param> |
||||||
|
/// <param name="remark">备注</param> |
||||||
|
public static void WriteLog(string describe, Exception ex, string path, string remark) |
||||||
|
{ |
||||||
|
var errormessage = CreateErrorMessage(ex, remark); |
||||||
|
WriteLog("Describe:" + describe + " Error:" + errormessage, path ?? Path.Combine(GetLogPath(), "Logs/ExceptionLog")); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 创建异常消息 |
||||||
|
/// </summary> |
||||||
|
/// <param name="ex">异常信息</param> |
||||||
|
/// <param name="remark">备注</param> |
||||||
|
/// <returns>结果</returns> |
||||||
|
private static StringBuilder CreateErrorMessage(Exception ex, string remark) |
||||||
|
{ |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
stringBuilder.Append("************************Exception Start********************************"); |
||||||
|
string newLine = Environment.NewLine; |
||||||
|
stringBuilder.Append(newLine); |
||||||
|
stringBuilder.AppendLine("Exception Remark:" + remark); |
||||||
|
Exception innerException = ex.InnerException; |
||||||
|
stringBuilder.AppendFormat("Exception Date:{0}{1}", DateTime.Now, Environment.NewLine); |
||||||
|
if (innerException != null) |
||||||
|
{ |
||||||
|
stringBuilder.AppendFormat("Inner Exception Type:{0}{1}", innerException.GetType(), newLine); |
||||||
|
stringBuilder.AppendFormat("Inner Exception Message:{0}{1}", innerException.Message, newLine); |
||||||
|
stringBuilder.AppendFormat("Inner Exception Source:{0}{1}", innerException.Source, newLine); |
||||||
|
stringBuilder.AppendFormat("Inner Exception StackTrace:{0}{1}", innerException.StackTrace, newLine); |
||||||
|
} |
||||||
|
stringBuilder.AppendFormat("Exception Type:{0}{1}", ex.GetType(), newLine); |
||||||
|
stringBuilder.AppendFormat("Exception Message:{0}{1}", ex.Message, newLine); |
||||||
|
stringBuilder.AppendFormat("Exception Source:{0}{1}", ex.Source, newLine); |
||||||
|
stringBuilder.AppendFormat("Exception StackTrace:{0}{1}", ex.StackTrace, newLine); |
||||||
|
stringBuilder.Append("************************Exception End************************************"); |
||||||
|
stringBuilder.Append(newLine); |
||||||
|
return stringBuilder; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录文本日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="content">日志内容</param> |
||||||
|
/// <param name="logLevel">The log level.</param> |
||||||
|
public static void WriteLog(string content, LogLevel logLevel = LogLevel.G有用信息) |
||||||
|
{ |
||||||
|
if (logLevel > LogWriteLevel) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
WriteLog(logLevel.ToString() + "\t" + content, Path.Combine(GetLogPath(), "Logs")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录文本日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="content">日志内容</param> |
||||||
|
/// <param name="path">日志路径</param> |
||||||
|
public static void WriteLog(string content, string path) |
||||||
|
{ |
||||||
|
//Action action = () => Log(content, path); |
||||||
|
//action.BeginInvoke(null, null); |
||||||
|
//BeginInvoke只能在framework里使用 |
||||||
|
|
||||||
|
Task task = Task.Run(() => Log(content, path)); |
||||||
|
task.Wait(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录文本日志 大于等于配置的等级 才写日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="content">日志内容</param> |
||||||
|
/// <param name="path">日志路径</param> |
||||||
|
/// <param name="logLevel">写日志的等级</param> |
||||||
|
public static void WriteLog(string content, string path, LogLevel logLevel = LogLevel.G有用信息) |
||||||
|
{ |
||||||
|
if (logLevel > LogWriteLevel) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
WriteLog(logLevel + "\t" + content, path); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 记录日志 |
||||||
|
/// </summary> |
||||||
|
/// <param name="method">调用方法(必填)</param> |
||||||
|
/// <param name="request">请求参数</param> |
||||||
|
/// <param name="response">输出参数</param> |
||||||
|
/// <param name="saveFolder">保存文件夹,默认为CallLog</param> |
||||||
|
public static void SaveLog(string method, object request, object response, string saveFolder = "CallLog") |
||||||
|
{ |
||||||
|
//try |
||||||
|
//{ |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
stringBuilder.Append("************************Start********************************"); |
||||||
|
stringBuilder.Append(Environment.NewLine); |
||||||
|
stringBuilder.AppendFormat("Method:{0}{1}", method, Environment.NewLine); |
||||||
|
stringBuilder.AppendFormat("Request:{0}{1}", request == null ? string.Empty : JsonConvert.SerializeObject(request), Environment.NewLine); |
||||||
|
stringBuilder.AppendFormat("Response:{0}{1}", response == null ? "void" : JsonConvert.SerializeObject(response), Environment.NewLine); |
||||||
|
stringBuilder.Append("************************End************************************"); |
||||||
|
stringBuilder.Append(Environment.NewLine); |
||||||
|
var logContent = stringBuilder.ToString(); |
||||||
|
var path = Path.Combine(GetLogPath(), "Logs/" + saveFolder); |
||||||
|
WriteLog(logContent, path); |
||||||
|
//} |
||||||
|
//catch (Exception ex) |
||||||
|
//{ |
||||||
|
// WriteLog(ex, "记录调用日志异常"); |
||||||
|
//} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// The log. |
||||||
|
/// </summary> |
||||||
|
/// <param name="content"> |
||||||
|
/// The content. |
||||||
|
/// </param> |
||||||
|
/// <param name="path"> |
||||||
|
/// The path. |
||||||
|
/// </param> |
||||||
|
/// <returns> |
||||||
|
/// The |
||||||
|
/// </returns> |
||||||
|
internal static bool Log(string content, string path) |
||||||
|
{ |
||||||
|
lock (obj) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
TextWriter textWriter = new TextWriter(path); |
||||||
|
return |
||||||
|
textWriter.WriteLog( |
||||||
|
DateTime.Now.ToString("日志时间:yyyy-MM-dd HH:mm:ss") + Environment.NewLine + content |
||||||
|
+ Environment.NewLine); |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// 获取日志路径 |
||||||
|
/// </summary> |
||||||
|
/// <returns>路径</returns> |
||||||
|
internal static string GetLogPath() |
||||||
|
{ |
||||||
|
var _path = "/CaseFile/logs"; |
||||||
|
var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot"); |
||||||
|
if (!string.IsNullOrEmpty(_path)) |
||||||
|
dic += _path; |
||||||
|
if (string.IsNullOrWhiteSpace(dic)) |
||||||
|
{ |
||||||
|
return AppDomain.CurrentDomain.BaseDirectory; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return dic; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue