301 lines
9.4 KiB
C#
301 lines
9.4 KiB
C#
using log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using ADODB;
|
|
using MSXML2;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
|
using System.Collections;
|
|
|
|
// ReSharper disable IdentifierTypo
|
|
// ReSharper disable InconsistentNaming
|
|
// ReSharper disable StringLiteralTypo
|
|
|
|
namespace UFIDA.U8.Framework.Api.ControlObject.AP
|
|
{
|
|
public class UFAPBO
|
|
{
|
|
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
|
|
|
/// <summary>
|
|
/// 收付款单保存
|
|
/// </summary>
|
|
/// <param name="baseLogin">登录对象</param>
|
|
/// <param name="dictionary">单据数据</param>
|
|
/// <param name="cSubId">子系统Id</param>
|
|
/// <param name="isAdd">是否新增</param>
|
|
/// <param name="bFirst">是否期初</param>
|
|
/// <param name="bodyKey">表体数据字段</param>
|
|
/// <returns></returns>
|
|
public BaseResult<string> CloseBillSave(BaseLogin baseLogin,Dictionary<string,object> dictionary,string cSubId,bool isAdd=true, bool bFirst=false,string bodyKey="body")
|
|
{
|
|
try
|
|
{
|
|
var m_Login = baseLogin._vbLogin;
|
|
|
|
var domHead = dictionary.ToDocument2();
|
|
|
|
IXMLDOMDocument2 domBody = new DOMDocument();
|
|
|
|
if (dictionary[bodyKey] is List<Dictionary<string, object>> bodyList && bodyList.Count > 0)
|
|
{
|
|
domBody = bodyList.ToDocument2(domBody);
|
|
}
|
|
|
|
var bo = "UFAPBO.clsCloseBill".GetComObject();
|
|
|
|
var m_conn = new Connection();
|
|
|
|
m_conn.Open(m_Login.UfDbName);
|
|
|
|
bo.Init(m_Login, m_conn, null,cSubId);
|
|
|
|
bo.First = bFirst;
|
|
|
|
var errorMessage = "";
|
|
|
|
var checkFlag = bo.VouchCheck(domHead, domBody, ref errorMessage, isAdd);
|
|
|
|
if (!checkFlag)
|
|
throw new Exception(errorMessage);
|
|
|
|
errorMessage = "";
|
|
|
|
var saveFlag = bo.SaveVouch(domHead, domBody, ref errorMessage, isAdd);
|
|
|
|
if (!saveFlag)
|
|
throw new Exception(errorMessage);
|
|
|
|
return new BaseResult<string> { bSuccess = true, message = "保存成功", result = "保存成功" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "保存失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 收付款单审核
|
|
/// </summary>
|
|
/// <param name="baseLogin">登录对象</param>
|
|
/// <param name="cLink">单号</param>
|
|
/// <param name="cVouchType">单据类型</param>
|
|
/// <param name="cVouchID">单据Id</param>
|
|
/// <param name="cSubId">子系统Id</param>
|
|
/// <param name="bFirst">是否期初</param>
|
|
/// <returns></returns>
|
|
public BaseResult<dynamic> CloseBillSign(BaseLogin baseLogin,string cLink,string cVouchType,string cVouchID, string cSubId, bool bFirst = false)
|
|
{
|
|
try
|
|
{
|
|
IXMLDOMDocument2 oDom = new DOMDocument();
|
|
|
|
oDom.loadXML("<condition/>");
|
|
|
|
var oElm = oDom.documentElement;
|
|
|
|
oElm.setAttribute("type", 0);
|
|
oElm.setAttribute("cLink", cLink);
|
|
oElm.setAttribute("cVouchType", cVouchType);
|
|
oElm.setAttribute("cVouchID", cVouchID);
|
|
oElm.setAttribute("bFirst", bFirst);
|
|
|
|
var bo = "UFAPBO.clsCloseBill".GetComObject();
|
|
|
|
var m_Login = baseLogin._vbLogin;
|
|
|
|
var m_conn = new Connection();
|
|
|
|
m_conn.Open(m_Login.UfDbName);
|
|
|
|
bo.Init(m_Login, m_conn, null, cSubId);
|
|
|
|
var errorMessage = "";
|
|
|
|
var signFlag = bo.Sign(oElm.xml, ref errorMessage);
|
|
|
|
if (!signFlag)
|
|
throw new Exception(errorMessage);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = true, message = "审核成功", result = "审核成功" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = false, message = "审核失败", result = ex.Message };
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 票据录入
|
|
/// </summary>
|
|
/// <param name="baseLogin">登录对象</param>
|
|
/// <param name="dictionary">单据数据</param>
|
|
/// <param name="isAdd">是否新增</param>
|
|
/// <param name="bFirst"></param>
|
|
/// <returns></returns>
|
|
public BaseResult<dynamic> ApNote_SaveVouch(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cSubId, bool isAdd = true, bool bFirst = false)
|
|
{
|
|
try
|
|
{
|
|
var m_Login = baseLogin._vbLogin;
|
|
|
|
var domHead = dictionary.ToDocument2();
|
|
|
|
var ap = "UFAPBO.clsAccount_AP".GetComObject();
|
|
|
|
var bo = "UFAPBO.clsApNote".GetComObject();
|
|
|
|
bool initResult = ap.Init(m_Login, cSubId);
|
|
|
|
if (!initResult)
|
|
{
|
|
logInfo.Debug($"1-----初始化参数失败,正在重新初始化");
|
|
|
|
initResult = ap.Init(m_Login);
|
|
|
|
if (!initResult)
|
|
{
|
|
logInfo.Debug($"2-----初始化参数失败");
|
|
}
|
|
}
|
|
|
|
var m_conn = new Connection();
|
|
|
|
m_conn.Open(m_Login.UfDbName);
|
|
|
|
var boResult = false;
|
|
|
|
if (initResult)
|
|
{
|
|
bool b = ap.InitSubOption2(cSubId);
|
|
|
|
if (!b)
|
|
{
|
|
logInfo.Debug($"初始化参数2失败");
|
|
}
|
|
|
|
logInfo.Debug($"调用初始化方法1");
|
|
|
|
boResult = bo.Init(m_Login, m_conn, ap);
|
|
}
|
|
else
|
|
{
|
|
logInfo.Debug($"调用初始化方法2");
|
|
|
|
boResult = bo.Init(m_Login, m_conn);
|
|
}
|
|
|
|
var errorMessage = "";
|
|
|
|
bool saveFlag = bo.SaveVouch(domHead, ref errorMessage);
|
|
|
|
if (!saveFlag)
|
|
{
|
|
throw new Exception(errorMessage);
|
|
}
|
|
|
|
return new BaseResult<dynamic> { bSuccess = true, message = "保存成功", result = "保存成功" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = false, message = "保存失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
public BaseResult<dynamic> ApNote_Sign(BaseLogin baseLogin, string cLink, string cSubId, bool isAdd = true, bool bFirst = false)
|
|
{
|
|
try
|
|
{
|
|
var m_Login = baseLogin._vbLogin;
|
|
|
|
var ap = "UFAPBO.clsAccount_AP".GetComObject();
|
|
|
|
var bo = "UFAPBO.clsApNote".GetComObject();
|
|
|
|
bool initResult = ap.Init(m_Login, cSubId);
|
|
|
|
if (!initResult)
|
|
{
|
|
logInfo.Debug($"1-----初始化参数失败,正在重新初始化");
|
|
|
|
initResult = ap.Init(m_Login);
|
|
|
|
if (!initResult)
|
|
{
|
|
logInfo.Debug($"2-----初始化参数失败");
|
|
}
|
|
}
|
|
|
|
var m_conn = new Connection();
|
|
|
|
m_conn.Open(m_Login.UfDbName);
|
|
|
|
|
|
if (initResult)
|
|
{
|
|
bool b = ap.InitSubOption2(cSubId);
|
|
|
|
if (!b)
|
|
{
|
|
logInfo.Debug($"初始化参数2失败");
|
|
}
|
|
|
|
logInfo.Debug($"调用初始化方法1");
|
|
|
|
bo.Init(m_Login, m_conn, ap);
|
|
}
|
|
else
|
|
{
|
|
logInfo.Debug($"调用初始化方法2");
|
|
|
|
bo.Init(m_Login, m_conn);
|
|
}
|
|
|
|
|
|
var xmlCondition = $"<condition type=\"1\" cLink=\"AR123414125132\" cVouchType=\"50\" cVouchID=\"{123414125132}\" bFirst=\"{bFirst}\"/>";
|
|
var errorMessage = "";
|
|
|
|
bool saveFlag = bo.Sign(xmlCondition, ref errorMessage);
|
|
|
|
|
|
if (!saveFlag)
|
|
{
|
|
throw new Exception(errorMessage);
|
|
}
|
|
|
|
//if (saveFlag)
|
|
//{
|
|
// saveFlag = bo.Sign($"<condition type=\"1\" cLink=\"AR{da.CVouchId}\" cVouchType=\"{da.cVouchType}\" cVouchID=\"{da.CVouchId}\" />", ref errorMessage);
|
|
//}
|
|
|
|
|
|
|
|
|
|
//logInfo.Debug($"bo.SaveVouch:{errorMessage}");
|
|
|
|
//if (!saveFlag)
|
|
// throw new Exception(errorMessage);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = true, message = "保存成功", result = "保存成功" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = false, message = "保存失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|