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