-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSAccessInterface.cs
More file actions
228 lines (209 loc) · 6.79 KB
/
MSAccessInterface.cs
File metadata and controls
228 lines (209 loc) · 6.79 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eqecat.AccessMdbRelated;
using WCeFramework.WCeDBInterface;
using System.Data;
using System.Collections;
namespace TDMEngine
{
class MSAccessInterface
{
AccessDbInterface accessDbInterface = null;
int _migrStepCount = 0;
public string accessDBError = "";
public MSAccessInterface(string tdmFile)
{
accessDBError = GetAccessDbInterface(tdmFile);
}
public string GetAccessDbInterface(string tdmFile)
{
try
{
AccessDbConnectionMdb accessDbConnectionMdb = new AccessDbConnectionMdb();
accessDbInterface = new AccessDbInterface(accessDbConnectionMdb.GetMSAccess2007Connection (tdmFile));
return "";
}
catch (Exception ex)
{
return ex.Message ;
}
}
private int GetTotalSteps(string tdmTbl)
{
int cnt=0;
string s = string.Format(TDMEngineSettings.Default.A_SQL_GetMigrStepCount, new string[] { tdmTbl });
DataTable dt = accessDbInterface.ExecuteSql(s,null);
if (dt != null && dt.Rows.Count > 0)
{
cnt = Int32.Parse(dt.Rows[0][0].ToString());
}
return cnt;
}
public int GetTotalMigrStepsCount()
{
return _migrStepCount;
}
public Dictionary<String, TDMDestBuilds> GetDestBuilds(string srcBuild, string destBuild)
{
Dictionary<String, TDMDestBuilds> destBuildTable = new Dictionary<String, TDMDestBuilds>();
DataTable dt = null;
try
{
string s = string.Format(TDMEngineSettings.Default.A_SQL_GetDestBuilds, new string[] { srcBuild, destBuild });
LogWriter.LogIt(s);
dt = accessDbInterface.ExecuteSql(s,null);
if (dt.Rows.Count > 0)
{
foreach (DataRow dataRow in dt.Rows)
{
TDMDestBuilds tdmDestBuildInfo = new TDMDestBuilds();
string destWceBuild = (string)dataRow["DESTBUILD"];
tdmDestBuildInfo.DestWceBuild = destWceBuild;
string destWceVersion = (string)dataRow["DESTWCE"];
tdmDestBuildInfo.DestWceVersion = destWceVersion;
tdmDestBuildInfo.SourceWceBuild = dataRow["SRCBUILD"] != System.DBNull.Value ? (string)dataRow["SRCBUILD"] : "";
tdmDestBuildInfo.SourceWceBuild = dataRow["SRCWCE"] != System.DBNull.Value ? (string)dataRow["SRCWCE"] : "";
tdmDestBuildInfo.DBSchema = dataRow["DBSCHEMA"] != System.DBNull.Value ? (string)dataRow["DBSCHEMA"] : "";
tdmDestBuildInfo.TableName = dataRow["TDMTBL"] != System.DBNull.Value ? (string)dataRow["TDMTBL"] : "";
tdmDestBuildInfo.EDMDir = dataRow["EDMDIR"] != System.DBNull.Value ? (string)dataRow["EDMDIR"] : "";
tdmDestBuildInfo.ArcSchema = dataRow["ARCSCHEMA"] != System.DBNull.Value ? (string)dataRow["ARCSCHEMA"] : "";
tdmDestBuildInfo.EqeVer = dataRow["SRCEQE"] != System.DBNull.Value ? (string)dataRow["SRCEQE"] : "";
tdmDestBuildInfo.Desc = dataRow["DESC"] != System.DBNull.Value ? (string)dataRow["DESC"] : "";
tdmDestBuildInfo.FlCertVer = dataRow["FL_CERTVER"] != System.DBNull.Value ? (string)dataRow["FL_CERTVER"] : "";
tdmDestBuildInfo.NoteDelete = dataRow["NOTEDELETE"] != System.DBNull.Value ? (string)dataRow["NOTEDELETE"] : "";
tdmDestBuildInfo.NotePreserve = dataRow["NOTEPRESERVE"] != System.DBNull.Value ? (string)dataRow["NOTEPRESERVE"] : "";
// tdmDestBuildInfo.PrevDate = dataRow["PREVDATE"] != System.DBNull.Value ? (DateTime )dataRow["PREVDATE"] : "";
tdmDestBuildInfo.PrevDate = (DateTime)dataRow["PREVDATE"] ;
String destKey = destWceVersion + " - " + destWceBuild.Replace(TDMEngineSettings.Default.StringToReplace, String.Empty);
destBuildTable.Add(destKey, tdmDestBuildInfo);
_migrStepCount += GetTotalSteps(tdmDestBuildInfo.TableName);
}
}
}
catch (Exception )
{
accessDBError = "Error reading TDMCTRL";
}
finally
{
if (dt != null)
dt.Clear();
}
return destBuildTable;
}
public ArrayList GetTDMTblData(string tableName)
{
ArrayList MigrSteps = new ArrayList();
DataTable dt = null;
string colName=string.Empty ;
try
{
if(tableName.Equals("TDMPRECMD")||tableName.Equals("TDMPOSTCMD")) // We have an extra column EDMDIR
colName="EDMDIR," ;
string s = string.Format(TDMEngineSettings.Default.A_SQL_GetTDMTableData, new string[] { tableName, colName });
dt = accessDbInterface.ExecuteSql(s,null);
if (dt.Rows.Count > 0)
{
foreach (DataRow dataRow in dt.Rows)
{
TdmTableStep tdmTbl = new TdmTableStep();
tdmTbl.Key = dataRow["KEY"] != System.DBNull.Value ? (Int32 )dataRow["KEY"] : 0;
tdmTbl.Seq = dataRow["SEQ"] != System.DBNull.Value ? (Int32)dataRow["SEQ"] : 0;
tdmTbl.Defect = dataRow["DEFECT"] != System.DBNull.Value ? (Int32)dataRow["DEFECT"] : 0;
tdmTbl.Rem_sql = dataRow["REM_SQL"] != System.DBNull.Value ? (string)dataRow["REM_SQL"] : "";
tdmTbl.Tname = dataRow["TNAME"] != System.DBNull.Value ? (string)dataRow["TNAME"] :"";
tdmTbl.Cmd_sql = dataRow["CMD_SQL"] != System.DBNull.Value ? (string)dataRow["CMD_SQL"] : "";
tdmTbl.Depend = dataRow["DEPEND"] != System.DBNull.Value ? (string)dataRow["DEPEND"] : "";
tdmTbl.Notes = dataRow["NOTES"] != System.DBNull.Value ? (string)dataRow["NOTES"] : "";
tdmTbl.Type = dataRow["TYPE"] != System.DBNull.Value ? (string)dataRow["TYPE"] : "";
tdmTbl.Descr = dataRow["DESCR"] != System.DBNull.Value ? (string)dataRow["DESCR"] : "";
if(tableName.Equals("TDMPRECMD")||tableName.Equals("TDMPOSTCMD"))
tdmTbl.EdmDir = dataRow["EDMDIR"] != System.DBNull.Value ? (string)dataRow["EDMDIR"] : "";
MigrSteps.Add(tdmTbl);
}
}
}
catch (Exception ex)
{
accessDBError = "Error in " + tableName +". " + ex ;
}
finally
{
if (dt != null)
dt.Clear();
}
return MigrSteps;
}
}
class TdmTableStep
{
Int32 _key;
Int32 _seq;
string _rem_sql;
Int32 _defect;
string _descr;
string _type;
string _tname;
string _depend;
string _cmd_sql;
string _notes;
string _edmdir = "";
public Int32 Key
{
get { return _key; }
set { _key = value; }
}
public Int32 Seq
{
get { return _seq; }
set { _seq = value; }
}
public string Rem_sql
{
get { return _rem_sql; }
set { _rem_sql = value; }
}
public Int32 Defect
{
get { return _defect; }
set { _defect = value; }
}
public string Descr
{
get { return _descr; }
set { _descr = value; }
}
public string Type
{
get { return _type; }
set { _type = value; }
}
public string Tname
{
get { return _tname; }
set { _tname = value; }
}
public string Depend
{
get { return _depend; }
set { _depend = value; }
}
public string Cmd_sql
{
get { return _cmd_sql; }
set { _cmd_sql = value; }
}
public string Notes
{
get { return _notes; }
set { _notes = value; }
}
public string EdmDir
{
get { return _edmdir; }
set { _edmdir = value; }
}
}
}