-
Notifications
You must be signed in to change notification settings - Fork 1
/
clsSW_Models.cs
525 lines (391 loc) · 21.8 KB
/
clsSW_Models.cs
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
//===============================================================================
// '
// SOFTWARE : "BearingCAD" '
// CLASS MODULE : clsSW_Models '
// VERSION NO : 2.0 '
// DEVELOPED BY : AdvEnSoft, Inc. '
// LAST MODIFIED : 05APR13 '
// '
//===============================================================================
//
//Routines
//--------
//===============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using EXCEL = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
namespace BearingCAD20
{
partial class clsSW_Models
{
#region "NAMED CONSTANTS:"
//------------------------
//....SW Files:
//........Model Files:
private const string mcRadial_Title = "RADIAL BEARING.SLDPRT";
private const string mcSeal_Title = "SEAL.SLDPRT";
private const string mcBlankAssy_Title = "BLANK.SLDASM";
private const string mcCompleteAssy_Title = "COMPLETE ASSY.SLDASM";
private const string mcTL_TB_Title = "TL THRUST BEARING.SLDPRT";
private const string mcTBAssy_Title = "THRUST BEARING ASSY.SLDASM";
//........Drawing Files:
//private const string mcDwg01_Title_Suffix = "-01.SLDDRW"; //SG 23JAN13
//private const string mcDwg02_Title_Suffix = "-02.SLDDRW";
//private const string mcDwg03_Title_Suffix = "-03.SLDDRW";
//private const string mcDwg04_Title_Suffix = "-04.SLDDRW";
//private const string mcDwg05_Title_Suffix = "-05.SLDDRW";
//private const string mcDwg06_Title_Suffix = "-06.SLDDRW";
//private const string mcDwg07_Title_Suffix = "-07.SLDDRW";
#endregion
#region "MEMBER VARIABLE DECLARATION"
//***********************************
private object mobjMissing = Missing.Value; //....Missing object.
private string[] mDwg_Title_Suffix = new string[8]; //....1-based
#endregion
#region "CLASS METHODS:"
//----------------------
////public void PopulateAndMove_SWFiles_ProjectFolder(clsFiles Files_In, clsProject Project_In,
//// clsOpCond OpCond_In, clsDB DB_In, string FilePath_In)
//////====================================================================================================
////{
//// //....SWFiles - Design tables, Model & Drawing files.
//// //
//// PopulateAndMove_DesignTables(Files_In, Project_In, OpCond_In, DB_In, FilePath_In);
//// CopyAndMove_SW_Model_Dwg_Files(Project_In, Files_In, FilePath_In);
////}
#region "DESIGN TABLES POPULATION:"
private void PopulateAndMove_DesignTables(clsFiles Files_In, clsProject Project_In,
clsOpCond OpCond_In, clsDB DB_In, string FilePath_In)
//===============================================================================================
{
//....This routine copies the design table templates to the project design tables, populates them
//........and places them in the given project folder.
Close_DesignTables();
// RADIAL:
// -------
Populate_tblMapping_Radial(Project_In, OpCond_In, DB_In); //....Software variable value field.
PopulateAndMove_DT_Radial(Files_In, Project_In, DB_In, FilePath_In); //....Design Table.
// BLANK Assy:
// -----------
Populate_tblMapping_Blank(Project_In, DB_In);
PopulateAndMove_DT_BlankAssy(Files_In, Project_In, DB_In, FilePath_In);
// SEAL:
// -----
if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Seal ||
Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Seal)
{
Populate_tblMapping_Seal(Project_In, DB_In);
PopulateAndMove_DT_Seal(Files_In, Project_In, DB_In, FilePath_In);
}
// TL THRUST BEARING:
// ------------------
if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Thrust_Bearing_TL ||
Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Thrust_Bearing_TL)
{
Populate_tblMapping_TL_TB(Project_In, DB_In);
PopulateAndMove_DT_TL_TB(Files_In, Project_In, DB_In, FilePath_In);
}
// THRUST BEARING ASSY:
// --------------------
if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Thrust_Bearing_TL ||
Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Thrust_Bearing_TL)
{
Populate_tblMapping_TB_Assy(Project_In, DB_In);
PopulateAndMove_DT_TB_Assy(Files_In, Project_In, DB_In, FilePath_In);
}
// COMPLETE ASSY:
// --------------
Populate_tblMapping_Complete(Project_In, OpCond_In, DB_In);
PopulateAndMove_DT_CompleteAssy(Files_In, Project_In, DB_In, FilePath_In);
}
#region "HELPER ROUTINES:"
private void Close_DesignTables()
//===============================
{
Process[] pProcesses = Process.GetProcesses();
try
{
foreach (Process p in pProcesses)
if (p.ProcessName == "EXCEL")
p.Kill();
}
catch (Exception pEXP)
{
}
}
#endregion
#endregion
#region "COPY & MOVE SW Model & Dwg FILES:"
////private void CopyAndMove_SW_Model_Dwg_Files(clsProject Project_In, clsFiles Files_In, String FilePath_In)
//////========================================================================================================
////{
//// try
//// {
//// // MODEL FILES.
//// // -----------
//// //
//// //....Complete Assy:
//// //
//// string pFileName_CompleteAssy = FilePath_In + "\\" + mcCompleteAssy_Title;
//// if (File.Exists(pFileName_CompleteAssy))
//// File.Delete(pFileName_CompleteAssy);
//// File.Copy(Files_In.FileTitle_Template_SW_CompleteAssy, pFileName_CompleteAssy);
//// //....Blank Assy:
//// //
//// string pFileName_BlankAssy = FilePath_In + "\\" + mcBlankAssy_Title;
//// if (File.Exists(pFileName_BlankAssy))
//// File.Delete(pFileName_BlankAssy);
//// File.Copy(Files_In.FileTitle_Template_SW_BlankAssy, pFileName_BlankAssy);
//// //....Radial:
//// //
//// string pFileName_Radial = FilePath_In + "\\" + mcRadial_Title;
//// if (File.Exists(pFileName_Radial))
//// File.Delete(pFileName_Radial);
//// File.Copy(Files_In.FileTitle_Template_SW_Radial, pFileName_Radial);
//// //....Seal:
//// //
//// if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Seal ||
//// Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Seal)
//// {
//// string pFileName_Seal = FilePath_In + "\\" + mcSeal_Title;
//// if (File.Exists(pFileName_Seal))
//// File.Delete(pFileName_Seal);
//// File.Copy(Files_In.FileTitle_Template_SW_Seal, pFileName_Seal);
//// }
//// //....Thrust Bearing:
//// //
//// if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Thrust_Bearing_TL ||
//// Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Thrust_Bearing_TL)
//// {
//// string pFileName_TL_TB = FilePath_In + "\\" + mcTL_TB_Title;
//// if (File.Exists(pFileName_TL_TB))
//// File.Delete(pFileName_TL_TB);
//// File.Copy(Files_In.FileTitle_Template_SW_TL_TB, pFileName_TL_TB);
//// string pFileName_TB_Assy = FilePath_In + "\\" + mcTBAssy_Title;
//// if (File.Exists(pFileName_TB_Assy))
//// File.Delete(pFileName_TB_Assy);
//// File.Copy(Files_In.FileTitle_Template_SW_TBAssy, pFileName_TB_Assy);
//// }
//// // DRAWING FILES.
//// // -------------
//// Populate_Dwg_Title_Suffix_Array(Project_In);
//// //....Complete Assy.
//// //
//// string pFileName_Dwg_CompleteAssy = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[1];
//// if (File.Exists(pFileName_Dwg_CompleteAssy))
//// File.Delete(pFileName_Dwg_CompleteAssy);
//// //File.Copy(Files_In.FileTitle_Template_SW_CompleteAssy, pFileName_Dwg_CompleteAssy);\
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_CompleteAssy, pFileName_Dwg_CompleteAssy);
//// //....Radial.
//// //
//// string pFileName_Dwg_Radial = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[2];
//// if (File.Exists(pFileName_Dwg_Radial))
//// File.Delete(pFileName_Dwg_Radial);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_Radial, pFileName_Dwg_Radial);
//// //....Roughing.
//// //
//// string pFileName_Dwg_Roughing = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[5];
//// if (File.Exists(pFileName_Dwg_Roughing))
//// File.Delete(pFileName_Dwg_Roughing);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_Roughing, pFileName_Dwg_Roughing);
//// //....Seal(s):
//// //
//// //....FRONT.
//// //
//// if (modMain.gProject.Product.EndConfig[0].Type == clsEndConfig.eType.Seal)
//// {
//// string pFileName_Dwg_Seal_Front = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[3];
//// if (File.Exists(pFileName_Dwg_Seal_Front))
//// File.Delete(pFileName_Dwg_Seal_Front);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_Seal, pFileName_Dwg_Seal_Front);
//// }
//// //....BACK.
//// //
//// if (modMain.gProject.Product.EndConfig[1].Type == clsEndConfig.eType.Seal)
//// {
//// string pFileName_Dwg_Seal_Back = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[4];
//// if (File.Exists(pFileName_Dwg_Seal_Back))
//// File.Delete(pFileName_Dwg_Seal_Back);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_Seal, pFileName_Dwg_Seal_Back);
//// }
//// //....Thrust Bearing(s):
//// //
//// //....FRONT.
//// //
//// if (modMain.gProject.Product.EndConfig[0].Type == clsEndConfig.eType.Thrust_Bearing_TL)
//// {
//// string pFileName_Dwg_TB_Front = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[3];
//// if (File.Exists(pFileName_Dwg_TB_Front))
//// File.Delete(pFileName_Dwg_TB_Front);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_TL_TB, pFileName_Dwg_TB_Front);
//// //....Blank.
//// string pFileName_Dwg_TB_Blank_Front = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[6];
//// if (File.Exists(pFileName_Dwg_TB_Blank_Front))
//// File.Delete(pFileName_Dwg_TB_Blank_Front);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_TL_TB_Blank, pFileName_Dwg_TB_Blank_Front);
//// }
//// //....BACK.
//// //
//// if (modMain.gProject.Product.EndConfig[1].Type == clsEndConfig.eType.Thrust_Bearing_TL)
//// {
//// string pFileName_Dwg_TB_Back = FilePath_In + "\\" + Project_In.AssyDwg.No + mDwg_Title_Suffix[4];
//// if (File.Exists(pFileName_Dwg_TB_Back))
//// File.Delete(pFileName_Dwg_TB_Back);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_TL_TB, pFileName_Dwg_TB_Back);
//// //....Blank.
//// //
//// string pDwg_Title_Suffix = "";
//// if (modMain.gProject.Product.EndConfig[0].Type == clsEndConfig.eType.Seal)
//// {
//// pDwg_Title_Suffix = mDwg_Title_Suffix[6];
//// }
//// else if (modMain.gProject.Product.EndConfig[0].Type == clsEndConfig.eType.Thrust_Bearing_TL)
//// {
//// pDwg_Title_Suffix = mDwg_Title_Suffix[7];
//// }
//// string pFileName_Dwg_TB_Blank_Back = FilePath_In + "\\" + Project_In.AssyDwg.No + pDwg_Title_Suffix;
//// if (File.Exists(pFileName_Dwg_TB_Blank_Back))
//// File.Delete(pFileName_Dwg_TB_Blank_Back);
//// File.Copy(Files_In.FileTitle_Template_SW_Dwg_TL_TB_Blank, pFileName_Dwg_TB_Blank_Back);
//// }
//// }
//// catch (Exception ex)
//// {
//// MessageBox.Show("Unable to copy SW File.Please close SW Files.");
//// }
////}
//private void Copy_Inventor_Model_Files(clsProject Project_In, clsFiles Files_In, String FilePath_In)
////===================================================================================================
//{
// try
// {
// // MODEL FILES.
// // -----------
// //
// //....Complete Assy:
// //
// string pFileName_CompleteAssy = FilePath_In + "\\" + Files_In.FileTitle_Template_Inventor_Complete;
// if (File.Exists(pFileName_CompleteAssy))
// File.Delete(pFileName_CompleteAssy);
// File.Copy(Files_In.FileTitle_Template_Inventor_Complete, pFileName_CompleteAssy);
// //....Radial Assy:
// //
// string pFileName_RadialAssy = FilePath_In + "\\" + Files_In.FileTitle_Template_Inventor_Radial_Assy;
// if (File.Exists(pFileName_RadialAssy))
// File.Delete(pFileName_RadialAssy);
// File.Copy(Files_In.FileTitle_Template_Inventor_Radial_Assy, pFileName_RadialAssy);
// //....Radial:
// //
// string pFileName_Radial = FilePath_In + "\\" + Files_In.FileTitle_Template_Inventor_Radial;
// if (File.Exists(pFileName_Radial))
// File.Delete(pFileName_Radial);
// File.Copy(Files_In.FileTitle_Template_Inventor_Radial, pFileName_Radial);
// //....Seal Front:
// //
// if (Project_In.Product.EndConfig[0].Type == clsEndConfig.eType.Seal)
// {
// string pFileName_Seal_Front = FilePath_In + "\\" + Files_In.FileTitle_Template_Inventor_Seal_Front;
// if (File.Exists(pFileName_Seal_Front))
// File.Delete(pFileName_Seal_Front);
// File.Copy(Files_In.FileTitle_Template_Inventor_Seal_Front, pFileName_Seal_Front);
// }
// //....Seal Back:
// //
// if (Project_In.Product.EndConfig[1].Type == clsEndConfig.eType.Seal)
// {
// string pFileName_Seal_Back = FilePath_In + "\\" + Files_In.FileTitle_Template_Inventor_Seal_Back;
// if (File.Exists(pFileName_Seal_Back))
// File.Delete(pFileName_Seal_Back);
// File.Copy(Files_In.FileTitle_Template_Inventor_Seal_Back, pFileName_Seal_Back);
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show("Unable to copy SW File.Please close SW Files.");
// }
//}
#region "HELPER ROUTINE:"
private void Populate_Dwg_Title_Suffix_Array (clsProject Project_In)
//==================================================================
{
int pNo = Convert.ToInt32(Project_In.AssyDwg.No_Suffix);
string pPrefix = "";
for (int i = 1; i < mDwg_Title_Suffix.Length; i++)
{
if (pNo < 10)
pPrefix = "-0";
else
pPrefix = "-";
mDwg_Title_Suffix [i] = pPrefix + pNo + ".SLDDRW";
pNo++;
}
}
#endregion
#endregion
#region "UTILITY ROUTINES:"
private string MatAbbr(string Mat_In)
//====================================
{
string pMat = null;
if (Mat_In.ToUpper().Contains("STEEL"))
pMat = "STL";
else if (Mat_In.ToUpper().Contains("BABBITT"))
pMat = "BABB";
else if (Mat_In.ToUpper().Contains("BRONZE"))
pMat = "BRNZ";
else
pMat = Mat_In;
return pMat;
}
private int ColumnNumber(string ColumnName_In)
//============================================
{
int pIndx = 0;
if (ColumnName_In.Length == 1)
{
for (int i = 0; i < 26; i++)
{
char[] pAny = ColumnName_In.ToCharArray();
if (pAny[0] == Convert.ToChar(65+i))
{
pIndx = (i+1);
break;
}
}
}
else if (ColumnName_In.Length == 2)
{
char[] pAny = ColumnName_In.ToCharArray();
for (int i = 0; i < 26; i++)
{
if (Convert.ToChar(65+i) == pAny[0])
{
pIndx = (i+1) * 26;
break;
}
}
for (int i = 0; i < 26; i++)
{
if (Convert.ToChar(65+i) == pAny[1])
{
pIndx = pIndx + i + 1;
break;
}
}
}
return pIndx;
}
#endregion
#endregion
}
}