修复受流程控制不受控制的问题(益邦)
This commit is contained in:
@@ -122,6 +122,9 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
|
||||
IXMLDOMDocument2 domMsg = new DOMDocument();
|
||||
errorMsg = "";
|
||||
|
||||
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum);
|
||||
|
||||
baseLogin.Connection.BeginTrans();
|
||||
object vouchId = "";
|
||||
|
||||
@@ -140,125 +143,71 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
|
||||
logInfo.Debug("执行插入操作...");
|
||||
//var cmd = new Command
|
||||
//{
|
||||
// CommandText = "Select '开始执行插入操作'",
|
||||
// ActiveConnection = baseLogin.Connection
|
||||
//};
|
||||
//object rsts = new Recordset();
|
||||
//cmd.Execute(out rsts);
|
||||
res.bSuccess = co.Insert(sVouchType, domHead, domBody, null, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
|
||||
|
||||
if (res.bSuccess)
|
||||
{
|
||||
res.voucherId = $"{vouchId}";
|
||||
logInfo.Debug($"操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
|
||||
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
|
||||
|
||||
if (bAudit)
|
||||
{
|
||||
var res2 = co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
|
||||
|
||||
if (!res2)
|
||||
{
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception(errorMsg);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(domMsg.xml))
|
||||
throw new Exception(domMsg.xml);
|
||||
|
||||
throw new Exception("审核单据时发生异常,请检查数据");
|
||||
}
|
||||
|
||||
baseLogin.Connection.CommitTrans();
|
||||
|
||||
res.message = "新增成功";
|
||||
}
|
||||
|
||||
res.message = "新增成功";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception(errorMsg);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(domMsg.xml))
|
||||
throw new Exception(domMsg.xml);
|
||||
|
||||
throw new Exception("新增单据时发生异常,请检查数据");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
await Task.Delay(1);
|
||||
throw;
|
||||
}
|
||||
|
||||
res.message = errorMsg;
|
||||
|
||||
if (res.bSuccess && bAudit)
|
||||
{
|
||||
errorMsg = "";
|
||||
try
|
||||
{
|
||||
if (!co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg))
|
||||
{
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception(errorMsg);
|
||||
|
||||
throw new Exception("审核单据时发生异常,请检查数据");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
res.bSuccess = false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.bSuccess)
|
||||
{
|
||||
baseLogin.Connection.RollbackTrans();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception(errorMsg);
|
||||
|
||||
throw new Exception(domMsg.xml);
|
||||
}
|
||||
|
||||
baseLogin.Connection.CommitTrans();
|
||||
|
||||
var rst = new Recordset();
|
||||
rst.Open($"SELECT CardNumber,BTTblName,BTQName,BWTblName,BWQName,VchListQName,VchTblPrimarykeyNames,ReceiptNOFieldName FROM dbo.vouchers WITH(NOLOCK) WHERE CardNumber='{cCardNum}'", baseLogin.Connection);
|
||||
|
||||
if (rst.BOF || rst.EOF)
|
||||
{
|
||||
res.bSuccess = false;
|
||||
res.result = $"已在U8生成单据ID为{vouchId}的单据,但是未能查询到该单据的配置信息!";
|
||||
}
|
||||
else
|
||||
{
|
||||
rst.MoveFirst();
|
||||
var fieldName = $"{rst.Fields["c"].Value}";
|
||||
var codeName = $"{rst.Fields["ReceiptNOFieldName"].Value}";
|
||||
if (string.IsNullOrWhiteSpace(fieldName) || string.IsNullOrWhiteSpace(codeName))
|
||||
{
|
||||
res.voucherCode = $"{res.voucherId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (codeName.Contains("{##}"))
|
||||
{
|
||||
codeName = codeName.Split('{', '#', '#', '}')[0];
|
||||
}
|
||||
|
||||
var strSql = $"SELECT {codeName} AS cCode FROM {rst.Fields["BTTblName"].Value} WITH(NOLOCK) WHERE {fieldName}='{vouchId}'";
|
||||
rst.Close();
|
||||
|
||||
rst.Open(strSql, baseLogin.Connection);
|
||||
|
||||
if (rst.EOF || rst.BOF)
|
||||
{
|
||||
res.voucherCode = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
rst.MoveFirst();
|
||||
res.voucherCode = $"{rst.Fields["cCode"].Value}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.message = "新增成功";
|
||||
res.result = $"{vouchId}";
|
||||
|
||||
|
||||
return res;
|
||||
|
||||
//var bodys = dictionary.TryGetValue() dictionary["body"];
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
await Task.Delay(1);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user