프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ f1232880

이력 | 보기 | 이력해설 | 다운로드 (26.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 f1c9dbaa gaqhf
        private DataTable _ID2SymbolTypeDT = new DataTable();
42
43 bca86986 gaqhf
44
        private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
45
        private List<LineMapping> lineMappings = new List<LineMapping>();
46
        private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
47
        private List<AssociationMapping> associationMappings = new List<AssociationMapping>();
48
49 96a2080c gaqhf
        public ConverterForm()
50
        {
51
            InitializeComponent();
52 1278ba59 gaqhf
53 fab4f207 gaqhf
            CultureInfo culture = CultureInfo.GetCultureInfo("ko");
54 23eb98bf gaqhf
            Msg.Culture = culture;
55
56 bca86986 gaqhf
            InitUsedDataTable();
57 1278ba59 gaqhf
            InitGridControl();
58 fab4f207 gaqhf
            InitID2Project();
59 1278ba59 gaqhf
        }
60
61 f1232880 gaqhf
        #region
62
        /// <summary>
63
        /// The Activate Event is where the command should show its form
64
        /// if it should be displayed.
65
        /// </summary>
66
        /// <param name="sender">The sender of the event</param>
67
        /// <param name="e">Arguments passed during event</param>
68
        private void commandControl_Activate(object sender, EventArgs e)
69
        {
70
            if (ShowDialog() == DialogResult.OK)
71
            {
72
73
            }
74
75
            foreach (var item in commandControl.Application.RADApplication.ActiveSelectSet)
76
            {
77
                //MessageBox.Show(item.GetType());
78
                int count = ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).VertexCount;
79
                double[] iii = null;
80
                ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertices(ref count, ref iii);
81
                for (int i = 0; i < count; i++)
82
                {
83
                    double x = 0;
84
                    double y = 0;
85
                    ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertex(i + 1, ref x, ref y);
86
87
                }
88
                Ingr.RAD2D.Symbol2d symbol2D;
89
                //symbol2D.Move
90
            }
91
92
            //commandControl.Application.RADApplication.Interactive = true;
93
            //Hide();
94
            //commandControl.Done = true;
95
        }
96
97
        /// <summary>
98
        /// The Deactivate event is where the command should hide its form if it
99
        /// was displayed.  The command should not unload the form here.
100
        /// The command's form should be unloaded in the Class Module Terminate event.
101
        /// </summary>
102
        /// <param name="sender">The sender of the event</param>
103
        /// <param name="e">Arguments passed during event</param>
104
        private void commandControl_Deactivate(object sender, EventArgs e)
105
        {
106
            Hide();
107
        }
108
109
        /// <summary>
110
        /// The Initialize event is where the command should perform 1 time 
111
        /// initialization, for example it might save a reference to the 
112
        /// active document in private global data.
113
        /// </summary>
114
        /// <param name="sender">The sender of the event</param>
115
        /// <param name="e">Arguments passed during event</param>
116
        private void commandControl_Initialize(object sender, EventArgs e)
117
        {
118
119
        }
120
121
        /// <summary>
122
        /// The Terminate event is where the command can clean up any command
123
        /// specific allocated resources.
124
        /// </summary>
125
        /// <param name="sender">The sender of the event</param>
126
        /// <param name="e">Arguments passed during event</param>
127
        public void commandControl_Terminate(object sender, EventArgs e)
128
        {
129
130
        }
131
132
        /// <summary>
133
        /// The primary form should not simply be unloaded. You should set the
134
        /// Intergraph Command Control Done property to True when you want the 
135
        /// form to be unloaded. Then unload the form in the dispose method.
136
        /// </summary>
137
        /// <param name="sender">The sender of the event</param>
138
        /// <param name="e">Arguments passed during event</param>
139
        private void ConverterForm_FormClosing(object sender, FormClosingEventArgs e)
140
        {
141
            Hide();
142
            commandControl.Done = true;
143
            e.Cancel = true; //Do not let C# close out the form ... Let RAD close it.
144
        }
145
        #endregion
146
147 bca86986 gaqhf
        private void InitUsedDataTable()
