hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ bc42255c
이력 | 보기 | 이력해설 | 다운로드 (26.6 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 | f1232880 | gaqhf | } |
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 | bca86986 | gaqhf | private void InitUsedDataTable() |
126 | 1278ba59 | gaqhf | { |
127 | bca86986 | gaqhf | // Converter Table |
128 | DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
||
129 | 1278ba59 | gaqhf | col.Caption = "Drawing File Name"; |
130 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
131 | 0d8062b2 | gaqhf | col.Caption = "DrawingFilePath"; |
132 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUnit"); |
133 | 1278ba59 | gaqhf | col.Caption = "Unit"; |
134 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colTemplate"); |
135 | 1278ba59 | gaqhf | col.Caption = "Template"; |
136 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingNumber"); |
137 | 1278ba59 | gaqhf | col.Caption = "Drawing Number"; |
138 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingName"); |
139 | 1278ba59 | gaqhf | col.Caption = "Drawing Name"; |
140 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colStatus"); |
141 | 1278ba59 | gaqhf | col.Caption = "Status"; |
142 | bca86986 | gaqhf | 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 | 1278ba59 | gaqhf | |
163 | templateComboBox = new RepositoryItemComboBox(); |
||
164 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
165 | 635a8747 | gaqhf | templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
166 | 1278ba59 | gaqhf | gridControlConverter.RepositoryItems.Add(templateComboBox); |
167 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
168 | |||
169 | 635a8747 | gaqhf | gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
170 | 1278ba59 | gaqhf | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
171 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
172 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
173 | 0d8062b2 | gaqhf | gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
174 | 1278ba59 | gaqhf | gridViewConverter.Columns["colUID"].Visible = false; |
175 | |||
176 | gridViewConverter.BestFitColumns(); |
||
177 | #endregion |
||
178 | } |
||
179 | f1c9dbaa | gaqhf | |
180 | 635a8747 | gaqhf | 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 | 1278ba59 | gaqhf | |
205 | 23eb98bf | gaqhf | private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
206 | { |
||
207 | fab4f207 | gaqhf | xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
208 | |||
209 | 23eb98bf | gaqhf | if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
210 | { |
||
211 | fab4f207 | gaqhf | 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 | 635a8747 | gaqhf | { |
217 | fab4f207 | gaqhf | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
218 | 635a8747 | gaqhf | } |
219 | fab4f207 | gaqhf | else |
220 | 23eb98bf | gaqhf | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
221 | } |
||
222 | } |
||
223 | |||
224 | fab4f207 | gaqhf | private bool InitID2Project() |
225 | 23eb98bf | gaqhf | { |
226 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
227 | fab4f207 | gaqhf | _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
228 | if (Project_DB.ConnTestAndCreateTable()) |
||
229 | 23eb98bf | gaqhf | { |
230 | fab4f207 | gaqhf | _ProjectInfo.Enable = true; |
231 | 171142c5 | gaqhf | btnID2Project.Text = _ProjectInfo.DefaultPath; |
232 | 23eb98bf | gaqhf | labelID2ProjectName.Text = _ProjectInfo.Name; |
233 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
234 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
235 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
236 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
237 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
||
238 | 23eb98bf | gaqhf | } |
239 | else |
||
240 | { |
||
241 | fab4f207 | gaqhf | _ProjectInfo.Enable = false; |
242 | 23eb98bf | gaqhf | btnID2Project.Text = ""; |
243 | labelID2ProjectName.Text = " "; |
||
244 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
245 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
246 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
247 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
248 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
249 | bca86986 | gaqhf | } |
250 | fab4f207 | gaqhf | |
251 | bca86986 | gaqhf | 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 | 1efc25a3 | gaqhf | InitID2Attribute(); |
266 | e00e891d | gaqhf | |
267 | InitETCSetting(); |
||
268 | } |
||
269 | } |
||
270 | fbdb9f2a | gaqhf | |
271 | e00e891d | gaqhf | 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 | bca86986 | gaqhf | } |
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 | 4b4dbca9 | gaqhf | |
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 | bca86986 | gaqhf | } |
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 | 1efc25a3 | gaqhf | private void InitID2Attribute() |
375 | bca86986 | gaqhf | { |
376 | 1efc25a3 | gaqhf | using (DataTable attributeDT = Project_DB.SelectProjectAttribute()) |
377 | bca86986 | gaqhf | { |
378 | 1efc25a3 | gaqhf | attributeMappings.Clear(); |
379 | _ID2AttributeDT = attributeDT; |
||
380 | _ID2AttributeDT.Columns.Add("Clear"); |
||
381 | _ID2AttributeDT.Columns["Clear"].Caption = ""; |
||
382 | foreach (DataRow row in attributeDT.Rows) |
||
383 | bca86986 | gaqhf | { |
384 | 1efc25a3 | gaqhf | attributeMappings.Add(new AttributeMapping() |
385 | bca86986 | gaqhf | { |
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 | 1a3a74a8 | gaqhf | 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 | bca86986 | gaqhf | }); |
393 | } |
||
394 | 23eb98bf | gaqhf | } |
395 | } |
||
396 | |||
397 | fab4f207 | gaqhf | private void InitSPPIDDB() |
398 | 23eb98bf | gaqhf | { |
399 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
400 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
401 | { |
||
402 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
403 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
404 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
405 | else |
||
406 | SPPID_DBInfo.Clear(); |
||
407 | fab4f207 | gaqhf | } |
408 | ec0c7045 | gaqhf | |
409 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
410 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
411 | 23eb98bf | gaqhf | 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 | 635a8747 | gaqhf | |
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 | 23eb98bf | gaqhf | } |
426 | else |
||
427 | { |
||
428 | labelSPPIDPlantName.Text = " "; |
||
429 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
430 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
431 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
432 | bca86986 | gaqhf | |
433 | 635a8747 | gaqhf | layoutControlGroupAutoConverter.Enabled = false; |
434 | 23eb98bf | gaqhf | } |
435 | bca86986 | gaqhf | |
436 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
437 | _ConverterDT.Rows.Clear(); |
||
438 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
439 | 23eb98bf | gaqhf | } |
440 | |||
441 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
442 | 23eb98bf | gaqhf | { |
443 | bca86986 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
444 | |||
445 | 26c6f818 | gaqhf | 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 | bca86986 | gaqhf | |
453 | 26c6f818 | gaqhf | 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 | 23eb98bf | gaqhf | { |
463 | 26c6f818 | gaqhf | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
464 | 23eb98bf | gaqhf | } |
465 | bca86986 | gaqhf | } |
466 | 23eb98bf | gaqhf | |
467 | bca86986 | gaqhf | 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 | 23eb98bf | gaqhf | } |
483 | |||
484 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
485 | { |
||
486 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
487 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
488 | { |
||
489 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
490 | return; |
||
491 | } |
||
492 | 1278ba59 | gaqhf | |
493 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
494 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
495 | 1278ba59 | gaqhf | { |
496 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
497 | 1278ba59 | gaqhf | { |
498 | bca86986 | gaqhf | SPPID_Document document = new SPPID_Document(fileName); |
499 | 4314b3f3 | gaqhf | |
500 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
501 | 0d8062b2 | gaqhf | DataRow row; |
502 | if (rows.Length == 0) |
||
503 | { |
||
504 | bca86986 | gaqhf | row = _ConverterDT.NewRow(); |
505 | 0d8062b2 | gaqhf | 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 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
515 | 0d8062b2 | gaqhf | } |
516 | if (!_DicDocuments.ContainsKey(fileName)) |
||
517 | _DicDocuments.Add(fileName, null); |
||
518 | |||
519 | _DicDocuments[fileName] = document; |
||
520 | 1278ba59 | gaqhf | } |
521 | } |
||
522 | 65a1ed4b | gaqhf | } |
523 | 17f2a3a7 | gaqhf | |
524 | 1278ba59 | gaqhf | private void btnRun_Click(object sender, EventArgs e) |
525 | { |
||
526 | 68f01206 | gaqhf | this.Visible = false; |
527 | 17f2a3a7 | gaqhf | _Documents.Clear(); |
528 | 5dfb8a24 | gaqhf | |
529 | 17f2a3a7 | gaqhf | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
530 | { |
||
531 | string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
||
532 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
533 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
534 | string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
||
535 | string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
||
536 | SPPID_Document document = _DicDocuments[_FilePath]; |
||
537 | document.Unit = _Unit; |
||
538 | document.Template = _Template; |
||
539 | document.DrawingNumber = _DrawingNumber; |
||
540 | document.DrawingName = _DrawingName; |
||
541 | 712860bb | gaqhf | |
542 | document.SymbolMappings = symbolMappings; |
||
543 | document.ChildSymbolMappings = childSymbolMappings; |
||
544 | document.LineMappings = lineMappings; |
||
545 | document.LineNumberMappings = lineNumberMappings; |
||
546 | document.AttributeMappings = attributeMappings; |
||
547 | document.ETCSetting = ETCSetting.GetInstance(); |
||
548 | document.SetSPPIDInfo(); |
||
549 | |||
550 | 17f2a3a7 | gaqhf | _Documents.Add(document); |
551 | } |
||
552 | 5dfb8a24 | gaqhf | |
553 | 021176df | gaqhf | foreach (var document in _Documents) |
554 | { |
||
555 | if (document.SetSPPIDMapping() && document.Enable) |
||
556 | { |
||
557 | AutoModeling modeling = new AutoModeling(document, commandControl.Application.RADApplication); |
||
558 | modeling.Run(); |
||
559 | 68f01206 | gaqhf | break; |
560 | 021176df | gaqhf | } |
561 | } |
||
562 | 68f01206 | gaqhf | this.Visible = true; |
563 | 712860bb | gaqhf | MessageBox.Show("End Modeling"); |
564 | 96a2080c | gaqhf | } |
565 | 23eb98bf | gaqhf | |
566 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
567 | { |
||
568 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
569 | if (form.ShowDialog() == DialogResult.OK) |
||
570 | fab4f207 | gaqhf | InitSPPIDDB(); |
571 | 23eb98bf | gaqhf | } |
572 | df4559fc | gaqhf | |
573 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
574 | { |
||
575 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
576 | df4559fc | gaqhf | if (!_ProjectInfo.Enable) |
577 | { |
||
578 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
579 | return; |
||
580 | } |
||
581 | |||
582 | 1efc25a3 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT); |
583 | df4559fc | gaqhf | form.ShowDialog(); |
584 | bca86986 | gaqhf | InitMapping(); |
585 | df4559fc | gaqhf | } |
586 | 4314b3f3 | gaqhf | private List<int> prevSelectedList = new List<int>(); |
587 | |||
588 | private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
||
589 | { |
||
590 | if (e.Action == CollectionChangeAction.Add) |
||
591 | { |
||
592 | string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
||
593 | string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
||
594 | |||
595 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
596 | gridViewConverter.UnselectRow(e.ControllerRow); |
||
597 | } |
||
598 | else if (e.Action == CollectionChangeAction.Refresh) |
||
599 | { |
||
600 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
601 | { |
||
602 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
603 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
604 | |||
605 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
606 | gridViewConverter.UnselectRow(rowHandle); |
||
607 | } |
||
608 | |||
609 | List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
||
610 | var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
||
611 | var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
||
612 | 635a8747 | gaqhf | |
613 | 4314b3f3 | gaqhf | if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
614 | { |
||
615 | this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
616 | gridViewConverter.ClearSelection(); |
||
617 | this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
618 | } |
||
619 | } |
||
620 | |||
621 | prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
||
622 | } |
||
623 | 96a2080c | gaqhf | } |
624 | } |