프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ e4b3e191

이력 | 보기 | 이력해설 | 다운로드 (26.1 KB)

1
Imports System.IO
2
Imports System.Data.SqlClient
3
Imports System.Data.SQLite
4
Imports Plaice
5
Imports Llama
6
Imports PidA
7

    
8
Public Class Main
9

    
10
    Dim _DB As DataTable = New DataTable()
11
    Dim _Placement As New Placement
12
    Dim _DWG_X = 0.84 '0.695 '1 '
13
    Dim _DWG_Y = 0.594 '0.585 '0.8 '
14

    
15
    Dim _IMG_X = 0
16
    Dim _IMG_Y = 0
17

    
18
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
19
        Dim sDBPath As String = "C:\Users\kyusu\Desktop\Auto SPPID 변환 프로젝트\PID.db"
20
        LoadDB(sDBPath)
21

    
22
        SetUpListViewColumns()
23
        LoadTree()
24

    
25

    
26
    End Sub
27
    Private Sub LoadTree()
28

    
29
        Dim i As Integer
30
        Dim j() As String
31
        j = Directory.GetLogicalDrives
32
        For i = 0 To UBound(j)
33

    
34
            Dim cdrive As System.IO.DriveInfo
35
            cdrive = My.Computer.FileSystem.GetDriveInfo(j(i).ToString)
36

    
37
            Select Case cdrive.DriveType
38
                Case DriveType.Fixed
39
                    Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 3)
40
                Case DriveType.CDRom
41
                    Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 11)
42
                Case DriveType.Network
43
                    Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 5)
44
                Case DriveType.Removable
45
                    Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 12)
46
            End Select
47

    
48
        Next
49
    End Sub
50

    
51
    Private Sub SetUpListViewColumns()
52
        ' TODO: Add code to set up listview columns
53
        ListView_File.Columns.Add("  Name ")
54
        '   ListView_File.Columns.Add(" Size  ")
55
        '    ListView_File.Columns.Add(" Extension  ")
56
        ListView_File.Columns.Add(" Date Modified  ")
57
        SetView(View.Details)
58
    End Sub
59

    
60

    
61
    Private Sub SetView(ByVal View As System.Windows.Forms.View)
62
        'Figure out which menu item should be checked
63
        'Dim MenuItemToCheck As ToolStripMenuItem = Nothing
64
        'Select Case View
65
        '    Case View.Details
66
        '        MenuItemToCheck = DetailsToolStripMenuItem
67
        '    Case View.LargeIcon
68
        '        MenuItemToCheck = LargeIconsToolStripMenuItem
69
        '    Case View.List
70
        '        MenuItemToCheck = ListToolStripMenuItem
71
        '    Case View.SmallIcon
72
        '        MenuItemToCheck = SmallIconsToolStripMenuItem
73
        '    Case View.Tile
74
        '        MenuItemToCheck = TileToolStripMenuItem
75
        '    Case Else
76
        '        Debug.Fail("Unexpected View")
77
        '        View = View.Details
78
        '        MenuItemToCheck = DetailsToolStripMenuItem
79
        'End Select
80

    
81
        ''Check the appropriate menu item and deselect all others under the Views menu
82
        'For Each MenuItem As ToolStripMenuItem In ListViewToolStripButton.DropDownItems
83
        '    If MenuItem Is MenuItemToCheck Then
84
        '        MenuItem.Checked = True
85
        '    Else
86
        '        MenuItem.Checked = False
87
        '    End If
88
        'Next
89

    
90
        'Finally, set the view requested
91
        ListView_File.View = View.Details
92
    End Sub
93

    
94
    Private Sub Btn_FolderPath_Click(sender As Object, e As EventArgs)
95
        Dim oOpenFolderDlg = New FolderBrowserDialog()
96
        Dim result As DialogResult = oOpenFolderDlg.ShowDialog()
97
        Dim sFolderName As String = ""
98

    
99
        If (result = DialogResult.OK) Then
