1
|
using System;
|
2
|
using System.Collections.Generic;
|
3
|
using System.ComponentModel;
|
4
|
using System.Data;
|
5
|
using System.Drawing;
|
6
|
using System.Linq;
|
7
|
using System.Text;
|
8
|
using System.Threading.Tasks;
|
9
|
using System.Windows.Forms;
|
10
|
using Microsoft.VisualBasic;
|
11
|
using Converter.BaseModel;
|
12
|
using DevExpress.XtraEditors.Repository;
|
13
|
using DevExpress.XtraEditors.Controls;
|
14
|
using DevExpress.XtraEditors;
|
15
|
using System.Globalization;
|
16
|
using System.Threading;
|
17
|
using System.IO;
|
18
|
using Converter.SPPID.Properties;
|
19
|
using Converter.SPPID.DB;
|
20
|
using Converter.SPPID.Util;
|
21
|
using Converter.SPPID.Form;
|
22
|
using Converter.SPPID.Model;
|
23
|
|
24
|
namespace Converter.SPPID
|
25
|
{
|
26
|
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm
|
27
|
{
|
28
|
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>();
|
29
|
private List<SPPID_Document> _Documents = new List<SPPID_Document>();
|
30
|
public List<SPPID_Document> Documents { get { return _Documents; } }
|
31
|
private DataTable _ConverterDT = new DataTable();
|
32
|
private DataTable _SPPIDSymbolPathDT = new DataTable();
|
33
|
private DataTable _SPPIDUnitDT = new DataTable();
|
34
|
private RepositoryItemComboBox templateComboBox;
|
35
|
|
36
|
|
37
|
private DataTable _ID2SymbolDT = new DataTable();
|
38
|
private DataTable _ID2ChildSymbolDT = new DataTable();
|
39
|
private DataTable _ID2LineDT = new DataTable();
|
40
|
private DataTable _ID2AttributeDT = new DataTable();
|
41
|
private DataTable _ID2LinePropertyDT = new DataTable();
|
42
|
private DataTable _ID2SymbolTypeDT = new DataTable();
|
43
|
|
44
|
|
45
|
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
|
46
|
private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>();
|
47
|
private List<LineMapping> lineMappings = new List<LineMapping>();
|
48
|
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
|
49
|
private List<AttributeMapping> attributeMappings = new List<AttributeMapping>();
|
50
|
|
51
|
public ConverterForm()
|
52
|
{
|
53
|
InitializeComponent();
|
54
|
|
55
|
CultureInfo culture = CultureInfo.GetCultureInfo("ko");
|
56
|
Msg.Culture = culture;
|
57
|
|
58
|
InitUsedDataTable();
|
59
|
InitGridControl();
|
60
|
InitID2Project();
|
61
|
}
|
62
|
|
63
|
#region
|
64
|
/// <summary>
|
65
|
/// The Activate Event is where the command should show its form
|
66
|
/// if it should be displayed.
|
67
|
/// </summary>
|
68
|
/// <param name="sender">The sender of the event</param>
|
69
|
/// <param name="e">Arguments passed during event</param>
|
70
|
private void commandControl_Activate(object sender, EventArgs e)
|
71
|
{
|
72
|
Show();
|
73
|
//if (ShowDialog() == DialogResult.OK)
|
74
|
//{
|
75
|
|
76
|
//}
|
77
|
|
78
|
//foreach (var item in commandControl.Application.RADApplication.ActiveSelectSet)
|
79
|
//{
|
80
|
// //MessageBox.Show(item.GetType());
|
81
|
// int count = ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).VertexCount;
|
82
|
// double[] iii = null;
|
83
|
// ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertices(ref count, ref iii);
|
84
|
// for (int i = 0; i < count; i++)
|
85
|
// {
|
86
|
// double x = 0;
|
87
|
// double y = 0;
|
88
|
// ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertex(i + 1, ref x, ref y);
|
89
|
|
90
|
// }
|
91
|
// Ingr.RAD2D.Symbol2d symbol2D;
|
92
|
// //symbol2D.Move
|
93
|
//}
|
94
|
|
95
|
//commandControl.Application.RADApplication.Interactive = true;
|
96
|
//Hide();
|
97
|
//commandControl.Done = true;
|
98
|
}
|
99
|
|
100
|
/// <summary>
|
101
|
/// The Deactivate event is where the command should hide its form if it
|
102
|
/// was displayed. The command should not unload the form here.
|
103
|
/// The command's form should be unloaded in the Class Module Terminate event.
|
104
|
/// </summary>
|
105
|
/// <param name="sender">The sender of the event</param>
|
106
|
/// <param name="e">Arguments passed during event</param>
|
107
|
private void commandControl_Deactivate(object sender, EventArgs e)
|
108
|
{
|
109
|
Hide();
|
110
|
}
|
111
|
|
112
|
/// <summary>
|
113
|
/// The Initialize event is where the command should perform 1 time
|
114
|
/// initialization, for example it might save a reference to the
|
115
|
/// active document in private global data.
|
116
|
/// </summary>
|
117
|
/// <param name="sender">The sender of the event</param>
|
118
|
/// <param name="e">Arguments passed during event</param>
|
119
|
private void commandControl_Initialize(object sender, EventArgs e)
|
120
|
{
|
121
|
|
122
|
}
|
123
|
|
124
|
/// <summary>
|
125
|
/// The Terminate event is where the command can clean up any command
|
126
|
/// specific allocated resources.
|
127
|
/// </summary>
|
128
|
/// <param name="sender">The sender of the event</param>
|
129
|
/// <param name="e">Arguments passed during event</param>
|
130
|
public void commandControl_Terminate(object sender, EventArgs e)
|
131
|
{
|
132
|
|
133
|
}
|
134
|
|
135
|
/// <summary>
|
136
|
/// The primary form should not simply be unloaded. You should set the
|
137
|
/// Intergraph Command Control Done property to True when you want the
|
138
|
/// form to be unloaded. Then unload the form in the dispose method.
|
139
|
/// </summary>
|
140
|
/// <param name="sender">The sender of the event</param>
|
141
|
/// <param name="e">Arguments passed during event</param>
|
142
|
private void ConverterForm_FormClosing(object sender, FormClosingEventArgs e)
|
143
|
{
|
144
|
Hide();
|
145
|
commandControl.Done = true;
|
146
|
e.Cancel = true; //Do not let C# close out the form ... Let RAD close it.
|
147
|
}
|
148
|
#endregion
|
149
|
|
150
|
private void InitUsedDataTable()
|
151
|
{
|
152
|
// Converter Table
|
153
|
DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
|
154
|
col.Caption = "Drawing File Name";
|
155
|
col = _ConverterDT.Columns.Add("colDrawingFilePath");
|
156
|
col.Caption = "DrawingFilePath";
|
157
|
col = _ConverterDT.Columns.Add("colUnit");
|
158
|
col.Caption = "Unit";
|
159
|
col = _ConverterDT.Columns.Add("colTemplate");
|
160
|
col.Caption = "Template";
|
161
|
col = _ConverterDT.Columns.Add("colDrawingNumber");
|
162
|
col.Caption = "Drawing Number";
|
163
|
col = _ConverterDT.Columns.Add("colDrawingName");
|
164
|
col.Caption = "Drawing Name";
|
165
|
col = _ConverterDT.Columns.Add("colStatus");
|
166
|
col.Caption = "Status";
|
167
|
col = _ConverterDT.Columns.Add("colUID");
|
168
|
|
169
|
col = _ID2LineDT.Columns.Add("UID");
|
170
|
col = _ID2LineDT.Columns.Add("Name");
|
171
|
col.Caption = "Name";
|
172
|
col = _ID2LineDT.Columns.Add("Type");
|
173
|
col.Caption = "Type";
|
174
|
col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH");
|
175
|
col.Caption = "SPPID Symbol Path";
|
176
|
col = _ID2LineDT.Columns.Add("Clear");
|
177
|
col.Caption = "";
|
178
|
}
|
179
|
|
180
|
private void InitGridControl()
|
181
|
{
|
182
|
#region Converter Page
|
183
|
gridViewConverter.OptionsSelection.MultiSelect = true;
|
184
|
gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
|
185
|
|
186
|
gridControlConverter.DataSource = _ConverterDT;
|
187
|
|
188
|
templateComboBox = new RepositoryItemComboBox();
|
189
|
templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
|
190
|
templateComboBox.EditValueChanged += templateComboBox_EditValueChanged;
|
191
|
gridControlConverter.RepositoryItems.Add(templateComboBox);
|
192
|
gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
|
193
|
|
194
|
gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
|
195
|
gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
|
196
|
gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
|
197
|
gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
|
198
|
gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
|
199
|
gridViewConverter.Columns["colUID"].Visible = false;
|
200
|
|
201
|
gridViewConverter.BestFitColumns();
|
202
|
#endregion
|
203
|
}
|
204
|
|
205
|
private void templateComboBox_EditValueChanged(object sender, EventArgs e)
|
206
|
{
|
207
|
gridViewConverter.CloseEditor();
|
208
|
gridViewConverter.UpdateCurrentRow();
|
209
|
}
|
210
|
|
211
|
private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
212
|
{
|
213
|
if (e.Column.Name == "colcolTemplate")
|
214
|
{
|
215
|
gridViewConverter.ShowEditor();
|
216
|
(gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup();
|
217
|
}
|
218
|
else if (e.Column.Name == "colcolUnit")
|
219
|
{
|
220
|
UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
|
221
|
if (unitForm.ShowDialog() == DialogResult.OK)
|
222
|
{
|
223
|
gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit);
|
224
|
gridViewConverter.CloseEditor();
|
225
|
gridViewConverter.UpdateCurrentRow();
|
226
|
}
|
227
|
}
|
228
|
}
|
229
|
|
230
|
private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e)
|
231
|
{
|
232
|
xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text;
|
233
|
|
234
|
if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
|
235
|
{
|
236
|
if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
|
237
|
xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
|
238
|
Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath;
|
239
|
Settings.Default.Save();
|
240
|
if (InitID2Project())
|
241
|
{
|
242
|
MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
243
|
}
|
244
|
else
|
245
|
MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
246
|
}
|
247
|
}
|
248
|
|
249
|
private bool InitID2Project()
|
250
|
{
|
251
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
252
|
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath;
|
253
|
if (Project_DB.ConnTestAndCreateTable())
|
254
|
{
|
255
|
_ProjectInfo.Enable = true;
|
256
|
btnID2Project.Text = _ProjectInfo.DefaultPath;
|
257
|
labelID2ProjectName.Text = _ProjectInfo.Name;
|
258
|
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
|
259
|
labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
|
260
|
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
|
261
|
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
262
|
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
263
|
}
|
264
|
else
|
265
|
{
|
266
|
_ProjectInfo.Enable = false;
|
267
|
btnID2Project.Text = "";
|
268
|
labelID2ProjectName.Text = " ";
|
269
|
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
|
270
|
labelID2ProjectStatus.Text = Msg.ConnectionFail;
|
271
|
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
|
272
|
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
273
|
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
274
|
}
|
275
|
|
276
|
InitMapping();
|
277
|
InitSPPIDDB();
|
278
|
|
279
|
return _ProjectInfo.Enable;
|
280
|
}
|
281
|
|
282
|
private void InitMapping()
|
283
|
{
|
284
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
285
|
if (_ProjectInfo.Enable)
|
286
|
{
|
287
|
InitID2Symbol();
|
288
|
InitID2Line();
|
289
|
InitID2LineNumber();
|
290
|
InitID2Attribute();
|
291
|
|
292
|
InitETCSetting();
|
293
|
}
|
294
|
}
|
295
|
|
296
|
private void InitETCSetting()
|
297
|
{
|
298
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
299
|
if (_ProjectInfo.Enable)
|
300
|
{
|
301
|
DataTable dt = Project_DB.SelectETCSetting();
|
302
|
if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
|
303
|
SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString());
|
304
|
else
|
305
|
SPPID_DBInfo.Clear();
|
306
|
}
|
307
|
}
|
308
|
|
309
|
private void InitID2Symbol()
|
310
|
{
|
311
|
using (DataTable symbolDT = Project_DB.SelectProjectSymbol())
|
312
|
{
|
313
|
symbolMappings.Clear();
|
314
|
_ID2SymbolDT = symbolDT;
|
315
|
_ID2SymbolDT.Columns.Add("Clear");
|
316
|
_ID2SymbolDT.Columns["Clear"].Caption = "";
|
317
|
foreach (DataRow row in symbolDT.Rows)
|
318
|
{
|
319
|
symbolMappings.Add(new SymbolMapping()
|
320
|
{
|
321
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
322
|
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
323
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
324
|
});
|
325
|
}
|
326
|
|
327
|
MergeID2ChildSymbol();
|
328
|
}
|
329
|
}
|
330
|
|
331
|
private void MergeID2ChildSymbol()
|
332
|
{
|
333
|
using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol())
|
334
|
{
|
335
|
childSymbolMappings.Clear();
|
336
|
_ID2ChildSymbolDT = childSymbolDT;
|
337
|
_ID2ChildSymbolDT.Columns.Add("Clear");
|
338
|
_ID2ChildSymbolDT.Columns["Clear"].Caption = "";
|
339
|
foreach (DataRow row in childSymbolDT.Rows)
|
340
|
{
|
341
|
childSymbolMappings.Add(new ChildSymbolMapping()
|
342
|
{
|
343
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
344
|
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
345
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
346
|
});
|
347
|
}
|
348
|
|
349
|
_ID2SymbolDT.Merge(_ID2ChildSymbolDT);
|
350
|
}
|
351
|
}
|
352
|
|
353
|
private void InitID2Line()
|
354
|
{
|
355
|
using (DataTable lineTypes = Project_DB.SelectProjectLine())
|
356
|
{
|
357
|
lineMappings.Clear();
|
358
|
_ID2LineDT.Rows.Clear();
|
359
|
foreach (DataRow row in lineTypes.Rows)
|
360
|
{
|
361
|
DataRow newRow = _ID2LineDT.NewRow();
|
362
|
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
|
363
|
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
|
364
|
newRow["Type"] = "Line";
|
365
|
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
|
366
|
_ID2LineDT.Rows.Add(newRow);
|
367
|
|
368
|
lineMappings.Add(new LineMapping()
|
369
|
{
|
370
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
371
|
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
372
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
373
|
});
|
374
|
}
|
375
|
}
|
376
|
}
|
377
|
|
378
|
private void InitID2LineNumber()
|
379
|
{
|
380
|
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties())
|
381
|
{
|
382
|
lineNumberMappings.Clear();
|
383
|
_ID2LinePropertyDT = linePropertiesDT;
|
384
|
_ID2LinePropertyDT.Columns.Add("Type");
|
385
|
foreach (DataRow row in linePropertiesDT.Rows)
|
386
|
{
|
387
|
row["Type"] = "Line Property";
|
388
|
lineNumberMappings.Add(new LineNumberMapping()
|
389
|
{
|
390
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
391
|
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(),
|
392
|
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
|
393
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
|
394
|
});
|
395
|
}
|
396
|
}
|
397
|
}
|
398
|
|
399
|
private void InitID2Attribute()
|
400
|
{
|
401
|
using (DataTable attributeDT = Project_DB.SelectProjectAttribute())
|
402
|
{
|
403
|
attributeMappings.Clear();
|
404
|
_ID2AttributeDT = attributeDT;
|
405
|
_ID2AttributeDT.Columns.Add("Clear");
|
406
|
_ID2AttributeDT.Columns["Clear"].Caption = "";
|
407
|
foreach (DataRow row in attributeDT.Rows)
|
408
|
{
|
409
|
attributeMappings.Add(new AttributeMapping()
|
410
|
{
|
411
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
412
|
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(),
|
413
|
Type = row["Type"] == null ? "" : row["Type"].ToString(),
|
414
|
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
|
415
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
416
|
Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"]
|
417
|
});
|
418
|
}
|
419
|
}
|
420
|
}
|
421
|
|
422
|
private void InitSPPIDDB()
|
423
|
{
|
424
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
425
|
if (_ProjectInfo.Enable)
|
426
|
{
|
427
|
DataTable dt = Project_DB.SelectSPPID_DB_INFO();
|
428
|
if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
|
429
|
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
|
430
|
else
|
431
|
SPPID_DBInfo.Clear();
|
432
|
}
|
433
|
|
434
|
templateComboBox.Items.Clear();
|
435
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
436
|
if (_SPPIDInfo.Enable)
|
437
|
{
|
438
|
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
|
439
|
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
|
440
|
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
|
441
|
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
|
442
|
|
443
|
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
|
444
|
if (!string.IsNullOrEmpty(TemplatePath))
|
445
|
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList());
|
446
|
|
447
|
_SPPIDUnitDT = SPPID_DB.GetUnitTree();
|
448
|
|
449
|
layoutControlGroupAutoConverter.Enabled = true;
|
450
|
}
|
451
|
else
|
452
|
{
|
453
|
labelSPPIDPlantName.Text = " ";
|
454
|
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
|
455
|
labelSPPIDDBStatus.Text = Msg.ConnectionFail;
|
456
|
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
|
457
|
|
458
|
layoutControlGroupAutoConverter.Enabled = false;
|
459
|
}
|
460
|
|
461
|
_DicDocuments.Clear();
|
462
|
_ConverterDT.Rows.Clear();
|
463
|
InitSPPIDSymbolTreeTable();
|
464
|
}
|
465
|
|
466
|
private void InitSPPIDSymbolTreeTable()
|
467
|
{
|
468
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
469
|
|
470
|
try
|
471
|
{
|
472
|
_SPPIDSymbolPathDT = new DataTable();
|
473
|
_SPPIDSymbolPathDT.Columns.Add("ID");
|
474
|
_SPPIDSymbolPathDT.Columns.Add("Parent");
|
475
|
_SPPIDSymbolPathDT.Columns.Add("Name");
|
476
|
_SPPIDSymbolPathDT.Columns.Add("FullPath");
|
477
|
|
478
|
if (_SPPIDInfo.Enable)
|
479
|
{
|
480
|
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
|
481
|
DirectoryInfo info = new DirectoryInfo(symbolPath);
|
482
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
|
483
|
loop(info, "0", symbolPath);
|
484
|
}
|
485
|
}
|
486
|
catch (Exception ex)
|
487
|
{
|
488
|
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
489
|
}
|
490
|
}
|
491
|
|
492
|
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
|
493
|
{
|
494
|
DirectoryInfo[] infos = parentInfo.GetDirectories();
|
495
|
foreach (DirectoryInfo info in infos)
|
496
|
{
|
497
|
string uid = Guid.NewGuid().ToString();
|
498
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
|
499
|
loop(info, uid, defaultPath);
|
500
|
|
501
|
FileInfo[] files = info.GetFiles("*.sym");
|
502
|
foreach (FileInfo fileInfo in files)
|
503
|
{
|
504
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
|
505
|
}
|
506
|
}
|
507
|
}
|
508
|
|
509
|
private void btnLoadFile_Click(object sender, EventArgs e)
|
510
|
{
|
511
|
modeling.Test();
|
512
|
return;
|
513
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
514
|
if (!_ProjectInfo.Enable)
|
515
|
{
|
516
|
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
517
|
return;
|
518
|
}
|
519
|
|
520
|
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
|
521
|
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
|
522
|
{
|
523
|
foreach (string fileName in xtraOpenFileDialog.FileNames)
|
524
|
{
|
525
|
SPPID_Document document = new SPPID_Document(fileName);
|
526
|
|
527
|
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
|
528
|
DataRow row;
|
529
|
if (rows.Length == 0)
|
530
|
{
|
531
|
row = _ConverterDT.NewRow();
|
532
|
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
|
533
|
row["colDrawingFilePath"] = fileName;
|
534
|
row["colDrawingNumber"] = document.DWGNAME;
|
535
|
row["colDrawingName"] = document.DWGNAME;
|
536
|
if (document.Enable)
|
537
|
row["colStatus"] = "Ready";
|
538
|
else
|
539
|
row["colStatus"] = "Error";
|
540
|
row["colUID"] = "";
|
541
|
_ConverterDT.Rows.Add(row);
|
542
|
}
|
543
|
if (!_DicDocuments.ContainsKey(fileName))
|
544
|
_DicDocuments.Add(fileName, null);
|
545
|
|
546
|
_DicDocuments[fileName] = document;
|
547
|
}
|
548
|
}
|
549
|
}
|
550
|
static AutoModeling modeling;
|
551
|
private void btnRun_Click(object sender, EventArgs e)
|
552
|
{
|
553
|
#if DEBUG
|
554
|
this.Visible = false;
|
555
|
|
556
|
//SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml");
|
557
|
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\Isocynates-325_Page50.xml");
|
558
|
//SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\Isocynates-325_Page49.xml");
|
559
|
document.SymbolMappings = symbolMappings;
|
560
|
document.ChildSymbolMappings = childSymbolMappings;
|
561
|
document.LineMappings = lineMappings;
|
562
|
document.LineNumberMappings = lineNumberMappings;
|
563
|
document.AttributeMappings = attributeMappings;
|
564
|
document.ETCSetting = ETCSetting.GetInstance();
|
565
|
|
566
|
document.SetSPPIDInfo();
|
567
|
|
568
|
if (document.SetSPPIDMapping() && document.Enable)
|
569
|
{
|
570
|
modeling = new AutoModeling(document, commandControl.Application.RADApplication);
|
571
|
modeling.Run();
|
572
|
}
|
573
|
|
574
|
this.Visible = true;
|
575
|
return;
|
576
|
#endif
|
577
|
|
578
|
//_Documents.Clear();
|
579
|
|
580
|
//foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
581
|
//{
|
582
|
// string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
|
583
|
// string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
584
|
// string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
585
|
// string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
|
586
|
// string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
|
587
|
// SPPID_Document document = _DicDocuments[_FilePath];
|
588
|
// document.Unit = _Unit;
|
589
|
// document.Template = _Template;
|
590
|
// document.DrawingNumber = _DrawingNumber;
|
591
|
// document.DrawingName = _DrawingName;
|
592
|
// _Documents.Add(document);
|
593
|
//}
|
594
|
|
595
|
DialogResult = DialogResult.OK;
|
596
|
}
|
597
|
|
598
|
private void btnSPPIDDB_Click(object sender, EventArgs e)
|
599
|
{
|
600
|
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
|
601
|
if (form.ShowDialog() == DialogResult.OK)
|
602
|
InitSPPIDDB();
|
603
|
}
|
604
|
|
605
|
private void btnItemMapping_Click(object sender, EventArgs e)
|
606
|
{
|
607
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
608
|
if (!_ProjectInfo.Enable)
|
609
|
{
|
610
|
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
611
|
return;
|
612
|
}
|
613
|
|
614
|
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT);
|
615
|
form.ShowDialog();
|
616
|
InitMapping();
|
617
|
}
|
618
|
private List<int> prevSelectedList = new List<int>();
|
619
|
|
620
|
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
621
|
{
|
622
|
if (e.Action == CollectionChangeAction.Add)
|
623
|
{
|
624
|
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
|
625
|
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
|
626
|
|
627
|
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
628
|
gridViewConverter.UnselectRow(e.ControllerRow);
|
629
|
}
|
630
|
else if (e.Action == CollectionChangeAction.Refresh)
|
631
|
{
|
632
|
foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
633
|
{
|
634
|
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
635
|
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
636
|
|
637
|
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
638
|
gridViewConverter.UnselectRow(rowHandle);
|
639
|
}
|
640
|
|
641
|
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
|
642
|
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
|
643
|
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
|
644
|
|
645
|
if (!firstNotSecond.Any() && !secondNotFirst.Any())
|
646
|
{
|
647
|
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
648
|
gridViewConverter.ClearSelection();
|
649
|
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
650
|
}
|
651
|
}
|
652
|
|
653
|
prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
|
654
|
}
|
655
|
}
|
656
|
}
|