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() + "<ReturnCode>0000</ReturnCode>")));
|
|
} 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("<SettleFile>\n");
|
|
writer.Write("<SettleDate>");
|
|
writer.Write(this.SettleDate);
|
|
writer.Write("</SettleDate>\n");
|
|
writer.Write("<SettleType>");
|
|
writer.Write(this.SettleType);
|
|
writer.Write("</SettleType>\n");
|
|
writer.Write("<BatchNo>");
|
|
writer.Write(this.BatchNo);
|
|
writer.Write("</BatchNo>\n");
|
|
writer.Write("<NumOfPayments>");
|
|
writer.Write(this.NumOfPayments);
|
|
writer.Write("</NumOfPayments>\n");
|
|
writer.Write("<SumOfPayAmount>");
|
|
writer.Write(this.SumOfPayAmount);
|
|
writer.Write("</SumOfPayAmount>\n");
|
|
writer.Write("<NumOfRefunds>");
|
|
writer.Write(this.NumOfRefunds);
|
|
writer.Write("</NumOfRefunds>\n");
|
|
writer.Write("<SumOfRefundAmount>");
|
|
writer.Write(this.SumOfRefundAmount);
|
|
writer.Write("</SumOfRefundAmount>\n");
|
|
if (this.iSettleType.Equals("SETTLE")) {
|
|
writer.Write("<SettleAmount>");
|
|
writer.Write(this.SettleAmount);
|
|
writer.Write("</SettleAmount>\n");
|
|
writer.Write("<Fee>");
|
|
writer.Write(this.Fee);
|
|
writer.Write("</Fee>\n");
|
|
}
|
|
writer.Write("<DetailRecords>\n");
|
|
for (int i = 0; i < this.iDetailRecords.Count; i++) {
|
|
writer.Write(this.iDetailRecords[i]);
|
|
writer.Write("\n");
|
|
}
|
|
writer.Write("</DetailRecords>\n");
|
|
writer.Write("</SettleFile>\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; }
|
|
}
|
|
}
|