修复受流程控制不受控制的问题(益邦)

This commit is contained in:
qmj
2025-05-08 22:39:36 +08:00
parent 46c20e2895
commit 9e01715ea2
8 changed files with 210 additions and 112 deletions
@@ -1,8 +1,10 @@
using ADODB;
using log4net;
using Microsoft.VisualBasic;
using MSXML2;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
@@ -61,8 +63,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// <param name="codeKey"></param>
/// <param name="bAudit"></param>
/// <param name="bPrintDom"></param>
/// <param name="iswfcontrolled"></param>
/// <param name="cFlowFieldName"></param>
/// <returns></returns>
public async Task<BaseResult<string>> VoucherSave(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, int VoucherState = 2, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool bPrintDom = false)
public async Task<BaseResult<string>> VoucherSave(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, int VoucherState = 2, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool bPrintDom = false,bool iswfcontrolled=false,string cFlowFieldName= "IsWfControlled")
{
try
{
@@ -129,9 +133,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domMsg = new DOMDocument();
IXMLDOMDocument2 curDom = new DOMDocument();
co.bOutTrans = true;
baseLogin.Connection.BeginTrans();
logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
@@ -140,11 +143,24 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
var res = new BaseResult<string>();
if (bAudit)
{
logInfo.Debug("开始事务...");
co.bOutTrans = true;
baseLogin.Connection.BeginTrans();
}
try
{
logInfo.Debug("开始保存...");
errorMsg = co.VoucherSave(ref domHead, ref domBody, VoucherState, ref vouchId, ref curDom, UserMode, sOverDetailsXml, ref domMsg);
errorMsg = bAudit
? (string)co.VoucherSave2(ref domHead, ref domBody, VoucherState, ref vouchId, sOverDetailsXml, ref domMsg)
: (string)co.VoucherSave(ref domHead, ref domBody, VoucherState, ref vouchId, ref curDom, UserMode, sOverDetailsXml, ref domMsg);
logInfo.Debug("保存结束...");
logInfo.Debug(errorMsg);
logInfo.Debug($"{vouchId}");
@@ -153,15 +169,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
if (!res.bSuccess)
{
try
{
baseLogin.Connection.RollbackTrans();
}
catch (Exception ex)
{
logInfo.Error(ex.Message, ex);
}
if (!string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
@@ -177,8 +184,20 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
throw new Exception(curDom.xml);
}
throw new Exception("未知错误");
}
if (iswfcontrolled == false && VoucherState == 2)
{
var strSql = $"UPDATE {vouchers.cBTTblName} SET {cFlowFieldName} = 0 WHERE {vouchers.voucherIdFieldName}={vouchId}";
object rsts = new Recordset();
baseLogin.Connection.Execute(strSql,out rsts);
}
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
res.voucherId = $"{vouchId}";
res.result = errorMsg;
@@ -186,7 +205,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
}
catch (Exception)
{
baseLogin.Connection.RollbackTrans();
try
{
if (bAudit)
baseLogin.Connection.RollbackTrans();
}
catch(Exception ex)
{
Trace.WriteLine(ex.Message);
}
throw;
}
@@ -194,7 +222,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
if (!res.bSuccess)
{
res.message = "保存失败";
baseLogin.Connection.RollbackTrans();
if (bAudit)
baseLogin.Connection.RollbackTrans();
return res;
}
@@ -225,9 +254,15 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
}
}
logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
if (bAudit)
{
logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
}
return res;