namespace com.hitrust.trustpay.client.b2c { using client; using System; using System.Collections; using System.IO; public class SettleFile { private string iBatchNo = ""; private ArrayList iDetailRecords = null; private string iSettleDate = ""; private string iSettleType = ""; public const string SETTLE_TYPE_SETTLE = "SETTLE"; public const string SETTLE_TYPE_TRX = "TRX"; public const string SETTLE_TYPE_TRX_BYHOUR = "TRXBYHOUR"; public SettleFile() { this.iDetailRecords = new ArrayList(); } public SettleFile init(TrxResponse aTrxResponse) { this.SettleDate = aTrxResponse.getValue("SettleDate"); this.SettleType = aTrxResponse.getValue("SettleType"); this.BatchNo = aTrxResponse.getValue("BatchNo"); this.NumOfPayments = int.Parse(aTrxResponse.getValue("NumOfPayments")); this.SumOfPayAmount = double.Parse(aTrxResponse.getValue("SumOfPayAmount")); this.NumOfRefunds = int.Parse(aTrxResponse.getValue("NumOfRefunds")); this.SumOfRefundAmount = double.Parse(aTrxResponse.getValue("SumOfRefundAmount")); if (this.iSettleType.Equals("SETTLE")) { this.SettleAmount = double.Parse(aTrxResponse.getValue("SettleAmount")); this.Fee = float.Parse(aTrxResponse.getValue("Fee")); } this.iDetailRecords = new XMLDocument(aTrxResponse.getValue("DetailRecords")).getDocuments("Record"); return this; } public SettleFile load(string aFileName) { StreamReader reader = null; try { reader = new StreamReader(new FileStream(aFileName, FileMode.Open)); this.init(new TrxResponse(new XMLDocument(reader.ReadToEnd() + "0000"))); } catch (Exception exception) { throw exception; } finally { if (reader != null) { try { reader.Close(); } catch (Exception) {} } } return this; } public SettleFile save(string aFileName) { StreamWriter writer = null; try { writer = new StreamWriter(new FileStream(aFileName, FileMode.CreateNew)); writer.Write("\n"); writer.Write(""); writer.Write(this.SettleDate); writer.Write("\n"); writer.Write(""); writer.Write(this.SettleType); writer.Write("\n"); writer.Write(""); writer.Write(this.BatchNo); writer.Write("\n"); writer.Write(""); writer.Write(this.NumOfPayments); writer.Write("\n"); writer.Write(""); writer.Write(this.SumOfPayAmount); writer.Write("\n"); writer.Write(""); writer.Write(this.NumOfRefunds); writer.Write("\n"); writer.Write(""); writer.Write(this.SumOfRefundAmount); writer.Write("\n"); if (this.iSettleType.Equals("SETTLE")) { writer.Write(""); writer.Write(this.SettleAmount); writer.Write("\n"); writer.Write(""); writer.Write(this.Fee); writer.Write("\n"); } writer.Write("\n"); for (int i = 0; i < this.iDetailRecords.Count; i++) { writer.Write(this.iDetailRecords[i]); writer.Write("\n"); } writer.Write("\n"); writer.Write("\n"); } catch (Exception exception) { throw exception; } finally { if (writer != null) { try { writer.Flush(); } catch (Exception) {} try { writer.Close(); } catch (Exception) {} } } return this; } public virtual string BatchNo { get { return this.iBatchNo; } set { this.iBatchNo = value.Trim(); } } public virtual ArrayList DetailRecords { get { return this.iDetailRecords; } set { this.iDetailRecords = value; } } public virtual float Fee { get; set; } public virtual int NumOfPayments { get; set; } public virtual int NumOfRefunds { get; set; } public virtual double SettleAmount { get; set; } public virtual string SettleDate { get { return this.iSettleDate; } set { this.iSettleDate = value.Trim(); } } public virtual string SettleType { get { return this.iSettleType; } set { this.iSettleType = value.Trim(); } } public virtual double SumOfPayAmount { get; set; } public virtual double SumOfRefundAmount { get; set; } } }