Files
U8-Import/NX.ERP.U8/Store/VoucherBase.cs
2021-01-12 14:45:59 +08:00

100 lines
2.6 KiB
C#

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;
protected string VoucherID
{
get
{
return this.voucherID;
}
}
public VoucherBase(string voucherID)
{
this.voucherID = voucherID;
}
protected string HeadTemplate
{
get
{
return this.GetHeadTemplate();
}
}
protected string BodyTemplate
{
get
{
return this.GetBodyTemplate();
}
}
private string GetHeadTemplate()
{
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomHead{this.voucherID}.xml");
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetHeadTemplate();
}
return strTemlate;
}
private string GetBodyTemplate()
{
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomBody{this.voucherID}.xml");
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetBodyTemplate();
}
return strTemlate;
}
public void LoadTemplate()
{
VoucherParameter rdVoucherParameter = null;
try
{
if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM"))
{
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM");
}
rdVoucherParameter = new VoucherParameter();
rdVoucherParameter.VoucherType =this.VoucherID;
rdVoucherParameter.IsGetBlank = true;
U8LoginContext.Instance.LoadRdVoucher(rdVoucherParameter);
if (rdVoucherParameter.ReturnValue)
{
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");
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
}
}