hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 4b4dbca9
이력 | 보기 | 이력해설 | 다운로드 (27.7 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 |
//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 |
}); |
417 |
} |
418 |
} |
419 |
} |
420 |
|
421 |
private void InitSPPIDDB() |
422 |
{ |
423 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
424 |
if (_ProjectInfo.Enable) |
425 |
{ |
426 |
DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
427 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
428 |
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
429 |
else |
430 |
SPPID_DBInfo.Clear(); |
431 |
} |
432 |
|
433 |
templateComboBox.Items.Clear(); |
434 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
435 |
if (_SPPIDInfo.Enable) |
436 |
{ |
437 |
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
438 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
439 |
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
440 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
441 |
|
442 |
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
443 |
if (!string.IsNullOrEmpty(TemplatePath)) |
444 |
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
445 |
|
446 |
_SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
447 |
|
448 |
layoutControlGroupAutoConverter.Enabled = true; |
449 |
} |
450 |
else |
451 |
{ |
452 |
labelSPPIDPlantName.Text = " "; |
453 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
454 |
labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
455 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
456 |
|
457 |
layoutControlGroupAutoConverter.Enabled = false; |
458 |
} |
459 |
|
460 |
_DicDocuments.Clear(); |
461 |
_ConverterDT.Rows.Clear(); |
462 |
InitSPPIDSymbolTreeTable(); |
463 |
} |
464 |
|
465 |
private void InitSPPIDSymbolTreeTable() |
466 |
{ |
467 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
468 |
|
469 |
_SPPIDSymbolPathDT = new DataTable(); |
470 |
_SPPIDSymbolPathDT.Columns.Add("ID"); |
471 |
_SPPIDSymbolPathDT.Columns.Add("Parent"); |
472 |
_SPPIDSymbolPathDT.Columns.Add("Name"); |
473 |
_SPPIDSymbolPathDT.Columns.Add("FullPath"); |
474 |
|
475 |
if (_SPPIDInfo.Enable) |
476 |
{ |
477 |
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
478 |
DirectoryInfo info = new DirectoryInfo(symbolPath); |
479 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
480 |
loop(info, "0", symbolPath); |
481 |
} |
482 |
} |
483 |
|
484 |
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
485 |
{ |
486 |
DirectoryInfo[] infos = parentInfo.GetDirectories(); |
487 |
foreach (DirectoryInfo info in infos) |
488 |
{ |
489 |
string uid = Guid.NewGuid().ToString(); |
490 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
491 |
loop(info, uid, defaultPath); |
492 |
|
493 |
FileInfo[] files = info.GetFiles("*.sym"); |
494 |
foreach (FileInfo fileInfo in files) |
495 |
{ |
496 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
497 |
} |
498 |
} |
499 |
} |
500 |
|
501 |
private void btnLoadFile_Click(object sender, EventArgs e) |
502 |
{ |
503 |
modeling.Test(); |
504 |
return; |
505 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
506 |
if (!_ProjectInfo.Enable) |
507 |
{ |
508 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
509 |
return; |
510 |
} |
511 |
|
512 |
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
513 |
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
514 |
{ |
515 |
foreach (string fileName in xtraOpenFileDialog.FileNames) |
516 |
{ |
517 |
SPPID_Document document = new SPPID_Document(fileName); |
518 |
|
519 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
520 |
DataRow row; |
521 |
if (rows.Length == 0) |
522 |
{ |
523 |
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 |
_ConverterDT.Rows.Add(row); |
534 |
} |
535 |
if (!_DicDocuments.ContainsKey(fileName)) |
536 |
_DicDocuments.Add(fileName, null); |
537 |
|
538 |
_DicDocuments[fileName] = document; |
539 |
} |
540 |
} |
541 |
} |
542 |
static AutoModeling modeling; |
543 |
private void btnRun_Click(object sender, EventArgs e) |
544 |
{ |
545 |
#if DEBUG |
546 |
this.Visible = false; |
547 |
|
548 |
//SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml"); |
549 |
//SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
550 |
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\Isocynates-325_Page49.xml"); |
551 |
document.SymbolMappings = symbolMappings; |
552 |
document.ChildSymbolMappings = childSymbolMappings; |
553 |
document.LineMappings = lineMappings; |
554 |
document.LineNumberMappings = lineNumberMappings; |
555 |
document.AttributeMappings = attributeMappings; |
556 |
document.ETCSetting = ETCSetting.GetInstance(); |
557 |
|
558 |
document.SetSPPIDInfo(); |
559 |
|
560 |
if (document.SetSPPIDMapping() && document.Enable) |
561 |
{ |
562 |
modeling = new AutoModeling(document, commandControl.Application.RADApplication); |
563 |
modeling.Run(); |
564 |
} |
565 |
|
566 |
this.Visible = true; |
567 |
return; |
568 |
#endif |
569 |
|
570 |
//_Documents.Clear(); |
571 |
|
572 |
//foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
573 |
//{ |
574 |
// string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
575 |
// string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
576 |
// string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
577 |
// string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
578 |
// string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
579 |
// SPPID_Document document = _DicDocuments[_FilePath]; |
580 |
// document.Unit = _Unit; |
581 |
// document.Template = _Template; |
582 |
// document.DrawingNumber = _DrawingNumber; |
583 |
// document.DrawingName = _DrawingName; |
584 |
// _Documents.Add(document); |
585 |
//} |
586 |
|
587 |
DialogResult = DialogResult.OK; |
588 |
} |
589 |
|
590 |
private void btnSPPIDDB_Click(object sender, EventArgs e) |
591 |
{ |
592 |
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
593 |
if (form.ShowDialog() == DialogResult.OK) |
594 |
InitSPPIDDB(); |
595 |
} |
596 |
|
597 |
private void btnItemMapping_Click(object sender, EventArgs e) |
598 |
{ |
599 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
600 |
if (!_ProjectInfo.Enable) |
601 |
{ |
602 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
603 |
return; |
604 |
} |
605 |
|
606 |
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT); |
607 |
form.ShowDialog(); |
608 |
InitMapping(); |
609 |
} |
610 |
private List<int> prevSelectedList = new List<int>(); |
611 |
|
612 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
613 |
{ |
614 |
if (e.Action == CollectionChangeAction.Add) |
615 |
{ |
616 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
617 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
618 |
|
619 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
620 |
gridViewConverter.UnselectRow(e.ControllerRow); |
621 |
} |
622 |
else if (e.Action == CollectionChangeAction.Refresh) |
623 |
{ |
624 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
625 |
{ |
626 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
627 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
628 |
|
629 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
630 |
gridViewConverter.UnselectRow(rowHandle); |
631 |
} |
632 |
|
633 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
634 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
635 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
636 |
|
637 |
if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
638 |
{ |
639 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
640 |
gridViewConverter.ClearSelection(); |
641 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
642 |
} |
643 |
} |
644 |
|
645 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
646 |
} |
647 |
} |
648 |
} |