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; private string Url; public string LoadUrl { get { return $"{Url}/Load"; } } public string AddUrl { get { return $"{Url}/Add"; } } protected string VoucherID { get { return this.voucherID; } } public VoucherBase(string voucherID, string Url) { this.voucherID = voucherID; this.Url = Url; } protected string HeadTemplate { get { return this.GetHeadTemplate(); } } protected string BodyTemplate { get { return this.GetBodyTemplate(); } } private string GetHeadTemplate() { var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.RelativeSearchPath + $"XMLDOM\\XMLDomHead{this.voucherID}.xml"); if (strTemlate == string.Empty) { this.LoadTemplate(); strTemlate = GetHeadTemplate(); } return strTemlate; } private string GetBodyTemplate() { var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.RelativeSearchPath + $"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.RelativeSearchPath + "XMLDOM")) { Directory.CreateDirectory(AppDomain.CurrentDomain.RelativeSearchPath + "XMLDOM"); } rdVoucherParameter = new VoucherParameter(); rdVoucherParameter.VoucherType = this.VoucherID; rdVoucherParameter.IsGetBlank = true; U8LoginContext.Instance.LoadRdVoucher(this.LoadUrl, rdVoucherParameter); if (rdVoucherParameter.ReturnValue) { FileHelp.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.RelativeSearchPath + $"XMLDOM\\XMLDomHead{this.voucherID}.xml"); FileHelp.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.RelativeSearchPath + $"XMLDOM\\XMLDomBody{this.voucherID}.xml"); } } catch (Exception ex) { throw ex; } finally { } } } }