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 DevExpress.XtraEditors.Repository;
|
12
|
using DevExpress.XtraEditors.Controls;
|
13
|
using DevExpress.XtraEditors;
|
14
|
using System.Globalization;
|
15
|
using System.Threading;
|
16
|
using System.IO;
|
17
|
using Ingr.RAD2D;
|
18
|
using Converter.BaseModel;
|
19
|
using Converter.SPPID.Properties;
|
20
|
using Converter.SPPID.DB;
|
21
|
using Converter.SPPID.Util;
|
22
|
using Converter.SPPID.Form;
|
23
|
using Converter.SPPID.Model;
|
24
|
using Plaice;
|
25
|
using Llama;
|
26
|
|
27
|
|
28
|
namespace Converter.SPPID
|
29
|
{
|
30
|
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm
|
31
|
{
|
32
|
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>();
|
33
|
private List<SPPID_Document> _Documents = new List<SPPID_Document>();
|
34
|
public List<SPPID_Document> Documents { get { return _Documents; } }
|
35
|
private DataTable _ConverterDT = new DataTable();
|
36
|
private DataTable _SPPIDSymbolPathDT = new DataTable();
|
37
|
private DataTable _SPPIDUnitDT = new DataTable();
|
38
|
private DataTable _SPPIDAttributeDT = new DataTable();
|
39
|
private RepositoryItemComboBox templateComboBox;
|
40
|
|
41
|
|
42
|
private DataTable _ID2SymbolDT = new DataTable();
|
43
|
private DataTable _ID2ChildSymbolDT = new DataTable();
|
44
|
private DataTable _ID2LineDT = new DataTable();
|
45
|
private DataTable _ID2AttributeDT = new DataTable();
|
46
|
private DataTable _ID2DrawingAttributeDT = new DataTable();
|
47
|
private DataTable _ID2LinePropertyDT = new DataTable();
|
48
|
private DataTable _ID2SymbolTypeDT = new DataTable();
|
49
|
private DataTable _ID2SymbolTable = new DataTable();
|
50
|
|
51
|
|
52
|
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
|
53
|
private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>();
|
54
|
private List<LineMapping> lineMappings = new List<LineMapping>();
|
55
|
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
|
56
|
private List<AttributeMapping> attributeMappings = new List<AttributeMapping>();
|
57
|
|
58
|
string TemplatePath;
|
59
|
|
60
|
public ConverterForm()
|
61
|
{
|
62
|
InitializeComponent();
|
63
|
|
64
|
CultureInfo culture = CultureInfo.GetCultureInfo("ko");
|
65
|
Msg.Culture = culture;
|
66
|
|
67
|
this._SPPIDUnitDT = SPPIDUtil.GetUnitInfo();
|
68
|
TemplatePath = SPPIDUtil.T_OPTIONSETTING_Value("PID Template Path");
|
69
|
|
70
|
InitUsedDataTable();
|
71
|
InitGridControl();
|
72
|
InitID2Project();
|
73
|
}
|
74
|
|
75
|
private void InitUsedDataTable()
|
76
|
{
|
77
|
// Converter Table
|
78
|
DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
|
79
|
col.Caption = "Drawing File Name";
|
80
|
col = _ConverterDT.Columns.Add("colDrawingFilePath");
|
81
|
col.Caption = "DrawingFilePath";
|
82
|
col = _ConverterDT.Columns.Add("colUnit");
|
83
|
col.Caption = "Unit";
|
84
|
col = _ConverterDT.Columns.Add("colTemplate");
|
85
|
col.Caption = "Template";
|
86
|
col = _ConverterDT.Columns.Add("colDrawingNumber");
|
87
|
col.Caption = "Drawing Number";
|
88
|
col = _ConverterDT.Columns.Add("colDrawingName");
|
89
|
col.Caption = "Drawing Name";
|
90
|
col = _ConverterDT.Columns.Add("colStatus");
|
91
|
col.Caption = "Status";
|
92
|
col = _ConverterDT.Columns.Add("colUID");
|
93
|
|
94
|
col = _ID2LineDT.Columns.Add("UID");
|
95
|
col = _ID2LineDT.Columns.Add("Name");
|
96
|
col.Caption = "Name";
|
97
|
col = _ID2LineDT.Columns.Add("Type");
|
98
|
col.Caption = "Type";
|
99
|
col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH");
|
100
|
col.Caption = "SPPID Symbol Path";
|
101
|
col = _ID2LineDT.Columns.Add("Clear");
|
102
|
col.Caption = "";
|
103
|
}
|
104
|
|
105
|
private void InitGridControl()
|
106
|
{
|
107
|
#region Converter Page
|
108
|
gridViewConverter.OptionsSelection.MultiSelect = true;
|
109
|
gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
|
110
|
|
111
|
gridControlConverter.DataSource = _ConverterDT;
|
112
|
|
113
|
templateComboBox = new RepositoryItemComboBox();
|
114
|
templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
|
115
|
templateComboBox.EditValueChanged += templateComboBox_EditValueChanged;
|
116
|
gridControlConverter.RepositoryItems.Add(templateComboBox);
|
117
|
gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
|
118
|
|
119
|
gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
|
120
|
gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
|
121
|
gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
|
122
|
gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
|
123
|
gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
|
124
|
gridViewConverter.Columns["colUID"].Visible = false;
|
125
|
|
126
|
gridViewConverter.BestFitColumns();
|
127
|
#endregion
|
128
|
}
|
129
|
|
130
|
private void templateComboBox_EditValueChanged(object sender, EventArgs e)
|
131
|
{
|
132
|
gridViewConverter.CloseEditor();
|
133
|
gridViewConverter.UpdateCurrentRow();
|
134
|
}
|
135
|
|
136
|
private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
137
|
{
|
138
|
if (e.Column.Name == "colcolTemplate")
|
139
|
{
|
140
|
gridViewConverter.ShowEditor();
|
141
|
(gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup();
|
142
|
}
|
143
|
else if (e.Column.Name == "colcolUnit")
|
144
|
{
|
145
|
UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
|
146
|
if (unitForm.ShowDialog() == DialogResult.OK)
|
147
|
{
|
148
|
gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit);
|
149
|
gridViewConverter.CloseEditor();
|
150
|
gridViewConverter.UpdateCurrentRow();
|
151
|
}
|
152
|
}
|
153
|
}
|
154
|
|
155
|
private void btnID2DB_Click(object sender, EventArgs e)
|
156
|
{
|
157
|
ID2DBSetting form = new ID2DBSetting();
|
158
|
DialogResult dialogResult = form.ShowDialog();
|
159
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
160
|
_ProjectInfo.DefaultPath = Settings.Default.ProjectPath;
|
161
|
_ProjectInfo.DBType = (ID2DB_Type)Settings.Default.ProjectDBType;
|
162
|
_ProjectInfo.ServerIP = Settings.Default.ProjectServerIP;
|
163
|
_ProjectInfo.Port = Settings.Default.ProjectPort;
|
164
|
_ProjectInfo.DBUser = Settings.Default.ProjectDBUser;
|
165
|
_ProjectInfo.DBPassword = Settings.Default.ProjectDBPassword;
|
166
|
|
167
|
if (dialogResult == DialogResult.OK)
|
168
|
{
|
169
|
if (InitID2Project())
|
170
|
MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
171
|
else
|
172
|
MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
173
|
}
|
174
|
}
|
175
|
|
176
|
private bool InitID2Project()
|
177
|
{
|
178
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
179
|
if (Project_DB.ConnTestAndCreateTable())
|
180
|
{
|
181
|
_ProjectInfo.Enable = true;
|
182
|
labelDBType.Text = _ProjectInfo.DBType.ToString();
|
183
|
labelDBType.AppearanceItemCaption.ForeColor = Color.Blue;
|
184
|
labelID2ProjectName.Text = _ProjectInfo.Name;
|
185
|
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
|
186
|
labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
|
187
|
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
|
188
|
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
189
|
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
190
|
}
|
191
|
else
|
192
|
{
|
193
|
_ProjectInfo.Enable = false;
|
194
|
labelDBType.Text = " ";
|
195
|
labelID2ProjectName.Text = " ";
|
196
|
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
|
197
|
labelID2ProjectStatus.Text = Msg.ConnectionFail;
|
198
|
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
|
199
|
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
200
|
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
201
|
}
|
202
|
|
203
|
InitMapping();
|
204
|
InitSPPIDDB();
|
205
|
|
206
|
return _ProjectInfo.Enable;
|
207
|
}
|
208
|
|
209
|
private void InitMapping()
|
210
|
{
|
211
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
212
|
if (_ProjectInfo.Enable)
|
213
|
{
|
214
|
if (_ID2SymbolTable != null)
|
215
|
{
|
216
|
_ID2SymbolTable.Dispose();
|
217
|
_ID2SymbolTable = null;
|
218
|
}
|
219
|
_ID2SymbolTable = Project_DB.SelectID2SymbolTable();
|
220
|
|
221
|
if (_ID2SymbolTypeDT != null)
|
222
|
{
|
223
|
_ID2SymbolTypeDT.Dispose();
|
224
|
_ID2SymbolTypeDT = null;
|
225
|
}
|
226
|
_ID2SymbolTypeDT = Project_DB.SelectSymbolType();
|
227
|
InitID2Symbol();
|
228
|
InitID2Line();
|
229
|
InitID2LineNumber();
|
230
|
InitID2Attribute();
|
231
|
InitID2DrawingAttribute();
|
232
|
|
233
|
InitETCSetting();
|
234
|
}
|
235
|
}
|
236
|
|
237
|
private void InitETCSetting()
|
238
|
{
|
239
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
240
|
if (_ProjectInfo.Enable)
|
241
|
{
|
242
|
DataTable dt = Project_DB.SelectSetting();
|
243
|
foreach (DataRow item in dt.Rows)
|
244
|
{
|
245
|
string settingType = item["SettingType"].ToString();
|
246
|
if (settingType == "ETCSetting")
|
247
|
SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString());
|
248
|
else if (settingType == "GridSetting")
|
249
|
SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString());
|
250
|
}
|
251
|
}
|
252
|
}
|
253
|
|
254
|
private void InitID2Symbol()
|
255
|
{
|
256
|
using (DataTable symbolDT = Project_DB.SelectProjectSymbol())
|
257
|
{
|
258
|
symbolMappings.Clear();
|
259
|
_ID2SymbolDT = symbolDT;
|
260
|
_ID2SymbolDT.Columns.Add("Clear");
|
261
|
_ID2SymbolDT.Columns["Clear"].Caption = "";
|
262
|
foreach (DataRow row in symbolDT.Rows)
|
263
|
{
|
264
|
symbolMappings.Add(new SymbolMapping()
|
265
|
{
|
266
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
267
|
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
268
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
269
|
LEADERLINE = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"]
|
270
|
});
|
271
|
}
|
272
|
|
273
|
MergeID2ChildSymbol();
|
274
|
}
|
275
|
}
|
276
|
|
277
|
private void MergeID2ChildSymbol()
|
278
|
{
|
279
|
using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol())
|
280
|
{
|
281
|
childSymbolMappings.Clear();
|
282
|
_ID2ChildSymbolDT = childSymbolDT;
|
283
|
_ID2ChildSymbolDT.Columns.Add("Clear");
|
284
|
_ID2ChildSymbolDT.Columns["Clear"].Caption = "";
|
285
|
foreach (DataRow row in childSymbolDT.Rows)
|
286
|
{
|
287
|
childSymbolMappings.Add(new ChildSymbolMapping()
|
288
|
{
|
289
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
290
|
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
291
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
292
|
});
|
293
|
}
|
294
|
|
295
|
_ID2SymbolDT.Merge(_ID2ChildSymbolDT);
|
296
|
}
|
297
|
}
|
298
|
|
299
|
private void InitID2Line()
|
300
|
{
|
301
|
using (DataTable lineTypes = Project_DB.SelectProjectLine())
|
302
|
{
|
303
|
lineMappings.Clear();
|
304
|
_ID2LineDT.Rows.Clear();
|
305
|
foreach (DataRow row in lineTypes.Rows)
|
306
|
{
|
307
|
DataRow newRow = _ID2LineDT.NewRow();
|
308
|
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
|
309
|
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
|
310
|
newRow["Type"] = "Line";
|
311
|
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
|
312
|
_ID2LineDT.Rows.Add(newRow);
|
313
|
|
314
|
lineMappings.Add(new LineMapping()
|
315
|
{
|
316
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
317
|
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
|
318
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
319
|
});
|
320
|
}
|
321
|
}
|
322
|
}
|
323
|
|
324
|
private void InitID2LineNumber()
|
325
|
{
|
326
|
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties())
|
327
|
{
|
328
|
lineNumberMappings.Clear();
|
329
|
_ID2LinePropertyDT = linePropertiesDT;
|
330
|
_ID2LinePropertyDT.Columns.Add("Type");
|
331
|
foreach (DataRow row in linePropertiesDT.Rows)
|
332
|
{
|
333
|
row["Type"] = "Line Property";
|
334
|
lineNumberMappings.Add(new LineNumberMapping()
|
335
|
{
|
336
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
337
|
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(),
|
338
|
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
|
339
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
|
340
|
});
|
341
|
}
|
342
|
}
|
343
|
}
|
344
|
|
345
|
private void InitID2Attribute()
|
346
|
{
|
347
|
using (DataTable attributeDT = Project_DB.SelectProjectAttribute())
|
348
|
{
|
349
|
attributeMappings.Clear();
|
350
|
_ID2AttributeDT = attributeDT;
|
351
|
_ID2AttributeDT.Columns.Add("Clear");
|
352
|
_ID2AttributeDT.Columns["Clear"].Caption = "";
|
353
|
foreach (DataRow row in attributeDT.Rows)
|
354
|
{
|
355
|
attributeMappings.Add(new AttributeMapping()
|
356
|
{
|
357
|
UID = row["UID"] == null ? "" : row["UID"].ToString(),
|
358
|
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(),
|
359
|
Type = row["Type"] == null ? "" : row["Type"].ToString(),
|
360
|
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
|
361
|
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
|
362
|
Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"],
|
363
|
LeaderLine = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"],
|
364
|
IsText = DBNull.Value.Equals(row["ISTEXT"]) ? false : (bool)row["ISTEXT"]
|
365
|
});
|
366
|
}
|
367
|
}
|
368
|
}
|
369
|
|
370
|
private void InitID2DrawingAttribute()
|
371
|
{
|
372
|
using (DataTable drawingAttributeDT = Project_DB.SelectDrawingProjectAttribute())
|
373
|
{
|
374
|
_ID2DrawingAttributeDT = drawingAttributeDT;
|
375
|
}
|
376
|
}
|
377
|
|
378
|
private void InitSPPIDDB()
|
379
|
{
|
380
|
buttonEditDefaultUnit.TextChanged -= new EventHandler(buttonEditDefaultUnit_TextChanged);
|
381
|
comboBoxEditDefaultTemplate.SelectedIndexChanged -= new EventHandler(comboBoxEditDefaultTemplate_SelectedIndexChanged);
|
382
|
|
383
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
384
|
if (_ProjectInfo.Enable)
|
385
|
{
|
386
|
DataTable dt = Project_DB.SelectSPPID_DB_INFO();
|
387
|
if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
|
388
|
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
|
389
|
else
|
390
|
SPPID_DBInfo.Clear();
|
391
|
}
|
392
|
|
393
|
templateComboBox.Items.Clear();
|
394
|
comboBoxEditDefaultTemplate.SelectedIndex = -1;
|
395
|
comboBoxEditDefaultTemplate.Properties.Items.Clear();
|
396
|
buttonEditDefaultUnit.Text = "";
|
397
|
|
398
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
399
|
if (_SPPIDInfo.Enable)
|
400
|
{
|
401
|
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
|
402
|
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
|
403
|
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
|
404
|
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
|
405
|
|
406
|
if (!string.IsNullOrEmpty(TemplatePath))
|
407
|
{
|
408
|
List<string> templateFiles = Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList();
|
409
|
templateComboBox.Items.AddRange(templateFiles);
|
410
|
comboBoxEditDefaultTemplate.Properties.Items.AddRange(templateFiles);
|
411
|
}
|
412
|
|
413
|
if (_SPPIDAttributeDT != null)
|
414
|
{
|
415
|
_SPPIDAttributeDT.Dispose();
|
416
|
_SPPIDAttributeDT = null;
|
417
|
}
|
418
|
|
419
|
_SPPIDAttributeDT = SPPID_DB.GetSPPIDAttribute();
|
420
|
if (_SPPIDAttributeDT != null)
|
421
|
{
|
422
|
_SPPIDAttributeDT.Columns["DISPLAYNAME"].ColumnName = "DISPLAY NAME";
|
423
|
}
|
424
|
|
425
|
if (!string.IsNullOrEmpty(Settings.Default.DefaultTemplate) && comboBoxEditDefaultTemplate.Properties.Items.Contains(Settings.Default.DefaultTemplate))
|
426
|
comboBoxEditDefaultTemplate.SelectedItem = Settings.Default.DefaultTemplate;
|
427
|
|
428
|
// Unit 있는지 없는지 검사 필요
|
429
|
if (!string.IsNullOrEmpty(Settings.Default.DefaultUnit))
|
430
|
buttonEditDefaultUnit.Text = Settings.Default.DefaultUnit;
|
431
|
}
|
432
|
else
|
433
|
{
|
434
|
labelSPPIDPlantName.Text = " ";
|
435
|
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
|
436
|
labelSPPIDDBStatus.Text = Msg.ConnectionFail;
|
437
|
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
|
438
|
}
|
439
|
|
440
|
_DicDocuments.Clear();
|
441
|
_ConverterDT.Rows.Clear();
|
442
|
InitSPPIDSymbolTreeTable();
|
443
|
|
444
|
buttonEditDefaultUnit.TextChanged += new EventHandler(buttonEditDefaultUnit_TextChanged);
|
445
|
comboBoxEditDefaultTemplate.SelectedIndexChanged += new EventHandler(comboBoxEditDefaultTemplate_SelectedIndexChanged);
|
446
|
}
|
447
|
|
448
|
private void InitSPPIDSymbolTreeTable()
|
449
|
{
|
450
|
try
|
451
|
{
|
452
|
_SPPIDSymbolPathDT = new DataTable();
|
453
|
_SPPIDSymbolPathDT.Columns.Add("ID");
|
454
|
_SPPIDSymbolPathDT.Columns.Add("Parent");
|
455
|
_SPPIDSymbolPathDT.Columns.Add("Name");
|
456
|
_SPPIDSymbolPathDT.Columns.Add("FullPath");
|
457
|
|
458
|
string symbolPath = SPPIDUtil.T_OPTIONSETTING_Value("Catalog Explorer root path");
|
459
|
DirectoryInfo info = new DirectoryInfo(symbolPath);
|
460
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
|
461
|
loop(info, "0", symbolPath);
|
462
|
}
|
463
|
catch (Exception ex)
|
464
|
{
|
465
|
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
466
|
}
|
467
|
}
|
468
|
|
469
|
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
|
470
|
{
|
471
|
DirectoryInfo[] infos = parentInfo.GetDirectories();
|
472
|
foreach (DirectoryInfo info in infos)
|
473
|
{
|
474
|
string uid = Guid.NewGuid().ToString();
|
475
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
|
476
|
loop(info, uid, defaultPath);
|
477
|
|
478
|
FileInfo[] files = info.GetFiles("*.sym");
|
479
|
foreach (FileInfo fileInfo in files)
|
480
|
{
|
481
|
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
|
482
|
}
|
483
|
}
|
484
|
}
|
485
|
|
486
|
private void btnLoadFile_Click(object sender, EventArgs e)
|
487
|
{
|
488
|
List< BaseModel.Document> validationFailDocs = new List<BaseModel.Document>();
|
489
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
490
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
491
|
if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable)
|
492
|
{
|
493
|
MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
494
|
return;
|
495
|
}
|
496
|
|
497
|
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
|
498
|
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
|
499
|
{
|
500
|
foreach (string fileName in xtraOpenFileDialog.FileNames)
|
501
|
{
|
502
|
SPPID_Document document = new SPPID_Document(fileName, _ID2SymbolTypeDT);
|
503
|
|
504
|
document.SymbolTable = _ID2SymbolTable;
|
505
|
document.SymbolMappings = symbolMappings;
|
506
|
document.ChildSymbolMappings = childSymbolMappings;
|
507
|
document.LineMappings = lineMappings;
|
508
|
document.LineNumberMappings = lineNumberMappings;
|
509
|
document.AttributeMappings = attributeMappings;
|
510
|
document.ETCSetting = ETCSetting.GetInstance();
|
511
|
document.SetSPPIDInfo();
|
512
|
|
513
|
|
514
|
if (!document.SetSPPIDMapping())
|
515
|
{
|
516
|
document.Enable = false;
|
517
|
document.MappingValidation = false;
|
518
|
}
|
519
|
|
520
|
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
|
521
|
if (rows.Length == 0)
|
522
|
{
|
523
|
DataRow row = _ConverterDT.NewRow();
|
524
|
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
|
525
|
row["colDrawingFilePath"] = fileName;
|
526
|
row["colDrawingNumber"] = document.DWGNAME;
|
527
|
row["colDrawingName"] = document.DWGNAME;
|
528
|
if (document.Enable)
|
529
|
row["colStatus"] = "Ready";
|
530
|
else
|
531
|
row["colStatus"] = "Error";
|
532
|
row["colUID"] = "";
|
533
|
if (comboBoxEditDefaultTemplate.SelectedIndex > -1)
|
534
|
row["colTemplate"] = comboBoxEditDefaultTemplate.SelectedItem;
|
535
|
if (!string.IsNullOrEmpty(buttonEditDefaultUnit.Text))
|
536
|
row["colUnit"] = buttonEditDefaultUnit.Text;
|
537
|
|
538
|
_ConverterDT.Rows.Add(row);
|
539
|
|
540
|
if (document.Enable && document.Validation && document.MappingValidation)
|
541
|
gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
|
542
|
}
|
543
|
else
|
544
|
{
|
545
|
foreach (DataRow row in rows)
|
546
|
{
|
547
|
if (document.Enable)
|
548
|
row["colStatus"] = "Ready";
|
549
|
else
|
550
|
row["colStatus"] = "Error";
|
551
|
|
552
|
if (comboBoxEditDefaultTemplate.SelectedIndex > -1)
|
553
|
row["colTemplate"] = comboBoxEditDefaultTemplate.SelectedItem;
|
554
|
if (!string.IsNullOrEmpty(buttonEditDefaultUnit.Text))
|
555
|
row["colUnit"] = buttonEditDefaultUnit.Text;
|
556
|
|
557
|
if (document.Enable && document.Validation && document.MappingValidation)
|
558
|
gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
|
559
|
}
|
560
|
}
|
561
|
if (!_DicDocuments.ContainsKey(fileName))
|
562
|
_DicDocuments.Add(fileName, null);
|
563
|
|
564
|
if (!document.Validation || !document.MappingValidation)
|
565
|
validationFailDocs.Add(document);
|
566
|
|
567
|
_DicDocuments[fileName] = document;
|
568
|
}
|
569
|
if (validationFailDocs.Count > 0)
|
570
|
{
|
571
|
MessageForm messageForm = new MessageForm(validationFailDocs);
|
572
|
messageForm.ShowDialog();
|
573
|
}
|
574
|
}
|
575
|
}
|
576
|
|
577
|
/// <summary>
|
578
|
/// 선택한 도면의 정보를 로딩한다
|
579
|
/// </summary>
|
580
|
/// <param name="sender"></param>
|
581
|
/// <param name="e"></param>
|
582
|
private void btnRun_Click(object sender, EventArgs e)
|
583
|
{
|
584
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
585
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
586
|
if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable)
|
587
|
{
|
588
|
MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
589
|
return;
|
590
|
}
|
591
|
|
592
|
if (gridViewConverter.GetSelectedRows().Length == 0)
|
593
|
{
|
594
|
MessageBox.Show(Msg.SelectDocument, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
595
|
return;
|
596
|
}
|
597
|
DataTable tDrawing = Project_DB.SelectDrawings();
|
598
|
this._Documents.Clear();
|
599
|
foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
600
|
{
|
601
|
string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
|
602
|
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
603
|
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
604
|
string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
|
605
|
string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
|
606
|
|
607
|
DataRow[] rows = tDrawing.Select(string.Format("NAME = '{0}'", Path.GetFileNameWithoutExtension(_FilePath) + ".png"));
|
608
|
if (rows.Length != 1)
|
609
|
continue;
|
610
|
|
611
|
SPPID_Document document = _DicDocuments[_FilePath];
|
612
|
document.Unit = _Unit;
|
613
|
document.Template = _Template;
|
614
|
document.DrawingNumber = _DrawingNumber;
|
615
|
document.DrawingName = _DrawingName;
|
616
|
document.UID = rows[0]["UID"].ToString();
|
617
|
|
618
|
document.SymbolTable = _ID2SymbolTable;
|
619
|
document.SymbolMappings = symbolMappings;
|
620
|
document.ChildSymbolMappings = childSymbolMappings;
|
621
|
document.LineMappings = lineMappings;
|
622
|
document.LineNumberMappings = lineNumberMappings;
|
623
|
document.AttributeMappings = attributeMappings;
|
624
|
document.ETCSetting = ETCSetting.GetInstance();
|
625
|
document.SetSPPIDInfo();
|
626
|
|
627
|
if (document.SetSPPIDMapping() && document.Enable)
|
628
|
this._Documents.Add(document);
|
629
|
}
|
630
|
|
631
|
if (_Documents.Count > 50)
|
632
|
checkEditCloseDocument.Checked = true;
|
633
|
|
634
|
tDrawing.Dispose();
|
635
|
DialogResult = DialogResult.OK;
|
636
|
}
|
637
|
|
638
|
private void btnSPPIDDB_Click(object sender, EventArgs e)
|
639
|
{
|
640
|
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
|
641
|
if (form.ShowDialog() == DialogResult.OK)
|
642
|
InitSPPIDDB();
|
643
|
}
|
644
|
|
645
|
private void btnItemMapping_Click(object sender, EventArgs e)
|
646
|
{
|
647
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
648
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
649
|
if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable)
|
650
|
{
|
651
|
MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
652
|
return;
|
653
|
}
|
654
|
|
655
|
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT, _SPPIDAttributeDT, _ID2DrawingAttributeDT);
|
656
|
form.ShowDialog();
|
657
|
InitMapping();
|
658
|
}
|
659
|
private List<int> prevSelectedList = new List<int>();
|
660
|
|
661
|
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
662
|
{
|
663
|
if (e.Action == CollectionChangeAction.Add)
|
664
|
{
|
665
|
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
|
666
|
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
|
667
|
|
668
|
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
669
|
gridViewConverter.UnselectRow(e.ControllerRow);
|
670
|
}
|
671
|
else if (e.Action == CollectionChangeAction.Refresh)
|
672
|
{
|
673
|
foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
674
|
{
|
675
|
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
676
|
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
677
|
|
678
|
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
679
|
gridViewConverter.UnselectRow(rowHandle);
|
680
|
}
|
681
|
|
682
|
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
|
683
|
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
|
684
|
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
|
685
|
|
686
|
if (!firstNotSecond.Any() && !secondNotFirst.Any())
|
687
|
{
|
688
|
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
689
|
gridViewConverter.ClearSelection();
|
690
|
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
691
|
}
|
692
|
}
|
693
|
|
694
|
prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
|
695
|
}
|
696
|
|
697
|
private void buttonEditDefaulUnit_ButtonClick(object sender, ButtonPressedEventArgs e)
|
698
|
{
|
699
|
UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
|
700
|
if (unitForm.ShowDialog() == DialogResult.OK)
|
701
|
{
|
702
|
buttonEditDefaultUnit.Text = unitForm.SelectedUnit;
|
703
|
}
|
704
|
}
|
705
|
|
706
|
private void btnRefresh_Click(object sender, EventArgs e)
|
707
|
{
|
708
|
List<BaseModel.Document> validationFailDocs = new List<BaseModel.Document>();
|
709
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
710
|
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
|
711
|
if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable)
|
712
|
{
|
713
|
MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
714
|
return;
|
715
|
}
|
716
|
|
717
|
foreach (DataRow row in _ConverterDT.Rows)
|
718
|
{
|
719
|
string fileName = row["colDrawingFilePath"].ToString();
|
720
|
SPPID_Document document = new SPPID_Document(fileName, _ID2SymbolTypeDT);
|
721
|
document.SymbolTable = _ID2SymbolTable;
|
722
|
document.SymbolMappings = symbolMappings;
|
723
|
document.ChildSymbolMappings = childSymbolMappings;
|
724
|
document.LineMappings = lineMappings;
|
725
|
document.LineNumberMappings = lineNumberMappings;
|
726
|
document.AttributeMappings = attributeMappings;
|
727
|
document.ETCSetting = ETCSetting.GetInstance();
|
728
|
document.SetSPPIDInfo();
|
729
|
|
730
|
|
731
|
if (!document.SetSPPIDMapping())
|
732
|
{
|
733
|
document.Enable = false;
|
734
|
document.MappingValidation = false;
|
735
|
}
|
736
|
|
737
|
row["colDrawingNumber"] = document.DWGNAME;
|
738
|
row["colDrawingName"] = document.DWGNAME;
|
739
|
if (document.Enable)
|
740
|
row["colStatus"] = "Ready";
|
741
|
else
|
742
|
row["colStatus"] = "Error";
|
743
|
|
744
|
if (!_DicDocuments.ContainsKey(fileName))
|
745
|
_DicDocuments.Add(fileName, null);
|
746
|
|
747
|
if (!document.Validation || !document.MappingValidation)
|
748
|
validationFailDocs.Add(document);
|
749
|
|
750
|
_DicDocuments[fileName] = document;
|
751
|
|
752
|
if (document.Enable && document.Validation && document.MappingValidation)
|
753
|
gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
|
754
|
}
|
755
|
|
756
|
|
757
|
if (validationFailDocs.Count > 0)
|
758
|
{
|
759
|
MessageForm messageForm = new MessageForm(validationFailDocs);
|
760
|
messageForm.ShowDialog();
|
761
|
}
|
762
|
}
|
763
|
|
764
|
private void buttonEditDefaultUnit_TextChanged(object sender, EventArgs e)
|
765
|
{
|
766
|
Settings.Default.DefaultUnit = buttonEditDefaultUnit.Text;
|
767
|
Settings.Default.Save();
|
768
|
}
|
769
|
|
770
|
private void comboBoxEditDefaultTemplate_SelectedIndexChanged(object sender, EventArgs e)
|
771
|
{
|
772
|
Settings.Default.DefaultTemplate = comboBoxEditDefaultTemplate.SelectedItem.ToString();
|
773
|
Settings.Default.Save();
|
774
|
}
|
775
|
|
776
|
|
777
|
}
|
778
|
}
|