移除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:
@@ -3,7 +3,7 @@
|
||||
{
|
||||
// 远程测试服务器
|
||||
// "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306",
|
||||
"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=bzfm_mes;Port=3308",
|
||||
"Conn": "Data Source=115.190.214.62;User ID=bzfm_mes;Password=rSRGTzccN2ZQtnas;Initial Catalog=bzfm_mes;Port=3308",
|
||||
// "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306",
|
||||
"DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4
|
||||
"ConfigId": "0", //多租户唯一标识
|
||||
@@ -14,7 +14,7 @@
|
||||
//代码生成数据库配置
|
||||
"CodeGenDbConfig": {
|
||||
//代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名
|
||||
"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog={dbName};Port=3308",
|
||||
"Conn": "Data Source=115.190.214.62;User ID=root;Password=rSRGTzccN2ZQtnas;Initial Catalog={dbName};Port=3308",
|
||||
"DbType": 0,
|
||||
"IsAutoCloseConnection": true,
|
||||
"DbName": "bzfm_mes" //代码生成默认连接数据库,Oracle库是实例的名称
|
||||
|
||||
@@ -8,17 +8,6 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="BarTender">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>1</VersionMinor>
|
||||
<VersionMajor>10</VersionMajor>
|
||||
<Guid>d58562c1-e51b-11cf-8941-00a024a9083f</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NPOI" Version="2.7.2" />
|
||||
<PackageReference Include="QuestPDF" Version="2024.12.1" />
|
||||
|
||||
@@ -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);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
global.json
Normal file
6
global.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.416",
|
||||
"rollForward": "patch"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user