100
            sFolderName = oOpenFolderDlg.SelectedPath
101
            '    Txt_FolderPath.Text = sFolderName
102
            InitXMLTree(sFolderName)
103
        End If
104

    
105
    End Sub
106

    
107
    Private Sub InitXMLTree(ByVal sFolderPath As String)
108
        Tree_XMLFiles.Nodes.Clear()
109
        Dim oRootNode As TreeNode = Tree_XMLFiles.Nodes.Add("XML")
110
        '.XML 만 로드
111
        Dim sfileEntries As String() = Directory.GetFiles(sFolderPath, "*.xml")
112
        ' Process the list of files found in the directory.
113
        Dim sfileName As String
114
        For Each sfileName In sfileEntries
115
            oRootNode.Nodes.Add(sfileName)
116
        Next sfileName
117
        oRootNode.ExpandAll()
118
    End Sub
119

    
120
    Private Function CreateDwg(ByVal oDwgName As String, ByVal sPlantGroupName As String, ByVal sTemplateFileName As String) As Boolean
121
        Try
122
            Dim datasource As LMADataSource
123
            Dim objPIDAutoApp As Object
124
            Dim objPIDADrawing As Object
125
            Dim PlantGroupName As String
126
            Dim TemplateFileName As String
127
            Dim DrawingNumber As String
128
            Dim DrawingName As String
129

    
130
            Dim extension As String = Path.GetExtension(oDwgName)
131
            oDwgName = oDwgName.Replace(extension, "")
132
            datasource = New LMADataSource
133
            objPIDAutoApp = CreateObject("PIDAutomation.Application")
134
            PlantGroupName = sPlantGroupName
135
            'considering accessing T_OptinSetting to read the template files path, which will be more flexible
136
            TemplateFileName = sTemplateFileName
137
            DrawingNumber = oDwgName
138
            DrawingName = oDwgName
139
            objPIDADrawing = objPIDAutoApp.Drawings.Add(PlantGroupName, TemplateFileName, DrawingNumber, DrawingName)
140
            If Not objPIDADrawing Is Nothing Then
141
                '이미 오픈
142
                objPIDADrawing.CloseDrawing
143
            End If
144
            objPIDAutoApp.Quit
145
            objPIDAutoApp = Nothing
146
            objPIDADrawing = Nothing
147
            Return True
148
        Catch ex As Exception
149
            Return False
150
        End Try
151

    
152
    End Function
153

    
154
#Region "Load Pipe"
155
    Private Function LoadPipe_DT() As DataTable
156
        Dim oDt As New DataTable
157
        oDt.Columns.Add("start_x")
158
        oDt.Columns.Add("start_y")
159
        oDt.Columns.Add("end_x")
160
        oDt.Columns.Add("end_y")
161
        oDt.Columns.Add("Symbol")
162
        Return oDt
163

    
164
    End Function
165

    
166
#End Region
167

    
168
#Region "Load Symbol"
169
    Private Function LoadSymbol_DT() As DataTable
170
        Dim oDt As New DataTable
171
        oDt.Columns.Add("Name")
172
        oDt.Columns.Add("x")
173
        oDt.Columns.Add("y")
174
        oDt.Columns.Add("Angle")
175
        oDt.Columns.Add("Symbol")
176
        oDt.Columns.Add("Text")
177
        Return oDt
178
    End Function
179

    
180
#End Region
181

    
182
    Private Function GetSymbolMapping(ByVal oSymbolName As String) As String
183
        Dim oSystemPath As String = ""
184
        Dim oSelectRow() As DataRow = _DB.Select("[pid_symbolname] = '" + oSymbolName + "'")
185
        If oSelectRow.Length = 1 Then
186
            oSystemPath = oSelectRow(0).Item("sppid_systempath").ToString()
187
        End If
188
        Return oSystemPath
189
    End Function
190

    
191
    Private Function LoadSymbolInXml(ByVal sXmlPath As String) As DataTable
192
        Dim oDt As DataTable = LoadSymbol_DT()
