229 lines
6.8 KiB
C#
229 lines
6.8 KiB
C#
|
|
using MSXML2;
|
|||
|
|
using NX.ERP.U8.Store;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using UFIDA.U8.U8APIFramework;
|
|||
|
|
using UFIDA.U8.U8MOMAPIFramework;
|
|||
|
|
|
|||
|
|
namespace NX.ERP.U8.AP
|
|||
|
|
{
|
|||
|
|
public class APVouch : VoucherBase
|
|||
|
|
{
|
|||
|
|
public APVouch() : base("应付单", "U8API/APVouch")
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override string AddUrl
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return $"{BaseUrl}/SaveVouch";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
protected override string LoadUrl
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return $"{BaseUrl}/GetVouchData";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
protected override string UpdateUrl
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return $"{BaseUrl}/SaveVouch";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
protected override void LoadRdVoucher(VoucherParameter para)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
U8EnvContext u8EnvContext = new U8EnvContext();
|
|||
|
|
u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin;
|
|||
|
|
U8ApiAddress apiAddress = new U8ApiAddress(this.LoadUrl);
|
|||
|
|
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
|
|||
|
|
u8EnvContext.SetApiContext("VouchType",this.VoucherID);
|
|||
|
|
|
|||
|
|
u8ApiBroker.AssignNormalValue("linkid", "0");
|
|||
|
|
|
|||
|
|
if (!u8ApiBroker.Invoke())
|
|||
|
|
{
|
|||
|
|
Exception exception = u8ApiBroker.GetException();
|
|||
|
|
if (exception != null)
|
|||
|
|
{
|
|||
|
|
if (exception is MomSysException)
|
|||
|
|
{
|
|||
|
|
MomSysException ex = exception as MomSysException;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (exception is MomBizException)
|
|||
|
|
{
|
|||
|
|
MomBizException ex2 = exception as MomBizException;
|
|||
|
|
}
|
|||
|
|
string exceptionString = u8ApiBroker.GetExceptionString();
|
|||
|
|
if (exceptionString.Length != 0)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
para.ReturnValue = false;
|
|||
|
|
u8ApiBroker.Release();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
DOMDocument dOMDocument = u8ApiBroker.GetResult("ohead") as DOMDocument;
|
|||
|
|
if (dOMDocument != null)
|
|||
|
|
{
|
|||
|
|
para.DomHead = new DOMDocumentClass();
|
|||
|
|
para.DomHead.loadXML(dOMDocument.xml);
|
|||
|
|
}
|
|||
|
|
DOMDocument dOMDocument2 = u8ApiBroker.GetResult("obody") as DOMDocument;
|
|||
|
|
if (dOMDocument2 != null)
|
|||
|
|
{
|
|||
|
|
para.DomBody = new DOMDocumentClass();
|
|||
|
|
para.DomBody.loadXML(dOMDocument2.xml);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
|
|||
|
|
para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string;
|
|||
|
|
u8ApiBroker.Release();
|
|||
|
|
}
|
|||
|
|
catch (Exception err)
|
|||
|
|
{
|
|||
|
|
throw err;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
protected override string AddRdVoucher(VoucherParameter para)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
U8EnvContext u8EnvContext = new U8EnvContext();
|
|||
|
|
u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin;
|
|||
|
|
U8ApiAddress apiAddress = new U8ApiAddress(this.AddUrl);
|
|||
|
|
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
|
|||
|
|
u8EnvContext.SetApiContext("VouchType", this.VoucherID);
|
|||
|
|
u8ApiBroker.AssignNormalValue("ohead", para.DomHead);
|
|||
|
|
u8ApiBroker.AssignNormalValue("obody", para.DomBody);
|
|||
|
|
//给普通参数isadd赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示true新增,false修改
|
|||
|
|
u8ApiBroker.AssignNormalValue("isadd",true);
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (para.DOMMsg != null)
|
|||
|
|
{
|
|||
|
|
u8ApiBroker.AssignNormalValue("xmlmsg", para.DOMMsg);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
u8ApiBroker.AssignNormalValue("xmlmsg", new DOMDocumentClass());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// u8ApiBroker.AssignNormalValue("bReMote", para.IsReMote);
|
|||
|
|
if (!u8ApiBroker.Invoke())
|
|||
|
|
{
|
|||
|
|
Exception exception = u8ApiBroker.GetException();
|
|||
|
|
if (exception != null)
|
|||
|
|
{
|
|||
|
|
if (exception is MomSysException)
|
|||
|
|
{
|
|||
|
|
MomSysException ex = exception as MomSysException;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (exception is MomBizException)
|
|||
|
|
{
|
|||
|
|
MomBizException ex2 = exception as MomBizException;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
string exceptionString = u8ApiBroker.GetExceptionString();
|
|||
|
|
if (exceptionString.Length != 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
para.ReturnValue = false;
|
|||
|
|
|
|||
|
|
u8ApiBroker.Release();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
|
|||
|
|
|
|||
|
|
|
|||
|
|
para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string;
|
|||
|
|
|
|||
|
|
u8ApiBroker.Release();
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
catch (Exception err)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
throw err;
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public string AddVocher()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
VoucherParameter voucherParameter = new VoucherParameter
|
|||
|
|
{
|
|||
|
|
VoucherType = this.VoucherID,
|
|||
|
|
DomHead = new DOMDocumentClass(),
|
|||
|
|
DomBody = new DOMDocumentClass()
|
|||
|
|
};
|
|||
|
|
DOMDocument domHead = voucherParameter.DomHead;
|
|||
|
|
DOMDocument domBody = voucherParameter.DomBody;
|
|||
|
|
voucherParameter.DomHead.loadXML(HeadTemplate);
|
|||
|
|
voucherParameter.DomBody.loadXML(BodyTemplate);
|
|||
|
|
IXMLDOMElement headXml = domHead.createElement("z:row");
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
IXMLDOMElement bodyXml;
|
|||
|
|
//for (var n = 0; n < storeIn.details.Count(); n++)
|
|||
|
|
//{
|
|||
|
|
//var detail = storeIn.details[n];
|
|||
|
|
bodyXml = domBody.createElement("z:row");
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
domHead.selectSingleNode("//rs:data").appendChild(headXml);
|
|||
|
|
var str = voucherParameter.DomBody.xml;
|
|||
|
|
Console.WriteLine(str);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return AddRdVoucher(voucherParameter);
|
|||
|
|
}
|
|||
|
|
catch (Exception err)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
throw err;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|