Files
U8-Import/NX.ERP.U8/Store/VoucherBase.cs

118 lines
3.0 KiB
C#
Raw Normal View History

2021-01-12 14:45:59 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NX.ERP.U8.Store
{
public abstract class VoucherBase
{
private string voucherID;
2021-01-13 12:37:27 +08:00
private string Url;
public string LoadUrl
{
get
{
return $"{Url}/Load";
}
}
public string AddUrl
{
get
{
return $"{Url}/Add";
}
}
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 12:37:27 +08:00
this.Url = 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 12:39:34 +08:00
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomHead{this.voucherID}.xml");
2021-01-12 14:45:59 +08:00
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetHeadTemplate();
}
return strTemlate;
}
private string GetBodyTemplate()
{
2021-01-13 12:39:34 +08:00
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomBody{this.voucherID}.xml");
2021-01-12 14:45:59 +08:00
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetBodyTemplate();
}
return strTemlate;
}
public void LoadTemplate()
{
VoucherParameter rdVoucherParameter = null;
try
{
2021-01-13 12:39:34 +08:00
if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM"))
2021-01-12 14:45:59 +08:00
{
2021-01-13 12:37:27 +08:00
Directory.CreateDirectory(AppDomain.CurrentDomain.RelativeSearchPath + "XMLDOM");
2021-01-12 14:45:59 +08:00
}
rdVoucherParameter = new VoucherParameter();
2021-01-13 12:37:27 +08:00
rdVoucherParameter.VoucherType = this.VoucherID;
2021-01-12 14:45:59 +08:00
rdVoucherParameter.IsGetBlank = true;
2021-01-13 12:37:27 +08:00
U8LoginContext.Instance.LoadRdVoucher(this.LoadUrl, rdVoucherParameter);
2021-01-12 14:45:59 +08:00
if (rdVoucherParameter.ReturnValue)
{
2021-01-13 12:39:34 +08:00
FileHelp.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomHead{this.voucherID}.xml");
FileHelp.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomBody{this.voucherID}.xml");
2021-01-12 14:45:59 +08:00
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
}
}