148 1278ba59 gaqhf
        {
149 bca86986 gaqhf
            // Converter Table
150
            DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
151 1278ba59 gaqhf
            col.Caption = "Drawing File Name";
152 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colDrawingFilePath");
153 0d8062b2 gaqhf
            col.Caption = "DrawingFilePath";
154 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colUnit");
155 1278ba59 gaqhf
            col.Caption = "Unit";
156 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colTemplate");
157 1278ba59 gaqhf
            col.Caption = "Template";
158 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colDrawingNumber");
159 1278ba59 gaqhf
            col.Caption = "Drawing Number";
160 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colDrawingName");
161 1278ba59 gaqhf
            col.Caption = "Drawing Name";
162 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colStatus");
163 1278ba59 gaqhf
            col.Caption = "Status";
164 bca86986 gaqhf
            col = _ConverterDT.Columns.Add("colUID");
165
166
            col = _ID2LineDT.Columns.Add("UID");
167
            col = _ID2LineDT.Columns.Add("Name");
168
            col.Caption = "Name";
169
            col = _ID2LineDT.Columns.Add("Type");
170
            col.Caption = "Type";
171
            col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH");
172
            col.Caption = "SPPID Symbol Path";
173
            col = _ID2LineDT.Columns.Add("Clear");
174
            col.Caption = "";
175
        }
176
177
        private void InitGridControl()
178
        {
179
            #region Converter Page
180
            gridViewConverter.OptionsSelection.MultiSelect = true;
181
            gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
182
            
183
            gridControlConverter.DataSource = _ConverterDT;
184 1278ba59 gaqhf
185
            templateComboBox = new RepositoryItemComboBox();
186
            templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
187 635a8747 gaqhf
            templateComboBox.EditValueChanged += templateComboBox_EditValueChanged;
188 1278ba59 gaqhf
            gridControlConverter.RepositoryItems.Add(templateComboBox);
189
            gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
190
191 635a8747 gaqhf
            gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
192 1278ba59 gaqhf
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
193
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
194
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
195 0d8062b2 gaqhf
            gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
196 1278ba59 gaqhf
            gridViewConverter.Columns["colUID"].Visible = false;
197
198
            gridViewConverter.BestFitColumns();
199
            #endregion
200
        }
201 f1c9dbaa gaqhf
202 635a8747 gaqhf
        private void templateComboBox_EditValueChanged(object sender, EventArgs e)
203
        {
204
            gridViewConverter.CloseEditor();
205
            gridViewConverter.UpdateCurrentRow();
206
        }
207
208
        private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
209
        {
210
            if (e.Column.Name == "colcolTemplate")
211
            {
212
                gridViewConverter.ShowEditor();
213
                (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup();
214
            }
215
            else if (e.Column.Name == "colcolUnit")
216
            {
217
                UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
218
                if (unitForm.ShowDialog() == DialogResult.OK)
219
                {
220
                    gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit);
221
                    gridViewConverter.CloseEditor();
222
                    gridViewConverter.UpdateCurrentRow();
223
                }
224
            }
225
        }
226 1278ba59 gaqhf
227 23eb98bf gaqhf
        private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e)
228
        {
229 fab4f207 gaqhf
            xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text;
230
231 23eb98bf gaqhf
            if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
232
            {
233 fab4f207 gaqhf
                if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
234
                    xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
235
                Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath;
236
                Settings.Default.Save();
237
                if (InitID2Project())
238 635a8747 gaqhf
                {
239 fab4f207 gaqhf
                    MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
240 635a8747 gaqhf
                }
241 fab4f207 gaqhf
                else
242 23eb98bf gaqhf
                    MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
243
            }
244
        }
245
246 fab4f207 gaqhf
        private bool InitID2Project()
247 23eb98bf gaqhf
        {
248 ec0c7045 gaqhf
            Project_Info _ProjectInfo = Project_Info.GetInstance();
249 fab4f207 gaqhf
            _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath;
250
            if (Project_DB.ConnTestAndCreateTable())
251 23eb98bf gaqhf
            {
252 fab4f207 gaqhf
                _ProjectInfo.Enable = true;
253 171142c5 gaqhf
                btnID2Project.Text = _ProjectInfo.DefaultPath;
254 23eb98bf gaqhf
                labelID2ProjectName.Text = _ProjectInfo.Name;
255
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
256
                labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
257
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
258 fab4f207 gaqhf
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
259
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
260 23eb98bf gaqhf
            }
261
            else
262
            {
263 fab4f207 gaqhf
                _ProjectInfo.Enable = false;
264 23eb98bf gaqhf
                btnID2Project.Text = "";
265
                labelID2ProjectName.Text = " ";
266
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
267
                labelID2ProjectStatus.Text = Msg.ConnectionFail;
268
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
269 fab4f207 gaqhf
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
270
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
271 bca86986 gaqhf
            }
272 fab4f207 gaqhf
273 bca86986 gaqhf
            InitMapping();
274
            InitSPPIDDB();
275
276
            return _ProjectInfo.Enable;
277
        }
