hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ d19ae675
이력 | 보기 | 이력해설 | 다운로드 (23.8 KB)
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 |
|
25 |
namespace Converter.SPPID |
26 |
{ |
27 |
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
28 |
{ |
29 |
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
30 |
private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
31 |
public List<SPPID_Document> Documents { get { return _Documents; } } |
32 |
private DataTable _ConverterDT = new DataTable(); |
33 |
private DataTable _SPPIDSymbolPathDT = new DataTable(); |
34 |
private DataTable _SPPIDUnitDT = new DataTable(); |
35 |
private RepositoryItemComboBox templateComboBox; |
36 |
|
37 |
|
38 |
private DataTable _ID2SymbolDT = new DataTable(); |
39 |
private DataTable _ID2ChildSymbolDT = new DataTable(); |
40 |
private DataTable _ID2LineDT = new DataTable(); |
41 |
private DataTable _ID2AttributeDT = new DataTable(); |
42 |
private DataTable _ID2LinePropertyDT = new DataTable(); |
43 |
private DataTable _ID2SymbolTypeDT = new DataTable(); |
44 |
|
45 |
|
46 |
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
47 |
private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>(); |
48 |
private List<LineMapping> lineMappings = new List<LineMapping>(); |
49 |
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
50 |
private List<AttributeMapping> attributeMappings = new List<AttributeMapping>(); |
51 |
|
52 |
public ConverterForm() |
53 |
{ |
54 |
InitializeComponent(); |
55 |
|
56 |
CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
57 |
Msg.Culture = culture; |
58 |
|
59 |
InitUsedDataTable(); |
60 |
InitGridControl(); |
61 |
InitID2Project(); |
62 |
} |
63 |
|
64 |
private void InitUsedDataTable() |
65 |
{ |
66 |
// Converter Table |
67 |
DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
68 |
col.Caption = "Drawing File Name"; |
69 |
col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
70 |
col.Caption = "DrawingFilePath"; |
71 |
col = _ConverterDT.Columns.Add("colUnit"); |
72 |
col.Caption = "Unit"; |
73 |
col = _ConverterDT.Columns.Add("colTemplate"); |
74 |
col.Caption = "Template"; |
75 |
col = _ConverterDT.Columns.Add("colDrawingNumber"); |
76 |
col.Caption = "Drawing Number"; |
77 |
col = _ConverterDT.Columns.Add("colDrawingName"); |
78 |
col.Caption = "Drawing Name"; |
79 |
col = _ConverterDT.Columns.Add("colStatus"); |
80 |
col.Caption = "Status"; |
81 |
col = _ConverterDT.Columns.Add("colUID"); |
82 |
|
83 |
col = _ID2LineDT.Columns.Add("UID"); |
84 |
col = _ID2LineDT.Columns.Add("Name"); |
85 |
col.Caption = "Name"; |
86 |
col = _ID2LineDT.Columns.Add("Type"); |
87 |
col.Caption = "Type"; |
88 |
col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
89 |
col.Caption = "SPPID Symbol Path"; |
90 |
col = _ID2LineDT.Columns.Add("Clear"); |
91 |
col.Caption = ""; |
92 |
} |
93 |
|
94 |
private void InitGridControl() |
95 |
{ |
96 |
#region Converter Page |
97 |
gridViewConverter.OptionsSelection.MultiSelect = true; |
98 |
gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
99 |
|
100 |
gridControlConverter.DataSource = _ConverterDT; |
101 |
|
102 |
templateComboBox = new RepositoryItemComboBox(); |
103 |
templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
104 |
templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
105 |
gridControlConverter.RepositoryItems.Add(templateComboBox); |
106 |
gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
107 |
|
108 |
gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
109 |
gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
110 |
gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
111 |
gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
112 |
gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
113 |
gridViewConverter.Columns["colUID"].Visible = false; |
114 |
|
115 |
gridViewConverter.BestFitColumns(); |
116 |
#endregion |
117 |
} |
118 |
|
119 |
private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
120 |
{ |
121 |
gridViewConverter.CloseEditor(); |
122 |
gridViewConverter.UpdateCurrentRow(); |
123 |
} |
124 |
|
125 |
private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
126 |
{ |
127 |
if (e.Column.Name == "colcolTemplate") |
128 |
{ |
129 |
gridViewConverter.ShowEditor(); |
130 |
(gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
131 |
} |
132 |
else if (e.Column.Name == "colcolUnit") |
133 |
{ |
134 |
UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
135 |
if (unitForm.ShowDialog() == DialogResult.OK) |
136 |
{ |
137 |
gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
138 |
gridViewConverter.CloseEditor(); |
139 |
gridViewConverter.UpdateCurrentRow(); |
140 |
} |
141 |
} |
142 |
} |
143 |
|
144 |
private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
145 |
{ |
146 |
xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
147 |
|
148 |
if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
149 |
{ |
150 |
if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\') |
151 |
xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1); |
152 |
Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath; |
153 |
Settings.Default.Save(); |
154 |
if (InitID2Project()) |
155 |
{ |
156 |
MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
157 |
} |
158 |
else |
159 |
MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
160 |
} |
161 |
} |
162 |
|
163 |
private bool InitID2Project() |
164 |
{ |
165 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
166 |
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
167 |
if (Project_DB.ConnTestAndCreateTable()) |
168 |
{ |
169 |
_ProjectInfo.Enable = true; |
170 |
btnID2Project.Text = _ProjectInfo.DefaultPath; |
171 |
labelID2ProjectName.Text = _ProjectInfo.Name; |
172 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
173 |
labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
174 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
175 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
176 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
177 |
} |
178 |
else |
179 |
{ |
180 |
_ProjectInfo.Enable = false; |
181 |
btnID2Project.Text = ""; |
182 |
labelID2ProjectName.Text = " "; |
183 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
184 |
labelID2ProjectStatus.Text = Msg.ConnectionFail; |
185 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
186 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
187 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
188 |
} |
189 |
|
190 |
InitMapping(); |
191 |
InitSPPIDDB(); |
192 |
|
193 |
return _ProjectInfo.Enable; |
194 |
} |
195 |
|
196 |
private void InitMapping() |
197 |
{ |
198 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
199 |
if (_ProjectInfo.Enable) |
200 |
{ |
201 |
InitID2Symbol(); |
202 |
InitID2Line(); |
203 |
InitID2LineNumber(); |
204 |
InitID2Attribute(); |
205 |
|
206 |
InitETCSetting(); |
207 |
} |
208 |
} |
209 |
|
210 |
private void InitETCSetting() |
211 |
{ |
212 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
213 |
if (_ProjectInfo.Enable) |
214 |
{ |
215 |
DataTable dt = Project_DB.SelectETCSetting(); |
216 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
217 |
SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
218 |
else |
219 |
SPPID_DBInfo.Clear(); |
220 |
} |
221 |
} |
222 |
|
223 |
private void InitID2Symbol() |
224 |
{ |
225 |
using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
226 |
{ |
227 |
symbolMappings.Clear(); |
228 |
_ID2SymbolDT = symbolDT; |
229 |
_ID2SymbolDT.Columns.Add("Clear"); |
230 |
_ID2SymbolDT.Columns["Clear"].Caption = ""; |
231 |
foreach (DataRow row in symbolDT.Rows) |
232 |
{ |
233 |
symbolMappings.Add(new SymbolMapping() |
234 |
{ |
235 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
236 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
237 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
238 |
}); |
239 |
} |
240 |
|
241 |
MergeID2ChildSymbol(); |
242 |
} |
243 |
} |
244 |
|
245 |
private void MergeID2ChildSymbol() |
246 |
{ |
247 |
using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol()) |
248 |
{ |
249 |
childSymbolMappings.Clear(); |
250 |
_ID2ChildSymbolDT = childSymbolDT; |
251 |
_ID2ChildSymbolDT.Columns.Add("Clear"); |
252 |
_ID2ChildSymbolDT.Columns["Clear"].Caption = ""; |
253 |
foreach (DataRow row in childSymbolDT.Rows) |
254 |
{ |
255 |
childSymbolMappings.Add(new ChildSymbolMapping() |
256 |
{ |
257 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
258 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
259 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
260 |
}); |
261 |
} |
262 |
|
263 |
_ID2SymbolDT.Merge(_ID2ChildSymbolDT); |
264 |
} |
265 |
} |
266 |
|
267 |
private void InitID2Line() |
268 |
{ |
269 |
using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
270 |
{ |
271 |
lineMappings.Clear(); |
272 |
_ID2LineDT.Rows.Clear(); |
273 |
foreach (DataRow row in lineTypes.Rows) |
274 |
{ |
275 |
DataRow newRow = _ID2LineDT.NewRow(); |
276 |
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
277 |
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
278 |
newRow["Type"] = "Line"; |
279 |
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
280 |
_ID2LineDT.Rows.Add(newRow); |
281 |
|
282 |
lineMappings.Add(new LineMapping() |
283 |
{ |
284 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
285 |
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
286 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
287 |
}); |
288 |
} |
289 |
} |
290 |
} |
291 |
|
292 |
private void InitID2LineNumber() |
293 |
{ |
294 |
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
295 |
{ |
296 |
lineNumberMappings.Clear(); |
297 |
_ID2LinePropertyDT = linePropertiesDT; |
298 |
_ID2LinePropertyDT.Columns.Add("Type"); |
299 |
foreach (DataRow row in linePropertiesDT.Rows) |
300 |
{ |
301 |
row["Type"] = "Line Property"; |
302 |
lineNumberMappings.Add(new LineNumberMapping() |
303 |
{ |
304 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
305 |
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
306 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
307 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
308 |
}); |
309 |
} |
310 |
} |
311 |
} |
312 |
|
313 |
private void InitID2Attribute() |
314 |
{ |
315 |
using (DataTable attributeDT = Project_DB.SelectProjectAttribute()) |
316 |
{ |
317 |
attributeMappings.Clear(); |
318 |
_ID2AttributeDT = attributeDT; |
319 |
_ID2AttributeDT.Columns.Add("Clear"); |
320 |
_ID2AttributeDT.Columns["Clear"].Caption = ""; |
321 |
foreach (DataRow row in attributeDT.Rows) |
322 |
{ |
323 |
attributeMappings.Add(new AttributeMapping() |
324 |
{ |
325 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
326 |
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
327 |
Type = row["Type"] == null ? "" : row["Type"].ToString(), |
328 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
329 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
330 |
Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"] |
331 |
}); |
332 |
} |
333 |
} |
334 |
} |
335 |
|
336 |
private void InitSPPIDDB() |
337 |
{ |
338 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
339 |
if (_ProjectInfo.Enable) |
340 |
{ |
341 |
DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
342 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
343 |
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
344 |
else |
345 |
SPPID_DBInfo.Clear(); |
346 |
} |
347 |
|
348 |
templateComboBox.Items.Clear(); |
349 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
350 |
if (_SPPIDInfo.Enable) |
351 |
{ |
352 |
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
353 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
354 |
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
355 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
356 |
|
357 |
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
358 |
if (!string.IsNullOrEmpty(TemplatePath)) |
359 |
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
360 |
|
361 |
_SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
362 |
|
363 |
layoutControlGroupAutoConverter.Enabled = true; |
364 |
} |
365 |
else |
366 |
{ |
367 |
labelSPPIDPlantName.Text = " "; |
368 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
369 |
labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
370 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
371 |
|
372 |
layoutControlGroupAutoConverter.Enabled = false; |
373 |
} |
374 |
|
375 |
_DicDocuments.Clear(); |
376 |
_ConverterDT.Rows.Clear(); |
377 |
InitSPPIDSymbolTreeTable(); |
378 |
} |
379 |
|
380 |
private void InitSPPIDSymbolTreeTable() |
381 |
{ |
382 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
383 |
|
384 |
try |
385 |
{ |
386 |
_SPPIDSymbolPathDT = new DataTable(); |
387 |
_SPPIDSymbolPathDT.Columns.Add("ID"); |
388 |
_SPPIDSymbolPathDT.Columns.Add("Parent"); |
389 |
_SPPIDSymbolPathDT.Columns.Add("Name"); |
390 |
_SPPIDSymbolPathDT.Columns.Add("FullPath"); |
391 |
|
392 |
if (_SPPIDInfo.Enable) |
393 |
{ |
394 |
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
395 |
DirectoryInfo info = new DirectoryInfo(symbolPath); |
396 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
397 |
loop(info, "0", symbolPath); |
398 |
} |
399 |
} |
400 |
catch (Exception ex) |
401 |
{ |
402 |
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
403 |
} |
404 |
} |
405 |
|
406 |
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
407 |
{ |
408 |
DirectoryInfo[] infos = parentInfo.GetDirectories(); |
409 |
foreach (DirectoryInfo info in infos) |
410 |
{ |
411 |
string uid = Guid.NewGuid().ToString(); |
412 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
413 |
loop(info, uid, defaultPath); |
414 |
|
415 |
FileInfo[] files = info.GetFiles("*.sym"); |
416 |
foreach (FileInfo fileInfo in files) |
417 |
{ |
418 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
419 |
} |
420 |
} |
421 |
} |
422 |
|
423 |
private void btnLoadFile_Click(object sender, EventArgs e) |
424 |
{ |
425 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
426 |
if (!_ProjectInfo.Enable) |
427 |
{ |
428 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
429 |
return; |
430 |
} |
431 |
|
432 |
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
433 |
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
434 |
{ |
435 |
foreach (string fileName in xtraOpenFileDialog.FileNames) |
436 |
{ |
437 |
SPPID_Document document = new SPPID_Document(fileName); |
438 |
|
439 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
440 |
DataRow row; |
441 |
if (rows.Length == 0) |
442 |
{ |
443 |
row = _ConverterDT.NewRow(); |
444 |
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
445 |
row["colDrawingFilePath"] = fileName; |
446 |
row["colDrawingNumber"] = document.DWGNAME; |
447 |
row["colDrawingName"] = document.DWGNAME; |
448 |
if (document.Enable) |
449 |
row["colStatus"] = "Ready"; |
450 |
else |
451 |
row["colStatus"] = "Error"; |
452 |
row["colUID"] = ""; |
453 |
_ConverterDT.Rows.Add(row); |
454 |
} |
455 |
if (!_DicDocuments.ContainsKey(fileName)) |
456 |
_DicDocuments.Add(fileName, null); |
457 |
|
458 |
_DicDocuments[fileName] = document; |
459 |
} |
460 |
} |
461 |
} |
462 |
|
463 |
private void btnRun_Click(object sender, EventArgs e) |
464 |
{ |
465 |
_Documents.Clear(); |
466 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
467 |
{ |
468 |
string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
469 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
470 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
471 |
string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
472 |
string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
473 |
SPPID_Document document = _DicDocuments[_FilePath]; |
474 |
document.Unit = _Unit; |
475 |
document.Template = _Template; |
476 |
document.DrawingNumber = _DrawingNumber; |
477 |
document.DrawingName = _DrawingName; |
478 |
|
479 |
document.SymbolMappings = symbolMappings; |
480 |
document.ChildSymbolMappings = childSymbolMappings; |
481 |
document.LineMappings = lineMappings; |
482 |
document.LineNumberMappings = lineNumberMappings; |
483 |
document.AttributeMappings = attributeMappings; |
484 |
document.ETCSetting = ETCSetting.GetInstance(); |
485 |
document.SetSPPIDInfo(); |
486 |
|
487 |
if (document.SetSPPIDMapping() && document.Enable) |
488 |
_Documents.Add(document); |
489 |
} |
490 |
|
491 |
DialogResult = DialogResult.OK; |
492 |
} |
493 |
|
494 |
private void btnSPPIDDB_Click(object sender, EventArgs e) |
495 |
{ |
496 |
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
497 |
if (form.ShowDialog() == DialogResult.OK) |
498 |
InitSPPIDDB(); |
499 |
} |
500 |
|
501 |
private void btnItemMapping_Click(object sender, EventArgs e) |
502 |
{ |
503 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
504 |
if (!_ProjectInfo.Enable) |
505 |
{ |
506 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
507 |
return; |
508 |
} |
509 |
|
510 |
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT); |
511 |
form.ShowDialog(); |
512 |
InitMapping(); |
513 |
} |
514 |
private List<int> prevSelectedList = new List<int>(); |
515 |
|
516 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
517 |
{ |
518 |
if (e.Action == CollectionChangeAction.Add) |
519 |
{ |
520 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
521 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
522 |
|
523 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
524 |
gridViewConverter.UnselectRow(e.ControllerRow); |
525 |
} |
526 |
else if (e.Action == CollectionChangeAction.Refresh) |
527 |
{ |
528 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
529 |
{ |
530 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
531 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
532 |
|
533 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
534 |
gridViewConverter.UnselectRow(rowHandle); |
535 |
} |
536 |
|
537 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
538 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
539 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
540 |
|
541 |
if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
542 |
{ |
543 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
544 |
gridViewConverter.ClearSelection(); |
545 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
546 |
} |
547 |
} |
548 |
|
549 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
550 |
} |
551 |
} |
552 |
} |