2021-01-13 13:30:24 +08:00
|
|
|
|
using MSXML2;
|
|
|
|
|
|
using System;
|
2021-01-12 14:45:59 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2021-01-13 13:30:24 +08:00
|
|
|
|
using UFIDA.U8.U8APIFramework;
|
|
|
|
|
|
using UFIDA.U8.U8MOMAPIFramework;
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
|
|
|
|
|
namespace NX.ERP.U8.Store
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class VoucherBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private string voucherID;
|
|
|
|
|
|
|
2021-01-13 13:30:24 +08:00
|
|
|
|
private string BaseUrl;
|
2021-01-13 12:37:27 +08:00
|
|
|
|
|
2021-01-21 13:51:38 +08:00
|
|
|
|
private static string BasePath;
|
|
|
|
|
|
|
|
|
|
|
|
private const string FLODER_NAME = "xml";
|
|
|
|
|
|
|
|
|
|
|
|
static VoucherBase()
|
|
|
|
|
|
{
|
|
|
|
|
|
BasePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FLODER_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(BasePath))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(BasePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 13:30:24 +08:00
|
|
|
|
private string BodyFile
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-01-21 13:51:38 +08:00
|
|
|
|
return System.IO.Path.Combine(BasePath, $"XMLDomBody{this.voucherID}.xml");
|
2021-01-13 13:30:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string HeadFile
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-01-21 13:51:38 +08:00
|
|
|
|
return System.IO.Path.Combine(BasePath, $"XMLDomHead{this.voucherID}.xml");
|
|
|
|
|
|
|
2021-01-13 13:30:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-01-13 15:02:56 +08:00
|
|
|
|
protected string LoadUrl
|
2021-01-13 12:37:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-01-13 13:30:24 +08:00
|
|
|
|
return $"{BaseUrl}/Load";
|
2021-01-13 12:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-13 15:02:56 +08:00
|
|
|
|
protected string AddUrl
|
2021-01-13 12:37:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-01-13 13:30:24 +08:00
|
|
|
|
return $"{BaseUrl}/Add";
|
2021-01-13 12:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
|
|
|
|
|
protected string VoucherID
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.voucherID;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-01-13 12:37:27 +08:00
|
|
|
|
public VoucherBase(string voucherID, string Url)
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.voucherID = voucherID;
|
2021-01-13 13:30:24 +08:00
|
|
|
|
this.BaseUrl = Url;
|
2021-01-12 14:45:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected string HeadTemplate
|
2021-01-13 12:37:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
return this.GetHeadTemplate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected string BodyTemplate
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.GetBodyTemplate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetHeadTemplate()
|
|
|
|
|
|
{
|
2021-01-13 13:30:24 +08:00
|
|
|
|
var strTemlate = FileHelp.ReadFile(HeadFile);
|
2021-01-12 14:45:59 +08:00
|
|
|
|
if (strTemlate == string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadTemplate();
|
|
|
|
|
|
strTemlate = GetHeadTemplate();
|
|
|
|
|
|
}
|
|
|
|
|
|
return strTemlate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetBodyTemplate()
|
|
|
|
|
|
{
|
2021-01-13 13:30:24 +08:00
|
|
|
|
var strTemlate = FileHelp.ReadFile(BodyFile);
|
2021-01-12 14:45:59 +08:00
|
|
|
|
if (strTemlate == string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadTemplate();
|
|
|
|
|
|
strTemlate = GetBodyTemplate();
|
|
|
|
|
|
}
|
|
|
|
|
|
return strTemlate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 13:30:24 +08:00
|
|
|
|
|
|
|
|
|
|
private 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);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("sWhere", para.StrWhere);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("domPos", new DOMDocumentClass());
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("bGetBlank", para.IsGetBlank);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("sBodyWhere_Order", para.SBodyWhere_Order);
|
|
|
|
|
|
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("DomHead") as DOMDocument;
|
|
|
|
|
|
if (dOMDocument != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.DomHead = new DOMDocumentClass();
|
|
|
|
|
|
para.DomHead.loadXML(dOMDocument.xml);
|
|
|
|
|
|
}
|
|
|
|
|
|
DOMDocument dOMDocument2 = u8ApiBroker.GetResult("domBody") as DOMDocument;
|
|
|
|
|
|
if (dOMDocument2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.DomBody = new DOMDocumentClass();
|
|
|
|
|
|
para.DomBody.loadXML(dOMDocument2.xml);
|
|
|
|
|
|
}
|
|
|
|
|
|
DOMDocument dOMDocument3 = u8ApiBroker.GetResult("domPos") as DOMDocument;
|
|
|
|
|
|
if (dOMDocument3 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.DomPosition = new DOMDocumentClass();
|
|
|
|
|
|
para.DomPosition.loadXML(dOMDocument3.xml);
|
|
|
|
|
|
}
|
|
|
|
|
|
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
|
|
|
|
|
|
para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string;
|
|
|
|
|
|
u8ApiBroker.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex3)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw ex3;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected string AddRdVoucher(VoucherParameter para)
|
|
|
|
|
|
{
|
|
|
|
|
|
string VoucherId;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
U8EnvContext u8EnvContext = new U8EnvContext();
|
|
|
|
|
|
u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin;
|
|
|
|
|
|
U8ApiAddress apiAddress = new U8ApiAddress(this.AddUrl);
|
|
|
|
|
|
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("DomHead", para.DomHead);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("domBody", para.DomBody);
|
|
|
|
|
|
if (para.DomPosition != null && para.DomPosition.selectNodes("//z:row").length != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("cnnFrom", null);
|
|
|
|
|
|
if (para.DOMMsg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("domMsg", para.DOMMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("domMsg", new DOMDocumentClass());
|
|
|
|
|
|
}
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("bCheck", para.IsCheck);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("bBeforCheckStock", para.IsBeforCheckStock);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("bIsRedVouch", para.IsRedVouch);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("sAddedState", para.AddedState);
|
|
|
|
|
|
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.DOMMsg = u8ApiBroker.GetResult("domMsg") as DOMDocument;
|
|
|
|
|
|
|
|
|
|
|
|
para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string;
|
|
|
|
|
|
if (para.ReturnValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.VoucherId = u8ApiBroker.GetResult("VouchId") as string;
|
|
|
|
|
|
VoucherId = para.VoucherId;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception(para.ErrMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
u8ApiBroker.Release();
|
|
|
|
|
|
return VoucherId;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex3)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
throw ex3;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadTemplate()
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
VoucherParameter rdVoucherParameter = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-01-21 13:51:38 +08:00
|
|
|
|
|
2021-01-13 13:30:24 +08:00
|
|
|
|
rdVoucherParameter = new VoucherParameter
|
|
|
|
|
|
{
|
|
|
|
|
|
VoucherType = this.VoucherID,
|
|
|
|
|
|
IsGetBlank = true
|
|
|
|
|
|
};
|
|
|
|
|
|
this.LoadRdVoucher(rdVoucherParameter);
|
2021-01-12 14:45:59 +08:00
|
|
|
|
if (rdVoucherParameter.ReturnValue)
|
|
|
|
|
|
{
|
2021-01-13 13:30:24 +08:00
|
|
|
|
FileHelp.WriteFile(rdVoucherParameter.DomHead.xml, HeadFile);
|
|
|
|
|
|
FileHelp.WriteFile(rdVoucherParameter.DomBody.xml, BodyFile);
|
2021-01-12 14:45:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|