-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTDMConfig.cs
More file actions
433 lines (389 loc) · 11.1 KB
/
TDMConfig.cs
File metadata and controls
433 lines (389 loc) · 11.1 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data.SqlClient;
using System.Data;
namespace TDMEngine
{
#region enum def
public enum TDMMODE
{
STANDARD = 0,
SYS_DB,
COM_DB,
CF_DB,
CF_DB_IR,
}
public enum TDMOPTION
{
ALL = 0,
MASTER_ONLY = 1,
NUM_OPTION
}
#endregion
class TDMConfig
{
#region private members
string _primaryMDB = "";
string _IRMDB = "";
string _primaryDBFLocalPath = "";
string _IRDBFLocalPath = "";
string _primaryConStr = "";
string _IRConStr = "";
string _primaryDBName = "";
string _IRDBName = "";
bool _IsTrustedCon = false;
string _tdmFilePath = "";
string _currBuild = "";
string _destBuild = "";
string _currVersion = "";
string _snapshotName = "";
TDMMODE _tdmMode;
TDMOPTION _tdmOption;
bool _masterDB = true;
string _userID = "";
string _password = "";
int _snapshotType = 0;
string _snapshotUser = "";
string _snapshotDesc = "";
string _primaryServerName = "";
string _IRServerName = "";
string _EDMPath = "";
string _analysisPath = "";
string _PrimaryDBTempPath = "";
string _IRDBTempPath = "";
string _wceFolder = "";
public MSAccessInterface MSAccessInterface = null;
public Dictionary<String, TDMDestBuilds> DestBuilds;
public Dictionary<string, TableMap> SysDBTableList;
public Dictionary<string, TableMap> ComDBTableList;
public Dictionary<string, TableMap> CFDBTableList;
public Dictionary<string, TableMap> CFIRDBTableList;
public Dictionary<string, TableMap> SysLookupTableList;
private TDMDestBuilds _currentBuildInfo;
private DataTable[] _dataDictTables;
private long _totalErrors = 0;
#endregion
#region TDMConfig properties
public string PrimaryMDB
{
get { return _primaryMDB; }
set { _primaryMDB = value; }
}
public string IRMDB
{
get { return _IRMDB; }
set { _IRMDB = value; }
}
public string PrimaryDBName
{
get { return _primaryDBName; }
set { _primaryDBName = value; }
}
public string IRDBName
{
get { return _IRDBName; }
set { _IRDBName = value; }
}
public string PrimaryServerName
{
get { return _primaryServerName; }
set { _primaryServerName = value; }
}
public string IRServerName
{
get { return _IRServerName; }
set { _IRServerName = value; }
}
public string CurrBuild
{
get { return _currBuild; }
set { _currBuild = value; }
}
public string DestBuild
{
get { return _destBuild; }
set { _destBuild = value; }
}
public string TdmFilePath
{
get { return _tdmFilePath; }
set { _tdmFilePath = value; }
}
public string UserName
{
get { return _userID; }
set { _userID = value; }
}
public string Password
{
get { return _password; }
set { _password = value; }
}
public TDMMODE TDMMode
{
get { return _tdmMode; }
set { _tdmMode = value; }
}
public int SnapshotType
{
get { return _snapshotType; }
set { _snapshotType = value; }
}
public string SnapshotName
{
get { return _snapshotName; }
set { _snapshotName = value; }
}
public string SnapshotUser
{
get { return _snapshotUser; }
set { _snapshotUser = value; }
}
public long TotalErrors
{
get { return _totalErrors; }
set { _totalErrors = value; }
}
public string SnapshotDesc
{
get { return _snapshotDesc; }
set { _snapshotDesc = value; }
}
public bool CheckDate
{
get { return TDMEngineSettings.Default.CheckDate; }
}
public TDMDestBuilds CurrentBuildInfo
{
get { return _currentBuildInfo; }
set { _currentBuildInfo = value; }
}
public bool IsTrustedCon
{
get { return _IsTrustedCon; }
set { _IsTrustedCon = value; }
}
public bool MasterDB
{
get { return _masterDB; }
set { _masterDB = value; }
}
public string EDMPath
{
get { return _EDMPath; }
set { _EDMPath = value; }
}
public string WCEFolder
{
get { return _wceFolder ; }
set { _wceFolder = value; }
}
public string PrimaryDBTempPath
{
get { return _PrimaryDBTempPath; }
set { _PrimaryDBTempPath = value; }
}
public string AnalysisPath
{
get { return _analysisPath; }
set { _analysisPath = value; }
}
public string PrimaryConStr
{
get { return _primaryConStr; }
set { _primaryConStr = value; }
}
public string IRConStr
{
get { return _IRConStr; }
set { _IRConStr = value; }
}
public string IRDBTempPath
{
get { return _IRDBTempPath; }
set { _IRDBTempPath = value; }
}
public DataTable[] DataDictTables
{
get { return _dataDictTables; }
set { _dataDictTables = value; }
}
#endregion
#region public methods
public TDMConfig()
{
}
public bool IsEqecatSystemDB()
{
return (_tdmMode == TDMMODE.SYS_DB);
}
public bool IsEqecatCommonDB()
{
return (_tdmMode == TDMMODE.COM_DB);
}
public bool IsEqecatUserDB()
{
return (_tdmMode == TDMMODE.CF_DB || _tdmMode == TDMMODE.CF_DB_IR);
}
public void PutString(string csString, char csDelimiter = '|')
{
string key, value;
string[] options = csString.Split(csDelimiter);
// parse the options
foreach (string option in options)
{
key = option.Substring(0, option.IndexOf('='));
value = option.Substring(option.IndexOf('=') + 1);
if (key.Equals("MasterDBF", StringComparison.InvariantCultureIgnoreCase))
_primaryMDB = value;
else if (key.Equals("ResultDBF", StringComparison.InvariantCultureIgnoreCase))
_IRMDB = value;
else if (key.Equals("MasterDBFLocalPath", StringComparison.InvariantCultureIgnoreCase))
_primaryDBFLocalPath = value;
else if (key.Equals("ResultDBFLocalPath", StringComparison.InvariantCultureIgnoreCase))
_IRDBFLocalPath = value;
else if (key.Equals("MasterDSN", StringComparison.InvariantCultureIgnoreCase))
_primaryConStr = value;
else if (key.Equals("ResultDSN", StringComparison.InvariantCultureIgnoreCase))
_IRConStr = value;
else if (key.Equals("MasterDBN", StringComparison.InvariantCultureIgnoreCase))
_primaryDBName = value;
else if (key.Equals("ResultDBN", StringComparison.InvariantCultureIgnoreCase))
_IRDBName = value;
else if (key.Equals("MasterTempPath", StringComparison.InvariantCultureIgnoreCase))
_PrimaryDBTempPath = value;
else if (key.Equals("ResultTempPath", StringComparison.InvariantCultureIgnoreCase))
_IRDBTempPath = value;
else if (key.Equals("AnalysisPath", StringComparison.InvariantCultureIgnoreCase))
{
_analysisPath = value;
SetTDMFilePath(value);
}
else if (key.Equals("CurrBuild", StringComparison.InvariantCultureIgnoreCase))
{
_currBuild = value;
//_currVersion = GetWCeVersion(m_csCurrBuild);
_snapshotName = _snapshotName.Replace("@SnapshotName", _currVersion);
}
else if (key.Equals("DestBuild", StringComparison.InvariantCultureIgnoreCase))
_destBuild = value;
else if (key.Equals("TdmMode", StringComparison.InvariantCultureIgnoreCase))
_tdmMode = (TDMMODE)Int32.Parse(value);
else if (key.Equals("TDMOption", StringComparison.InvariantCultureIgnoreCase))
_tdmOption = (TDMOPTION)Int32.Parse(value);
else if (key.Equals("UserID", StringComparison.InvariantCultureIgnoreCase))
{
if (_userID == "")
_IsTrustedCon = true;
else
_userID = value;
}
else if (key.Equals("Password", StringComparison.InvariantCultureIgnoreCase))
_password = value;
else if (key.Equals("SSName", StringComparison.InvariantCultureIgnoreCase))
_snapshotName = value;
else if (key.Equals("SSDesc", StringComparison.InvariantCultureIgnoreCase))
_snapshotDesc = value;
else if (key.Equals("SSType", StringComparison.InvariantCultureIgnoreCase))
_snapshotType = Int32.Parse(value);
else if (key.Equals("SSUser", StringComparison.InvariantCultureIgnoreCase))
{
_snapshotUser = value;
_snapshotName = _snapshotName.Replace("@SnapshotUser", _snapshotUser);
_snapshotDesc = _snapshotDesc.Replace("@SnapshotUser", _snapshotUser);
}
}
_primaryServerName = ParseConnectionString(_primaryConStr);
_IRServerName = ParseConnectionString(_IRConStr);
}
public bool IsMigrateResults()
{
return (_tdmOption != TDMOPTION.MASTER_ONLY);
}
private string ParseConnectionString(string connstr)
{
SqlConnectionStringBuilder connStr = new SqlConnectionStringBuilder(connstr);
return connStr.DataSource;
}
public void SetTDMFilePath(string analysisPath)
{
// Check if we have the correct analysis path
// If not, base it on the location of TDMEngine32.exe
if (analysisPath.Length > 4) //Correct path
_tdmFilePath = Path.Combine(analysisPath, "TDM");
else
_tdmFilePath = Path.Combine(Environment.CurrentDirectory, "TDM");
string tdmMDBFile = Path.Combine(_tdmFilePath, TDMEngineSettings.Default.TDMFileName);
// if TDM.mdb is not found, check alternate path
if (!File.Exists(tdmMDBFile))
{
_tdmFilePath = Path.Combine(Directory.GetParent(analysisPath).FullName, "TDM");
tdmMDBFile = Path.Combine(_tdmFilePath, TDMEngineSettings.Default.TDMFileName);
}
// if TDM.mdb is not found, check alternate path
if (!File.Exists(tdmMDBFile))
{
_tdmFilePath = Path.Combine(Environment.CurrentDirectory, "ANALYSIS\\TDM");
tdmMDBFile = Path.Combine(_tdmFilePath + TDMEngineSettings.Default.TDMFileName);
// if TDM.mdb is still not found, error
if (!File.Exists(tdmMDBFile))
{
string csError = "TDMFile TDM.mdb not found.";
throw new TDMEngineException(csError);
}
}
}
public bool IsDictionaryTbl(string tablename)
{
foreach (DataDictTabNames tbl in Enum.GetValues(typeof(DataDictTabNames)))
{
if (tbl.ToString().ToUpper().Trim() == tablename.ToUpper().Trim())
return true;
}
return false;
}
public bool IsSystemLookupTable(string csTable)
{
bool success = false;
if (SysLookupTableList.ContainsKey(csTable.Trim().ToUpper()))
success = true;
return success;
}
public bool IsSystemDBTable(string csTable, bool logMsg = false)
{
bool success = false;
if (SysDBTableList.ContainsKey(csTable.Trim().ToUpper()))
success = true;
if (logMsg) LogWriter.LogIt(csTable + " is " + ((success) ? "" : "not ") + "an EqecatSystem table");
return success;
}
public bool IsCommonDBTable(string csTable, bool logMsg = false)
{
bool success = false;
if (ComDBTableList.ContainsKey(csTable.Trim().ToUpper()))
success = true;
if (logMsg) LogWriter.LogIt(csTable + " is " + ((success) ? "" : "not ") + "an EqecatCommon table");
return success;
}
public bool IsCFDBTable(string csTable, bool logMsg = false)
{
bool success = false;
if (CFDBTableList.ContainsKey(csTable.Trim().ToUpper()))
success = true;
if (logMsg) LogWriter.LogIt(csTable + " is " + ((success) ? "" : "not ") + "a CFDB table");
return success;
}
public bool IsCFIRDBTable(string csTable, bool logMsg = false)
{
bool success = false;
if (CFIRDBTableList.ContainsKey(csTable.Trim().ToUpper()))
success = true;
if (logMsg) LogWriter.LogIt(csTable + " is " + ((success) ? "" : "not ") + "a CFDB_IR table");
return success;
}
#endregion
}
}