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