cjy 3 weeks ago
commit 9d0cddf371

1
.gitignore vendored

@ -83,3 +83,4 @@ LinkAttach
/ds-wms-service/DS.WMS.CheckApi/Logs/internal-nlog.txt /ds-wms-service/DS.WMS.CheckApi/Logs/internal-nlog.txt
/ds-wms-service/DS.WMS.FinanceApi/.config/dotnet-tools.json /ds-wms-service/DS.WMS.FinanceApi/.config/dotnet-tools.json
/ds-wms-service/DS.WMS.FinanceApi/Properties/PublishProfiles/FolderProfile.pubxml /ds-wms-service/DS.WMS.FinanceApi/Properties/PublishProfiles/FolderProfile.pubxml
/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user

@ -485,7 +485,7 @@ namespace DS.WMS.Core.Fee.Method
/// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception> /// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception>
public virtual async Task MarkerChangedAsync(MarkerChangedCallback callback) public virtual async Task MarkerChangedAsync(MarkerChangedCallback callback)
{ {
await MarkerChangedAsync(callback); await taskService.MarkerChangedAsync(callback);
//同步到钉钉 //同步到钉钉

@ -663,13 +663,13 @@ namespace DS.WMS.Core.Op.Method
{ {
var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray(); var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray();
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l,r) => new { m = r, h=l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l,bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
//if (orderList.Count != model.bookids.Length) //if (orderList.Count != model.bookids.Length)
@ -685,7 +685,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -940,14 +940,13 @@ namespace DS.WMS.Core.Op.Method
if (model.bookids.Any(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase))) if (model.bookids.Any(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)))
{ {
var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray(); var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray();
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -956,7 +955,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -1174,12 +1173,10 @@ namespace DS.WMS.Core.Op.Method
var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray(); var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray();
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -1188,7 +1185,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -1397,15 +1394,13 @@ namespace DS.WMS.Core.Op.Method
if (model.bookids.Any(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase))) if (model.bookids.Any(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)))
{ {
var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray(); var checkIds = model.bookids.Where(a => a.MHBillType.Equals("H", StringComparison.OrdinalIgnoreCase)).Select(a => a.bookid).ToArray();
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -1414,7 +1409,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -1631,12 +1626,10 @@ namespace DS.WMS.Core.Op.Method
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -1645,7 +1638,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -1653,7 +1646,7 @@ namespace DS.WMS.Core.Op.Method
blModel = saveRlt.Data; blModel = saveRlt.Data;
} }
if (blModel.IsCheckIn) if (blModel.IsCheckIn || !blModel.IsChangeEndorse)
{ {
blModel.Status = BLIssueStatusEnum.ChangeEndorse.ToString(); blModel.Status = BLIssueStatusEnum.ChangeEndorse.ToString();
blModel.StatusName = BLIssueStatusEnum.ChangeEndorse.GetDescription(); blModel.StatusName = BLIssueStatusEnum.ChangeEndorse.GetDescription();
@ -1893,12 +1886,10 @@ namespace DS.WMS.Core.Op.Method
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -1907,7 +1898,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -1919,7 +1910,7 @@ namespace DS.WMS.Core.Op.Method
{ {
blModel.Status = BLIssueStatusEnum.RejectReleaeNotice.ToString(); blModel.Status = BLIssueStatusEnum.RejectReleaeNotice.ToString();
blModel.StatusName = BLIssueStatusEnum.RejectReleaeNotice.GetDescription(); blModel.StatusName = BLIssueStatusEnum.RejectReleaeNotice.GetDescription();
blModel.IsChangeEndorse = true; //blModel.Isrej = true;
await tenantDb.Updateable<BLIssueManageBase>(blModel) await tenantDb.Updateable<BLIssueManageBase>(blModel)
.UpdateColumns(x => new .UpdateColumns(x => new
@ -2042,12 +2033,10 @@ namespace DS.WMS.Core.Op.Method
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -2056,7 +2045,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -2080,8 +2069,8 @@ namespace DS.WMS.Core.Op.Method
var log = new BLIssueManageLog var log = new BLIssueManageLog
{ {
Pid = blModel.Id, Pid = blModel.Id,
ActionCode = BLIssueActionEnum.RejectReleaeNotice.ToString(), ActionCode = BLIssueActionEnum.BLModify.ToString(),
ActionName = BLIssueActionEnum.RejectReleaeNotice.GetDescription(), ActionName = BLIssueActionEnum.BLModify.GetDescription(),
Note = model.Notes, Note = model.Notes,
Result = "成功", Result = "成功",
CreateBy = long.Parse(user.UserId), CreateBy = long.Parse(user.UserId),
@ -2187,12 +2176,10 @@ namespace DS.WMS.Core.Op.Method
#region 主单处理 #region 主单处理
var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId)) var orderList = tenantDb.Queryable<SeaExportBillManage>().ClearFilter(typeof(IOrgId))
.LeftJoin<SeaExport>((l, r) => l.BusinessId == r.Id) .InnerJoin<SeaExport>((l, r) => l.BusinessId == r.Id)
.Select((l, r) => new { m = r, h = l }) .LeftJoin<BLIssueManageBase>((l, r, t) => l.Id == t.BookingId)
.MergeTable() .Where((l, r, t) => checkIds.Contains(l.Id) && l.Deleted == false)
.LeftJoin<BLIssueManageBase>((l, r) => l.h.Id == r.BookingId) .Select((l, r, t) => new { order = r, sub = l, bl = t })
.Where((l, r) => checkIds.Contains(l.h.Id) && l.h.Deleted == false)
.Select((l, r) => new { order = l, bl = r })
.ToList(); .ToList();
foreach (var data in orderList) foreach (var data in orderList)
@ -2201,7 +2188,7 @@ namespace DS.WMS.Core.Op.Method
if (blModel == null || blModel.Id == 0) if (blModel == null || blModel.Id == 0)
{ {
var dto = GetReadSaveInfo(data.order.m, data.order.h); var dto = GetReadSaveInfo(data.order, data.sub);
var saveRlt = await Save(dto); var saveRlt = await Save(dto);
@ -2353,7 +2340,6 @@ namespace DS.WMS.Core.Op.Method
{ {
var model = new BLIssueManageBaseInputDto var model = new BLIssueManageBaseInputDto
{ {
BookingId = order.Id,
BLNo = order.MBLNO, BLNo = order.MBLNO,
CustomerId = order.CustomerId, CustomerId = order.CustomerId,
CustomerName = order.CustomerName, CustomerName = order.CustomerName,
@ -2375,6 +2361,7 @@ namespace DS.WMS.Core.Op.Method
if (hOrder != null && hOrder.Id > 0) if (hOrder != null && hOrder.Id > 0)
{ {
model.BookingId = hOrder.Id;
model.IssueType = hOrder.IssueType; model.IssueType = hOrder.IssueType;
//model.IssueTypeCode = hOrder.IssueTypeCode; //model.IssueTypeCode = hOrder.IssueTypeCode;
//model.IssuePlaceCode = hOrder.IssuePlaceCode; //model.IssuePlaceCode = hOrder.IssuePlaceCode;
@ -2388,6 +2375,7 @@ namespace DS.WMS.Core.Op.Method
} }
else else
{ {
model.BookingId = order.Id;
model.IssueType = order.IssueType; model.IssueType = order.IssueType;
model.IssueTypeCode = order.IssueTypeCode; model.IssueTypeCode = order.IssueTypeCode;
model.IssuePlaceCode = order.IssuePlaceCode; model.IssuePlaceCode = order.IssuePlaceCode;
@ -2409,6 +2397,10 @@ namespace DS.WMS.Core.Op.Method
model.AgreementDays = (Int16)Math.Ceiling(timeDiff / (24 * 60m)); model.AgreementDays = (Int16)Math.Ceiling(timeDiff / (24 * 60m));
} }
model.UpdateBy = long.Parse(user.UserId);
model.UpdateUserName = user.UserName;
model.UpdateTime = DateTime.Now;
return model; return model;
} }
#endregion #endregion

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeBillRecvService
{
//public sealed class ArgumentExceptionHandler : IExceptionHandler
//{
// public async ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
// {
// httpContext.RequestServices.GetRequiredService<ILogger<ArgumentExceptionHandler>>()
// .LogError(exception, "Exception handled");
// if (exception is not ArgumentException) return false;
// httpContext.Response.StatusCode = 400;
// await httpContext.Response.WriteAsJsonAsync(new
// {
// exception.Message
// }, cancellationToken);
// return true;
// }
//}
}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DS.Module.AutofacModule\DS.Module.AutofacModule.csproj" />
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />
<ProjectReference Include="..\DS.Module.MQ\DS.Module.MQ.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.WMS.Core\DS.WMS.Core.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,35 @@
using Hangfire.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.FeeBillRecvService
{
public class GlobalExceptionFilter : IServerFilter
{
public void OnPerforming(PerformingContext context)
{
// 不需要在这里做任何事情
}
public void OnPerformed(PerformedContext context)
{
Console.WriteLine(context.BackgroundJob);
// 当job执行完毕后检查是否有异常
//if (context.BackgroundJob.State == JobState.Failed)
//{
// // 获取异常信息
// var exception = context.Exception;
// if (exception != null)
// {
// // 处理异常,例如发送邮件、记录日志等
// // 这里可以使用依赖注入来处理异常如记录日志到Logging Service
// Console.WriteLine($"Job failed with exception: {exception.Message}");
// }
//}
}
}
}

@ -0,0 +1,129 @@
using DS.Module.Core.Log;
using DS.Module.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace DS.WMS.FeeBillRecvService
{
/// <summary>
/// 全局异常错误日志
/// </summary>
public class GlobalExceptionsFilter : IExceptionFilter
{
private readonly IHostingEnvironment _env;
private readonly IServiceProvider _serviceProvider;
public GlobalExceptionsFilter(IHostingEnvironment env, IServiceProvider serviceProvider)
{
_env = env;
_serviceProvider = serviceProvider;
}
public void OnException(ExceptionContext context)
{
var json = new JsonErrorResponse();
json.Message = context.Exception.Message; //错误信息
if (_env.IsDevelopment())
{
json.DevelopmentMessage = context.Exception.StackTrace; //堆栈信息
}
var result = DataResult<Object>.Failed(json.Message);
var objectResult = new BadRequestObjectResult(result);
objectResult.StatusCode = (int?)StatusCodes.Status200OK;
context.Result = objectResult;
// context.Result = new InternalServerErrorObjectResult(json);
//MiniProfiler.Current.CustomTiming("Errors", json.Message);
//记录异常到日志
StringBuilder exMsg = new();
exMsg.AppendLine($"【异常方法:】{context.HttpContext.Request.Path}");
exMsg.AppendLine($"【请求类型:】{context.HttpContext.Request.Method}");
exMsg.AppendLine($"【异常错误:】{context.Exception.Message}");
exMsg.AppendLine($"【堆栈跟踪:】{context.Exception.StackTrace}");
#region 写入日志库
var className = context.Exception.TargetSite.DeclaringType?.FullName;
var groupCollection = Regex.Match(className, "<(.*?)>").Groups;
var methodName = "";
if (groupCollection.Count > 1)
{
methodName = groupCollection[1].Value;
}
var exLog = new SysLogException()
{
ClassName = className,
MethodName = methodName,
ExceptionName = context.Exception.Message,
ExceptionMsg = context.Exception.Message,
ExceptionSource = context.Exception.Source,
StackTrace = context.Exception.StackTrace,
ParamsObj = context.Exception.TargetSite.GetParameters().ToString(),
};
#endregion
// Logger.Log(NLog.LogLevel.Info, "异常信息:" + JsonConvert.SerializeObject(context.Exception));
//采用log4net 进行错误日志记录
//_loggerHelper.Error(json.Message, WriteLog(json.Message, context.Exception));
//_hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait();
}
/// <summary>
/// 自定义返回格式
/// </summary>
/// <param name="throwMsg"></param>
/// <param name="ex"></param>
/// <returns></returns>
public string WriteLog(string throwMsg, Exception ex)
{
return string.Format("【自定义错误】:{0} \r\n【异常类型】{1} \r\n【异常信息】{2} \r\n【堆栈调用】{3}", new object[]
{
throwMsg,
ex.GetType().Name, ex.Message, ex.StackTrace
});
}
}
/// <summary>
///
/// </summary>
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object value) : base(value)
{
StatusCode = StatusCodes.Status500InternalServerError;
}
}
/// <summary>
/// 返回错误信息
/// </summary>
public class JsonErrorResponse
{
/// <summary>
/// 生产环境的消息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 开发环境的消息
/// </summary>
public string DevelopmentMessage { get; set; }
}
}

@ -0,0 +1,57 @@
using Autofac.Extensions.DependencyInjection;
using Autofac;
using DS.Module.AutofacModule;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.Module.RedisModule;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using NLog.Web;
using DS.WMS.FeeBillRecvService;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddWindowsService(options =>
{
options.ServiceName = ".NET Work Service";
});
//注册配置
builder.Configuration
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
.Build();
builder.Configuration.AddEnvironmentVariables();
builder.Logging.AddNLog("nlog.config");
//Autofac注入
builder.ConfigureContainer(new AutofacServiceProviderFactory(), builder => builder.RegisterModule(new AutofacModuleRegister()));
//builder.Services.AddTransient<IProblemDetailsWriter, SampleProblemDetailsWriter>();
//builder.Services.AddExceptionHandler<GlobalExceptionsFilter>(); //全局异常
builder.Services.AddControllers(options =>
{
options.Filters.Add<GlobalExceptionsFilter>();
});
builder.Services.AddUserModuleInstall(); //用户服务
builder.Services.AddRedisModuleInstall();//redis
builder.Services.AddSqlSugarInstall();
builder.Services.AddSaasDbInstall();//分库服务
//应用作为 Windows 服务
//builder.Services.AddWindowsService();
//builder.Services.AddHostedService<WindowsBackgroundService>();
//允许 BackgroundService 中存在未经处理的异常,不停止主机
builder.Services.Configure<HostOptions>(hostOptions =>
{
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
hostOptions.ServicesStartConcurrently = true;
hostOptions.ServicesStopConcurrently = true;
});
var host = builder.Build();
host.Run();

@ -78,7 +78,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.WMS.JobService", "DS.WMS
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.Module.MQ", "DS.Module.MQ\DS.Module.MQ.csproj", "{9A0BAA77-B0C3-44F8-A97E-E041ED159FFA}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.Module.MQ", "DS.Module.MQ\DS.Module.MQ.csproj", "{9A0BAA77-B0C3-44F8-A97E-E041ED159FFA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.Module.Quartz", "DS.Module.Quartz\DS.Module.Quartz.csproj", "{A2D8FB23-569C-46F9-9B1F-902BA87D0481}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.Module.Quartz", "DS.Module.Quartz\DS.Module.Quartz.csproj", "{A2D8FB23-569C-46F9-9B1F-902BA87D0481}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.WMS.FeeBillRecvService", "DS.WMS.FeeBillRecvService\DS.WMS.FeeBillRecvService.csproj", "{A56184E2-1480-49EC-BB62-BDE95B4C262A}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -222,6 +224,10 @@ Global
{A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Release|Any CPU.ActiveCfg = Release|Any CPU {A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Release|Any CPU.Build.0 = Release|Any CPU {A2D8FB23-569C-46F9-9B1F-902BA87D0481}.Release|Any CPU.Build.0 = Release|Any CPU
{A56184E2-1480-49EC-BB62-BDE95B4C262A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A56184E2-1480-49EC-BB62-BDE95B4C262A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A56184E2-1480-49EC-BB62-BDE95B4C262A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A56184E2-1480-49EC-BB62-BDE95B4C262A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -261,6 +267,7 @@ Global
{99B79A25-3732-4023-BD56-ABD169CE43AD} = {65D75DB2-12D5-4D1F-893D-9750905CE5E4} {99B79A25-3732-4023-BD56-ABD169CE43AD} = {65D75DB2-12D5-4D1F-893D-9750905CE5E4}
{9A0BAA77-B0C3-44F8-A97E-E041ED159FFA} = {518DB9B5-80A8-4B2C-8570-52BD406458DE} {9A0BAA77-B0C3-44F8-A97E-E041ED159FFA} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
{A2D8FB23-569C-46F9-9B1F-902BA87D0481} = {518DB9B5-80A8-4B2C-8570-52BD406458DE} {A2D8FB23-569C-46F9-9B1F-902BA87D0481} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
{A56184E2-1480-49EC-BB62-BDE95B4C262A} = {65D75DB2-12D5-4D1F-893D-9750905CE5E4}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {66115F23-94B4-43C0-838E-33B5CF77F788} SolutionGuid = {66115F23-94B4-43C0-838E-33B5CF77F788}

Loading…
Cancel
Save