193
        Dim oElement As XElement = XElement.Load(sXmlPath)
194
        If oElement IsNot Nothing Then
195
            For Each symbols As Object In oElement.Elements("SYMBOLS")
196
                For Each page As Object In symbols.Elements("SYMBOL")
197
                    Dim oAddrow As DataRow = oDt.NewRow()
198
                    Dim oObj As XElement = page.Element("NAME")
199
                    Dim oSymbol = oObj.Value
200

    
201
                    oObj = page.Element("TEXT")
202
                    Dim oText = oObj.Value
203
                    oObj = page.Element("CLASS")
204
                    Dim oClass = oObj.Value
205
                    oObj = page.Element("TYPE")
206
                    Dim oType = oObj.Value
207
                    oObj = page.Element("ITEM")
208
                    Dim oItem = oObj.Value
209

    
210
                    ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym"
211
                    Dim oSymbolPath As String = GetSymbolMapping(oItem)
212

    
213
                    oObj = page.Element("ORIGINALPOINT")
214
                    Dim sOriginPoint = oObj.Value
215

    
216
                    oObj = page.Element("ANGLE")
217
                    Dim oAngle = oObj.Value
218

    
219
                    Dim oSplitPos As String() = sOriginPoint.Split(",")
220
                    Dim oX As Double = 0.0
221
                    Dim oY As Double = 0.0
222
                    If IsNumeric(oSplitPos(0)) Then
223
                        oX = Double.Parse(oSplitPos(0))
224
                    End If
225
                    If IsNumeric(oSplitPos(1)) Then
226
                        oY = Double.Parse(oSplitPos(1))
227
                    End If
228

    
229
                    ConvertPoint(oX, oY, _DWG_X, _DWG_Y)
230
                    oAddrow("X") = oX '+ 0.05
231
                    oAddrow("Y") = oY
232
                    oAddrow("Angle") = oAngle
233
                    oAddrow("Symbol") = oSymbolPath
234
                    oAddrow("Text") = oText
235
                    oAddrow("Name") = oSymbol
236

    
237
                    oDt.Rows.Add(oAddrow)
238

    
239
                Next
240
            Next
241

    
242
        End If
243
    End Function
244

    
245

    
246

    
247
    Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable
248
        Try
249
            Dim oDt As DataTable = LoadPipe_DT()
250
            Dim oElement As XElement = XElement.Load(sXmlPath)
251
            If oElement IsNot Nothing Then
252
                Dim DWGElement As XElement = oElement.Element("DWGNAME")
253
                Dim DWGNAME = DWGElement.Value
254
                Dim sXY As XElement = oElement.Element("SIZE")
255
                Dim sSize = sXY.Value
256
                Dim oSplitDWGPos As String() = sSize.Split(",")
257

    
258
                If IsNumeric(oSplitDWGPos(0)) Then
259
                    _IMG_X = Double.Parse(oSplitDWGPos(0))
260
                End If
261
                If IsNumeric(oSplitDWGPos(1)) Then
262
                    _IMG_Y = Double.Parse(oSplitDWGPos(1))
263
                End If
264

    
265
                For Each pipes As Object In oElement.Elements("IMGLINES")
266
                    For Each pipe As Object In pipes.Elements("IMGLINE")
267
                        Dim oAddrow As DataRow = oDt.NewRow()
268
                        Dim oObj As XElement = pipe.Element("ITEM")
269
                        Dim oItem = oObj.Value
270
                        ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym"
271
                        Dim oSymbolPath As String = GetSymbolMapping(oItem)
272
                        oObj = pipe.Element("START")
273
                        Dim oStartPoint = oObj.Value
274
                        Dim oSplitPos As String() = oStartPoint.Split(",")
275
                        Dim oStartpos_X As Double = 0.0
276
                        Dim oStartpos_Y As Double = 0.0
277
                        If IsNumeric(oSplitPos(0)) Then
278
                            oStartpos_X = Double.Parse(oSplitPos(0))
