This commit is contained in:
不做码农 2022-07-01 20:13:05 +08:00
commit 6de7d9b381
10 changed files with 96 additions and 84 deletions

View File

@ -24,6 +24,7 @@ namespace Infrastructure
public string Password { get; set; } public string Password { get; set; }
public string Smtp { get; set; } public string Smtp { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Signature { get; set; }
} }
/// <summary> /// <summary>
/// 上传 /// 上传

View File

@ -106,16 +106,18 @@ namespace ZR.Admin.WebApi.Middleware
sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : ""; sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : "";
} }
} }
LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error); LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error)
{
ei.Exception = ex; Exception = ex,
ei.Message = error; Message = error
};
ei.Properties["status"] = 1;//走正常返回都是通过走GlobalExceptionFilter不通过 ei.Properties["status"] = 1;//走正常返回都是通过走GlobalExceptionFilter不通过
ei.Properties["jsonResult"] = responseResult; ei.Properties["jsonResult"] = responseResult;
ei.Properties["requestParam"] = sysOperLog.operParam; ei.Properties["requestParam"] = sysOperLog.operParam;
ei.Properties["user"] = HttpContextExtension.GetName(context); ei.Properties["user"] = HttpContextExtension.GetName(context);
Logger.Log(ei); Logger.Log(ei);
context.Response.ContentType = "text/json;charset=utf-8";
await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8); await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8);
SysOperLogService.InsertOperlog(sysOperLog); SysOperLogService.InsertOperlog(sysOperLog);

View File

@ -47,7 +47,8 @@
"Password": "123456", "Password": "123456",
// //
"Smtp": "smtp.qq.com", "Smtp": "smtp.qq.com",
"Port": 587 "Port": 587,
"Signature": "系统邮件,请勿回复!"
}, },
//redis //redis
"RedisServer": { "RedisServer": {

View File

@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" /> <ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" /> <ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.0" /> <PackageReference Include="JinianNet.JNTemplate" Version="2.3.0" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9" /> <PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -27,10 +27,13 @@ namespace ZR.Common
/// </summary> /// </summary>
public int Port { get; set; } = 587; public int Port { get; set; } = 587;
/// <summary> /// <summary>
/// 邮件签名
/// </summary>
public string Signature { get; set; }
/// <summary>
/// 是否使用SSL协议 /// 是否使用SSL协议
/// </summary> /// </summary>
public bool UseSsl { get; set; } = false; public bool UseSsl { get; set; } = false;
public string mailSign = @"邮件来自C# 程序发送";
private readonly MailOptions mailOptions = new(); private readonly MailOptions mailOptions = new();
public MailHelper() public MailHelper()
@ -56,7 +59,7 @@ namespace ZR.Common
} }
/// <summary> /// <summary>
/// 发送一个 /// 发送一个
/// </summary> /// </summary>
/// <param name="toAddress"></param> /// <param name="toAddress"></param>
/// <param name="subject"></param> /// <param name="subject"></param>
@ -105,7 +108,7 @@ namespace ZR.Common
//收件人 //收件人
message.To.AddRange(toAddress); message.To.AddRange(toAddress);
message.Subject = subject; message.Subject = subject;
//message.Date = DateTime.Now; message.Date = DateTime.Now;
//创建附件Multipart //创建附件Multipart
Multipart multipart = new Multipart("mixed"); Multipart multipart = new Multipart("mixed");
@ -120,14 +123,14 @@ namespace ZR.Common
alternative.Add(Html); alternative.Add(Html);
} }
//文本内容 //文本内容
if (!string.IsNullOrEmpty(text)) //if (!string.IsNullOrEmpty(text))
//{
var plain = new TextPart(TextFormat.Plain)
{ {
var plain = new TextPart(TextFormat.Plain) Text = text + "\r\n\n\n" + mailOptions.Signature
{ };
Text = text + "\r\n\n\n" + mailSign alternative.Add(plain);
}; //}
alternative.Add(plain);
}
//附件 //附件
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))

View File

@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" /> <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="CSRedisCore" Version="3.6.9" /> <PackageReference Include="CSRedisCore" Version="3.6.9" />
<PackageReference Include="EPPlus" Version="6.0.4" /> <PackageReference Include="EPPlus" Version="6.0.4" />
<PackageReference Include="MailKit" Version="3.1.1" /> <PackageReference Include="MailKit" Version="3.3.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="EPPlus" Version="6.0.4" /> <PackageReference Include="EPPlus" Version="6.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9" /> <PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Dto\" /> <Folder Include="Dto\" />
<Folder Include="Enum\" /> <Folder Include="Enum\" />
<Folder Include="Vo\" /> <Folder Include="Vo\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" /> <ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.29" /> <PackageReference Include="MySql.Data" Version="8.0.29" />
<PackageReference Include="NETCore.Encrypt" Version="2.1.0" /> <PackageReference Include="NETCore.Encrypt" Version="2.1.0" />
<PackageReference Include="SqlSugar.IOC" Version="1.8.0" /> <PackageReference Include="SqlSugar.IOC" Version="1.8.0" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9" /> <PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.9.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Business\" /> <Folder Include="Business\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" /> <ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
<ProjectReference Include="..\ZR.Repository\ZR.Repository.csproj" /> <ProjectReference Include="..\ZR.Repository\ZR.Repository.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Business\" /> <Folder Include="Business\" />
<Folder Include="Business\IBusinessService\" /> <Folder Include="Business\IBusinessService\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -16,6 +16,7 @@ namespace ZR.Tasks.TaskScheduler
internal class Job_HttpRequest : JobBase, IJob internal class Job_HttpRequest : JobBase, IJob
{ {
private readonly ISysTasksQzService tasksQzService; private readonly ISysTasksQzService tasksQzService;
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public Job_HttpRequest(ISysTasksQzService tasksQzService) public Job_HttpRequest(ISysTasksQzService tasksQzService)
{ {
@ -32,7 +33,11 @@ namespace ZR.Tasks.TaskScheduler
if (info != null) if (info != null)
{ {
var result = await HttpHelper.HttpGetAsync("http://" + info.ApiUrl); var result = await HttpHelper.HttpGetAsync("http://" + info.ApiUrl);
Console.WriteLine(result); logger.Info($"任务【{info.Name}】网络请求执行结果=" + result);
}
else
{
throw new CustomException("任务网络请求执行失败,任务不存在");
} }
} }
} }