移除BarTender依赖并更新数据库配置

移除了对BarTender的COM引用及相关代码逻辑,更新了
`appsettings.Development.json`中的数据库连接配置,替换为
新的远程服务器信息。新增`global.json`文件以指定.NET SDK
版本为8.0.416,确保项目运行环境一致性。保留了对NPOI和
QuestPDF的依赖支持。

切换数据库连接并移除BarTender依赖,锁定SDK版本

本次提交主要内容:
- 数据库连接切换至 115.190.214.62,并同步更新代码生成连接字符串。
- 移除 BarTender 相关 COM 组件依赖及打印实现,PrintTicketsByTemplate 方法暂时返回 null。
- 新增 global.json,锁定 .NET SDK 版本为 8.0.416,确保开发环境一致性。
This commit is contained in:
2025-12-20 10:26:54 +08:00
parent 8203a8f013
commit 2b66f83893
4 changed files with 54 additions and 58 deletions

View File

@@ -2,7 +2,7 @@ using System;
using System.Data.Common;
using System.Globalization;
using System.Linq;
using BarTender;
//using BarTender;
using DOAN.Infrastructure.Helper;
using DOAN.Model;
using DOAN.Model.MES.base_;
@@ -1505,50 +1505,51 @@ namespace DOAN.Service.MES.product
ProWorkorderExportDto param
)
{
var dataList = await Context
.Queryable<ProWorkorder>()
.Where(p => param.WorkorderArray.Contains(p.Workorder))
.ToListAsync();
if (dataList.Count == 0)
{
return new CustomException(500, "未找到匹配的工单数据");
}
Application bartenderApp = null;
Format bartenderFormat = null;
try
{
bartenderApp = new Application { Visible = false };
bartenderFormat = bartenderApp.Formats.Open(param.Path);
// 4. 遍历数据并打印
foreach (var data in dataList)
{
bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder);
bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode);
bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString());
await Task.Delay(500);
bartenderFormat.PrintOut(false, false); // 静默打印
}
return null;
//var dataList = await Context
// .Queryable<ProWorkorder>()
// .Where(p => param.WorkorderArray.Contains(p.Workorder))
// .ToListAsync();
//if (dataList.Count == 0)
//{
// return new CustomException(500, "未找到匹配的工单数据");
//}
//Application bartenderApp = null;
//Format bartenderFormat = null;
//try
//{
// bartenderApp = new Application { Visible = false };
// bartenderFormat = bartenderApp.Formats.Open(param.Path);
// // 4. 遍历数据并打印
// foreach (var data in dataList)
// {
// bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder);
// bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode);
// bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString());
// await Task.Delay(500);
// bartenderFormat.PrintOut(false, false); // 静默打印
// }
return new CustomException(200, "标签打印成功");
}
catch (Exception ex)
{
// 5. 错误处理(记录日志)
Console.WriteLine($"打印标签时出错: {ex.Message}");
return new CustomException(500, $"打印标签失败: {ex.Message}");
}
finally
{
// 6. 确保资源释放(逆序关闭)
if (bartenderFormat != null)
{
bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges);
}
if (bartenderApp != null)
{
bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges);
}
}
// return new CustomException(200, "标签打印成功");
//}
//catch (Exception ex)
//{
// // 5. 错误处理(记录日志)
// Console.WriteLine($"打印标签时出错: {ex.Message}");
// return new CustomException(500, $"打印标签失败: {ex.Message}");
//}
//finally
//{
// // 6. 确保资源释放(逆序关闭)
// if (bartenderFormat != null)
// {
// bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges);
// }
// if (bartenderApp != null)
// {
// bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges);
// }
//}
}
}
}