hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 4abf114c
이력 | 보기 | 이력해설 | 다운로드 (23.9 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 | 1278ba59 | gaqhf | using DevExpress.XtraEditors.Repository; |
12 | using DevExpress.XtraEditors.Controls; |
||
13 | using DevExpress.XtraEditors; |
||
14 | 23eb98bf | gaqhf | using System.Globalization; |
15 | using System.Threading; |
||
16 | using System.IO; |
||
17 | d19ae675 | gaqhf | using Ingr.RAD2D; |
18 | using Converter.BaseModel; |
||
19 | b8e2644e | gaqhf | using Converter.SPPID.Properties; |
20 | using Converter.SPPID.DB; |
||
21 | using Converter.SPPID.Util; |
||
22 | using Converter.SPPID.Form; |
||
23 | using Converter.SPPID.Model; |
||
24 | 96a2080c | gaqhf | |
25 | b8e2644e | gaqhf | namespace Converter.SPPID |
26 | 96a2080c | gaqhf | { |
27 | public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
||
28 | { |
||
29 | bca86986 | gaqhf | private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
30 | 4314b3f3 | gaqhf | private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
31 | public List<SPPID_Document> Documents { get { return _Documents; } } |
||
32 | bca86986 | gaqhf | private DataTable _ConverterDT = new DataTable(); |
33 | private DataTable _SPPIDSymbolPathDT = new DataTable(); |
||
34 | 635a8747 | gaqhf | private DataTable _SPPIDUnitDT = new DataTable(); |
35 | 23eb98bf | gaqhf | private RepositoryItemComboBox templateComboBox; |
36 | |||
37 | bca86986 | gaqhf | |
38 | private DataTable _ID2SymbolDT = new DataTable(); |
||
39 | 4b4dbca9 | gaqhf | private DataTable _ID2ChildSymbolDT = new DataTable(); |
40 | bca86986 | gaqhf | private DataTable _ID2LineDT = new DataTable(); |
41 | 1efc25a3 | gaqhf | private DataTable _ID2AttributeDT = new DataTable(); |
42 | bca86986 | gaqhf | private DataTable _ID2LinePropertyDT = new DataTable(); |
43 | f1c9dbaa | gaqhf | private DataTable _ID2SymbolTypeDT = new DataTable(); |
44 | |||
45 | bca86986 | gaqhf | |
46 | private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
||
47 | 4b4dbca9 | gaqhf | private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>(); |
48 | bca86986 | gaqhf | private List<LineMapping> lineMappings = new List<LineMapping>(); |
49 | private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
||
50 | 1efc25a3 | gaqhf | private List<AttributeMapping> attributeMappings = new List<AttributeMapping>(); |
51 | bca86986 | gaqhf | |
52 | 96a2080c | gaqhf | public ConverterForm() |
53 | { |
||
54 | InitializeComponent(); |
||
55 | 1278ba59 | gaqhf | |
56 | fab4f207 | gaqhf | CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
57 | 23eb98bf | gaqhf | Msg.Culture = culture; |
58 | |||
59 | bca86986 | gaqhf | InitUsedDataTable(); |
60 | 1278ba59 | gaqhf | InitGridControl(); |
61 | fab4f207 | gaqhf | InitID2Project(); |
62 | 1278ba59 | gaqhf | } |
63 | |||
64 | bca86986 | gaqhf | private void InitUsedDataTable() |
65 | 1278ba59 | gaqhf | { |
66 | bca86986 | gaqhf | // Converter Table |
67 | DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
||
68 | 1278ba59 | gaqhf | col.Caption = "Drawing File Name"; |
69 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
70 | 0d8062b2 | gaqhf | col.Caption = "DrawingFilePath"; |
71 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUnit"); |
72 | 1278ba59 | gaqhf | col.Caption = "Unit"; |
73 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colTemplate"); |
74 | 1278ba59 | gaqhf | col.Caption = "Template"; |
75 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingNumber"); |
76 | 1278ba59 | gaqhf | col.Caption = "Drawing Number"; |
77 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingName"); |
78 | 1278ba59 | gaqhf | col.Caption = "Drawing Name"; |
79 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colStatus"); |
80 | 1278ba59 | gaqhf | col.Caption = "Status"; |
81 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUID"); |
82 | |||
83 | col = _ID2LineDT.Columns.Add("UID"); |
||
84 | col = _ID2LineDT.Columns.Add("Name"); |
||
85 | col.Caption = "Name"; |
||
86 | col = _ID2LineDT.Columns.Add("Type"); |
||
87 | col.Caption = "Type"; |
||
88 | col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
||
89 | col.Caption = "SPPID Symbol Path"; |
||
90 | col = _ID2LineDT.Columns.Add("Clear"); |
||
91 | col.Caption = ""; |
||
92 | } |
||
93 | |||
94 | private void InitGridControl() |
||
95 | { |
||
96 | #region Converter Page |
||
97 | gridViewConverter.OptionsSelection.MultiSelect = true; |
||
98 | gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
||
99 | |||
100 | gridControlConverter.DataSource = _ConverterDT; |
||
101 | 1278ba59 | gaqhf | |
102 | templateComboBox = new RepositoryItemComboBox(); |
||
103 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
104 | 635a8747 | gaqhf | templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
105 | 1278ba59 | gaqhf | gridControlConverter.RepositoryItems.Add(templateComboBox); |
106 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
107 | |||
108 | 635a8747 | gaqhf | gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
109 | 1278ba59 | gaqhf | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
110 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
111 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
112 | 0d8062b2 | gaqhf | gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
113 | 1278ba59 | gaqhf | gridViewConverter.Columns["colUID"].Visible = false; |
114 | |||
115 | gridViewConverter.BestFitColumns(); |
||
116 | #endregion |
||
117 | } |
||
118 | f1c9dbaa | gaqhf | |
119 | 635a8747 | gaqhf | private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
120 | { |
||
121 | gridViewConverter.CloseEditor(); |
||
122 | gridViewConverter.UpdateCurrentRow(); |
||
123 | } |
||
124 | |||
125 | private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
||
126 | { |
||
127 | if (e.Column.Name == "colcolTemplate") |
||
128 | { |
||
129 | gridViewConverter.ShowEditor(); |
||
130 | (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
||
131 | } |
||
132 | else if (e.Column.Name == "colcolUnit") |
||
133 | { |
||
134 | UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
||
135 | if (unitForm.ShowDialog() == DialogResult.OK) |
||
136 | { |
||
137 | gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
||
138 | gridViewConverter.CloseEditor(); |
||
139 | gridViewConverter.UpdateCurrentRow(); |
||
140 | } |
||
141 | } |
||
142 | } |
||
143 | 1278ba59 | gaqhf | |
144 | 23eb98bf | gaqhf | private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
145 | { |
||
146 | fab4f207 | gaqhf | xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
147 | |||
148 | 23eb98bf | gaqhf | if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
149 | { |
||
150 | fab4f207 | gaqhf | if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\') |
151 | xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1); |
||
152 | Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath; |
||
153 | Settings.Default.Save(); |
||
154 | if (InitID2Project()) |
||
155 | 635a8747 | gaqhf | { |
156 | fab4f207 | gaqhf | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
157 | 635a8747 | gaqhf | } |
158 | fab4f207 | gaqhf | else |
159 | 23eb98bf | gaqhf | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
160 | } |
||
161 | } |
||
162 | |||
163 | fab4f207 | gaqhf | private bool InitID2Project() |
164 | 23eb98bf | gaqhf | { |
165 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
166 | fab4f207 | gaqhf | _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
167 | if (Project_DB.ConnTestAndCreateTable()) |
||
168 | 23eb98bf | gaqhf | { |
169 | fab4f207 | gaqhf | _ProjectInfo.Enable = true; |
170 | 171142c5 | gaqhf | btnID2Project.Text = _ProjectInfo.DefaultPath; |
171 | 23eb98bf | gaqhf | labelID2ProjectName.Text = _ProjectInfo.Name; |
172 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
173 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
174 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
175 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
176 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
||
177 | 23eb98bf | gaqhf | } |
178 | else |
||
179 | { |
||
180 | fab4f207 | gaqhf | _ProjectInfo.Enable = false; |
181 | 23eb98bf | gaqhf | btnID2Project.Text = ""; |
182 | labelID2ProjectName.Text = " "; |
||
183 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
184 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
185 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
186 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
187 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
188 | bca86986 | gaqhf | } |
189 | fab4f207 | gaqhf | |
190 | bca86986 | gaqhf | InitMapping(); |
191 | InitSPPIDDB(); |
||
192 | |||
193 | return _ProjectInfo.Enable; |
||
194 | } |
||
195 | |||
196 | private void InitMapping() |
||
197 | { |
||
198 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
199 | if (_ProjectInfo.Enable) |
||
200 | { |
||
201 | InitID2Symbol(); |
||
202 | InitID2Line(); |
||
203 | InitID2LineNumber(); |
||
204 | 1efc25a3 | gaqhf | InitID2Attribute(); |
205 | e00e891d | gaqhf | |
206 | InitETCSetting(); |
||
207 | } |
||
208 | } |
||
209 | fbdb9f2a | gaqhf | |
210 | e00e891d | gaqhf | private void InitETCSetting() |
211 | { |
||
212 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
213 | if (_ProjectInfo.Enable) |
||
214 | { |
||
215 | DataTable dt = Project_DB.SelectETCSetting(); |
||
216 | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
||
217 | SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
||
218 | else |
||
219 | SPPID_DBInfo.Clear(); |
||
220 | bca86986 | gaqhf | } |
221 | } |
||
222 | |||
223 | private void InitID2Symbol() |
||
224 | { |
||
225 | using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
||
226 | { |
||
227 | symbolMappings.Clear(); |
||
228 | _ID2SymbolDT = symbolDT; |
||
229 | _ID2SymbolDT.Columns.Add("Clear"); |
||
230 | _ID2SymbolDT.Columns["Clear"].Caption = ""; |
||
231 | foreach (DataRow row in symbolDT.Rows) |
||
232 | { |
||
233 | symbolMappings.Add(new SymbolMapping() |
||
234 | { |
||
235 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
236 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
237 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
238 | }); |
||
239 | } |
||
240 | 4b4dbca9 | gaqhf | |
241 | MergeID2ChildSymbol(); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | private void MergeID2ChildSymbol() |
||
246 | { |
||
247 | using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol()) |
||
248 | { |
||
249 | childSymbolMappings.Clear(); |
||
250 | _ID2ChildSymbolDT = childSymbolDT; |
||
251 | _ID2ChildSymbolDT.Columns.Add("Clear"); |
||
252 | _ID2ChildSymbolDT.Columns["Clear"].Caption = ""; |
||
253 | foreach (DataRow row in childSymbolDT.Rows) |
||
254 | { |
||
255 | childSymbolMappings.Add(new ChildSymbolMapping() |
||
256 | { |
||
257 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
258 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
259 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
260 | }); |
||
261 | } |
||
262 | |||
263 | _ID2SymbolDT.Merge(_ID2ChildSymbolDT); |
||
264 | bca86986 | gaqhf | } |
265 | } |
||
266 | |||
267 | private void InitID2Line() |
||
268 | { |
||
269 | using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
||
270 | { |
||
271 | lineMappings.Clear(); |
||
272 | _ID2LineDT.Rows.Clear(); |
||
273 | foreach (DataRow row in lineTypes.Rows) |
||
274 | { |
||
275 | DataRow newRow = _ID2LineDT.NewRow(); |
||
276 | newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
||
277 | newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
||
278 | newRow["Type"] = "Line"; |
||
279 | newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
||
280 | _ID2LineDT.Rows.Add(newRow); |
||
281 | |||
282 | lineMappings.Add(new LineMapping() |
||
283 | { |
||
284 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
285 | LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
286 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
287 | }); |
||
288 | } |
||
289 | } |
||
290 | } |
||
291 | |||
292 | private void InitID2LineNumber() |
||
293 | { |
||
294 | using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
||
295 | { |
||
296 | lineNumberMappings.Clear(); |
||
297 | _ID2LinePropertyDT = linePropertiesDT; |
||
298 | _ID2LinePropertyDT.Columns.Add("Type"); |
||
299 | foreach (DataRow row in linePropertiesDT.Rows) |
||
300 | { |
||
301 | row["Type"] = "Line Property"; |
||
302 | lineNumberMappings.Add(new LineNumberMapping() |
||
303 | { |
||
304 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
305 | DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
||
306 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
307 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
308 | }); |
||
309 | } |
||
310 | } |
||
311 | } |
||
312 | |||
313 | 1efc25a3 | gaqhf | private void InitID2Attribute() |
314 | bca86986 | gaqhf | { |
315 | 1efc25a3 | gaqhf | using (DataTable attributeDT = Project_DB.SelectProjectAttribute()) |
316 | bca86986 | gaqhf | { |
317 | 1efc25a3 | gaqhf | attributeMappings.Clear(); |
318 | _ID2AttributeDT = attributeDT; |
||
319 | _ID2AttributeDT.Columns.Add("Clear"); |
||
320 | _ID2AttributeDT.Columns["Clear"].Caption = ""; |
||
321 | foreach (DataRow row in attributeDT.Rows) |
||
322 | bca86986 | gaqhf | { |
323 | 1efc25a3 | gaqhf | attributeMappings.Add(new AttributeMapping() |
324 | bca86986 | gaqhf | { |
325 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
326 | DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
||
327 | Type = row["Type"] == null ? "" : row["Type"].ToString(), |
||
328 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
329 | 1a3a74a8 | gaqhf | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
330 | 1ba9c671 | gaqhf | Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"], |
331 | LeaderLine = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"] |
||
332 | bca86986 | gaqhf | }); |
333 | } |
||
334 | 23eb98bf | gaqhf | } |
335 | } |
||
336 | |||
337 | fab4f207 | gaqhf | private void InitSPPIDDB() |
338 | 23eb98bf | gaqhf | { |
339 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
340 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
341 | { |
||
342 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
343 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
344 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
345 | else |
||
346 | SPPID_DBInfo.Clear(); |
||
347 | fab4f207 | gaqhf | } |
348 | ec0c7045 | gaqhf | |
349 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
350 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
351 | 23eb98bf | gaqhf | if (_SPPIDInfo.Enable) |
352 | { |
||
353 | labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
||
354 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
355 | labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
||
356 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
357 | 635a8747 | gaqhf | |
358 | string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
||
359 | if (!string.IsNullOrEmpty(TemplatePath)) |
||
360 | templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
||
361 | |||
362 | _SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
||
363 | |||
364 | layoutControlGroupAutoConverter.Enabled = true; |
||
365 | 23eb98bf | gaqhf | } |
366 | else |
||
367 | { |
||
368 | labelSPPIDPlantName.Text = " "; |
||
369 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
370 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
371 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
372 | bca86986 | gaqhf | |
373 | 635a8747 | gaqhf | layoutControlGroupAutoConverter.Enabled = false; |
374 | 23eb98bf | gaqhf | } |
375 | bca86986 | gaqhf | |
376 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
377 | _ConverterDT.Rows.Clear(); |
||
378 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
379 | 23eb98bf | gaqhf | } |
380 | |||
381 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
382 | 23eb98bf | gaqhf | { |
383 | bca86986 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
384 | |||
385 | 26c6f818 | gaqhf | try |
386 | { |
||
387 | _SPPIDSymbolPathDT = new DataTable(); |
||
388 | _SPPIDSymbolPathDT.Columns.Add("ID"); |
||
389 | _SPPIDSymbolPathDT.Columns.Add("Parent"); |
||
390 | _SPPIDSymbolPathDT.Columns.Add("Name"); |
||
391 | _SPPIDSymbolPathDT.Columns.Add("FullPath"); |
||
392 | bca86986 | gaqhf | |
393 | 26c6f818 | gaqhf | if (_SPPIDInfo.Enable) |
394 | { |
||
395 | string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
||
396 | DirectoryInfo info = new DirectoryInfo(symbolPath); |
||
397 | _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
||
398 | loop(info, "0", symbolPath); |
||
399 | } |
||
400 | } |
||
401 | catch (Exception ex) |
||
402 | 23eb98bf | gaqhf | { |
403 | 26c6f818 | gaqhf | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
404 | 23eb98bf | gaqhf | } |
405 | bca86986 | gaqhf | } |
406 | 23eb98bf | gaqhf | |
407 | bca86986 | gaqhf | private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
408 | { |
||
409 | DirectoryInfo[] infos = parentInfo.GetDirectories(); |
||
410 | foreach (DirectoryInfo info in infos) |
||
411 | { |
||
412 | string uid = Guid.NewGuid().ToString(); |
||
413 | _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
||
414 | loop(info, uid, defaultPath); |
||
415 | |||
416 | FileInfo[] files = info.GetFiles("*.sym"); |
||
417 | foreach (FileInfo fileInfo in files) |
||
418 | { |
||
419 | _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
||
420 | } |
||
421 | } |
||
422 | 23eb98bf | gaqhf | } |
423 | |||
424 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
425 | { |
||
426 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
427 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
428 | { |
||
429 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
430 | return; |
||
431 | } |
||
432 | 1278ba59 | gaqhf | |
433 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
434 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
435 | 1278ba59 | gaqhf | { |
436 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
437 | 1278ba59 | gaqhf | { |
438 | bca86986 | gaqhf | SPPID_Document document = new SPPID_Document(fileName); |
439 | 4314b3f3 | gaqhf | |
440 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
441 | 0d8062b2 | gaqhf | DataRow row; |
442 | if (rows.Length == 0) |
||
443 | { |
||
444 | bca86986 | gaqhf | row = _ConverterDT.NewRow(); |
445 | 0d8062b2 | gaqhf | row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
446 | row["colDrawingFilePath"] = fileName; |
||
447 | row["colDrawingNumber"] = document.DWGNAME; |
||
448 | row["colDrawingName"] = document.DWGNAME; |
||
449 | if (document.Enable) |
||
450 | row["colStatus"] = "Ready"; |
||
451 | else |
||
452 | row["colStatus"] = "Error"; |
||
453 | row["colUID"] = ""; |
||
454 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
455 | 0d8062b2 | gaqhf | } |
456 | if (!_DicDocuments.ContainsKey(fileName)) |
||
457 | _DicDocuments.Add(fileName, null); |
||
458 | |||
459 | _DicDocuments[fileName] = document; |
||
460 | 1278ba59 | gaqhf | } |
461 | } |
||
462 | 65a1ed4b | gaqhf | } |
463 | 17f2a3a7 | gaqhf | |
464 | 1278ba59 | gaqhf | private void btnRun_Click(object sender, EventArgs e) |
465 | { |
||
466 | 17f2a3a7 | gaqhf | _Documents.Clear(); |
467 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
468 | { |
||
469 | string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
||
470 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
471 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
472 | string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
||
473 | string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
||
474 | SPPID_Document document = _DicDocuments[_FilePath]; |
||
475 | document.Unit = _Unit; |
||
476 | document.Template = _Template; |
||
477 | document.DrawingNumber = _DrawingNumber; |
||
478 | document.DrawingName = _DrawingName; |
||
479 | 712860bb | gaqhf | |
480 | document.SymbolMappings = symbolMappings; |
||
481 | document.ChildSymbolMappings = childSymbolMappings; |
||
482 | document.LineMappings = lineMappings; |
||
483 | document.LineNumberMappings = lineNumberMappings; |
||
484 | document.AttributeMappings = attributeMappings; |
||
485 | document.ETCSetting = ETCSetting.GetInstance(); |
||
486 | document.SetSPPIDInfo(); |
||
487 | |||
488 | e3e2d41f | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
489 | _Documents.Add(document); |
||
490 | 17f2a3a7 | gaqhf | } |
491 | 5dfb8a24 | gaqhf | |
492 | d19ae675 | gaqhf | DialogResult = DialogResult.OK; |
493 | 96a2080c | gaqhf | } |
494 | 23eb98bf | gaqhf | |
495 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
496 | { |
||
497 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
498 | if (form.ShowDialog() == DialogResult.OK) |
||
499 | fab4f207 | gaqhf | InitSPPIDDB(); |
500 | 23eb98bf | gaqhf | } |
501 | df4559fc | gaqhf | |
502 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
503 | { |
||
504 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
505 | df4559fc | gaqhf | if (!_ProjectInfo.Enable) |
506 | { |
||
507 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
508 | return; |
||
509 | } |
||
510 | |||
511 | 1efc25a3 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT); |
512 | df4559fc | gaqhf | form.ShowDialog(); |
513 | bca86986 | gaqhf | InitMapping(); |
514 | df4559fc | gaqhf | } |
515 | 4314b3f3 | gaqhf | private List<int> prevSelectedList = new List<int>(); |
516 | |||
517 | private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
||
518 | { |
||
519 | if (e.Action == CollectionChangeAction.Add) |
||
520 | { |
||
521 | string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
||
522 | string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
||
523 | |||
524 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
525 | gridViewConverter.UnselectRow(e.ControllerRow); |
||
526 | } |
||
527 | else if (e.Action == CollectionChangeAction.Refresh) |
||
528 | { |
||
529 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
530 | { |
||
531 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
532 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
533 | |||
534 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
535 | gridViewConverter.UnselectRow(rowHandle); |
||
536 | } |
||
537 | |||
538 | List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
||
539 | var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
||
540 | var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
||
541 | 635a8747 | gaqhf | |
542 | 4314b3f3 | gaqhf | if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
543 | { |
||
544 | this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
545 | gridViewConverter.ClearSelection(); |
||
546 | this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
547 | } |
||
548 | } |
||
549 | |||
550 | prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
||
551 | } |
||
552 | 96a2080c | gaqhf | } |
553 | } |