278
279
        private void InitMapping()
280
        {
281
            Project_Info _ProjectInfo = Project_Info.GetInstance();
282
            if (_ProjectInfo.Enable)
283
            {
284
                InitID2Symbol();
285
                InitID2Line();
286
                InitID2LineNumber();
287
                InitID2Association();
288 e00e891d gaqhf
289
                InitETCSetting();
290
            }
291
        }
292 fbdb9f2a gaqhf
293 e00e891d gaqhf
        private void InitETCSetting()
294
        {
295
            Project_Info _ProjectInfo = Project_Info.GetInstance();
296
            if (_ProjectInfo.Enable)
297
            {
298
                DataTable dt = Project_DB.SelectETCSetting();
299
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
300
                    SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString());
301
                else
302
                    SPPID_DBInfo.Clear();
303 bca86986 gaqhf
            }
304
        }
305
306
        private void InitID2Symbol()
307
        {
308
            using (DataTable symbolDT = Project_DB.SelectProjectSymbol())
309
            {
310
                symbolMappings.Clear();
311
                _ID2SymbolDT = symbolDT;
312
                _ID2SymbolDT.Columns.Add("Clear");
313
                _ID2SymbolDT.Columns["Clear"].Caption = "";
314
                foreach (DataRow row in symbolDT.Rows)
315
                {
316
                    symbolMappings.Add(new SymbolMapping()
317
                    {
318
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
319
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
320
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
321
                    });
322
                }
323
            }
324
        }
325
326
        private void InitID2Line()
327
        {
328
            using (DataTable lineTypes = Project_DB.SelectProjectLine())
329
            {
330
                lineMappings.Clear();
331
                _ID2LineDT.Rows.Clear();
332
                foreach (DataRow row in lineTypes.Rows)
333
                {
334
                    DataRow newRow = _ID2LineDT.NewRow();
335
                    newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
336
                    newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
337
                    newRow["Type"] = "Line";
338
                    newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
339
                    _ID2LineDT.Rows.Add(newRow);
340
341
                    lineMappings.Add(new LineMapping()
342
                    {
343
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
344
                        LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
345
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
346
                    });
347
                }
348
            }
349
        }
350
351
        private void InitID2LineNumber()
352
        {
353
            using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties())
354
            {
355
                lineNumberMappings.Clear();
356
                _ID2LinePropertyDT = linePropertiesDT;
357
                _ID2LinePropertyDT.Columns.Add("Type");
358
                foreach (DataRow row in linePropertiesDT.Rows)
359
                {
360
                    row["Type"] = "Line Property";
361
                    lineNumberMappings.Add(new LineNumberMapping()
362
                    {
363
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
364
                        DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(),
365
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
366
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
367
                    });
368
                }
369
            }
370
        }
371
372
        private void InitID2Association()
373
        {
374
            using (DataTable associationDT = Project_DB.SelectProjectAssociation())
375
            {
376
                associationMappings.Clear();
377
                _ID2AssociationDT = associationDT;
378
                _ID2AssociationDT.Columns.Add("Clear");
379
                _ID2AssociationDT.Columns["Clear"].Caption = "";
380
                foreach (DataRow row in associationDT.Rows)
381
                {
382
                    associationMappings.Add(new AssociationMapping()
383
                    {
384
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
385
                        DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(),
386
                        Type = row["Type"] == null ? "" : row["Type"].ToString(),
387
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
388
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
389
                    });
390
                }
391 23eb98bf gaqhf
            }
392
        }
393
394 fab4f207 gaqhf
        private void InitSPPIDDB()
