hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 1b261371
이력 | 보기 | 이력해설 | 다운로드 (23.2 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 | fbdb9f2a | gaqhf | |
204 | e00e891d | gaqhf | private void InitETCSetting() |
205 | { |
||
206 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
207 | if (_ProjectInfo.Enable) |
||
208 | { |
||
209 | DataTable dt = Project_DB.SelectETCSetting(); |
||
210 | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
||
211 | SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
||
212 | else |
||
213 | SPPID_DBInfo.Clear(); |
||
214 | bca86986 | gaqhf | } |
215 | } |
||
216 | |||
217 | private void InitID2Symbol() |
||
218 | { |
||
219 | using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
||
220 | { |
||
221 | symbolMappings.Clear(); |
||
222 | _ID2SymbolDT = symbolDT; |
||
223 | _ID2SymbolDT.Columns.Add("Clear"); |
||
224 | _ID2SymbolDT.Columns["Clear"].Caption = ""; |
||
225 | foreach (DataRow row in symbolDT.Rows) |
||
226 | { |
||
227 | symbolMappings.Add(new SymbolMapping() |
||
228 | { |
||
229 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
230 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
231 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
232 | }); |
||
233 | } |
||
234 | } |
||
235 | } |
||
236 | |||
237 | private void InitID2Line() |
||
238 | { |
||
239 | using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
||
240 | { |
||
241 | lineMappings.Clear(); |
||
242 | _ID2LineDT.Rows.Clear(); |
||
243 | foreach (DataRow row in lineTypes.Rows) |
||
244 | { |
||
245 | DataRow newRow = _ID2LineDT.NewRow(); |
||
246 | newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
||
247 | newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
||
248 | newRow["Type"] = "Line"; |
||
249 | newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
||
250 | _ID2LineDT.Rows.Add(newRow); |
||
251 | |||
252 | lineMappings.Add(new LineMapping() |
||
253 | { |
||
254 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
255 | LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
256 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
257 | }); |
||
258 | } |
||
259 | } |
||
260 | } |
||
261 | |||
262 | private void InitID2LineNumber() |
||
263 | { |
||
264 | using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
||
265 | { |
||
266 | lineNumberMappings.Clear(); |
||
267 | _ID2LinePropertyDT = linePropertiesDT; |
||
268 | _ID2LinePropertyDT.Columns.Add("Type"); |
||
269 | foreach (DataRow row in linePropertiesDT.Rows) |
||
270 | { |
||
271 | row["Type"] = "Line Property"; |
||
272 | lineNumberMappings.Add(new LineNumberMapping() |
||
273 | { |
||
274 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
275 | DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
||
276 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
277 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
278 | }); |
||
279 | } |
||
280 | } |
||
281 | } |
||
282 | |||
283 | private void InitID2Association() |
||
284 | { |
||
285 | using (DataTable associationDT = Project_DB.SelectProjectAssociation()) |
||
286 | { |
||
287 | associationMappings.Clear(); |
||
288 | _ID2AssociationDT = associationDT; |
||
289 | _ID2AssociationDT.Columns.Add("Clear"); |
||
290 | _ID2AssociationDT.Columns["Clear"].Caption = ""; |
||
291 | foreach (DataRow row in associationDT.Rows) |
||
292 | { |
||
293 | associationMappings.Add(new AssociationMapping() |
||
294 | { |
||
295 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
296 | DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
||
297 | Type = row["Type"] == null ? "" : row["Type"].ToString(), |
||
298 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
299 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
300 | }); |
||
301 | } |
||
302 | 23eb98bf | gaqhf | } |
303 | } |
||
304 | |||
305 | fab4f207 | gaqhf | private void InitSPPIDDB() |
306 | 23eb98bf | gaqhf | { |
307 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
308 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
309 | { |
||
310 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
311 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
312 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
313 | else |
||
314 | SPPID_DBInfo.Clear(); |
||
315 | fab4f207 | gaqhf | } |
316 | ec0c7045 | gaqhf | |
317 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
318 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
319 | 23eb98bf | gaqhf | if (_SPPIDInfo.Enable) |
320 | { |
||
321 | labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
||
322 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
323 | labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
||
324 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
325 | 635a8747 | gaqhf | |
326 | string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
||
327 | if (!string.IsNullOrEmpty(TemplatePath)) |
||
328 | templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
||
329 | |||
330 | _SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
||
331 | |||
332 | layoutControlGroupAutoConverter.Enabled = true; |
||
333 | 23eb98bf | gaqhf | } |
334 | else |
||
335 | { |
||
336 | labelSPPIDPlantName.Text = " "; |
||
337 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
338 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
339 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
340 | bca86986 | gaqhf | |
341 | 635a8747 | gaqhf | layoutControlGroupAutoConverter.Enabled = false; |
342 | 23eb98bf | gaqhf | } |
343 | bca86986 | gaqhf | |
344 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
345 | _ConverterDT.Rows.Clear(); |
||
346 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
347 | 23eb98bf | gaqhf | } |
348 | |||
349 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
350 | 23eb98bf | gaqhf | { |
351 | bca86986 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
352 | |||
353 | _SPPIDSymbolPathDT = new DataTable(); |
||
354 | _SPPIDSymbolPathDT.Columns.Add("ID"); |
||
355 | _SPPIDSymbolPathDT.Columns.Add("Parent"); |
||
356 | _SPPIDSymbolPathDT.Columns.Add("Name"); |
||
357 | _SPPIDSymbolPathDT.Columns.Add("FullPath"); |
||
358 | |||
359 | if (_SPPIDInfo.Enable) |
||
360 | 23eb98bf | gaqhf | { |
361 | bca86986 | gaqhf | string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
362 | DirectoryInfo info = new DirectoryInfo(symbolPath); |
||
363 | _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
||
364 | loop(info, "0", symbolPath); |
||
365 | 23eb98bf | gaqhf | } |
366 | bca86986 | gaqhf | } |
367 | 23eb98bf | gaqhf | |
368 | bca86986 | gaqhf | private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
369 | { |
||
370 | DirectoryInfo[] infos = parentInfo.GetDirectories(); |
||
371 | foreach (DirectoryInfo info in infos) |
||
372 | { |
||
373 | string uid = Guid.NewGuid().ToString(); |
||
374 | _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
||
375 | loop(info, uid, defaultPath); |
||
376 | |||
377 | FileInfo[] files = info.GetFiles("*.sym"); |
||
378 | foreach (FileInfo fileInfo in files) |
||
379 | { |
||
380 | _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
||
381 | } |
||
382 | } |
||
383 | 23eb98bf | gaqhf | } |
384 | |||
385 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
386 | { |
||
387 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
388 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
389 | { |
||
390 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
391 | return; |
||
392 | } |
||
393 | 1278ba59 | gaqhf | |
394 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
395 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
396 | 1278ba59 | gaqhf | { |
397 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
398 | 1278ba59 | gaqhf | { |
399 | bca86986 | gaqhf | SPPID_Document document = new SPPID_Document(fileName); |
400 | 4314b3f3 | gaqhf | |
401 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
402 | 0d8062b2 | gaqhf | DataRow row; |
403 | if (rows.Length == 0) |
||
404 | { |
||
405 | bca86986 | gaqhf | row = _ConverterDT.NewRow(); |
406 | 0d8062b2 | gaqhf | row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
407 | row["colDrawingFilePath"] = fileName; |
||
408 | row["colDrawingNumber"] = document.DWGNAME; |
||
409 | row["colDrawingName"] = document.DWGNAME; |
||
410 | if (document.Enable) |
||
411 | row["colStatus"] = "Ready"; |
||
412 | else |
||
413 | row["colStatus"] = "Error"; |
||
414 | row["colUID"] = ""; |
||
415 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
416 | 0d8062b2 | gaqhf | } |
417 | if (!_DicDocuments.ContainsKey(fileName)) |
||
418 | _DicDocuments.Add(fileName, null); |
||
419 | |||
420 | _DicDocuments[fileName] = document; |
||
421 | 1278ba59 | gaqhf | } |
422 | } |
||
423 | f6d90b6e | gaqhf | } |
424 | 1278ba59 | gaqhf | |
425 | private void btnRun_Click(object sender, EventArgs e) |
||
426 | { |
||
427 | 5dfb8a24 | gaqhf | #if DEBUG |
428 | SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
||
429 | document.SymbolMappings = symbolMappings; |
||
430 | document.LineMappings = lineMappings; |
||
431 | document.LineNumberMappings = lineNumberMappings; |
||
432 | document.AssociationMappings = associationMappings; |
||
433 | document.ETCSetting = ETCSetting.GetInstance(); |
||
434 | document.SetSPPIDInfo(); |
||
435 | 4314b3f3 | gaqhf | |
436 | 5dfb8a24 | gaqhf | if (document.SetSPPIDMapping()) |
437 | 4314b3f3 | gaqhf | { |
438 | 5dfb8a24 | gaqhf | AutoModeling modeling = new AutoModeling(document); |
439 | modeling.Run(); |
||
440 | 4314b3f3 | gaqhf | } |
441 | |||
442 | 5dfb8a24 | gaqhf | return; |
443 | #endif |
||
444 | |||
445 | //_Documents.Clear(); |
||
446 | |||
447 | //foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
448 | //{ |
||
449 | // string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
||
450 | // string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
451 | // string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
452 | // string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
||
453 | // string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
||
454 | // SPPID_Document document = _DicDocuments[_FilePath]; |
||
455 | // document.Unit = _Unit; |
||
456 | // document.Template = _Template; |
||
457 | // document.DrawingNumber = _DrawingNumber; |
||
458 | // document.DrawingName = _DrawingName; |
||
459 | // _Documents.Add(document); |
||
460 | //} |
||
461 | |||
462 | 1278ba59 | gaqhf | DialogResult = DialogResult.OK; |
463 | 96a2080c | gaqhf | } |
464 | 23eb98bf | gaqhf | |
465 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
466 | { |
||
467 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
468 | if (form.ShowDialog() == DialogResult.OK) |
||
469 | fab4f207 | gaqhf | InitSPPIDDB(); |
470 | 23eb98bf | gaqhf | } |
471 | df4559fc | gaqhf | |
472 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
473 | { |
||
474 | f947c634 | gaqhf | #if DEBUG |
475 | SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
||
476 | 39a2a688 | gaqhf | document.SymbolMappings = symbolMappings; |
477 | document.LineMappings = lineMappings; |
||
478 | document.LineNumberMappings = lineNumberMappings; |
||
479 | document.AssociationMappings = associationMappings; |
||
480 | document.ETCSetting = ETCSetting.GetInstance(); |
||
481 | document.SetSPPIDInfo(); |
||
482 | |||
483 | if (document.SetSPPIDMapping()) |
||
484 | { |
||
485 | AutoModeling modeling = new AutoModeling(document); |
||
486 | modeling.Run(); |
||
487 | } |
||
488 | |||
489 | f947c634 | gaqhf | return; |
490 | #endif |
||
491 | |||
492 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
493 | df4559fc | gaqhf | if (!_ProjectInfo.Enable) |
494 | { |
||
495 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
496 | return; |
||
497 | } |
||
498 | |||
499 | bca86986 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT); |
500 | df4559fc | gaqhf | form.ShowDialog(); |
501 | bca86986 | gaqhf | InitMapping(); |
502 | df4559fc | gaqhf | } |
503 | 4314b3f3 | gaqhf | private List<int> prevSelectedList = new List<int>(); |
504 | |||
505 | private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
||
506 | { |
||
507 | if (e.Action == CollectionChangeAction.Add) |
||
508 | { |
||
509 | string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
||
510 | string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
||
511 | |||
512 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
513 | gridViewConverter.UnselectRow(e.ControllerRow); |
||
514 | } |
||
515 | else if (e.Action == CollectionChangeAction.Refresh) |
||
516 | { |
||
517 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
518 | { |
||
519 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
520 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
521 | |||
522 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
523 | gridViewConverter.UnselectRow(rowHandle); |
||
524 | } |
||
525 | |||
526 | List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
||
527 | var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
||
528 | var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
||
529 | 635a8747 | gaqhf | |
530 | 4314b3f3 | gaqhf | if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
531 | { |
||
532 | this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
533 | gridViewConverter.ClearSelection(); |
||
534 | this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
535 | } |
||
536 | } |
||
537 | |||
538 | prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
||
539 | } |
||
540 | 96a2080c | gaqhf | } |
541 | } |