/[msmoney_db_parser]/trunk/libmsmoneyfile/jetdb_parser.cs
ViewVC logotype

Contents of /trunk/libmsmoneyfile/jetdb_parser.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations) (download)
Mon Sep 19 05:09:46 2016 UTC (2 years, 9 months ago) by william
File size: 3149 byte(s)
add some files that were not comitted
1 using System;
2 using System.Data;
3 using System.Data.Odbc;
4 using Enterprise.Logging;
5
6 namespace libmsmoneyfile
7 {
8 internal class jetdb_parser : IMSMoneyParser
9 {
10 public jetdb_parser (IMSMoneyFile file)
11 {
12 if (file.FileType != MSMONEY_FILE_TYPE.STANDARDJET_DATABASE_FILE) {
13 throw new InvalidOperationException (string.Format("Not a JET Database file: '{0}'", file.FileType.ToString ()));
14 }
15 m_File = file;
16 parse ();
17 }
18 #region IMSMoneyParser member
19 private IMSMoneyFile m_File;
20
21 public IMSMoneyFile File{ get { return m_File; } }
22 #endregion
23 private void parse ()
24 {
25 try {
26 // MDBTools Driver
27 // /usr/lib64/libmdbodbc.so.0
28
29 // Driver={Microsoft Access Driver (*.mdb)}
30
31 //string connectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + "\"" + m_File.File + "\"";
32
33 string connectionString= "";
34
35 var builder = new MDBConnectionStringBuilder(m_File.File);
36 connectionString = builder.BuildConnectionString();
37 //string connectionString = string.Format ("Driver=MDBTools Driver;SERVERNAME=localhost;UID=;PWD=;DATABASE={0}", m_File.File);
38 //string connectionString = string.Format ("Driver=Microsoft Access Driver (*.mdb);SERVERNAME=localhost;UID=;PWD=;DATABASE={0}", m_File.File);
39 //string connectionString = string.Format ("Driver=/usr/lib/libmdb.so; DBQ=///{0}; UID=; PWD=;", m_File.File);
40 //string connectionString = string.Format ("Driver=MDBTools Driver;DBQ=///{0};UID=;PWD=;", m_File.File);
41
42 gLog.Verbose.Debug.WriteLine("connectionString: {0}", connectionString);
43 OdbcConnection dbcon;
44 dbcon = new OdbcConnection(connectionString);
45 dbcon.Open ();
46 // IDbCommand dbcmd = dbcon.CreateCommand();
47 // string sql = "select * from MSysObjects";
48 // dbcmd.CommandText = sql;
49 // IDataReader reader = dbcmd.ExecuteReader();
50 // int index=0;
51 // while(reader.Read()) {
52 //
53 // int count = reader.FieldCount;
54 // for(int i=0;i<count;i++)
55 // {
56 //
57 // try {
58 // object o = reader[i];
59 // gLog.Verbose.Debug.WriteLine("[{0}]::reader[{1}]: {2} [{3}]", index, i, o == null ? "(null)" : o.ToString().Replace("\0",""), o == null ? "" : o.GetType().Name);
60 // }
61 // catch(Exception ex)
62 // {
63 // gLog.Error.WriteLine("An error occured -- '{0}'", ex.Message);
64 // //gLog.Verbose.Error.WriteLine(ex.ToString());
65 // }
66 // }
67 // index++;
68 //
69 // }
70
71 var tables = dbcon.GetSchema();
72 // for(int i =0; i < tables.Rows.Count;i++)
73 // {
74 // tables.Rows[i];
75 // }
76 gLog.Verbose.Debug.WriteLine("Colums: {0} Rows: {1}", tables.Columns.Count, tables.Rows.Count);
77 for(int i=0;i<tables.Rows.Count;i++)
78 {
79 var row = tables.Rows[i];
80 var cols = row.ItemArray;
81 for(int j=0;j<cols.Length;j++)
82 {
83 string col_name = tables.Columns[j].ColumnName;
84 gLog.Verbose.Debug.WriteLine("[{0}]: '{1}' = '{2}'", i, col_name, cols[j] == null ? "(null)" : cols[j].ToString());
85 }
86
87 }
88
89
90
91
92
93 // reader.Close();
94 // reader = null;
95 // dbcmd.Dispose();
96 // dbcmd = null;
97 dbcon.Close();
98 dbcon = null;
99 }
100 catch (Exception ex)
101 {
102 throw;
103 }
104 }
105 }
106 }

  ViewVC Help
Powered by ViewVC 1.1.22