279
                        End If
280
                        If IsNumeric(oSplitPos(1)) Then
281
                            oStartpos_Y = Double.Parse(oSplitPos(1))
282
                        End If
283

    
284
                        ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y)
285
                        oObj = pipe.Element("END")
286
                        Dim oEndPoint = oObj.Value
287
                        oSplitPos = oEndPoint.Split(",")
288
                        Dim oEndpos_X As Double = 0.0
289
                        Dim oEndpos_Y As Double = 0.0
290
                        If IsNumeric(oSplitPos(0)) Then
291
                            oEndpos_X = Double.Parse(oSplitPos(0))
292
                        End If
293
                        If IsNumeric(oSplitPos(1)) Then
294
                            oEndpos_Y = Double.Parse(oSplitPos(1))
295
                        End If
296
                        ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y)
297

    
298
                        oAddrow("start_x") = oStartpos_X '+ 0.05
299
                        oAddrow("start_y") = oStartpos_Y
300
                        oAddrow("end_x") = oEndpos_X
301
                        oAddrow("end_y") = oEndpos_Y
302
                        oAddrow("Symbol") = oSymbolPath
303
                        oDt.Rows.Add(oAddrow)
304

    
305

    
306
                    Next
307
                Next
308

    
309
            End If
310

    
311

    
312
            Return oDt
313
        Catch ex As Exception
314
            Return Nothing
315
        End Try
316
    End Function
317

    
318

    
319
    Private Sub ConvertPoint(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double)
320

    
321
        Dim calcx As Double = 0
322
        Dim calcy As Double = 0
323
        calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
324
        calcy = _DWG_Y - (dY * _DWG_Y) / dDwgY '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
325
        dX = calcx
326
        dY = calcy
327
    End Sub
328

    
329

    
330

    
331

    
332
    Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable) As Boolean
333
        Dim iSymbolcount = 0
334
        Dim datasource As LMADataSource
335
        datasource = _Placement.PIDDataSource
336
        Dim iPipecnt As Integer = 0
337

    
338
        For Each oRow As DataRow In oPipe_Dt.Rows
339
            Dim oposition As String = oRow("position").ToString()
340
            Dim oSymbol As String = oRow("Symbol").ToString()
341
            Dim oSplitStr As String() = Split(oposition, " ")
342
            Dim objConnector As LMConnector
343
            Dim objInputs As PlaceRunInputs
344
            objInputs = New PlaceRunInputs
345
            Dim oDwg_x As Double = 9933
346
            Dim oDwg_y As Double = 7016
347
            For Each sposition As String In oSplitStr
348
                Dim opointstr As String() = Split(sposition, ",")
349

    
350
                If (opointstr.Length > 1) Then
351
                    If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
352
                        Dim ox As Double = opointstr(0)
353
                        Dim oy As Double = opointstr(1)
354
                        ConvertPoint(ox, oy, oDwg_x, oDwg_y)
355
                        objInputs.AddPoint(ox, oy)
356
                    End If
357
                End If
358
            Next
359
            Dim objItem As LMAItem
360
            objItem = _Placement.PIDCreateItem(oSymbol)
361
            objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
362

    
363
            'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID)
364
            'objPipeRun.Attributes("OperFluidCode").Value = "AFS"
365
            'objPipeRun.Commit()
366
            iPipecnt = iPipecnt + 1
367

    
368
        Next
369

    
370

    
371
        For Each oRow As DataRow In oSymbol_Dt.Rows
372

    
373
            Dim oSymbol As String = oRow("Symbol").ToString()
374
            Dim oType As String = oRow("Name").ToString()
375
            Dim oText As String = oRow("Text").ToString()
376
            Dim oX As Double = 0.0
377
            Dim oY As Double = 0.0
378
            If IsNumeric(oRow("x").ToString()) Then
379
                oX = Double.Parse(oRow("x").ToString())
380
            End If
381
            If IsNumeric(oRow("y").ToString()) Then