395 23eb98bf gaqhf
        {
396 ec0c7045 gaqhf
            Project_Info _ProjectInfo = Project_Info.GetInstance();
397 fab4f207 gaqhf
            if (_ProjectInfo.Enable)
398
            {
399
                DataTable dt = Project_DB.SelectSPPID_DB_INFO();
400 ec0c7045 gaqhf
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
401
                    SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
402
                else
403
                    SPPID_DBInfo.Clear();
404 fab4f207 gaqhf
            }
405 ec0c7045 gaqhf
406 635a8747 gaqhf
            templateComboBox.Items.Clear();
407 ec0c7045 gaqhf
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
408 23eb98bf gaqhf
            if (_SPPIDInfo.Enable)
409
            {
410
                labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
411
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
412
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
413
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
414 635a8747 gaqhf
415
                string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
416
                if (!string.IsNullOrEmpty(TemplatePath))
417
                    templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList());
418
419
                _SPPIDUnitDT = SPPID_DB.GetUnitTree();
420
421
                layoutControlGroupAutoConverter.Enabled = true;
422 23eb98bf gaqhf
            }
423
            else
424
            {
425
                labelSPPIDPlantName.Text = " ";
426
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
427
                labelSPPIDDBStatus.Text = Msg.ConnectionFail;
428
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
429 bca86986 gaqhf
430 635a8747 gaqhf
                layoutControlGroupAutoConverter.Enabled = false;
431 23eb98bf gaqhf
            }
432 bca86986 gaqhf
433 635a8747 gaqhf
            _DicDocuments.Clear();
434
            _ConverterDT.Rows.Clear();
435 bca86986 gaqhf
            InitSPPIDSymbolTreeTable();
436 23eb98bf gaqhf
        }
437
438 bca86986 gaqhf
        private void InitSPPIDSymbolTreeTable()
439 23eb98bf gaqhf
        {
440 bca86986 gaqhf
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
441
442
            _SPPIDSymbolPathDT = new DataTable();
443
            _SPPIDSymbolPathDT.Columns.Add("ID");
444
            _SPPIDSymbolPathDT.Columns.Add("Parent");
445
            _SPPIDSymbolPathDT.Columns.Add("Name");
446
            _SPPIDSymbolPathDT.Columns.Add("FullPath");
447
448
            if (_SPPIDInfo.Enable)
449 23eb98bf gaqhf
            {
450 bca86986 gaqhf
                string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
451
                DirectoryInfo info = new DirectoryInfo(symbolPath);
452
                _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
453
                loop(info, "0", symbolPath);
454 23eb98bf gaqhf
            }
455 bca86986 gaqhf
        }
456 23eb98bf gaqhf
457 bca86986 gaqhf
        private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
458
        {
459
            DirectoryInfo[] infos = parentInfo.GetDirectories();
460
            foreach (DirectoryInfo info in infos)
461
            {
462
                string uid = Guid.NewGuid().ToString();
463
                _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
464
                loop(info, uid, defaultPath);
465
466
                FileInfo[] files = info.GetFiles("*.sym");
467
                foreach (FileInfo fileInfo in files)
468
                {
469
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
470
                }
471
            }
472 23eb98bf gaqhf
        }
473
474 1278ba59 gaqhf
        private void btnLoadFile_Click(object sender, EventArgs e)
475
        {
476 ec0c7045 gaqhf
            Project_Info _ProjectInfo = Project_Info.GetInstance();
477 23eb98bf gaqhf
            if (!_ProjectInfo.Enable)
478
            {
479
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
480
                return;
481
            }
482 1278ba59 gaqhf
483 171142c5 gaqhf
            xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
484 23eb98bf gaqhf
            if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
485 1278ba59 gaqhf
            {
486 23eb98bf gaqhf
                foreach (string fileName in xtraOpenFileDialog.FileNames)
487 1278ba59 gaqhf
                {
488 bca86986 gaqhf
                    SPPID_Document document = new SPPID_Document(fileName);
489 4314b3f3 gaqhf
490 bca86986 gaqhf
                    DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
491 0d8062b2 gaqhf
                    DataRow row;
492
                    if (rows.Length == 0)
493
                    {
494 bca86986 gaqhf
                        row = _ConverterDT.NewRow();
495 0d8062b2 gaqhf
                        row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
496
                        row["colDrawingFilePath"] = fileName;
497
                        row["colDrawingNumber"] = document.DWGNAME;
498
                        row["colDrawingName"] = document.DWGNAME;
499
                        if (document.Enable)
500
                            row["colStatus"] = "Ready";
501
                        else
502
                            row["colStatus"] = "Error";
503
                        row["colUID"] = "";
504 bca86986 gaqhf
                        _ConverterDT.Rows.Add(row);
505 0d8062b2 gaqhf
                    }
506
                    if (!_DicDocuments.ContainsKey(fileName))
507
                        _DicDocuments.Add(fileName, null);
508
509
                    _DicDocuments[fileName] = document;
510 1278ba59 gaqhf
                }
511
            }
512 f6d90b6e gaqhf
        } 
