hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ f4880c6a
이력 | 보기 | 이력해설 | 다운로드 (27.7 KB)
1 | 96a2080c | gaqhf | 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 | 23eb98bf | gaqhf | using Converter.BaseModel; |
12 | 1278ba59 | gaqhf | using DevExpress.XtraEditors.Repository; |
13 | using DevExpress.XtraEditors.Controls; |
||
14 | using DevExpress.XtraEditors; |
||
15 | 23eb98bf | gaqhf | using System.Globalization; |
16 | using System.Threading; |
||
17 | using System.IO; |
||
18 | b8e2644e | gaqhf | 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 | 96a2080c | gaqhf | |
24 | b8e2644e | gaqhf | namespace Converter.SPPID |
25 | 96a2080c | gaqhf | { |
26 | public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
||
27 | { |
||
28 | bca86986 | gaqhf | private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
29 | 4314b3f3 | gaqhf | private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
30 | public List<SPPID_Document> Documents { get { return _Documents; } } |
||
31 | bca86986 | gaqhf | private DataTable _ConverterDT = new DataTable(); |
32 | private DataTable _SPPIDSymbolPathDT = new DataTable(); |
||
33 | 635a8747 | gaqhf | private DataTable _SPPIDUnitDT = new DataTable(); |
34 | 23eb98bf | gaqhf | private RepositoryItemComboBox templateComboBox; |
35 | |||
36 | bca86986 | gaqhf | |
37 | private DataTable _ID2SymbolDT = new DataTable(); |
||
38 | 4b4dbca9 | gaqhf | private DataTable _ID2ChildSymbolDT = new DataTable(); |
39 | bca86986 | gaqhf | private DataTable _ID2LineDT = new DataTable(); |
40 | 1efc25a3 | gaqhf | private DataTable _ID2AttributeDT = new DataTable(); |
41 | bca86986 | gaqhf | private DataTable _ID2LinePropertyDT = new DataTable(); |
42 | f1c9dbaa | gaqhf | private DataTable _ID2SymbolTypeDT = new DataTable(); |
43 | |||
44 | bca86986 | gaqhf | |
45 | private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
||
46 | 4b4dbca9 | gaqhf | private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>(); |
47 | bca86986 | gaqhf | private List<LineMapping> lineMappings = new List<LineMapping>(); |
48 | private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
||
49 | 1efc25a3 | gaqhf | private List<AttributeMapping> attributeMappings = new List<AttributeMapping>(); |
50 | bca86986 | gaqhf | |
51 | 96a2080c | gaqhf | public ConverterForm() |
52 | { |
||
53 | InitializeComponent(); |
||
54 | 1278ba59 | gaqhf | |
55 | fab4f207 | gaqhf | CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
56 | 23eb98bf | gaqhf | Msg.Culture = culture; |
57 | |||
58 | bca86986 | gaqhf | InitUsedDataTable(); |
59 | 1278ba59 | gaqhf | InitGridControl(); |
60 | fab4f207 | gaqhf | InitID2Project(); |
61 | 1278ba59 | gaqhf | } |
62 | |||
63 | f1232880 | gaqhf | #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 | 5e6ecf05 | gaqhf | Show(); |
73 | //if (ShowDialog() == DialogResult.OK) |
||
74 | //{ |
||
75 | f1232880 | gaqhf | |
76 | 5e6ecf05 | gaqhf | //} |
77 | f1232880 | gaqhf | |
78 | 5e6ecf05 | gaqhf | //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 | f1232880 | gaqhf | |
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 | bca86986 | gaqhf | private void InitUsedDataTable() |
151 | 1278ba59 | gaqhf | { |
152 | bca86986 | gaqhf | // Converter Table |
153 | DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
||
154 | 1278ba59 | gaqhf | col.Caption = "Drawing File Name"; |
155 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
156 | 0d8062b2 | gaqhf | col.Caption = "DrawingFilePath"; |
157 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUnit"); |
158 | 1278ba59 | gaqhf | col.Caption = "Unit"; |
159 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colTemplate"); |
160 | 1278ba59 | gaqhf | col.Caption = "Template"; |
161 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingNumber"); |
162 | 1278ba59 | gaqhf | col.Caption = "Drawing Number"; |
163 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingName"); |
164 | 1278ba59 | gaqhf | col.Caption = "Drawing Name"; |
165 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colStatus"); |
166 | 1278ba59 | gaqhf | col.Caption = "Status"; |
167 | bca86986 | gaqhf | 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 | 1278ba59 | gaqhf | |
188 | templateComboBox = new RepositoryItemComboBox(); |
||
189 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
190 | 635a8747 | gaqhf | templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
191 | 1278ba59 | gaqhf | gridControlConverter.RepositoryItems.Add(templateComboBox); |
192 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
193 | |||
194 | 635a8747 | gaqhf | gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
195 | 1278ba59 | gaqhf | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
196 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
197 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
198 | 0d8062b2 | gaqhf | gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
199 | 1278ba59 | gaqhf | gridViewConverter.Columns["colUID"].Visible = false; |
200 | |||
201 | gridViewConverter.BestFitColumns(); |
||
202 | #endregion |
||
203 | } |
||
204 | f1c9dbaa | gaqhf | |
205 | 635a8747 | gaqhf | 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 | 1278ba59 | gaqhf | |
230 | 23eb98bf | gaqhf | private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
231 | { |
||
232 | fab4f207 | gaqhf | xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
233 | |||
234 | 23eb98bf | gaqhf | if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
235 | { |
||
236 | fab4f207 | gaqhf | 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 | 635a8747 | gaqhf | { |
242 | fab4f207 | gaqhf | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
243 | 635a8747 | gaqhf | } |
244 | fab4f207 | gaqhf | else |
245 | 23eb98bf | gaqhf | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
246 | } |
||
247 | } |
||
248 | |||
249 | fab4f207 | gaqhf | private bool InitID2Project() |
250 | 23eb98bf | gaqhf | { |
251 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
252 | fab4f207 | gaqhf | _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
253 | if (Project_DB.ConnTestAndCreateTable()) |
||
254 | 23eb98bf | gaqhf | { |
255 | fab4f207 | gaqhf | _ProjectInfo.Enable = true; |
256 | 171142c5 | gaqhf | btnID2Project.Text = _ProjectInfo.DefaultPath; |
257 | 23eb98bf | gaqhf | labelID2ProjectName.Text = _ProjectInfo.Name; |
258 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
259 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
260 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
261 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
262 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
||
263 | 23eb98bf | gaqhf | } |
264 | else |
||
265 | { |
||
266 | fab4f207 | gaqhf | _ProjectInfo.Enable = false; |
267 | 23eb98bf | gaqhf | btnID2Project.Text = ""; |
268 | labelID2ProjectName.Text = " "; |
||
269 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
270 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
271 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
272 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
273 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
274 | bca86986 | gaqhf | } |
275 | fab4f207 | gaqhf | |
276 | bca86986 | gaqhf | 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 | 1efc25a3 | gaqhf | InitID2Attribute(); |
291 | e00e891d | gaqhf | |
292 | InitETCSetting(); |
||
293 | } |
||
294 | } |
||
295 | fbdb9f2a | gaqhf | |
296 | e00e891d | gaqhf | 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 | bca86986 | gaqhf | } |
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 | 4b4dbca9 | gaqhf | |
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 | bca86986 | gaqhf | } |
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 | 1efc25a3 | gaqhf | private void InitID2Attribute() |
400 | bca86986 | gaqhf | { |
401 | 1efc25a3 | gaqhf | using (DataTable attributeDT = Project_DB.SelectProjectAttribute()) |
402 | bca86986 | gaqhf | { |
403 | 1efc25a3 | gaqhf | attributeMappings.Clear(); |
404 | _ID2AttributeDT = attributeDT; |
||
405 | _ID2AttributeDT.Columns.Add("Clear"); |
||
406 | _ID2AttributeDT.Columns["Clear"].Caption = ""; |
||
407 | foreach (DataRow row in attributeDT.Rows) |
||
408 | bca86986 | gaqhf | { |
409 | 1efc25a3 | gaqhf | attributeMappings.Add(new AttributeMapping() |
410 | bca86986 | gaqhf | { |
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 | 23eb98bf | gaqhf | } |
419 | } |
||
420 | |||
421 | fab4f207 | gaqhf | private void InitSPPIDDB() |
422 | 23eb98bf | gaqhf | { |
423 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
424 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
425 | { |
||
426 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
427 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
428 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
429 | else |
||
430 | SPPID_DBInfo.Clear(); |
||
431 | fab4f207 | gaqhf | } |
432 | ec0c7045 | gaqhf | |
433 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
434 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
435 | 23eb98bf | gaqhf | 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 | 635a8747 | gaqhf | |
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 | 23eb98bf | gaqhf | } |
450 | else |
||
451 | { |
||
452 | labelSPPIDPlantName.Text = " "; |
||
453 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
454 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
455 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
456 | bca86986 | gaqhf | |
457 | 635a8747 | gaqhf | layoutControlGroupAutoConverter.Enabled = false; |
458 | 23eb98bf | gaqhf | } |
459 | bca86986 | gaqhf | |
460 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
461 | _ConverterDT.Rows.Clear(); |
||
462 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
463 | 23eb98bf | gaqhf | } |
464 | |||
465 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
466 | 23eb98bf | gaqhf | { |
467 | bca86986 | gaqhf | 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 | 23eb98bf | gaqhf | { |
477 | bca86986 | gaqhf | 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 | 23eb98bf | gaqhf | } |
482 | bca86986 | gaqhf | } |
483 | 23eb98bf | gaqhf | |
484 | bca86986 | gaqhf | 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 | 23eb98bf | gaqhf | } |
500 | |||
501 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
502 | { |
||
503 | 65a1ed4b | gaqhf | modeling.Test(); |
504 | return; |
||
505 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
506 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
507 | { |
||
508 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
509 | return; |
||
510 | } |
||
511 | 1278ba59 | gaqhf | |
512 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
513 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
514 | 1278ba59 | gaqhf | { |
515 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
516 | 1278ba59 | gaqhf | { |
517 | bca86986 | gaqhf | SPPID_Document document = new SPPID_Document(fileName); |
518 | 4314b3f3 | gaqhf | |
519 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
520 | 0d8062b2 | gaqhf | DataRow row; |
521 | if (rows.Length == 0) |
||
522 | { |
||
523 | bca86986 | gaqhf | row = _ConverterDT.NewRow(); |
524 | 0d8062b2 | gaqhf | 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 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
534 | 0d8062b2 | gaqhf | } |
535 | if (!_DicDocuments.ContainsKey(fileName)) |
||
536 | _DicDocuments.Add(fileName, null); |
||
537 | |||
538 | _DicDocuments[fileName] = document; |
||
539 | 1278ba59 | gaqhf | } |
540 | } |
||
541 | 65a1ed4b | gaqhf | } |
542 | static AutoModeling modeling; |
||
543 | 1278ba59 | gaqhf | private void btnRun_Click(object sender, EventArgs e) |
544 | { |
||
545 | 5dfb8a24 | gaqhf | #if DEBUG |
546 | 402ef5b1 | gaqhf | this.Visible = false; |
547 | |||
548 | f4880c6a | gaqhf | //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml"); |
549 | 8b085570 | gaqhf | //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
550 | f4880c6a | gaqhf | SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\Isocynates-325_Page49.xml"); |
551 | 5dfb8a24 | gaqhf | document.SymbolMappings = symbolMappings; |
552 | 4b4dbca9 | gaqhf | document.ChildSymbolMappings = childSymbolMappings; |
553 | 5dfb8a24 | gaqhf | document.LineMappings = lineMappings; |
554 | document.LineNumberMappings = lineNumberMappings; |
||
555 | 1efc25a3 | gaqhf | document.AttributeMappings = attributeMappings; |
556 | 5dfb8a24 | gaqhf | document.ETCSetting = ETCSetting.GetInstance(); |
557 | f1c9dbaa | gaqhf | |
558 | 5dfb8a24 | gaqhf | document.SetSPPIDInfo(); |
559 | 4314b3f3 | gaqhf | |
560 | 8aa6f2db | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
561 | 4314b3f3 | gaqhf | { |
562 | 65a1ed4b | gaqhf | modeling = new AutoModeling(document, commandControl.Application.RADApplication); |
563 | 5dfb8a24 | gaqhf | modeling.Run(); |
564 | 4314b3f3 | gaqhf | } |
565 | |||
566 | 402ef5b1 | gaqhf | this.Visible = true; |
567 | 5dfb8a24 | gaqhf | 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 | 1278ba59 | gaqhf | DialogResult = DialogResult.OK; |
588 | 96a2080c | gaqhf | } |
589 | 23eb98bf | gaqhf | |
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 | fab4f207 | gaqhf | InitSPPIDDB(); |
595 | 23eb98bf | gaqhf | } |
596 | df4559fc | gaqhf | |
597 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
598 | { |
||
599 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
600 | df4559fc | gaqhf | if (!_ProjectInfo.Enable) |
601 | { |
||
602 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
603 | return; |
||
604 | } |
||
605 | |||
606 | 1efc25a3 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT); |
607 | df4559fc | gaqhf | form.ShowDialog(); |
608 | bca86986 | gaqhf | InitMapping(); |
609 | df4559fc | gaqhf | } |
610 | 4314b3f3 | gaqhf | 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 | 635a8747 | gaqhf | |
637 | 4314b3f3 | gaqhf | 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 | 96a2080c | gaqhf | } |
648 | } |