382
                oY = Double.Parse(oRow("y").ToString())
383
            End If
384
            Dim oAngle As Double = 0.0
385
            If IsNumeric(oRow("Angle").ToString()) Then
386
                oAngle = Double.Parse(oRow("Angle").ToString())
387
            End If
388
            '   oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym"
389
            If oSymbol <> "" Then
390
                If oType = "INSTRUMENT" Then
391
                    Dim sTagsuffix As String = ""
392
                    Dim sTagSequenceNo As String = ""
393
                    Dim sMeasuredVariableCode As String = ""
394
                    Dim sInstrumentTypeModifier As String = ""
395
                    If oText <> "" Then
396
                        If oText.Contains(",") Then
397
                            Dim splitstr() As String = oText.Split(",")
398
                            For i = 0 To splitstr.Count - 1
399
                                If i = 0 Then
400
                                    sMeasuredVariableCode = Mid(splitstr(i), 1, 1)
401
                                    sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i)))
402
                                Else
403
                                    If Len(splitstr(i)) = 1 Then
404
                                        sInstrumentTypeModifier = splitstr(i)
405
                                    ElseIf Len(splitstr(i)) = 0 Then
406

    
407
                                    ElseIf Len(splitstr(i)) > 1 Then
408
                                        sInstrumentTypeModifier = Mid(splitstr(i), 1, 1)
409
                                        sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i)))
410
                                    End If
411
                                End If
412
                            Next
413
                        Else
414
                            sMeasuredVariableCode = Mid(oText, 1, 1)
415
                            sTagSequenceNo = Mid(oText, 2, Len(oText))
416
                        End If
417

    
418
                    End If
419

    
420
                    Dim objInstrSym As LMSymbol
421
                    objInstrSym = _Placement.PIDPlaceSymbol(oSymbol, oX, oY, , oAngle)
422
                    Dim objInstr As LMInstrument
423
                    objInstr = datasource.GetInstrument(objInstrSym.ModelItemID)
424

    
425
                    Dim objItem As LMAItem
426
                    objItem = _Placement.PIDCreateItem(oSymbol)
427

    
428
                    'Dim objInstrClass As LMInstrument
429
                    'objInstrClass = datasource.GetInstrument(objItem.Id)
430
                    objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode
431
                    objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier
432
                    objInstr.Attributes("TagSuffix").Value = sTagsuffix
433
                    objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo
434
                    objInstr.Commit()
435

    
436

    
437
                    'objItem = objPlacement.PIDCreateItem(oSymbol)
438
                    'Dim objInstrLoop As LMInstrLoop
439
                    'objInstrLoop = datasource.GetInstrLoop(objItem.Id)
440

    
441
                    'objInstrLoop.Commit()
442

    
443
                ElseIf oType = "GATE VALVE WITH PLUG" Then
444

    
445
                ElseIf oType = "MEDIUM 1D 1TO1" Then
446

    
447
1:
448
                Else
449
                    _Placement.PIDPlaceSymbol(oSymbol, oX, oY, , oAngle)
450

    
451
                End If
452
                iSymbolcount = iSymbolcount + 1
453
            Else
454
            End If
455

    
456
        Next
457
        'For Each oRow As DataRow In oPipe_Dt.Rows
458
        '    Dim oSymbol As String = oRow("Symbol").ToString()
459
        '    Dim oStartPos_x As Double = 0.0
460
        '    Dim oStartPos_y As Double = 0.0
461
        '    Dim oEndPos_x As Double = 0.0
462
        '    Dim oEndPos_y As Double = 0.0
463
        '    If IsNumeric(oRow("start_x").ToString()) Then
464
        '        oStartPos_x = Double.Parse(oRow("start_x").ToString())
465
        '    End If
466
        '    If IsNumeric(oRow("start_y").ToString()) Then
467
        '        oStartPos_y = Double.Parse(oRow("start_y").ToString())
468
        '    End If