513 1278ba59 gaqhf
514
        private void btnRun_Click(object sender, EventArgs e)
515
        {
516 5dfb8a24 gaqhf
#if DEBUG
517 809a7640 gaqhf
            //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml");
518 5dfb8a24 gaqhf
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
519
            document.SymbolMappings = symbolMappings;
520
            document.LineMappings = lineMappings;
521
            document.LineNumberMappings = lineNumberMappings;
522
            document.AssociationMappings = associationMappings;
523
            document.ETCSetting = ETCSetting.GetInstance();
524 f1c9dbaa gaqhf
525 5dfb8a24 gaqhf
            document.SetSPPIDInfo();
526 4314b3f3 gaqhf
527 8aa6f2db gaqhf
            if (document.SetSPPIDMapping() && document.Enable)
528 4314b3f3 gaqhf
            {
529 5dfb8a24 gaqhf
                AutoModeling modeling = new AutoModeling(document);
530
                modeling.Run();
531 4314b3f3 gaqhf
            }
532
533 5dfb8a24 gaqhf
            return;
534
#endif
535
536
            //_Documents.Clear();
537
538
            //foreach (int rowHandle in gridViewConverter.GetSelectedRows())
539
            //{
540
            //    string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
541
            //    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
542
            //    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
543
            //    string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
544
            //    string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
545
            //    SPPID_Document document = _DicDocuments[_FilePath];
546
            //    document.Unit = _Unit;
547
            //    document.Template = _Template;
548
            //    document.DrawingNumber = _DrawingNumber;
549
            //    document.DrawingName = _DrawingName;
550
            //    _Documents.Add(document);
551
            //}
552
553 1278ba59 gaqhf
            DialogResult = DialogResult.OK;
554 96a2080c gaqhf
        }
555 23eb98bf gaqhf
556
        private void btnSPPIDDB_Click(object sender, EventArgs e)
557
        {
558
            SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
559
            if (form.ShowDialog() == DialogResult.OK)
560 fab4f207 gaqhf
                InitSPPIDDB();
561 23eb98bf gaqhf
        }
562 df4559fc gaqhf
563
        private void btnItemMapping_Click(object sender, EventArgs e)
564
        {
565 ec0c7045 gaqhf
            Project_Info _ProjectInfo = Project_Info.GetInstance();
566 df4559fc gaqhf
            if (!_ProjectInfo.Enable)
567
            {
568
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
569
                return;
570
            }
571
572 bca86986 gaqhf
            MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT);
573 df4559fc gaqhf
            form.ShowDialog();
574 bca86986 gaqhf
            InitMapping();
575 df4559fc gaqhf
        }
576 4314b3f3 gaqhf
        private List<int> prevSelectedList = new List<int>();
577
578
        private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
579
        {
580
            if (e.Action == CollectionChangeAction.Add)
581
            {
582
                string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
583
                string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
584
585
                if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
586
                    gridViewConverter.UnselectRow(e.ControllerRow);
587
            }
588
            else if (e.Action == CollectionChangeAction.Refresh)
589
            {
590
                foreach (int rowHandle in gridViewConverter.GetSelectedRows())
591
                {
592
                    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
593
                    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
594
595
                    if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
596
                        gridViewConverter.UnselectRow(rowHandle);
597
                }
598
599
                List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
600
                var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
601
                var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
602 635a8747 gaqhf
603 4314b3f3 gaqhf
                if (!firstNotSecond.Any() && !secondNotFirst.Any())
604
                {
605
                    this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
606
                    gridViewConverter.ClearSelection();
607
                    this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
608
                }
609
            }
610
611
            prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
612
        }
613 96a2080c gaqhf
    }
614
}
클립보드 이미지 추가 (최대 크기: 500 MB)