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