469

    
470
        '    If IsNumeric(oRow("end_x").ToString()) Then
471
        '        oEndPos_x = Double.Parse(oRow("end_x").ToString())
472
        '    End If
473
        '    If IsNumeric(oRow("end_y").ToString()) Then
474
        '        oEndPos_y = Double.Parse(oRow("end_y").ToString())
475
        '    End If
476
        '    Dim objConnector As LMConnector
477
        '    Dim objInputs As PlaceRunInputs
478
        '    objInputs = New PlaceRunInputs
479
        '    objInputs.AddPoint(oStartPos_x, oStartPos_y)
480
        '    objInputs.AddPoint(oEndPos_x, oEndPos_y)
481
        '    Dim objItem As LMAItem
482
        '    objItem = objPlacement.PIDCreateItem(oSymbol)
483
        '    objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
484
        '    'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID)
485
        '    'objPipeRun.Attributes("OperFluidCode").Value = "AFS"
486
        '    'objPipeRun.Commit()
487
        '    pipecnt = pipecnt + 1
488

    
489
        'Next
490

    
491

    
492

    
493

    
494
        MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료")
495
    End Function
496

    
497

    
498
    Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterCheck
499
        If e.Node.Checked = True Then
500
            For Each oNode As TreeNode In e.Node.Nodes
501
                oNode.Checked = True
502
            Next
503
        Else
504
            For Each oNode As TreeNode In e.Node.Nodes
505
                oNode.Checked = False
506
            Next
507
        End If
508
    End Sub
509

    
510
    Private Sub LoadDB(ByVal sDBPath As String)
511

    
512
        Try
513
            Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;"
514
            Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring)
515
            conn.Open()
516
            Dim sQuery As String = "Select * from Mapping"
517
            Dim cmd As SQLiteCommand = conn.CreateCommand()
518
            Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn)
519
            Dim oDataSet As DataSet = New DataSet()
520
            adapter.Fill(oDataSet)
521
            _DB = oDataSet.Tables(0)
522
        Catch ex As Exception
523

    
524
        End Try
525

    
526

    
527
    End Sub
528

    
529
    Dim first_start As Boolean = False
530
    Dim folders_path As String
531

    
532
    Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect
533
        If first_start = False Then Exit Sub
534
        Dim pa = e.Node.FullPath.ToString
535

    
536
        printfilesfolders_here(pa, e.Node)
537

    
538
        displayfiles(pa)
539

    
540
        ''be careful ! displayfils comes BEFORE you change // to / in pa !!!
541
        Dim coco As String = ""
542
        coco = pa.ToString
543
        coco = coco.Replace("\\", "\")
544
        Me.Text = coco
545
        folders_path = coco
546
    End Sub
547

    
548
    Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode)
549

    
550
        Dim foldername As String
551
        Dim filename As String
552
        itree.Nodes.Clear()
553
        On Error GoTo eee
554
        For Each foldername In Directory.GetDirectories(path)
555
            On Error GoTo eee
