95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using ADODB;
|
|
using log4net;
|
|
using MSXML2;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.UI.WebControls;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
|
|
|
namespace UFIDA.U8.Framework.Api.ControlObject.AP
|
|
{
|
|
public class clsVouchFacade
|
|
{
|
|
private readonly ILog _logInfo = LogManager.GetLogger("logInfo");
|
|
|
|
/// <summary>
|
|
/// 保存单据
|
|
/// </summary>
|
|
/// <param name="login"></param>
|
|
/// <param name="input"></param>
|
|
/// <param name="VouchClass"></param>
|
|
/// <param name="bGetCode"></param>
|
|
/// <param name="codeKey"></param>
|
|
/// <param name="bPrintDom"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public async Task<BaseResult<string>> SaveVouch(BaseLogin baseLogin, Dictionary<string, object> input,string VouchClass,bool IsAdd = true,bool bVerify=false)
|
|
{
|
|
try
|
|
{
|
|
var clsVouchFacade = $"UFAPApplyPay.clsVouchFacade".GetComObject();
|
|
|
|
clsVouchFacade.init(VouchClass, baseLogin._vbLogin, baseLogin.Connection);
|
|
|
|
IXMLDOMDocument2 domHead = new DOMDocument();
|
|
IXMLDOMDocument2 domBody = new DOMDocument();
|
|
|
|
var errMsg = "";
|
|
|
|
_logInfo.Debug("填充表头DOM...");
|
|
|
|
domHead = input.ToDocument2(domHead);
|
|
|
|
if (!input.TryGetValue("body", out var bodys))
|
|
{
|
|
throw new Exception("无法获取表体数据");
|
|
}
|
|
|
|
if (!(bodys is List<Dictionary<string, object>> dictionarys) || dictionarys.Count <= 0)
|
|
{
|
|
throw new Exception("无法获取表体数据");
|
|
}
|
|
|
|
_logInfo.Debug("填充表体DOM...");
|
|
domBody = dictionarys.ToDocument2(domBody);
|
|
|
|
var res = new BaseResult<string>();
|
|
|
|
res.bSuccess = clsVouchFacade.SaveVouch(domHead, domBody, ref errMsg, IsAdd);
|
|
|
|
if (!res.bSuccess)
|
|
{
|
|
throw new Exception(errMsg);
|
|
}
|
|
|
|
if (bVerify)
|
|
{
|
|
clsVouchFacade.Verify();
|
|
}
|
|
|
|
res.message = "保存成功";
|
|
res.voucherCode = "";
|
|
res.voucherId = "";
|
|
|
|
return res;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
_logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "保存失败", result = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
}
|