打印模块修改

dev
cjy 2 months ago
parent b28c083651
commit 4281b9e2a6

@ -1,8 +1,10 @@
using DS.WMS.PrintApi.Model;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NLog;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace DS.WMS.PrintApi.Middleware
{
@ -39,6 +41,7 @@ namespace DS.WMS.PrintApi.Middleware
/// <returns></returns>
public SqlSugarScopeProvider GetBizDbScopeById(object configId)
{
//db.RemoveConnection(configId);
if (!db.IsAnyConnection(configId))
{
var connInfo = GetMasterDb().Queryable<SysTenantLink>().Filter(null,true).First(x => x.TenantId == Convert.ToInt64(configId));
@ -82,15 +85,38 @@ namespace DS.WMS.PrintApi.Middleware
sqlStr = sqlStr.Replace(item.ParameterName, strValue);
}
}
Console.WriteLine("configId" + Environment.NewLine + configId);
//sqlStr = sqlStr.Replace('[', ' ').Replace(']', ' ');
Console.WriteLine("执行的SQL" + Environment.NewLine + sqlStr);
};
//数据处理事件
dbProvider.Aop.OnExecutingChangeSql = (sql, pars) => //可以修改SQL和参数的值
{
//sql = sql.Replace('[', ' ').Replace(']', ' ');
//sql=newsql
foreach (var p in pars) //修改
{
if (p.Value.ToString().Contains("["))
{
var temp = JsonConvert.DeserializeObject<List<string>>(p.Value.ToString());
p.Value = string.Join(", ", temp);
}
//p.Value = p.Value.ToString().Replace('[', ' ').Replace(']', ' ').Replace('&', ',');
}
return new KeyValuePair<string, SugarParameter[]>(sql, pars);
};
//数据处理事件
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
{
};
//SQL执行完
dbProvider.Aop.OnLogExecuted = (sql, pars) =>
{
//执行完了可以输出SQL执行时间 (OnLogExecutedDelegate)
Console.Write("time:" + db.Ado.SqlExecutionTime.ToString());
Console.Write("time:" + db.Ado.Connection.ConnectionString);
Console.Write("time:" + db.Ado.SqlStackTrace.SugarStackTraceList);
};
dbProvider.Aop.OnDiffLogEvent = it =>
{
//排除日志库操作

Loading…
Cancel
Save