556
            Dim jj = foldername.LastIndexOf("\")
557
            Dim jj1 = foldername.Length - jj
558
            Dim foldr = foldername.Substring((jj + 1), (jj1 - 1))
559
            itree.Nodes.Add(foldr, foldr)
560
        Next ' if you put this next at the end of procedure recursive will be done on first folder only
561
        Exit Sub
562
eee:
563
    End Sub
564

    
565
    Sub displayfiles(ByVal path As String)
566

    
567
        Dim lvItem As ListViewItem
568
        ListView_File.Items.Clear()
569
        Me.ToolStripProgressBar1.Visible = True
570
        ' lvItem = ListView.Items.Add("ListViewItem1")
571
        '   lvItem.SubItems.AddRange(New String() {"Size", "extention", "date modified"})
572

    
573
        Dim filename As String
574
        On Error GoTo wwq
575
        ' Directory.GetFiles(path).Length.
576
        Me.ToolStripProgressBar1.Maximum = Directory.GetFiles(path).Length + 1
577
        Me.ToolStripProgressBar1.Value = 0
578
        For Each filename In Directory.GetFiles(path)
579
            On Error GoTo wwq
580
            Dim jj_ = filename.LastIndexOf("\")
581
            Dim jj1_ = filename.Length - jj_
582
            Dim fil = filename.Substring((jj_ + 1), (jj1_ - 1))
583
            If fil.Contains(".xml") Then
584
                Me.ToolStripProgressBar1.Value = Me.ToolStripProgressBar1.Value + 1
585
                ' ListView.Items.Add(fil, 13) ''old 13 28
586
                lvItem = ListView_File.Items.Add(fil, 13) '2 5 7 work, 0 alos
587
                Dim infoReader As System.IO.FileInfo
588
                infoReader = My.Computer.FileSystem.GetFileInfo(filename)
589
                '    lvItem.SubItems.AddRange(New String() {infoReader.Length.ToString + " Byte", infoReader.Extension.ToString, infoReader.LastWriteTime})
590
                lvItem.SubItems.AddRange(New String() {infoReader.LastWriteTime})
591
                ListView_File.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
592
            End If
593

    
594

    
595
        Next
596
        Me.ToolStripProgressBar1.Visible = False
597
        Exit Sub
598
wwq:
599
        Me.ToolStripProgressBar1.Visible = False
600
        MsgBox(Err.Description)
601
    End Sub
602

    
603
    Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove
604
        first_start = True
605
    End Sub
606

    
607
    Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged
608
        Dim indexes As ListView.SelectedIndexCollection =
609
                         Me.ListView_File.SelectedIndices
610
        Dim index As Integer
611

    
612
        For Each index In indexes
613
            'On Error Resume Next
614
            If folders_path.EndsWith("\") = True Then
615
                Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text)
616
                'On Error Resume Next
617
            Else
618
                Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text)
619
            End If
620

    
621
            Dim infoReader As System.IO.FileInfo
622
            infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text)
623
            Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString
624
        Next
625
    End Sub
626

    
627
    Private Sub Procees()
628
        Dim indexes As ListView.SelectedIndexCollection =
629
                            Me.ListView_File.SelectedIndices
630
        Dim index As Integer
631

    
632
        For Each index In indexes
633
            'On Error Resume Next
634
            If folders_path.EndsWith("\") = True Then
635
                On Error GoTo out
636
                Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text)
637
                On Error GoTo out
638
                'On Error Resume Next
639
            Else
640
                Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text)
641
                On Error GoTo out
642
            End If
643

    
644
            Dim infoReader As System.IO.FileInfo
645
            infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text)
646
            Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString
647
            On Error GoTo out
648
            MsgBox(Me.Status_Main.Items(0).Text + " is processed")
649
            On Error GoTo out
650
        Next
651
        Exit Sub
652
out:
653
        MsgBox(Err.Description)
654
    End Sub
655

    
656
    Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click
657
        If ListView_File.Items.Count > 0 Then
658
            For Each oItem As ListViewItem In ListView_File.Items
659
                If oItem.Checked Then
660
                    Dim sDwgName As String = oItem.Text
661
                    Dim sDwgNo As String = oItem.Text
662
                    Dim oDwgPath As String = ""
663
                    oDwgPath = Tree_XMLFiles.SelectedNode.FullPath + "\" + sDwgName
664
                    Dim sPlantGroupName As String = "Test"
665
                    Dim sTemplateName As String = "Gazprom Project.pid"
666
                    Dim oPipe_Dt As DataTable = LoadPipeInXml(oDwgPath)
667
                    Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath)
668
                    '도면 생성
669
                    If CreateDwg(sDwgName, sPlantGroupName, sTemplateName) Then
670
                        'AutoConverting
671
                        AutoConverting(oPipe_Dt, oSymbol_Dt)
672
                    End If
673
                End If
674

    
675
            Next
676
        End If
677
    End Sub
678
End Class
클립보드 이미지 추가 (최대 크기: 500 MB)