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