프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 06b40010

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