-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTransactionParser.cs
More file actions
70 lines (62 loc) · 1.96 KB
/
TransactionParser.cs
File metadata and controls
70 lines (62 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System.Xml;
using Ofx.Configuration;
using Ofx.Repository;
namespace Ofx
{
/// <summary>
/// Transaction parser
/// </summary>
public class TransactionParser
{
/// <summary>
/// Gets the file name
/// </summary>
public string File { get; private set; }
/// <summary>
/// Xml document
/// </summary>
private XmlDocument _doc = null;
/// <summary>
/// Statement
/// </summary>
public Statement ElectronicStatement { get; private set; }
/// <summary>
/// Default constructor
/// </summary>
public TransactionParser(string filename)
{
this.ReadFile(filename);
}
/// <summary>
/// Read ofx file
/// </summary>
/// <param name="filename">File name to read</param>
private void ReadFile(string filename)
{
this.File = filename;
this._doc = new XmlDocument();
this._doc.Load(filename);
// little to no checking here
// to be updated later if I need to
// check ofx
XmlElement ofx = this._doc[Config.S_OFX_HEADER];
if (ofx != null)
{
// check bank element
XmlElement bankmsgsrsv1 = ofx[Config.S_OFX_HEADER_BANK];
if (bankmsgsrsv1 != null)
{
// check statement transactions element
XmlElement stmttrnrs = bankmsgsrsv1[Config.S_OFX_HEADER_STATEMENT];
if (stmttrnrs != null)
{
// check statement element
XmlElement stmtrs = stmttrnrs[Config.S_OFX_HEADER_STATEMENT_TRANSACTIONS];
// get the full statement
this.ElectronicStatement = new Statement(stmtrs);
}
}
}
}
}
}