프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ f9b63682

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

1 4f359afa Gyusu
Imports System.IO
2
Imports System.Data.SqlClient
3
Imports System.Data.SQLite
4
Imports Plaice
5
Imports Llama
6 b08338e3 Gyusu
Imports ComUtil.MessageLog.CEventLog
7 e282643f Gyusu
8
Imports System.Threading
9
10 4f359afa Gyusu
Public Class Main
11
12 54b98e09 Gyusu
    'Dim _Mapping_DB As DataTable = New DataTable()
13
    Dim _Mapping_DB As DataSet = New DataSet()
14 171ac39d Gyusu
    Dim _Attribute_DB As DataTable = New DataTable()
15 39d43554 Gyusu
    Dim _PIDSymbol_DB As DataTable = New DataTable()
16 e4000111 Gyusu
    Dim _ResultModeling_DT As DataTable = New DataTable()
17
18
19 4f359afa Gyusu
    Dim _Placement As New Placement
20 e4000111 Gyusu
    Dim _DWG_X = 0.875 '0.695 '1 '
21
    Dim _DWG_Y = 0.617 '0.585 '0.8 '
22 c2c36314 Gyusu
    'Dim _DWG_X = 0.842 '0.695 '1 '
23
    'Dim _DWG_Y = 0.614 '0.585 '0.8 '
24 171ac39d Gyusu
    Dim _IMG_X = 0
25
    Dim _IMG_Y = 0
26
27
    Dim _Unit As String
28 4f359afa Gyusu
29 31d47a80 Gyusu
    'Drawing 전역변수
30
    Dim _objPIDADrawing As Object
31 e282643f Gyusu
    '현재선택한 폴더경로
32
    Dim _selectFolderPath As String
33
34
    Private _Main_trd As Thread
35 54b98e09 Gyusu
    Private _Opc_trd As Thread
36
37
    Private _CompleteConvert As Boolean = False
38 e282643f Gyusu
39 171ac39d Gyusu
    Private _DrawingsList As List(Of Drawing)
40 272662f9 Gyusu
41
42 9e1e7135 Gyusu
    Private _iPipeLineNocnt As Integer
43
    Private _iPipecnt As Integer
44
    Private _iFittingcnt As Integer
45
    Private _iValvecnt As Integer
46
    Private _iInstrumentcnt As Integer
47
    Private _iEquipmentcnt As Integer
48
    Private _iNozzlecnt As Integer
49 e4000111 Gyusu
    Private _iPipintOpccnt As Integer
50 9e1e7135 Gyusu
51 41e4023e Gyusu
    Private _allItem As Integer
52
    Private _Itemcnt As Integer
53 b08338e3 Gyusu
54
    Dim _Gembox As New CGembox()
55 4f359afa Gyusu
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
56 54b98e09 Gyusu
        LoadDB()
57
    End Sub
58 272662f9 Gyusu
59 54b98e09 Gyusu
    Private Sub LoadDB()
60 e282643f Gyusu
        If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then
61
            Dim sDBPath As String = My.Settings.DBPath
62 54b98e09 Gyusu
63
            _Gembox.isLoadFile(My.Settings.SymbolLibrary)
64
            _Mapping_DB = _Gembox.LoadFileFunc()
65 171ac39d Gyusu
            _Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE)
66 39d43554 Gyusu
            _PIDSymbol_DB = Load_DB(sDBPath, _DB_TABLE_SYMBOLNAME)
67 e4000111 Gyusu
            _ResultModeling_DT = ModelingResult_Dt()
68 e282643f Gyusu
        Else
69
            MessageBox.Show("설정값을 먼저 확인해주세요")
70
        End If
71
    End Sub
72 41e4023e Gyusu
73 1229ad76 Gyusu
74 171ac39d Gyusu
    Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String
75
        Dim sValue As String = ""
76 54b98e09 Gyusu
        For Each oDt As DataTable In _Mapping_DB.Tables
77
            If oDt.Rows.Count > 0 Then
78
                Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'")
79
                If oSelectRow.Length = 1 Then
80
                    If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then
81
                        sValue = oSelectRow(0).Item("SYM FILE NAME").ToString()
82
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH Then
83
                        sValue = "\" & oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
84
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_COMPTPYE Then
85
                        sValue = oSelectRow(0).Item("ITEM TYPE").ToString()
86
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_CLASS Then
87
                        sValue = oSelectRow(0).Item("CLASS").ToString()
88
                    Else
89
                        sValue = oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
90
                    End If
91
                End If
92 e282643f Gyusu
            End If
93 54b98e09 Gyusu
        Next
94 171ac39d Gyusu
        Return sValue
95 4f359afa Gyusu
    End Function
96
97 171ac39d Gyusu
    Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String
98
        Dim sSPPIDAttribute As String = ""
99
        If _Attribute_DB.Rows.Count > 0 Then
100
            Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'")
101
            If oSelectRow.Length = 1 Then
102
                sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString()
103
            End If
104
        End If
105
        Return sSPPIDAttribute
106
    End Function
107 e282643f Gyusu
108 6a6d8ab4 Gyusu
109
110 171ac39d Gyusu
    Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing
111 54b98e09 Gyusu
        Try
112
            ''  _TempSymbolDt = Symbol_Dt()
113
            Dim CDrawing As Drawing = New Drawing()
114
            Dim oDt As DataTable = LoadSymbol_DT()
115
            Dim oElement As XElement = XElement.Load(sXmlPath)
116 6a6d8ab4 Gyusu
117 54b98e09 Gyusu
            If oElement IsNot Nothing Then
118
                CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value
119
                CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value
120
                SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y)
121
                CDrawing.Unit = oElement.Element(_XML_UNIT).Value
122 171ac39d Gyusu
123 54b98e09 Gyusu
                Dim oLineno_list As New List(Of Line_no)
124
                Dim oEqp_list As New List(Of Eqp_no)
125 3acffcee Gyusu
                Dim oTrim_Lineno_list As New List(Of Line_no)
126
                oLineno_list = LoadLineNo(oElement, _XML_CATEGORY_LINENO)
127 54b98e09 Gyusu
                For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT)
128
                    Dim CEqp_no As Eqp_no = New Eqp_no()
129
                    Dim oSymbol_Dt As DataTable = Symbol_Dt()
130
                    Dim oAttribute_Dt As DataTable = Attribute_Dt()
131 b08338e3 Gyusu
                    Dim sUid As String = ""
132 54b98e09 Gyusu
                    For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL)
133
                        Try
134 b08338e3 Gyusu
                            Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
135 54b98e09 Gyusu
                            Dim oEleObj As XElement
136
                            Dim sName As String
137
                            Dim sLocation As String
138
                            Dim sSize As String
139
                            Dim sAngle As String
140 b08338e3 Gyusu
                            Dim sOriginalPoint As String = ""
141 e4000111 Gyusu
                            Dim sConnectionPoint As String = ""
142 b08338e3 Gyusu
                            Dim sConnectionUids As String = ""
143
                            Dim sConnArray As String()
144
                            Dim sConnPointArray As String()
145
146 54b98e09 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
147
                            sUid = oEleObj.Value
148
                            oEleObj = oSymbol.Element(_XML_SYMBOL_NAME)
149
                            sName = oEleObj.Value
150
                            oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
151
                            sLocation = oEleObj.Value
152
                            oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
153
                            sSize = oEleObj.Value
154
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
155
                            sAngle = oEleObj.Value
156 e4000111 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
157
                            sConnectionPoint = oEleObj.Value
158 b08338e3 Gyusu
                            sConnPointArray = sConnectionPoint.Split("/")
159
160 f9b63682 Gyusu
                            If sConnPointArray.Length > 4 Then
161
                                MessageBox.Show(sConnPointArray.Length)
162
                            End If
163
                            For i = 0 To sConnPointArray.Length - 1
164
                                If i = 0 Then
165
                                    oAddrow(_XML_SYMBOL_Conn1_Point) = sConnPointArray(i)
166
                                ElseIf i = 1 Then
167
                                    oAddrow(_XML_SYMBOL_Conn2_Point) = sConnPointArray(i)
168
                                ElseIf i = 2 Then
169
                                    oAddrow(_XML_SYMBOL_Conn3_Point) = sConnPointArray(i)
170
                                ElseIf i = 3 Then
171
                                    oAddrow(_XML_SYMBOL_Conn4_Point) = sConnPointArray(i)
172
                                End If
173
                            Next
174 b08338e3 Gyusu
175
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNS)
176
                            sConnectionUids = oEleObj.Value
177
                            sConnArray = sConnectionUids.Split(",")
178 54b98e09 Gyusu
                            Try
179
                                oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
180
                                sOriginalPoint = oEleObj.Value
181
                            Catch ex As Exception
182
                            End Try
183 b08338e3 Gyusu
184
185
186 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_UID) = sUid
187 b08338e3 Gyusu
                            oAddrow(_XML_SYMBOL_LINENOUID) = sUid
188 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_NAME) = sName
189
                            oAddrow(_XML_SYMBOL_LOCATION) = sLocation
190
                            oAddrow(_XML_SYMBOL_SIZE) = sSize
191
                            oAddrow(_XML_SYMBOL_ANGLE) = sAngle
192
                            oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
193
                            oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
194
                            oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
195 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
196 f9b63682 Gyusu
197 b08338e3 Gyusu
                            If sConnArray.Length > 4 Then
198
                                MessageBox.Show(sConnArray.Length)
199
                            End If
200
                            For i = 0 To sConnArray.Length - 1
201
                                If i = 0 Then
202
                                    oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
203
                                ElseIf i = 1 Then
204
                                    oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
205
                                ElseIf i = 2 Then
206
                                    oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
207
                                ElseIf i = 3 Then
208
                                    oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
209
                                End If
210
                            Next
211
212 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
213 54b98e09 Gyusu
                            oSymbol_Dt.Rows.Add(oAddrow)
214
                        Catch ex As Exception
215
216
                        End Try
217 d039e347 Gyusu
                    Next
218 54b98e09 Gyusu
                    For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE)
219
                        Try
220
                            Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
221
                            Dim oEleObj As XElement
222 41e4023e Gyusu
                            Dim sAttUid As String
223 54b98e09 Gyusu
                            Dim sName As String
224
                            Dim sValue As String
225
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
226 41e4023e Gyusu
                            sAttUid = oEleObj.Value
227 54b98e09 Gyusu
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
228
                            sName = oEleObj.Value
229
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
230
                            sValue = oEleObj.Value
231 41e4023e Gyusu
                            oAddrow(_XML_ATTRIBUTE_UID) = sAttUid
232 54b98e09 Gyusu
                            oAddrow(_XML_ATTRIBUTE_NAME) = sName
233
                            oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
234
                            oAttribute_Dt.Rows.Add(oAddrow)
235
                        Catch ex As Exception
236
                        End Try
237
                    Next
238 41e4023e Gyusu
                    CEqp_no.Uid = sUid
239 54b98e09 Gyusu
                    CEqp_no.Dt_Equipment = oSymbol_Dt
240
                    CEqp_no.Dt_Attribute = oAttribute_Dt
241
                    oEqp_list.Add(CEqp_no)
242 4f359afa Gyusu
                Next
243 3acffcee Gyusu
                oTrim_Lineno_list = LoadLineNo(oElement, _XML_CATEGORY_TRIM_LINENO)
244 54b98e09 Gyusu
                CDrawing.Line_nos = oLineno_list
245
                CDrawing.Eqp_nos = oEqp_list
246 3acffcee Gyusu
                CDrawing.TrimLine_nos = oTrim_Lineno_list
247
248 54b98e09 Gyusu
            End If
249
            Return CDrawing
250
        Catch ex As Exception
251
            Return Nothing
252
        End Try
253
254 4f359afa Gyusu
    End Function
255
256
257 3acffcee Gyusu
    Private Function LoadLineNo(ByVal oElement As XElement, ByVal sLineType As String) As List(Of Line_no)
258
259
        Dim oLineno_list As New List(Of Line_no)
260
261
        For Each oLineNo As Object In oElement.Elements(sLineType)
262
263
            Dim CLineNo As Line_no = New Line_no()
264
            Try
265
                CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value
266
                CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value
267
                CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value
268
                CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value
269
                CLineNo.SystemPath = "\Piping\Labels - Piping Segments\Kemya Line Number.sym" 'GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
270
            Catch ex As Exception
271
                'CLineNo.Text = "PipeLineNo"
272
                'CLineNo.Uid = "PipeLineNo"
273
            End Try
274
275
276
            Dim oLine_Dt As DataTable = Line_Dt()
277
            Dim oSymbol_Dt As DataTable = Symbol_Dt()
278
            Dim oAttribute_Dt As DataTable = Attribute_Dt()
279
280
            For Each oRun As Object In oLineNo.Elements(_XML_CATEGORY_RUN)
281
                For Each oLine As Object In oRun.Elements(_XML_CATEGORY_LINE)
282
                    Try
283
                        Dim oAddrow As DataRow = oLine_Dt.NewRow()
284
                        Dim oEleObj As XElement
285
                        Dim sUid As String
286
                        Dim sStartpoint As String
287
                        Dim sEndpoint As String
288 c2c36314 Gyusu
                        Dim sType As String
289 b08338e3 Gyusu
290
                        Dim sConnectionUids As String = ""
291
                        Dim sConnArray As String()
292
293 3acffcee Gyusu
                        oEleObj = oLine.Element(_XML_LINE_UID)
294
                        sUid = oEleObj.Value
295 e4000111 Gyusu
                        If oLine_Dt.Select(_XML_LINE_UID & "='" & sUid & "'").Length = 0 Then
296
                            oEleObj = oLine.Element(_XML_LINE_STARTPOINT)
297
                            sStartpoint = oEleObj.Value
298
                            oEleObj = oLine.Element(_XML_LINE_ENDPOINT)
299
                            sEndpoint = oEleObj.Value
300
                            oEleObj = oLine.Element(_XML_LINE_TYPE)
301
                            sType = oEleObj.Value
302 b08338e3 Gyusu
                            oEleObj = oLine.Element(_XML_LINE_CONNS)
303
                            sConnectionUids = oEleObj.Value
304
                            sConnArray = sConnectionUids.Split(",")
305
                            For i = 0 To sConnArray.Length - 1
306
                                If i = 0 Then
307
                                    oAddrow(_XML_LINE_Conn1_Uid) = sConnArray(i)
308
                                ElseIf i = 1 Then
309
                                    oAddrow(_XML_LINE_Conn2_Uid) = sConnArray(i)
310
                                End If
311
                            Next
312
                            If sConnArray.Length > 2 Then
313
                                MessageBox.Show(sConnArray.Length)
314
                            End If
315 e4000111 Gyusu
                            oAddrow(_XML_LINE_UID) = sUid
316 b08338e3 Gyusu
                            oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
317
                            oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
318 e4000111 Gyusu
                            oAddrow(_XML_LINE_STARTPOINT) = sStartpoint
319
                            oAddrow(_XML_LINE_ENDPOINT) = sEndpoint
320
                            oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
321
                            oAddrow(_XML_LINE_DRAWING_TF) = "FALSE"
322
                            oAddrow(_XML_LINE_TYPE) = sType
323
                            oLine_Dt.Rows.Add(oAddrow)
324
                        Else
325
                        End If
326 3acffcee Gyusu
                    Catch ex As Exception
327
328
                    End Try
329
330
                Next
331
332
                For Each oSymbol As Object In oRun.Elements(_XML_CATEGORY_SYMBOL)
333
                    Try
334
                        Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
335
                        Dim oEleObj As XElement
336
                        Dim sUid As String
337
                        Dim sName As String
338
                        Dim sLocation As String
339
                        Dim sSize As String
340
                        Dim sAngle As String
341
                        Dim sOriginalPoint As String = ""
342 bb2a0c79 Gyusu
                        Dim sConnectionPoint As String = ""
343 b08338e3 Gyusu
                        Dim sConnectionUids As String = ""
344
                        Dim sConnArray As String()
345
346 3acffcee Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
347
                        sUid = oEleObj.Value
348
                        oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT)
349
                        sName = oEleObj.Value
350
                        oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
351
                        sLocation = oEleObj.Value
352
                        oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
353
                        sSize = oEleObj.Value
354
                        oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
355
                        sAngle = oEleObj.Value
356 bb2a0c79 Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
357
                        sConnectionPoint = oEleObj.Value
358 3acffcee Gyusu
                        Try
359
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
360
                            sOriginalPoint = oEleObj.Value
361
                        Catch ex As Exception
362
363
                        End Try
364 b08338e3 Gyusu
                        oEleObj = oSymbol.Element(_XML_LINE_CONNS)
365
                        sConnectionUids = oEleObj.Value
366
                        sConnArray = sConnectionUids.Split(",")
367
                        If sConnArray.Length > 4 Then
368
                            MessageBox.Show(sConnArray.Length)
369
                        End If
370
                        For i = 0 To sConnArray.Length - 1
371
                            If i = 0 Then
372
                                oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
373
                            ElseIf i = 1 Then
374
                                oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
375
                            ElseIf i = 2 Then
376
                                oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
377
                            ElseIf i = 3 Then
378
                                oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
379
                            End If
380
                        Next
381
382 3acffcee Gyusu
383
                        oAddrow(_XML_SYMBOL_UID) = sUid
384 b08338e3 Gyusu
                        oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
385
                        oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
386 3acffcee Gyusu
                        oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME))
387
                        oAddrow(_XML_SYMBOL_LOCATION) = sLocation
388
                        oAddrow(_XML_SYMBOL_SIZE) = sSize
389
                        oAddrow(_XML_SYMBOL_ANGLE) = sAngle
390
                        oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
391
                        oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
392
                        oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_CLASS)
393
                        oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
394 bb2a0c79 Gyusu
                        oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
395 e4000111 Gyusu
                        oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
396 3acffcee Gyusu
                        oSymbol_Dt.Rows.Add(oAddrow)
397
                    Catch ex As Exception
398
399
                    End Try
400
401
                Next
402
403
                For Each oAtrribute As Object In oRun.Elements(_XML_CATEGORY_ATTRIBUTE)
404
                    Try
405
                        Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
406
                        Dim oEleObj As XElement
407
                        Dim sUid As String
408
                        Dim sName As String
409
                        Dim sValue As String
410
411
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
412
                        sUid = oEleObj.Value
413
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
414
                        sName = oEleObj.Value
415
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
416
                        sValue = oEleObj.Value
417
418
                        oAddrow(_XML_ATTRIBUTE_UID) = sUid
419
                        oAddrow(_XML_ATTRIBUTE_NAME) = sName
420
                        oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
421
                        oAttribute_Dt.Rows.Add(oAddrow)
422
                    Catch ex As Exception
423
424
                    End Try
425
426
                Next
427
428
            Next
429
            'Line No Attribute
430
            For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE)
431
                Try
432
                    Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
433
                    Dim oEleObj As XElement
434
                    Dim sUid As String = ""
435
                    Dim sName As String
436
                    Dim sValue As String
437
438
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
439
                    sUid = oEleObj.Value
440
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
441
                    sName = oEleObj.Value
442
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
443
                    sValue = oEleObj.Value
444
                    oAddrow(_XML_ATTRIBUTE_UID) = sUid
445
                    oAddrow(_XML_ATTRIBUTE_NAME) = sName
446
                    oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
447
                    oAttribute_Dt.Rows.Add(oAddrow)
448
                Catch ex As Exception
449
                End Try
450
            Next
451
            CLineNo.Dt_Line = oLine_Dt
452
            CLineNo.Dt_Symbol = oSymbol_Dt
453
            CLineNo.Dt_Attribute = oAttribute_Dt
454
            oLineno_list.Add(CLineNo)
455
        Next
456
        Return oLineno_list
457
    End Function
458
459 4f359afa Gyusu
460 9e1e7135 Gyusu
    Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double)
461 4f359afa Gyusu
462
        Dim calcx As Double = 0
463
        Dim calcy As Double = 0
464
        calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
465 171ac39d Gyusu
        calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
466 4f359afa Gyusu
        dX = calcx
467
        dY = calcy
468
    End Sub
469
470 e1cde8f2 Gyusu
471
    '@brief Convert To SPPID
472
    '@author : Gyusu Park
473
    '@date : 2018-04-10
474
    '@history:
475
476 171ac39d Gyusu
    Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double)
477
478
        Dim opointstr As String() = Split(sLocation, ",")
479
        If (opointstr.Length > 1) Then
480
            If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
481
                dX = opointstr(0)
482
                dY = opointstr(1)
483
            End If
484
        End If
485
486
    End Sub
487
488
    Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable
489 4f359afa Gyusu
490
        Try
491 171ac39d Gyusu
            Dim oDt As New DataTable
492 4f359afa Gyusu
            Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;"
493
            Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring)
494
            conn.Open()
495 171ac39d Gyusu
            Dim sQuery As String = "Select * from " & sTableName
496 4f359afa Gyusu
            Dim cmd As SQLiteCommand = conn.CreateCommand()
497
            Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn)
498
            Dim oDataSet As DataSet = New DataSet()
499
            adapter.Fill(oDataSet)
500 171ac39d Gyusu
            oDt = oDataSet.Tables(0)
501
            Return oDt
502 4f359afa Gyusu
        Catch ex As Exception
503 171ac39d Gyusu
            Return Nothing
504 4f359afa Gyusu
        End Try
505
506
507 171ac39d Gyusu
    End Function
508 4f359afa Gyusu
509 31d47a80 Gyusu
    Private Function LoadAllDrawing() As DataTable
510 e282643f Gyusu
511
512 e1cde8f2 Gyusu
        SetListBoxItems(ListBox_Result, "도면정보 로드중....")
513 b08338e3 Gyusu
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "도면정보 로드중....")
514 31d47a80 Gyusu
        Dim oDt As DataTable = Drawing_Dt()
515 e282643f Gyusu
        Dim sHierarchy As String = My.Settings.Plant_Hierarchy
516
517
518
        Dim files() As String
519
        files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories)
520
        For Each FileName As String In files
521
            Dim sName As String = FileName
522 31d47a80 Gyusu
            Dim oAddRow As DataRow = oDt.NewRow()
523 e282643f Gyusu
            oAddRow("Name") = Path.GetFileNameWithoutExtension(sName)
524
            oAddRow("Path") = FileName
525 31d47a80 Gyusu
            oDt.Rows.Add(oAddRow)
526
        Next
527
        Return oDt
528
    End Function
529
530 e282643f Gyusu
531 272662f9 Gyusu
    Dim _XMLList As ListView = New ListView()
532 e282643f Gyusu
533 272662f9 Gyusu
534
535 e1cde8f2 Gyusu
536 171ac39d Gyusu
537
538
    Private Function CheckOpenDrawing() As Boolean
539
        Try
540
541
            Dim lobjDatasource As Object
542
            _Placement = CreateObject("Plaice.Placement", "")
543
            lobjDatasource = _Placement.PIDDataSource
544
            Return True
545
        Catch ex As Exception
546
            Return False
547
        End Try
548
549
    End Function
550
551
552
    Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click
553
554
        Main_Tab.SelectedIndex = 1
555
        ListBox_Result.Items.Clear()
556 9e1e7135 Gyusu
        ' DataGrid_Result.DataSource = New DataTable()
557 171ac39d Gyusu
        Me.ProgressBar_Status.Visible = True
558
        ProgressBar_Status.Maximum = 100
559
        ProgressBar_Status.Value = 0
560 b08338e3 Gyusu
        InitItemCount()
561 171ac39d Gyusu
        ' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\")
562 54b98e09 Gyusu
        _Main_trd = New Thread(AddressOf ThreadConvert)
563 171ac39d Gyusu
        _Main_trd.IsBackground = True
564
        _Main_trd.Start()
565 54b98e09 Gyusu
        FineOPCForm()
566
    End Sub
567 171ac39d Gyusu
568 54b98e09 Gyusu
    Private Sub FineOPCForm()
569
        _Opc_trd = New Thread(AddressOf ThreadOPCRemove)
570
        _Opc_trd.IsBackground = True
571
        _Opc_trd.Start()
572 171ac39d Gyusu
    End Sub
573 54b98e09 Gyusu
574 31d47a80 Gyusu
575 b08338e3 Gyusu
    Dim _objPIDAutoApp As Object
576 e282643f Gyusu
577 b08338e3 Gyusu
    Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean
578
        Dim bCheckOpen As Boolean = False
579
        '   Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath)
580
        SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....")
581
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, sDwgName & " 도면 Open....")
582
        _objPIDAutoApp = CreateObject("PIDAutomation.Application")
583 e1cde8f2 Gyusu
584 b08338e3 Gyusu
        Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName)
585
        If sPath <> "" Then
586
            Process.Start(sPath)
587
        Else
588
            Return bCheckOpen
589
        End If
590 171ac39d Gyusu
591
            Dim bCheckOpenDrawing As Boolean = False
592
            While (True)
593
                bCheckOpenDrawing = CheckOpenDrawing()
594
                If bCheckOpenDrawing = True Then
595
                    bCheckOpen = True
596
                    Exit While
597
                Else
598
                    Thread.Sleep(2000)
599
                End If
600
            End While
601
602
603
            Return bCheckOpen
604
    End Function
605
606
    Private Function GetDrawing(ByVal sDwgName As String) As Drawing
607
        For Each CDrawing In _DrawingsList
608 559daf6d Gyusu
            If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then
609 171ac39d Gyusu
                Return CDrawing
610
            End If
611
        Next
612
        Return Nothing
613
    End Function
614
615
    Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
616
        For Each CLineNo In CDrawing.Line_nos
617
            If CLineNo.Uid = sLineNoUid Then
618
                Return CLineNo
619
            End If
620
        Next
621
        Return Nothing
622
    End Function
623
624 3acffcee Gyusu
    Private Function GetTrimLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
625
        For Each CLineNo In CDrawing.TrimLine_nos
626
            If CLineNo.Uid = sLineNoUid Then
627
                Return CLineNo
628
            End If
629
        Next
630
        Return Nothing
631
    End Function
632
633
634 bb2a0c79 Gyusu
635
    Private Function GetPipeFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
636 6a6d8ab4 Gyusu
        For Each CLineNo In CDrawing.Line_nos
637
            Dim odt As DataTable = CLineNo.Dt_Line
638
            If odt.Rows.Count > 0 Then
639 bb2a0c79 Gyusu
                If odt.Rows(0)(_XML_LINE_Conn1_Uid).ToString = sSymbolUid Then
640
                    sConnTypeNo = "1"
641
                    Return odt
642
                ElseIf odt.Rows(0)(_XML_LINE_Conn2_Uid).ToString() = sSymbolUid Then
643
                    sConnTypeNo = "2"
644
                    Return odt
645 6a6d8ab4 Gyusu
                End If
646
            End If
647
        Next
648 bb2a0c79 Gyusu
        Return New DataTable
649 6a6d8ab4 Gyusu
    End Function
650
651 bb2a0c79 Gyusu
    Private Function GetSymbolFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
652
        For Each CLineNo In CDrawing.Line_nos
653
            Dim odt As DataTable = CLineNo.Dt_Symbol
654
            If odt.Rows.Count > 0 Then
655
                If odt.Rows(0)(_XML_SYMBOL_Conn1_Uid).ToString = sSymbolUid Then
656
                    sConnTypeNo = "1"
657
                    Return odt
658
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn2_Uid).ToString() = sSymbolUid Then
659
                    sConnTypeNo = "2"
660
                    Return odt
661
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn3_Uid).ToString() = sSymbolUid Then
662
                    sConnTypeNo = "3"
663
                    Return odt
664
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn4_Uid).ToString() = sSymbolUid Then
665
                    sConnTypeNo = "4"
666
                    Return odt
667
                End If
668
            End If
669
        Next
670
        Return New DataTable
671
    End Function
672 6a6d8ab4 Gyusu
673
    Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no
674
        For Each CEqpNo In CDrawing.Eqp_nos
675
            If CEqpNo.Uid = sEqpUid Then
676
                Return CEqpNo
677
            End If
678
        Next
679
        Return Nothing
680
    End Function
681 9e1e7135 Gyusu
    Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean
682 171ac39d Gyusu
        Try
683
            Dim opointstr As String() = Split(sPoint, ",")
684
            If (opointstr.Length > 1) Then
685
                If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
686
                    dX = opointstr(0)
687
                    dY = opointstr(1)
688 9e1e7135 Gyusu
689 171ac39d Gyusu
                Else
690
                    dX = 0
691
                    dY = 0
692
                    Return False
693
                End If
694
            End If
695 e1cde8f2 Gyusu
            Return True
696
        Catch ex As Exception
697
            Return False
698
        End Try
699 171ac39d Gyusu
    End Function
700
701 54b98e09 Gyusu
702
    Dim _DrawLine_Dt As DataTable = DrawLind_Dt()
703
704 e1cde8f2 Gyusu
705 41e4023e Gyusu
    Private Sub AddModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double, ByVal sUid As String)
706 54b98e09 Gyusu
        Dim oAddRow = _DrawLine_Dt.NewRow()
707 41e4023e Gyusu
        oAddRow(_XML_LINE_UID) = sUid
708 54b98e09 Gyusu
        oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x
709
        oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y
710
        oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x
711
        oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y
712
        _DrawLine_Dt.Rows.Add(oAddRow)
713
    End Sub
714
715
716
717 b08338e3 Gyusu
    Private Sub PlaceEquipment(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sEqpName As String)
718 41e4023e Gyusu
        Try
719
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
720
            Dim oAttributeRow() As DataRow
721
            If oAttribute_Dt.Rows.Count > 0 Then
722
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
723
            End If
724
            If oSymbolRow.Length > 0 Then
725
                Dim oDatasource As Object = _Placement.PIDDataSource
726
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
727
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
728
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
729
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
730
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
731
                Dim dAngle As Double = 0.0
732
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
733
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
734
                End If
735
                Dim dLocationX As Double = 0.0
736
                Dim dLocationY As Double = 0.0
737
                Dim dX As Double = 0.0
738
                Dim dY As Double = 0.0
739
740
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
741
                    dX = dLocationX
742
                    dY = dLocationY
743
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
744
                    _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
745 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Equipment.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iEquipmentcnt & " count ")
746
747
                    _iEquipmentcnt = _iEquipmentcnt + 1
748
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Equipment : " & sUid)
749
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Name : " & sEqpName)
750
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
751
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
752
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Count : " & _iEquipmentcnt)
753
754
755 41e4023e Gyusu
                End If
756
            End If
757
        Catch ex As Exception
758
759
        End Try
760
761
762
    End Sub
763 54b98e09 Gyusu
764 b08338e3 Gyusu
    Private Function PlacePipingOPC(ByVal sUid As String, ByVal oOPCRow As DataRow, ByVal oAttribute_Dt As DataTable, ByVal sLineNoText As String) As LMSymbol
765 e4000111 Gyusu
        Try
766
            Dim oAttributeRow() As DataRow
767
            If oAttribute_Dt.Rows.Count > 0 Then
768
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
769
            End If
770
            Dim oDatasource As Object = _Placement.PIDDataSource
771
            Dim sSymbolCompType As String = oOPCRow(_XML_SYMBOL_TYPE).ToString()
772
            Dim sSystemPath As String = oOPCRow(_XML_SYMBOL_SYSTEMPATH).ToString()
773
            Dim sClass As String = oOPCRow(_XML_SYMBOL_CLASS).ToString()
774
            Dim sLocation As String = oOPCRow(_XML_SYMBOL_LOCATION).ToString()
775
            Dim sOriginalPoint As String = oOPCRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
776
            Dim dAngle As Double = 0.0
777
            If IsNumeric(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) Then
778
                dAngle = Double.Parse(oOPCRow(_XML_SYMBOL_ANGLE).ToString())
779
            End If
780
781
            Dim dLocationX As Double = 0.0
782
            Dim dLocationY As Double = 0.0
783
            Dim dX As Double = 0.0
784
            Dim dY As Double = 0.0
785 bb2a0c79 Gyusu
            Dim oLMSymbol As LMSymbol = Nothing
786 e4000111 Gyusu
            If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
787
                dX = dLocationX
788
                dY = dLocationY
789
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
790
                _iPipintOpccnt = _iPipintOpccnt + 1
791 bb2a0c79 Gyusu
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
792 e4000111 Gyusu
                '모델링된 형상은 Drawing True 로 처리
793 bb2a0c79 Gyusu
                oOPCRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
794 b08338e3 Gyusu
                SetListBoxItems(ListBox_Result, "Place Piping OPC.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iPipintOpccnt & " count ")
795
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Piping OPC : " & sUid & "")
796
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
797
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oOPCRow(_XML_SYMBOL_Conn1_Uid).ToString())
798
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oOPCRow(_XML_SYMBOL_Conn2_Uid).ToString())
799
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
800
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
801
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OPC Count : " & _iPipintOpccnt)
802 e4000111 Gyusu
803
                Dim dConn_X1 As Double, dConn_Y1 As Double, dConn_X2 As Double, dConn_Y2 As Double
804
                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dConn_X1, dConn_Y1)
805
                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dConn_X2, dConn_Y2)
806
807 bb2a0c79 Gyusu
                'Dim oAddrow As DataRow = _ResultModeling_DT.NewRow()
808
                'oAddrow(_Modeling_Uid) = sUid
809
                'oAddrow(_Modeling_Location_X) = dLocationX
810
                'oAddrow(_Modeling_Location_Y) = dLocationY
811
                'oAddrow(_Modeling_LineNoUid) = sLineUid
812
                'oAddrow(_Modeling_Type) = sSymbolCompType
813
                'oAddrow(_Modeling_Connection1_X) = dConn_X1
814
                'oAddrow(_Modeling_Connection1_Y) = dConn_Y1
815
                'oAddrow(_Modeling_Connection2_X) = dConn_X2
816
                'oAddrow(_Modeling_Connection2_X) = dConn_Y2
817
                'oAddrow(_Modeling_LMSymbol) = oLMSymbol
818
819
                '_ResultModeling_DT.Rows.Add(oAddrow)
820 e4000111 Gyusu
            End If
821
            _Itemcnt = _Itemcnt + 1
822
            Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
823
            SetProgressbar(ProgressBar_Status, dCalcProgressValue)
824
            Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
825 bb2a0c79 Gyusu
            Return oLMSymbol
826 e4000111 Gyusu
        Catch ex As Exception
827
828
        End Try
829 bb2a0c79 Gyusu
        Return Nothing
830 e4000111 Gyusu
831 bb2a0c79 Gyusu
    End Function
832 e4000111 Gyusu
833
834
    Private Function DrawSymbol(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean
835 171ac39d Gyusu
        Try
836 e282643f Gyusu
837 171ac39d Gyusu
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
838 b08338e3 Gyusu
                Dim oAttributeRow() As DataRow
839 6a6d8ab4 Gyusu
            If oAttribute_Dt.Rows.Count > 0 Then
840 460d6abd Gyusu
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
841 6a6d8ab4 Gyusu
            End If
842
843 171ac39d Gyusu
            If oSymbolRow.Length > 0 Then
844
                Dim oDatasource As Object = _Placement.PIDDataSource
845
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
846
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
847 54b98e09 Gyusu
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
848 171ac39d Gyusu
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
849 9e1e7135 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
850 171ac39d Gyusu
                Dim dAngle As Double = 0.0
851
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
852
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
853
                End If
854
855
                Dim objSymbol As LMSymbol
856 9e1e7135 Gyusu
                Dim dLocationX As Double = 0.0
857
                Dim dLocationY As Double = 0.0
858 171ac39d Gyusu
                Dim dX As Double = 0.0
859
                Dim dY As Double = 0.0
860
861 9e1e7135 Gyusu
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
862
                    dX = dLocationX
863
                    dY = dLocationY
864 54b98e09 Gyusu
                    If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then
865
                        FindConnectionLine(oLine_Dt, dX, dY)
866
                    End If
867
868 9e1e7135 Gyusu
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
869 e4000111 Gyusu
                    Dim oInstrument As LMInstrument
870 54b98e09 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
871 9e1e7135 Gyusu
                        _iInstrumentcnt = _iInstrumentcnt + 1
872 171ac39d Gyusu
                        objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
873 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ")
874 171ac39d Gyusu
                        oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID)
875 6a6d8ab4 Gyusu
                        Try
876
                            If oAttributeRow.Length > 0 Then
877
                                For Each oAttribute In oAttributeRow
878 54b98e09 Gyusu
                                    Try
879
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
880
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
881
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
882
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
883
                                    Catch ex As Exception
884
885
                                    End Try
886
887 6a6d8ab4 Gyusu
                                Next
888
                                oInstrument.Commit()
889
                            End If
890
                        Catch ex As Exception
891
                        End Try
892 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then
893 9e1e7135 Gyusu
                        _iValvecnt = _iValvecnt + 1
894 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
895 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ")
896 171ac39d Gyusu
897 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then
898 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
899 d039e347 Gyusu
                        If sSystemPath.Contains(",") Then
900
901
                            Dim sDuplicatePath As String() = sSystemPath.Split(",")
902
                            Dim sMainSymbol As String = ""
903
                            Dim sSubSymbol As String = ""
904
                            For Each sPath In sDuplicatePath
905
                                If sMainSymbol = "" Then
906
                                    sMainSymbol = sPath.Replace(vbLf, "")
907
                                Else
908
                                    sSubSymbol = sPath.Replace(vbLf, "")
909
                                End If
910
                            Next
911
                            Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
912
                            Dim dConnpos_x As Double = 0.0
913
                            Dim dConnpos_y As Double = 0.0
914
                            _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y)
915
                            '   _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation)
916
                            _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle)
917
918
                        Else
919
                            _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
920
                        End If
921
922
923 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
924 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then
925 d039e347 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
926
                        Dim sDuplicatePath As String() = sSystemPath.Split(",")
927
                        Dim sMainSymbol As String = ""
928
                        Dim sSubSymbol As String = ""
929
                        For Each sPath In sDuplicatePath
930
                            If sMainSymbol = "" Then
931
                                sMainSymbol = sPath.Replace(vbLf, "")
932
                            Else
933
                                sSubSymbol = sPath.Replace(vbLf, "")
934
                            End If
935
                        Next
936
                        Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
937
                        Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate
938
                        Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate
939
                        _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem)
940
941 171ac39d Gyusu
                    Else
942 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
943 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
944 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
945 171ac39d Gyusu
                    End If
946 e4000111 Gyusu
947
                End If
948 41e4023e Gyusu
                _Itemcnt = _Itemcnt + 1
949
                Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
950
                SetProgressbar(ProgressBar_Status, dCalcProgressValue)
951
                Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
952
            End If
953 171ac39d Gyusu
954 54b98e09 Gyusu
        Catch ex As Exception
955
            Return False
956
        End Try
957
    End Function
958
959
960
    Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double)
961
962
        Try
963
            For Each oRow In oLine_Dt.Rows
964
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
965
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
966
                Dim d기준s_x As Double = 0
967
                Dim d기준s_y As Double = 0
968
                Dim d기준e_x As Double = 0
969
                Dim d기준e_y As Double = 0
970
                ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
971
                ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
972
                If dx + 300 > d기준s_x And dx - 300 < d기준s_x And dy + 300 > d기준s_y And dy - 300 < d기준s_y Then
973
                    dx = d기준s_x
974
                    dy = d기준s_y
975
                ElseIf dx + 300 > d기준e_x And dx - 300 < d기준e_x And dy + 300 > d기준e_y And dy - 300 < d기준e_y Then
976
                    dx = d기준e_x
977
                    dy = d기준e_y
978
                End If
979
            Next
980
        Catch ex As Exception
981
        End Try
982
    End Sub
983
984
985
    Dim _라인보정기준값 As Integer = 10
986
987
    Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
988
                                      ByRef dex As Double, ByRef dey As Double)
989
        Try
990
            Dim bCheck라인 As Boolean = False
991
            '일치하는 Line 찾기
992
            For Each oRow In oLine_Dt.Rows
993
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
994
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
995
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
996
                If sBUid <> sUid Then
997
                    Dim d기준s_x As Double = 0
998
                    Dim d기준s_y As Double = 0
999
                    Dim d기준e_x As Double = 0
1000
                    Dim d기준e_y As Double = 0
1001
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1002
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1003
1004
                    If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or
1005
                       (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then
1006
                        bCheck라인 = True
1007
                    End If
1008
                End If
1009
            Next
1010
1011
            If bCheck라인 = False Then
1012
                For Each oRow In oLine_Dt.Rows
1013
                    Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1014
                    Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1015
                    Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1016
                    If sBUid <> sUid Then
1017
                        Dim d기준s_x As Double = 0
1018
                        Dim d기준s_y As Double = 0
1019
                        Dim d기준e_x As Double = 0
1020
                        Dim d기준e_y As Double = 0
1021
                        ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1022
                        ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1023
                        If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then
1024
                            oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy
1025
                            bCheck라인 = True
1026
                            Exit For
1027
                        ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then
1028
                            oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy
1029
                            bCheck라인 = True
1030
                            Exit For
1031
                        ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then
1032
                            oRow(_XML_LINE_STARTPOINT) = dex & "," & dey
1033
                            bCheck라인 = True
1034
                            Exit For
1035
                        ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then
1036
                            oRow(_XML_LINE_ENDPOINT) = dex & "," & dey
1037
                            bCheck라인 = True
1038
                            Exit For
1039
                        End If
1040
1041
                    End If
1042
                Next
1043 171ac39d Gyusu
            End If
1044
1045 54b98e09 Gyusu
            Return bCheck라인
1046 171ac39d Gyusu
        Catch ex As Exception
1047
            Return False
1048
        End Try
1049 54b98e09 Gyusu
1050
1051 171ac39d Gyusu
    End Function
1052
1053 460d6abd Gyusu
    Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1054
                                      ByRef dex As Double, ByRef dey As Double)
1055
        Try
1056
            Dim bCheckOverlap As Boolean = False
1057
            For Each oRow In oLine_Dt.Rows
1058
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1059
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1060
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1061
                If sBUid <> sUid Then
1062
                    Dim d기준s_x As Double = 0
1063
                    Dim d기준s_y As Double = 0
1064
                    Dim d기준e_x As Double = 0
1065
                    Dim d기준e_y As Double = 0
1066
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1067
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1068 54b98e09 Gyusu
                    If (d기준s_x <= dsx And d기준e_x >= dex And
1069
                        d기준s_y <= dsy And d기준e_y >= dey) Then
1070 460d6abd Gyusu
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1071
                        If dsy - d기준s_y > d기준e_y - dey Then
1072
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1073
                            If dResultCalc < 10 Then
1074
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1075
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1076
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1077
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1078
                                If dCalcStartY = 0 Then
1079
                                    dey = d기준e_y
1080
                                Else
1081
                                    dey = dCalcStartY
1082
                                End If
1083
                            End If
1084
                        Else
1085 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1086
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1087 460d6abd Gyusu
                            If dResultCalc < 10 Then
1088
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1089
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1090
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1091
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1092
                                If dCalcStartY = 0 Then
1093
                                    dsy = d기준s_y
1094
                                Else
1095
                                    dsy = dCalcStartY
1096
                                End If
1097
                            End If
1098
                        End If
1099
                        bCheckOverlap = True
1100
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1101
                            d기준s_y <= dey And d기준e_y >= dsy Then
1102
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1103
                        If dey - d기준s_y > d기준e_y - dsy Then
1104
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1105
                            If dResultCalc < 10 Then
1106
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1107
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1108
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1109
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1110
                                If dCalcStartY = 0 Then
1111 abb01e6c Gyusu
                                    dsy = d기준e_y
1112 460d6abd Gyusu
                                Else
1113 abb01e6c Gyusu
                                    dsy = dCalcStartY
1114 460d6abd Gyusu
                                End If
1115
1116
                            End If
1117
                            '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1118
                        Else
1119 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100
1120
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1121 460d6abd Gyusu
                            If dResultCalc < 10 Then
1122
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1123
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1124
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1125
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1126
                                If dCalcStartY = 0 Then
1127 abb01e6c Gyusu
                                    dey = d기준e_y
1128 460d6abd Gyusu
                                Else
1129 abb01e6c Gyusu
                                    dey = dCalcStartY
1130 460d6abd Gyusu
                                End If
1131
                            End If
1132
                        End If
1133
                        bCheckOverlap = True
1134
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1135
                            d기준s_y <= dey And d기준e_y >= dsy Then
1136
1137
                        If dsx - d기준s_x > d기준e_x - dex Then
1138
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1139
                            If dResultCalc < 10 Then
1140
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1141
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1142
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1143
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1144
                                If dCalcStartX = 0 Then
1145
                                    dex = d기준e_x
1146
                                Else
1147
                                    dex = dCalcStartX
1148
                                End If
1149
                            End If
1150
                        Else
1151 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1152
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1153 460d6abd Gyusu
                            If dResultCalc < 10 Then
1154
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1155
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1156
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1157
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1158
                                If dCalcStartX = 0 Then
1159
                                    dsx = d기준s_x
1160
                                Else
1161
                                    dsx = dCalcStartX
1162
                                End If
1163
                            End If
1164
                        End If
1165
                        bCheckOverlap = True
1166
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1167
                            d기준s_y <= dey And d기준e_y >= dsy Then
1168
1169
                        If dex - d기준s_x > d기준e_x - dsx Then
1170
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1171
                            If dResultCalc < 10 Then
1172
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1173
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1174
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1175
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1176
                                If dCalcStartX = 0 Then
1177 abb01e6c Gyusu
                                    dsx = d기준e_x
1178 460d6abd Gyusu
                                Else
1179 abb01e6c Gyusu
                                    dsx = dCalcStartX
1180 460d6abd Gyusu
                                End If
1181
                            End If
1182
                        Else
1183 abb01e6c Gyusu
                            ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1184
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1185 460d6abd Gyusu
                            If dResultCalc < 10 Then
1186
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1187
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1188
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1189
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1190
                                If dCalcStartX = 0 Then
1191 abb01e6c Gyusu
                                    dex = d기준s_x
1192 460d6abd Gyusu
                                Else
1193 abb01e6c Gyusu
                                    dex = dCalcStartX
1194 460d6abd Gyusu
                                End If
1195
                            End If
1196
1197
                        End If
1198
                        bCheckOverlap = True
1199
                    End If
1200
                End If
1201
            Next
1202 3acffcee Gyusu
1203 460d6abd Gyusu
            Return bCheckOverlap
1204
        Catch ex As Exception
1205
            Return False
1206
        End Try
1207
    End Function
1208
1209
    Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double,
1210
                                      ByRef dEndX As Double, ByRef dEndY As Double)
1211
        Try
1212 54b98e09 Gyusu
            Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기
1213 460d6abd Gyusu
            If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
1214 54b98e09 Gyusu
                Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1
1215 460d6abd Gyusu
                If dStartX > dEndX Then
1216
                    dStartX = dStartX + dCalc_x
1217
                    dEndX = dEndX - dCalc_x
1218
                Else
1219
                    dEndX = dEndX + dCalc_x
1220
                    dStartX = dStartX - dCalc_x
1221
                End If
1222
            Else
1223 54b98e09 Gyusu
                Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1
1224 460d6abd Gyusu
                If dStartY > dEndY Then
1225
                    dStartY = dStartY + dCalc_y
1226
                    dEndY = dEndY - dCalc_y
1227
                Else
1228
                    dEndY = dEndY + dCalc_y
1229
                    dStartY = dStartY - dCalc_y
1230
                End If
1231
            End If
1232
1233
        Catch ex As Exception
1234
1235
        End Try
1236
1237
1238
    End Sub
1239
1240 3acffcee Gyusu
    Private Function DrawLineNo(ByVal oPipeRun_Dt As DataTable, ByVal CLine_No As Line_no) As Boolean
1241 171ac39d Gyusu
        Try
1242
            Dim oDatasource As Object = _Placement.PIDDataSource
1243
            Dim sLocation = CLine_No.Location
1244 9e1e7135 Gyusu
            Dim dLocationx As Double = 0.0
1245
            Dim dLocationy As Double = 0.0
1246
1247 171ac39d Gyusu
            Dim dX As Double = 0.0
1248
            Dim dY As Double = 0.0
1249 9e1e7135 Gyusu
            If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then
1250
                dX = dLocationx
1251
                dY = dLocationy
1252 3acffcee Gyusu
1253
                For Each oRow In oPipeRun_Dt.Rows
1254
                    Dim dStartx As Double = Double.Parse(oRow("startx").ToString())
1255
                    Dim dStarty As Double = Double.Parse(oRow("starty").ToString())
1256
                    Dim dEndx As Double = Double.Parse(oRow("endx").ToString())
1257
                    Dim dEndy As Double = Double.Parse(oRow("endy").ToString())
1258
1259
                    Dim dStartSum As Double = Math.Abs(dStartx - dLocationx) + Math.Abs(dStarty - dLocationy)
1260
                    Dim dEndSum As Double = Math.Abs(dEndx - dLocationx) + Math.Abs(dEndy - dLocationy)
1261
                    If dStartSum > dEndSum Then
1262
                        oRow("value") = dEndSum
1263
                    Else
1264
                        oRow("value") = dStartSum
1265 171ac39d Gyusu
                    End If
1266 3acffcee Gyusu
1267 171ac39d Gyusu
                Next
1268 3acffcee Gyusu
                Dim dataView As New DataView(oPipeRun_Dt)
1269
                dataView.Sort = " value asc"
1270
                Dim oDt As DataTable = dataView.ToTable()
1271
                If oDt.Rows.Count > 0 Then
1272
                    Try
1273
                        Dim oPiperun As LMPipeRun = CType(oDt.Rows(0)("Piperun"), LMPipeRun)
1274
                        ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1275
                        Dim dLineNoLocation(2) As Double
1276
                        dLineNoLocation(1) = dX
1277
                        dLineNoLocation(2) = dY
1278
                        'Label
1279
                        Dim sSystemPath As String = CLine_No.SystemPath
1280
                        Dim dAngle As Double = CLine_No.Angle
1281
                        Dim labelpersist As LMLabelPersist
1282
1283
                        For Each representation In oPiperun.Representations
1284
                            If representation.RepresentationType = "Connector" Then
1285
                                labelpersist = _Placement.PIDPlaceLabel(sSystemPath,
1286
                                dLineNoLocation,, dAngle, LabeledItem:=representation)
1287
                                _iPipeLineNocnt = _iPipeLineNocnt + 1
1288 b08338e3 Gyusu
                                SetListBoxItems(ListBox_Result, "Place PipeLineNo Label.." & CLine_No.Uid & " (" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ")
1289
1290
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & CLine_No.Uid & "")
1291
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & CLine_No.Text)
1292
                                'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1293
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Origina lPoint : " & dLocationx & "," & dLocationy)
1294
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "PipeLineNo Count : " & _iPipeLineNocnt)
1295 3acffcee Gyusu
                            End If
1296
                        Next
1297
                    Catch ex As Exception
1298
1299
                    End Try
1300
1301
1302
                End If
1303
1304
1305
1306 171ac39d Gyusu
                Return True
1307
            Else
1308
                Return False
1309
            End If
1310
1311
        Catch ex As Exception
1312
            Return False
1313
        End Try
1314
    End Function
1315
1316 9e1e7135 Gyusu
1317
    Private Sub InitItemCount()
1318
        _iPipeLineNocnt = 0
1319 b08338e3 Gyusu
        _iPipecnt = 1
1320
        _iFittingcnt = 1
1321 9e1e7135 Gyusu
        _iValvecnt = 0
1322
        _iInstrumentcnt = 0
1323
        _iEquipmentcnt = 0
1324 3acffcee Gyusu
        _iNozzlecnt = 1
1325 e4000111 Gyusu
        _iPipintOpccnt = 0
1326 3acffcee Gyusu
1327 9e1e7135 Gyusu
    End Sub
1328 171ac39d Gyusu
1329 41e4023e Gyusu
    Private Function GetAllCheckNodeCount() As Integer
1330
        _allItem = 0
1331
        For i = 0 To Tree_Result.Nodes.Count - 1
1332
            For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1
1333
                For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1
1334
                    For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1
1335
                        If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then
1336
                            _allItem = _allItem + 1
1337
                        End If
1338
                    Next
1339
                Next
1340
            Next
1341
        Next
1342
        Return _allItem
1343
    End Function
1344 54b98e09 Gyusu
1345
1346 e4000111 Gyusu
    ''' <summary>
1347
    ''' Equipment 모델링
1348
    ''' </summary>
1349
    Private Sub EquipmentModeling(ByVal oDwg_Dt As DataTable)
1350
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1351
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1352
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
1353
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
1354
                If CDrawing IsNot Nothing Then
1355
                    If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then
1356 b08338e3 Gyusu
1357 e4000111 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
1358
                            Dim iItemcnt As Integer = 0
1359
                            Dim sNodeUid As String = oNode.Name
1360
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
1361
                            '1.Equipment
1362
                            '2.Piping OPC
1363
                            '3.OPC 시작되는 Line
1364
                            'Equipment 생성
1365
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
1366
                            If CEqpNo IsNot Nothing Then
1367
                                Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment
1368
                                Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute
1369
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1370
                                    If oSymbolNode.Checked Then
1371
                                        Dim sUid As String = oSymbolNode.Name
1372 b08338e3 Gyusu
                                        PlaceEquipment(sUid, oSymbol_Dt, oAttribute_Dt, CEqpNo.Text)
1373 e4000111 Gyusu
                                    End If
1374
                                Next
1375
                            End If
1376
                        Next
1377
                    End If
1378
                End If
1379
            Next
1380
        Next
1381
    End Sub
1382
1383 bb2a0c79 Gyusu
    Private Sub ManualCheckNode(ByRef oDt As DataTable)
1384
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1385
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1386
                For Each oNode As TreeNode In oDwgNode.Nodes
1387
                    For Each oSymbolNode As TreeNode In oNode.Nodes
1388
                        Dim sUid As String = oSymbolNode.Name
1389 b08338e3 Gyusu
                        Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid &
1390
                                                               "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'")
1391 bb2a0c79 Gyusu
                        If oSelectRows.Length = 1 Then
1392
                            If oSymbolNode.Checked Then
1393
                                oSelectRows(0)(_XML_SYMBOL_Check) = "TRUE"
1394
                            Else
1395
                                oSelectRows(0)(_XML_SYMBOL_Check) = "FALSE"
1396
                            End If
1397
                        End If
1398
1399
                    Next
1400
                Next
1401
            Next
1402
        Next
1403
1404
    End Sub
1405 b08338e3 Gyusu
1406 f9b63682 Gyusu
    Private Function FinalSymbolModeling(ByVal oCurrentSymbolRow As DataRow, ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
1407
                                  ByVal oAttribute_Dt As DataTable) As String
1408
        Dim sReturnUid As String = ""
1409
        Dim sOriginalPoint As String = ""
1410
        Dim dOriginal_x As Double = 0.0
1411
        Dim dOriginal_y As Double = 0.0
1412
1413
        Dim dConn1_x As Double = 0.0
1414
        Dim dConn1_y As Double = 0.0
1415
        Dim dConn2_x As Double = 0.0
1416
        Dim dConn2_y As Double = 0.0
1417
        Dim dConn3_x As Double = 0.0
1418
        Dim dConn3_y As Double = 0.0
1419
        Dim dConn4_x As Double = 0.0
1420
        Dim dConn4_y As Double = 0.0
1421
1422
        Dim sUid As String = oCurrentSymbolRow(_XML_SYMBOL_UID)
1423
        Dim sSystemPath As String = oCurrentSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1424
        Dim dAngle As Double = oCurrentSymbolRow(_XML_SYMBOL_ANGLE)
1425
        Dim sLineNoText As String = oCurrentSymbolRow(_XML_LINENO_TEXT)
1426
        Dim sLineNoUid As String = oCurrentSymbolRow(_XML_LINE_LINENOUID).ToString()
1427
        sOriginalPoint = oCurrentSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1428
1429
        ConvertPointBystring(sOriginalPoint, dOriginal_x, dOriginal_y)
1430
        ConvertPointByImage(dOriginal_x, dOriginal_y, _IMG_X, _IMG_Y)
1431
1432
        'Connection 정보 체크, 모델링 되어 있는지 유무
1433
        '양 커넥션의 모델링 유무를 체크한다.
1434
        Dim sConn1Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString()
1435
        Dim sConn2Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString()
1436
        Dim sConn3Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString()
1437
        Dim sConn4Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString()
1438
1439
        Dim sConn1Type As String = ""
1440
        Dim sConn2Type As String = ""
1441
        Dim sConn3Type As String = ""
1442
        Dim sConn4Type As String = ""
1443
1444
        Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
1445
        If oConn1Rows.Length = 0 Then
1446
            oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
1447
            If oConn1Rows.Length = 1 Then
1448
                sConn1Type = "Line"
1449 b08338e3 Gyusu
            End If
1450 f9b63682 Gyusu
        Else
1451
            sConn1Type = "Symbol"
1452
        End If
1453 b08338e3 Gyusu
1454 f9b63682 Gyusu
        Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
1455
        If oConn2Rows.Length = 0 Then
1456
            oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
1457
            If oConn2Rows.Length = 1 Then
1458
                sConn2Type = "Line"
1459 b08338e3 Gyusu
            End If
1460 f9b63682 Gyusu
        Else
1461
            sConn2Type = "Symbol"
1462
        End If
1463 b08338e3 Gyusu
1464 f9b63682 Gyusu
        Dim oConn3Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn3Uid & "'")
1465
        If oConn3Rows.Length = 0 Then
1466
            oConn3Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn3Uid & "'")
1467
            If oConn3Rows.Length = 1 Then
1468
                sConn3Type = "Line"
1469 b08338e3 Gyusu
            End If
1470 f9b63682 Gyusu
        Else
1471
            sConn3Type = "Symbol"
1472
        End If
1473 b08338e3 Gyusu
1474 f9b63682 Gyusu
        Dim oConn4Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn4Uid & "'")
1475
        If oConn4Rows.Length = 0 Then
1476
            oConn4Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn4Uid & "'")
1477
            If oConn4Rows.Length = 1 Then
1478
                sConn4Type = "Line"
1479 b08338e3 Gyusu
            End If
1480 f9b63682 Gyusu
        Else
1481
            sConn4Type = "Symbol"
1482
        End If
1483 b08338e3 Gyusu
1484 f9b63682 Gyusu
        Dim oStartLMConnector As LMConnector = Nothing
1485
        Dim oEndLMConnector As LMConnector = Nothing
1486
        Dim objInputs As PlaceRunInputs
1487
        objInputs = New PlaceRunInputs
1488
        Dim iModelingType As Integer = 0
1489 b08338e3 Gyusu
1490
1491 f9b63682 Gyusu
        If sConn1Type = "Line" Then
1492
            Dim sStartpoint As String = oConn1Rows(0)(_XML_LINE_STARTPOINT).ToString()
1493
            ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1494
            ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1495
        ElseIf sConn1Type = "Symbol" Then
1496
            ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1497
        End If
1498 b08338e3 Gyusu
1499 f9b63682 Gyusu
        If sConn2Type = "Line" Then
1500
            Dim sEndpoint As String = oConn2Rows(0)(_XML_LINE_ENDPOINT).ToString()
1501
            ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1502
            ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1503
        ElseIf sConn2Type = "Symbol" Then
1504
            ConvertPoint(oConn2Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1505
        End If
1506 b08338e3 Gyusu
1507 f9b63682 Gyusu
        If sConn3Type = "Line" Then
1508
            Dim sStartpoint As String = oConn3Rows(0)(_XML_LINE_STARTPOINT).ToString()
1509
            ConvertPointBystring(sStartpoint, dConn3_x, dConn3_y)
1510
            ConvertPointByImage(dConn3_x, dConn3_y, _IMG_X, _IMG_Y)
1511
        ElseIf sConn3Type = "Symbol" Then
1512
            ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1513
        End If
1514 b08338e3 Gyusu
1515 f9b63682 Gyusu
        If sConn4Type = "Line" Then
1516
            Dim sEndpoint As String = oConn4Rows(0)(_XML_LINE_ENDPOINT).ToString()
1517
            ConvertPointBystring(sEndpoint, dConn4_x, dConn4_y)
1518
            ConvertPointByImage(dConn4_x, dConn4_y, _IMG_X, _IMG_Y)
1519
        ElseIf sConn4Type = "Symbol" Then
1520
            ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1521
        End If
1522 b08338e3 Gyusu
1523
1524
1525 f9b63682 Gyusu
        'If sConn1Type = "Line" And sConn2Type = "Line" Then
1526
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1527
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1528
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1529
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1530
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1531
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1532
1533
        'ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
1534
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1535
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1536
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1537
1538
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1539
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
1540
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1541
1542
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1543
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1544
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1545
1546
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
1547
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1548
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1549
        'ElseIf sConn1Type = "Line" And sConn2Type = "" Then
1550
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1551
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1552
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1553
1554
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
1555
        '    iModelingType = 6
1556
        'ElseIf sConn1Type = "" And sConn2Type = "Line" Then
1557
        '    iModelingType = 7
1558
        'ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
1559
        '    iModelingType = 8
1560
        'ElseIf sConn3Type = "Line" And sConn4Type = "Line" Then
1561
        '        iModelingType = 4
1562
        '    ElseIf sConn3Type = "Line" And sConn4Type = "Symbol" Then
1563
        '        iModelingType = 4
1564
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Line" Then
1565
        '        iModelingType = 4
1566
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Symbol" Then
1567
        '        iModelingType = 4
1568
        '    ElseIf sConn3Type = "Line" And sConn4Type = "" Then
1569
        '        iModelingType = 5
1570
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "" Then
1571
        '        iModelingType = 5
1572
        '    ElseIf sConn3Type = "" And sConn4Type = "Line" Then
1573
        '        iModelingType = 6
1574
        '    ElseIf sConn3Type = "" And sConn4Type = "Symbol" Then
1575
        '        iModelingType = 6
1576
        '    Else
1577
        '        iModelingType = 7
1578
        '    End If
1579
1580
        'If iModelingType = 1 Then
1581
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1582
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1583
        '    ElseIf iModelingType = 2 Then
1584
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1585
        '    ElseIf iModelingType = 3 Then
1586
        '        ConvertPoint(oConn2Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1587
        '    ElseIf iModelingType = 4 Then
1588
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1589
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1590
        '    ElseIf iModelingType = 5 Then
1591
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1592
        '    ElseIf iModelingType = 6 Then
1593
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1594
        '    End If
1595
        Dim sFirstUid As String = ""
1596
        Dim sSecondUid As String = ""
1597
        Dim oLMSymbol As LMSymbol = Nothing
1598
        If sConn1Type <> "" And sConn2Type <> "" Then
1599
            CheckConnectionLine(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
1600
            CheckConnectionLine(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
1601
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1602
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1603
            dOriginal_x = dConn2_x
1604
            dOriginal_y = dConn2_y
1605
        ElseIf sConn1Type <> "" And sConn2Type = "" Then
1606
            CheckConnectionLine(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
1607
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1608
            dOriginal_x = dConn1_x
1609
            dOriginal_y = dConn1_y
1610
        ElseIf sConn1Type = "" And sConn2Type <> "" Then
1611
            CheckConnectionLine(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
1612
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1613
            dOriginal_x = dConn2_x
1614
            dOriginal_y = dConn2_y
1615
        ElseIf sConn3Type <> "" And sConn4Type <> "" Then
1616
            CheckConnectionLine(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
1617
            CheckConnectionLine(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
1618
            sFirstUid = CheckExistModeling(oConn3Rows(0))
1619
            sSecondUid = CheckExistModeling(oConn4Rows(0))
1620
            dOriginal_x = dConn4_x
1621
            dOriginal_y = dConn4_y
1622
        ElseIf sConn3Type <> "" And sConn4Type = "" Then
1623
            CheckConnectionLine(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
1624
            sFirstUid = CheckExistModeling(oConn3Rows(0))
1625
            dOriginal_x = dConn3_x
1626
            dOriginal_y = dConn3_y
1627
        ElseIf sConn3Type = "" And sConn4Type <> "" Then
1628
            CheckConnectionLine(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
1629
            sSecondUid = CheckExistModeling(oConn4Rows(0))
1630
            dOriginal_x = dConn4_x
1631
            dOriginal_y = dConn4_y
1632
        Else
1633
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
1634
        End If
1635 b08338e3 Gyusu
1636 f9b63682 Gyusu
        If sFirstUid <> "" And sSecondUid <> "" Then
1637
            sReturnUid = sSecondUid
1638
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1639
            sReturnUid = sFirstUid
1640
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1641
            sReturnUid = sFirstUid
1642
        Else
1643
            sReturnUid = ""
1644
        End If
1645 b08338e3 Gyusu
1646
1647 f9b63682 Gyusu
        If oStartLMConnector IsNot Nothing And oEndLMConnector IsNot Nothing Then
1648
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle, ExistingItem:=oStartLMConnector.AsLMAItem,
1649
                        TargetItem:=oEndLMConnector.AsLMAItem)
1650
        ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
1651
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
1652
                        TargetItem:=oStartLMConnector.AsLMAItem)
1653
        ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
1654
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
1655
            TargetItem:=oEndLMConnector.AsLMAItem)
1656
        Else
1657
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
1658 b08338e3 Gyusu
        End If
1659
1660 f9b63682 Gyusu
        SetListBoxItems(ListBox_Result, "Place Fitting.." & sUid & " (" & dOriginal_x & "," & dOriginal_y & ")..." & _iFittingcnt & " count ")
1661
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sUid)
1662
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1663
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "ModelingType : " & iModelingType)
1664
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn1_Point : " & dConn1_x & "," & dConn1_y)
1665
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn2_Point : " & dConn2_x & "," & dConn2_y)
1666
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn3_Point : " & dConn3_x & "," & dConn3_y)
1667
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn4_Point : " & dConn4_x & "," & dConn4_y)
1668
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
1669
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
1670
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
1671
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
1672
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1673
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dOriginal_x & "," & dOriginal_y)
1674
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
1675
        _iFittingcnt = _iFittingcnt + 1
1676
        oCurrentSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
1677
1678
        Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
1679
        If oAttributeRow.Length > 0 Then
1680
            For Each oAttribute In oAttributeRow
1681
                Try
1682
                    Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1683
                    Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1684
                    If sPIDValue.Contains("'") Then
1685
                        sPIDValue = sPIDValue.Replace("'", """")
1686
                    End If
1687
                    Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1688
                    oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
1689
                Catch ex As Exception
1690
                End Try
1691
            Next
1692
        End If
1693 b08338e3 Gyusu
1694 f9b63682 Gyusu
        Return sReturnUid
1695 b08338e3 Gyusu
1696
1697 f9b63682 Gyusu
        '현재 Uid 모델링
1698
    End Function
1699 b08338e3 Gyusu
1700 f9b63682 Gyusu
    Private Function CheckExistModeling(ByVal oRow As DataRow) As String
1701
        If oRow(_XML_LINE_DRAWING_TF).ToString() = "FALSE" And oRow(_XML_LINE_Check).ToString() = "TRUE" Then
1702
            Return oRow(_XML_LINE_UID).ToString()
1703
        End If
1704
        Return String.Empty
1705
    End Function
1706 b08338e3 Gyusu
1707
1708 f9b63682 Gyusu
    Private Sub ConvertPoint(ByVal sOriginalPoint As String, ByRef dConn1_x As Double, ByRef dConn1_y As Double)
1709
        ConvertPointBystring(sOriginalPoint, dConn1_x, dConn1_y)
1710
        ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1711
    End Sub
1712 b08338e3 Gyusu
1713 f9b63682 Gyusu
    Private Function FinalLineModeling(ByVal oCurrentLineRow As DataRow,
1714
                              ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
1715
                                  ByVal oAttribute_Dt As DataTable) As String
1716
        Dim sReturnUid As String = ""
1717
        '현재 Uid  모델링 여부 체크
1718
        Dim sStartpoint As String = ""
1719
        Dim sEndpoint As String = ""
1720
        Dim dOriginalStart_x As Double = 0.0
1721
        Dim dOriginalStart_y As Double = 0.0
1722
        Dim dOriginalEnd_x As Double = 0.0
1723
        Dim dOriginalEnd_y As Double = 0.0
1724
        Dim objItem As LMAItem
1725
1726
        Dim sUid As String = oCurrentLineRow(_XML_LINE_UID).ToString()
1727
        Dim sLineType As String = oCurrentLineRow(_XML_LINE_TYPE).ToString()
1728
        Dim sSystemPath As String = GetPipeType(sLineType)
1729
        Dim sLineNoText As String = oCurrentLineRow(_XML_LINENO_TEXT).ToString()
1730
        Dim sLineNoUid As String = oCurrentLineRow(_XML_LINE_LINENOUID).ToString()
1731
        sStartpoint = oCurrentLineRow(_XML_LINE_STARTPOINT).ToString()
1732
        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
1733
        ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
1734
        sEndpoint = oCurrentLineRow(_XML_LINE_ENDPOINT).ToString()
1735
        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
1736
        ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
1737
1738
        'Connection 정보 체크, 모델링 되어 있는지 유무
1739
        '양 커넥션의 모델링 유무를 체크한다.
1740
        Dim sConn1Uid As String = oCurrentLineRow(_XML_LINE_Conn1_Uid).ToString()
1741
        Dim sConn2Uid As String = oCurrentLineRow(_XML_LINE_Conn2_Uid).ToString()
1742
        Dim sConn1Type As String = ""
1743
        Dim sConn2Type As String = ""
1744
1745
        Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
1746
        If oConn1Rows.Length = 0 Then
1747
            oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
1748 b08338e3 Gyusu
            If oConn1Rows.Length = 1 Then
1749 f9b63682 Gyusu
                sConn1Type = "Line"
1750 b08338e3 Gyusu
            End If
1751 f9b63682 Gyusu
        Else
1752
            sConn1Type = "Symbol"
1753
        End If
1754
        Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
1755
        If oConn2Rows.Length = 0 Then
1756
            oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
1757 b08338e3 Gyusu
            If oConn2Rows.Length = 1 Then
1758 f9b63682 Gyusu
                sConn2Type = "Line"
1759 b08338e3 Gyusu
            End If
1760 f9b63682 Gyusu
        Else
1761
            sConn2Type = "Symbol"
1762
        End If
1763
        Dim sConn1LineNo As String = ""
1764
        If oConn1Rows.Length = 1 Then
1765 b08338e3 Gyusu
1766 f9b63682 Gyusu
        End If
1767
        Dim sConn2LineNo As String = ""
1768
        If oConn2Rows.Length = 1 Then
1769 b08338e3 Gyusu
1770 f9b63682 Gyusu
        End If
1771
        Dim oStartLMConnector As LMConnector = Nothing
1772
        Dim oEndLMConnector As LMConnector = Nothing
1773
        Dim objInputs As PlaceRunInputs
1774
        objInputs = New PlaceRunInputs
1775
        Dim iModelingType As Integer = 0
1776
        If sConn1Type = "Line" And sConn2Type = "Line" Then
1777
            iModelingType = 1
1778
        ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
1779
            iModelingType = 1
1780
        ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
1781
            iModelingType = 1
1782
        ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
1783
            iModelingType = 1
1784
        ElseIf sConn1Type = "Line" And sConn2Type = "" Then
1785
            iModelingType = 2
1786
        ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
1787
            iModelingType = 2
1788
        ElseIf sConn1Type = "" And sConn2Type = "Line" Then
1789
            iModelingType = 3
1790
        ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
1791
            iModelingType = 3
1792
        Else
1793
            iModelingType = 4
1794
        End If
1795 b08338e3 Gyusu
1796 f9b63682 Gyusu
        If iModelingType = 1 Then
1797
            CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
1798
            CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
1799
            'objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
1800
            'objInputs.AddConnectorTarget(oEndLMConnector, dOriginalEnd_x, dOriginalEnd_y)
1801
        ElseIf iModelingType = "2" Then
1802
            CheckConnectionLine(oConn2Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
1803
            'objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
1804
            'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
1805
        ElseIf iModelingType = "3" Then
1806
            CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oStartLMConnector)
1807
            'objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
1808
            'objInputs.AddConnectorTarget(oEndLMConnector, dOriginalEnd_x, dOriginalEnd_y)
1809
        Else
1810
            'objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
1811
            'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
1812
        End If
1813 b08338e3 Gyusu
1814 f9b63682 Gyusu
        Dim sFirstUid As String = ""
1815
        Dim sSecondUid As String = ""
1816
1817
        If oStartLMConnector Is Nothing And oEndLMConnector Is Nothing Then
1818
            objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
1819
            objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
1820
            'sFirstUid = CheckExistModeling(oConn1Rows(0))
1821
            'sSecondUid = CheckExistModeling(oConn2Rows(0))
1822
        ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
1823
            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
1824
            objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
1825
            '    sSecondUid = CheckExistModeling(oConn2Rows(0))
1826
        ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
1827
            objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
1828
            '   objInputs.AddConnectorTarget(oEndLMConnector, dOriginalEnd_x, dOriginalEnd_y)
1829
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1830
        Else
1831
            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
1832
            objInputs.AddConnectorTarget(oEndLMConnector, dOriginalEnd_x, dOriginalEnd_y)
1833
        End If
1834
        If sConn1Type <> "" And sConn2Type <> "" Then
1835
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1836
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1837
        ElseIf sConn1Type <> "" And sConn2Type = "" Then
1838
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1839
        ElseIf sConn1Type = "" And sConn2Type <> "" Then
1840
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1841
        End If
1842 b08338e3 Gyusu
1843 f9b63682 Gyusu
        If sFirstUid <> "" And sSecondUid <> "" Then
1844
            sReturnUid = sSecondUid
1845
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1846
            sReturnUid = sFirstUid
1847
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1848
            sReturnUid = sFirstUid
1849
        Else
1850
            sReturnUid = ""
1851
        End If
1852
        _iPipecnt = _iPipecnt + 1
1853
        objItem = _Placement.PIDCreateItem(sSystemPath)
1854
        Dim oCurrentConnector As LMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
1855
        oCurrentLineRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
1856
        oCurrentLineRow(_XML_LINE_DRAWING_TF) = "TRUE"
1857
1858
        SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
1859
1860
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
1861
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1862
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentLineRow(_XML_SYMBOL_Conn1_Uid).ToString())
1863
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentLineRow(_XML_SYMBOL_Conn2_Uid).ToString())
1864
        'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1865
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
1866
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
1867
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
1868
1869
        Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(oCurrentConnector.ModelItemID)
1870
        Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
1871
        If oAttributeRow.Length > 0 Then
1872
            For Each oAttribute In oAttributeRow
1873
                Try
1874
                    Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1875
                    Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1876
                    If sPIDValue.Contains("'") Then
1877
                        sPIDValue = sPIDValue.Replace("'", """")
1878
                    End If
1879
                    Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1880
                    oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
1881
                Catch ex As Exception
1882
                End Try
1883
            Next
1884
            oPipeRun.Commit()
1885
        End If
1886 b08338e3 Gyusu
1887 f9b63682 Gyusu
        Dim sID_1 As String = ""
1888
        Dim sID_2 As String = ""
1889
        If oStartLMConnector IsNot Nothing Then
1890
            sID_1 = oStartLMConnector.ModelItemID
1891
            sID_2 = oCurrentConnector.ModelItemID
1892
        ElseIf oEndLMConnector IsNot Nothing Then
1893
            sID_1 = oEndLMConnector.ModelItemID
1894
            sID_2 = oCurrentConnector.ModelItemID
1895 b08338e3 Gyusu
        End If
1896 f9b63682 Gyusu
        If sID_1 <> "" And sID_2 <> "" Then
1897
            Dim objSurvivorItem As LMAItem = Nothing
1898
            Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
1899
            Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
1900
            _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
1901
        End If
1902
        Return sReturnUid
1903 b08338e3 Gyusu
        '현재 Uid 모델링
1904 f9b63682 Gyusu
    End Function
1905 bb2a0c79 Gyusu
1906
    Private Sub PipingModeling()
1907 e4000111 Gyusu
1908 171ac39d Gyusu
        Try
1909
            For Each oDrwing As TreeNode In Tree_Result.Nodes
1910
                For Each oDwgNode As TreeNode In oDrwing.Nodes
1911
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
1912 54b98e09 Gyusu
                    Dim CDrawing As Drawing = GetDrawing(sDwgName)
1913
                    If CDrawing IsNot Nothing Then
1914 e4000111 Gyusu
                        Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
1915
                        Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
1916
                        For Each oNode As TreeNode In oDwgNode.Nodes
1917
                            Dim iItemcnt As Integer = 0
1918
                            Dim sNodeUid As String = oNode.Name
1919
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
1920
                            '1.Equipment
1921
                            '2.Piping OPC
1922
                            '3.OPC 시작되는 Line
1923
                            'Equipment 생성
1924
                            'If sNodeUid <> "PipeLineNo" Then
1925
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
1926 b08338e3 Gyusu
1927 e4000111 Gyusu
                            If CLineNo IsNot Nothing Then
1928
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
1929
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
1930
                                Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
1931
                                Dim oDrawLinenoLabel As Boolean = False
1932 b08338e3 Gyusu
                                Try
1933
                                    ManualCheckNode(oLine_Dt)
1934
                                    ManualCheckNode(oSymbol_Dt)
1935
                                Catch ex As Exception
1936 e4000111 Gyusu
1937 b08338e3 Gyusu
                                End Try
1938 bb2a0c79 Gyusu
1939 e4000111 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1940
                                    If oSymbolNode.Checked Then
1941 b08338e3 Gyusu
                                        Try
1942
                                            Dim sUid As String = oSymbolNode.Name
1943
                                            Dim sLineNoUid As String = CLineNo.Uid
1944
                                            Dim oOpc_Rows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" &
1945
                                             _XML_SYMBOL_Check & "] = 'TRUE'")
1946
                                            If oOpc_Rows.Length = 1 Then
1947
                                                If oOpc_Rows(0)(_XML_SYMBOL_TYPE) = _XML_PIPINGOPC Then
1948
                                                    Dim oOPCSymbol As LMSymbol = PlacePipingOPC(sUid, oOpc_Rows(0), oAttribute_Dt, CLineNo.Text)
1949
                                                    iPipingOPC_count = iPipingOPC_count + 1
1950
                                                    Dim sConnUid As String = SymbolToLine_Modeling(oLine_Dt, oAttribute_Dt, sLineNoUid, sUid, oOPCSymbol)
1951
1952
                                                    Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnUid & "'")
1953
                                                    If oLineRows.Length = 1 Then
1954
                                                        Dim sType As String = ""
1955
                                                        sType = oLineRows(0)(_XML_LINE_TYPE).ToString()
1956
                                                        Dim oLMConnector As LMConnector = Nothing
1957
                                                        Dim sLineUid As String = LineToLineModeling(sLineNoUid, oLine_Dt, oAttribute_Dt, sConnUid, sType, oLMConnector)
1958
                                                        '    Dim oLMSymbol As LMSymbol = Nothing
1959
                                                        '    Dim oSymbolUid As String = LineToSymbol_Modeling(oSymbol_Dt, oAttribute_Dt, sLineNoUid, sLineUid, oLMSymbol, oLMSymbol)
1960
                                                        'SymbolToSymbol 구현해야됨(20180726)
1961
                                                        '  SymbolToLine_Modeling(oLine_Dt, Attribute_Dt, sLineNoUid, oSymbolUid, oLMSymbol)
1962
                                                    End If
1963
                                                    '   OPCTOLineRouting(oLine_Dt, oAttribute_Dt, oOPCSymbol, sUid, CLineNo.Uid)
1964
                                                    '   LineRouting(oLine_Dt, oAttribute_Dt, CLineNo.Uid)
1965
                                                    '   SymbolModeling(oSymbol_Dt, oAttribute_Dt, CLineNo.Uid)
1966
                                                End If
1967 41e4023e Gyusu
                                            End If
1968 b08338e3 Gyusu
                                        Catch ex As Exception
1969
                                        End Try
1970 6a6d8ab4 Gyusu
                                    End If
1971 e4000111 Gyusu
                                Next
1972 f9b63682 Gyusu
1973 bb2a0c79 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1974
                                    If oSymbolNode.Checked Then
1975 b08338e3 Gyusu
                                        Try
1976
                                            Dim sUid As String = oSymbolNode.Name
1977
                                            Dim sLineNoUid As String = CLineNo.Uid
1978 f9b63682 Gyusu
                                            Dim sReturnUid = sUid
1979
                                            While True
1980
                                                Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
1981
                                                                   _XML_SYMBOL_Check & "] = 'TRUE'")
1982
                                                If oLineRows.Count > 0 Then
1983
                                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
1984
                                                Else
1985
                                                    Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
1986
                                                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
1987
                                                    If oSymbolRows.Count > 0 Then
1988
                                                        sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
1989
                                                    End If
1990
                                                End If
1991
                                                If sReturnUid = "" Then
1992
                                                    Exit While
1993
                                                End If
1994
                                            End While
1995 b08338e3 Gyusu
                                        Catch ex As Exception
1996
1997
                                        End Try
1998 bb2a0c79 Gyusu
                                    End If
1999
                                Next
2000 b08338e3 Gyusu
2001
2002 f9b63682 Gyusu
                                'For Each oSymbolNode As TreeNode In oNode.Nodes
2003
                                '    If oSymbolNode.Checked Then
2004
                                '        Try
2005
                                '            Dim sUid As String = oSymbolNode.Name
2006
                                '            Dim sLineNoUid As String = CLineNo.Uid
2007
                                '            Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2008
                                '                                                           _XML_SYMBOL_Check & "] = 'TRUE'")
2009
                                '            If oLineRows.Length = 1 Then
2010
                                '                Dim sType As String = ""
2011
                                '                sType = oLineRows(0)(_XML_LINE_TYPE).ToString()
2012
                                '                Dim sLineUid As String = oLineRows(0)(_XML_LINE_UID).ToString()
2013
                                '                FinalLineModeling(sLineUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2014
2015
                                '                'Dim oLMConnector As LMConnector = Nothing
2016
                                '                'sLineUid = LineToLineModeling(sLineNoUid, oLine_Dt, oAttribute_Dt, sLineUid, sType, oLMConnector)
2017
                                '                'Dim oLMSymbol As LMSymbol = Nothing
2018
                                '                'Dim oSymbolUid As String = LineToSymbol_Modeling(oSymbol_Dt, oAttribute_Dt, sLineNoUid, sLineUid, oLMSymbol, oLMSymbol)
2019
                                '                'SymbolToLine_Modeling(oLine_Dt, Attribute_Dt, sLineNoUid, oSymbolUid, oLMSymbol)
2020
2021
2022
2023
                                '                '    Dim sType As String = ""
2024
                                '                '    sType = oLineRows(0)(_XML_LINE_TYPE).ToString()
2025
                                '                '    Dim sLineUid As String = LineToLineModeling(sLineNoUid, oLine_Dt, oAttribute_Dt, sUid, sType)
2026
                                '                '    LineToSymbol_Modeling(oSymbol_Dt, oAttribute_Dt, sLineNoUid, sLineUid)
2027
                                '                '  LineRouting(oLine_Dt, oAttribute_Dt, CLineNo.Uid, CLineNo.Text)
2028
                                '            End If
2029
                                '            '      LineRouting(oLine_Dt, oAttribute_Dt, CLineNo.Uid)
2030
                                '        Catch ex As Exception
2031
2032
                                '        End Try
2033
2034
                                '    End If
2035
                                'Next
2036
                                'For Each oSymbolNode As TreeNode In oNode.Nodes
2037
                                '    Try
2038
                                '        If oSymbolNode.Checked Then
2039
                                '            Dim sUid As String = oSymbolNode.Name
2040
                                '            Dim oSymbolRow As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2041
                                '                                                           _XML_SYMBOL_Check & "] = 'TRUE'")
2042
                                '            If oSymbolRow.Length = 1 Then
2043
                                '                FinalSymbolModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2044
                                '                '   SymbolModeling(oSymbol_Dt, oAttribute_Dt, CLineNo.Uid, oSymbolRow(0))
2045
                                '                ' SymbolModeling(CDrawing, oLine_Dt, oSymbolRow(0), oAttribute_Dt, CLineNo.Text)
2046
                                '            End If
2047
                                '        End If
2048
                                '    Catch ex As Exception
2049
2050
                                '    End Try
2051
2052
                                'Next
2053 e4000111 Gyusu
                            End If
2054 3acffcee Gyusu
2055
2056 b08338e3 Gyusu
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2057 bb2a0c79 Gyusu
2058 b08338e3 Gyusu
                            If CTrimLineNo IsNot Nothing Then
2059
                                Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line
2060
                                Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol
2061
                                Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute
2062
                                Dim oDrawLinenoLabel As Boolean = False
2063
                                Try
2064
                                    ManualCheckNode(oLine_Dt)
2065
                                    ManualCheckNode(oSymbol_Dt)
2066
                                Catch ex As Exception
2067 bb2a0c79 Gyusu
2068 b08338e3 Gyusu
                                End Try
2069
2070
2071
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2072
                                    If oSymbolNode.Checked Then
2073
                                        Try
2074
                                            Dim sUid As String = oSymbolNode.Name
2075
                                            Dim sLineNoUid As String = CTrimLineNo.Uid
2076
                                            Dim oOpc_Rows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" &
2077
                            _XML_SYMBOL_Check & "] = 'TRUE'")
2078
                                            If oOpc_Rows.Length = 1 Then
2079
                                                If oOpc_Rows(0)(_XML_SYMBOL_TYPE) = _XML_PIPINGOPC Then
2080
                                                    Dim oOPCSymbol As LMSymbol = PlacePipingOPC(sUid, oOpc_Rows(0), oAttribute_Dt, CLineNo.Text)
2081
                                                    iPipingOPC_count = iPipingOPC_count + 1
2082
                                                    '     Dim sConnUid As String = SymbolToLine_Modeling(oLine_Dt, oAttribute_Dt, sLineNoUid, sUid, oOPCSymbol)
2083
2084
2085
                                                    'Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sUid & "'")
2086
                                                    'If oLineRows.Length = 1 Then
2087
                                                    '    Dim sType As String = ""
2088
                                                    '    sType = oLineRows(0)(_XML_LINE_TYPE).ToString()
2089
2090
                                                    '    LineToLineModeling(sLineNoUid, oLine_Dt, oAttribute_Dt, sConnUid, sType)
2091
                                                    'End If
2092
2093
2094
                                                    '  LineToSymbolModeling()
2095
                                                    'OPCTOLineRouting(oLine_Dt, oAttribute_Dt, oOPCSymbol, sUid, CLineNo.Uid)
2096
                                                    '   LineRouting(oLine_Dt, oAttribute_Dt, CLineNo.Uid)
2097
                                                    '   SymbolModeling(oSymbol_Dt, oAttribute_Dt, CLineNo.Uid)
2098
                                                End If
2099
                                            End If
2100
                                        Catch ex As Exception
2101
2102
                                        End Try
2103
2104
                                    End If
2105
                                Next
2106
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2107
                                    Try
2108
                                        If oSymbolNode.Checked Then
2109
                                            Dim sUid As String = oSymbolNode.Name
2110
                                            'Dim sLineNoUid As String = CLineNo.Uid
2111
                                            Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sUid & "'")
2112
                                            If oLineRows.Length = 1 Then
2113
                                                '    Dim sType As String = ""
2114
                                                '    sType = oLineRows(0)(_XML_LINE_TYPE).ToString()
2115
                                                '    Dim sLineUid As String = LineToLineModeling(sLineNoUid, oLine_Dt, oAttribute_Dt, sUid, sType)
2116
                                                '    LineToSymbol_Modeling(oSymbol_Dt, oAttribute_Dt, sLineNoUid, sLineUid)
2117
                                                LineRouting(oLine_Dt, oAttribute_Dt, CTrimLineNo.Uid, CTrimLineNo.Text)
2118
                                            End If
2119
                                            '      LineRouting(oLine_Dt, oAttribute_Dt, CLineNo.Uid)
2120
                                        End If
2121
                                    Catch ex As Exception
2122
2123
                                    End Try
2124
2125
                                Next
2126
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2127
                                    Try
2128
                                        If oSymbolNode.Checked Then
2129
                                            Dim sUid As String = oSymbolNode.Name
2130
                                            Dim oSymbolRow As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2131
                                                                                           _XML_SYMBOL_Check & "] = 'TRUE'")
2132
                                            If oSymbolRow.Length = 1 Then
2133
                                                '   SymbolModeling(oSymbol_Dt, oAttribute_Dt, CLineNo.Uid, oSymbolRow(0))
2134
                                                SymbolModeling(CDrawing, oLine_Dt, oSymbolRow(0), oAttribute_Dt, CTrimLineNo.Text)
2135
                                            End If
2136
                                        End If
2137
                                    Catch ex As Exception
2138
2139
                                    End Try
2140
2141
                                Next
2142
                            End If
2143
                        Next
2144
                    End If
2145
                Next
2146
            Next
2147
        Catch ex As Exception
2148
2149
        End Try
2150
    End Sub
2151
2152
2153
    Private Sub FindNearPoint(ByVal oOPCSymbol As LMSymbol, ByRef dNear_x As Double, ByRef dNear_y As Double)
2154
        Dim oConnectionPoints_x(4) As Double
2155
        Dim oConnectionPoints_y(4) As Double
2156
2157
        Try
2158
            _Placement.PIDConnectPointLocation(oOPCSymbol, 1, oConnectionPoints_x(0), oConnectionPoints_y(0))
2159
            _Placement.PIDConnectPointLocation(oOPCSymbol, 2, oConnectionPoints_x(1), oConnectionPoints_y(1))
2160
            _Placement.PIDConnectPointLocation(oOPCSymbol, 3, oConnectionPoints_x(2), oConnectionPoints_y(2))
2161
            _Placement.PIDConnectPointLocation(oOPCSymbol, 4, oConnectionPoints_x(3), oConnectionPoints_y(3))
2162
            Dim iNearPoint As Integer = 0
2163
            Dim dGap As Double = 0
2164
            For i = 0 To 3
2165
                If dGap = 0 Then
2166
                    iNearPoint = i
2167
                    dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
2168
                Else
2169
                    If dGap >= Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y) Then
2170
                        iNearPoint = i
2171
                        dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
2172
                    End If
2173
                End If
2174
            Next
2175
            dNear_x = oConnectionPoints_x(iNearPoint)
2176
            dNear_y = oConnectionPoints_y(iNearPoint)
2177
        Catch ex As Exception
2178 e4000111 Gyusu
2179 bb2a0c79 Gyusu
        End Try
2180 e4000111 Gyusu
2181 bb2a0c79 Gyusu
    End Sub
2182
2183
    Private Function GetPipeType(ByVal sType As String) As String
2184
        Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString()
2185
        If sType.ToUpper() = "ELECTRIC" Then
2186
            sSystempath = "\Instrumentation\Signal Line\Electric.sym"
2187
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
2188
            sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym"
2189
        Else
2190
        End If
2191
        Return sSystempath
2192
    End Function
2193
2194
    Private Sub InitAutoRouting()
2195
        For Each oDrwing As TreeNode In Tree_Result.Nodes
2196
            For Each oDwgNode As TreeNode In oDrwing.Nodes
2197
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
2198
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
2199
                If CDrawing IsNot Nothing Then
2200
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
2201
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
2202
                    SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....")
2203 b08338e3 Gyusu
2204 bb2a0c79 Gyusu
                    For Each oNode As TreeNode In oDwgNode.Nodes
2205
                        Dim iItemcnt As Integer = 0
2206
                        Dim sNodeUid As String = oNode.Name
2207
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2208
                        Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2209
                        If CLineNo IsNot Nothing Then
2210
                            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2211
                            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2212
2213
                            For Each oLineRow In oLine_Dt.Rows
2214
                                oLineRow(_XML_LINE_SPID) = ""
2215
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
2216
                            Next
2217
                            For Each oSymbolRow In oSymbol_Dt.Rows
2218
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
2219
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
2220
                            Next
2221
2222
                        End If
2223
                    Next
2224
                End If
2225
            Next
2226
        Next
2227
    End Sub
2228
2229
2230
2231
2232
2233
2234
    Private Function CheckBranchLine(ByVal oLine_Dt As DataTable, ByVal dStartX As Double, ByVal dStartY As Double,
2235
                                ByRef dEndX As Double, ByRef dEndY As Double, ByRef sBranchType As String, ByRef oLMConnector As LMConnector) As Boolean
2236
2237
        Try
2238
            Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And [" & _XML_LINE_SPID & "] <> ''")
2239
            For Each oModelrow In oModelingLineRows
2240
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
2241
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
2242
                Dim dModelStartX As Double
2243
                Dim dModelStartY As Double
2244
                Dim dModelEndX As Double
2245
                Dim dModelEndY As Double
2246
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
2247
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
2248
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
2249
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
2250
                Dim dGap As Double = 0.0002
2251
                Dim d기준x As Double = (dModelStartX + dModelEndX) / 2
2252
                Dim d기준y As Double = (dModelStartY + dModelEndY) / 2
2253
                Try
2254
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
2255
                Catch ex As Exception
2256
2257
                End Try
2258
                Dim oRun As LMPipeRun = Nothing
2259
                Try
2260
2261
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
2262
                    Dim dResultCalc As Double = -1
2263
                    For Each objRep In oRun.Representations
2264
                        If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
2265
                            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
2266
                            For Each objConnectorVertex In objConnector.ConnectorVertices
2267
                                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
2268
                                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
2269
                                Dim dStartCalc As Double = Math.Abs(dStartX - dConn_X) + Math.Abs(dStartY - dConn_Y)
2270
2271
                                If dResultCalc > dStartCalc Or dResultCalc = -1 Then
2272
                                    dResultCalc = dStartCalc
2273
                                    oLMConnector = objConnector
2274
                                    d기준x = dConn_X
2275
                                    d기준y = dConn_Y
2276
                                End If
2277
                                Dim dEndCalc As Double = Math.Abs(dEndX - dConn_X) + Math.Abs(dEndY - dConn_Y)
2278
                                If dResultCalc > dEndCalc Then
2279
                                    dResultCalc = dEndCalc
2280
                                    oLMConnector = objConnector
2281
                                    d기준x = dConn_X
2282
                                    d기준y = dConn_Y
2283
                                End If
2284
                            Next
2285
                        End If
2286
                    Next
2287
                    '        _Placement.PIDConnectPointLocation(oRun, 1, dModelStartX, dModelEndX)
2288
                    '       _Placement.PIDConnectPointLocation(oRun, 2, dModelEndX, dModelEndY)
2289
                Catch ex As Exception
2290
                End Try
2291
2292
2293
                'Dim sSPID As String = oModelrow(_XML_LINE_SPID).ToString()
2294
                'Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.Get PipeRun(sSPID)
2295
                'If dModelStartX + dGap > dStartX And dModelStartX - dGap < dStartX And
2296
                '        dModelStartY + dGap > dStartY And dModelStartY - dGap < dStartY Then
2297
                '    dStartX = dModelStartX
2298
                '    dStartY = dModelStartY
2299
                'ElseIf dModelEndX + dGap > dStartX And dModelEndX - dGap < dStartX And
2300
                '        dModelEndY + dGap > dStartY And dModelEndY - dGap < dStartY Then
2301
                '    dStartX = dModelEndX
2302
                '    dStartY = dModelEndY
2303
                'End If
2304
2305
                'Vetical
2306
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
2307
                    If Math.Abs(dStartX - dEndX) >= Math.Abs(dStartY - dEndY) Then
2308
                        'Horizontal 
2309
                        ' dGap = 0.0002 'Math.Abs(dStartX - dEndX) / 20
2310
                        '기준선의 Y범위안에 가로선이 포함되어야됨
2311
                        If (dModelStartY + dGap >= dStartY And dModelEndY - dGap <= dStartY) Or
2312
                            (dModelStartY - dGap <= dStartY And dModelEndY + dGap >= dStartY) And
2313
                            (dModelStartY + dGap >= dEndY And dModelEndY - dGap <= dEndY) Or
2314
                            (dModelStartY - dGap <= dEndY And dModelEndY + dGap >= dEndY) Then
2315
                            '기준선보다 왼쪽에 가로선이 있을때
2316
                            If d기준x >= dStartX And d기준x >= dEndX Then
2317
                                If dStartX >= dEndX Then
2318
                                    'dStartX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2319
                                    If dStartX + dGap >= d기준x Then
2320
                                        dStartX = d기준x
2321
                                        sBranchType = "1"
2322
                                        Return True
2323
                                    End If
2324
                                Else
2325
                                    'dEndX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2326
                                    If dEndX + dGap >= d기준x Then
2327
                                        dEndX = d기준x
2328
                                        sBranchType = "2"
2329
                                        Return True
2330
                                    End If
2331
                                End If
2332
                                '기준선보다 오른쪽에 가로선이 있을때
2333
                            ElseIf d기준x <= dStartX And d기준x <= dEndX Then
2334
                                If dStartX >= dEndX Then
2335
                                    'dEndX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2336
                                    If dEndX - dGap <= d기준x Then
2337
                                        dEndX = d기준x
2338
                                        sBranchType = "2"
2339
                                        Return True
2340
                                    End If
2341
                                Else
2342
                                    'dStartX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2343
                                    If dStartX - dGap <= d기준x Then
2344
                                        dStartX = d기준x
2345
                                        sBranchType = "1"
2346
                                        Return True
2347
                                    End If
2348
                                End If
2349
                            Else
2350
                                '기준선과 세로선이 겹칠때
2351
                                If (d기준x >= dStartX And d기준x <= dEndX) Or
2352
                                        (d기준x <= dStartX And d기준x >= dEndX) Then
2353
                                    If (dModelStartY <= dStartY And dModelEndY >= dEndY) Or
2354
                                        (dModelStartY >= dStartY And dModelEndY <= dEndY) Then
2355
                                        '기준선이 dStartX와 dEndX중 어느쪽에 가까운지 확인
2356
                                        '가로선의 왼쪽점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
2357
                                        '가로선의 오른쪽점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
2358
                                        If Math.Abs(d기준x - dStartX) >= Math.Abs(d기준x - dEndX) Then
2359
                                            'EndX점이 기준선과 더 가까이 있음
2360
                                            If dStartX >= dEndX Then
2361
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2362
                                                If dEndX - dGap <= d기준x Then
2363
                                                    dEndX = d기준x
2364
                                                    sBranchType = "4"
2365
                                                    Return True
2366
                                                End If
2367
                                            Else
2368
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2369
                                                If dEndX + dGap >= d기준x Then
2370
                                                    dEndX = d기준x
2371
                                                    sBranchType = "4"
2372
                                                    Return True
2373
                                                End If
2374
2375
                                            End If
2376
                                        Else
2377
                                            'dStartX점이 기준선과 더 가까이 있음
2378
                                            If dStartX >= dEndX Then
2379
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2380
                                                If dStartX + dGap >= d기준x Then
2381
                                                    dStartX = d기준x
2382
                                                    sBranchType = "3"
2383
                                                    Return True
2384
                                                End If
2385
2386
                                            Else
2387
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2388
                                                If dStartX - dGap <= d기준x Then
2389
                                                    dStartX = d기준x
2390
                                                    sBranchType = "3"
2391
                                                    Return True
2392
                                                End If
2393
                                            End If
2394
                                        End If
2395
                                    End If
2396
2397
                                End If
2398
                            End If
2399
                        End If
2400
2401
                    End If
2402
                    Else
2403
                    'Horizontal
2404
                    If Math.Abs(dModelStartX - dModelEndX) >= Math.Abs(dModelStartY - dModelEndY) Then
2405
                        'Vertical
2406
                        If Math.Abs(dStartX - dEndX) <= Math.Abs(dStartY - dEndY) Then
2407
                            '  dGap = 0.0015 'Math.Abs(dStartY - dEndY) / 80
2408
2409
                            '기준선의 X범위안에 세로선이 포함되어야됨
2410
                            If ((dModelStartX + dGap >= dStartX And dModelEndX - dGap <= dStartX) Or
2411
                            (dModelStartX - dGap <= dStartX And dModelEndX + dGap >= dStartX)) And
2412
                            ((dModelStartX + dGap >= dEndX And dModelEndX - dGap <= dEndX) Or
2413
                            (dModelStartX - dGap <= dEndX And dModelEndX + dGap >= dEndX)) Then
2414
2415
2416
                                '가로선보다 아래에 세로선이 있을때
2417
                                If d기준y >= dStartY And d기준y >= dEndY Then
2418
                                    If dStartY >= dEndY Then
2419
                                        'dStartY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2420
                                        If dStartY + dGap >= d기준y Then
2421
                                            dStartY = d기준y
2422
                                            sBranchType = "3"
2423
                                            Return True
2424
                                        End If
2425
                                    Else
2426
                                        'dEndY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2427
                                        If dEndY + dGap >= d기준y Then
2428
                                            dEndY = d기준y
2429
2430
                                            If Math.Abs(dEndX - dModelStartX) > Math.Abs(dEndX - dModelEndX) Then
2431
                                                dEndX = dModelEndX
2432
                                            Else
2433
                                                dEndX = dModelStartX
2434
                                            End If
2435
2436
                                            sBranchType = "4"
2437
                                            Return True
2438
                                        End If
2439
                                    End If
2440
                                    '기준선보다 위에 세로선이 있을때
2441
                                ElseIf d기준y <= dStartY And d기준y <= dEndY Then
2442
                                    If dStartY >= dEndY Then
2443
                                        'dEndY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2444
                                        If dEndY - dGap <= d기준y Then
2445
                                            dEndY = d기준y
2446
                                            sBranchType = "4"
2447
                                            Return True
2448
                                        End If
2449
                                    Else
2450
                                        'dStartY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2451
                                        If dStartY - dGap <= d기준y Then
2452
                                            dStartY = d기준y
2453
                                            sBranchType = "3"
2454
                                            Return True
2455
                                        End If
2456
                                    End If
2457
                                Else
2458
                                    '기준선과 세로선이 겹칠때
2459
                                    If (d기준y >= dStartY And d기준y <= dEndY) Or
2460
                                            (d기준y <= dStartY And d기준y >= dEndY) Then
2461
                                        '기준선이 dStartY와 dEndY중 어느쪽에 가까운지 확인
2462
                                        '세로선의 윗점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
2463
                                        '세로선의 아래점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
2464
                                        If (dModelStartX <= dStartX And dModelEndX >= dEndX) Or
2465
                                            (dModelStartX >= dStartX And dModelEndX <= dEndX) Then
2466
                                            If Math.Abs(d기준y - dStartY) >= Math.Abs(d기준y - dEndY) Then
2467
                                                'Endy점이 기준선과 더 가까이 있음
2468
                                                If dStartY >= dEndY Then
2469
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2470
                                                    If dEndY + dGap >= d기준y Then
2471
                                                        dEndY = d기준y
2472
                                                        sBranchType = "4"
2473
                                                        Return True
2474
                                                    End If
2475
                                                Else
2476
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2477
                                                    If dEndY - dGap <= d기준y Then
2478
                                                        dEndY = d기준y
2479
                                                        sBranchType = "4"
2480
                                                        Return True
2481
                                                    End If
2482
                                                End If
2483
                                            Else
2484
                                                'dStartY점이 기준선과 더 가까이 있음
2485
                                                If dStartY >= dEndY Then
2486
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2487
                                                    If dStartY - dGap <= d기준y Then
2488
                                                        dStartY = d기준y
2489
                                                        sBranchType = "3"
2490
                                                        Return True
2491
                                                    End If
2492
                                                Else
2493
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2494
                                                    If dStartY + dGap >= d기준y Then
2495
                                                        dStartY = d기준y
2496
                                                        sBranchType = "3"
2497
                                                        Return True
2498
                                                    End If
2499
                                                End If
2500
                                            End If
2501
                                        End If
2502
2503
                                    End If
2504
                                End If
2505
2506
2507
                            End If
2508 e4000111 Gyusu
2509 bb2a0c79 Gyusu
                        End If
2510
                    End If
2511
                End If
2512
            Next
2513
        Catch ex As Exception
2514
2515
        End Try
2516
        oLMConnector = Nothing
2517
        Return False
2518
    End Function
2519
2520 b08338e3 Gyusu
2521
2522
2523
2524
    Private Function CheckConnectionLine(ByVal oModelingLineRows() As DataRow, ByVal dX As Double, ByVal dY As Double,
2525
                                  ByRef oLMConnector As LMConnector) As Boolean
2526
        Dim bConnectionFlag As Boolean = False
2527
        Try
2528
            For Each oModelrow In oModelingLineRows
2529
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
2530
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
2531
                Dim dModelStartX As Double
2532
                Dim dModelStartY As Double
2533
                Dim dModelEndX As Double
2534
                Dim dModelEndY As Double
2535
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
2536
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
2537
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
2538
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
2539
                Dim dGap As Double = 0.0002
2540
                Dim d기준x As Double = (dModelStartX + dModelEndX) / 2
2541
                Dim d기준y As Double = (dModelStartY + dModelEndY) / 2
2542
                Try
2543
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
2544
                Catch ex As Exception
2545
                End Try
2546
                Dim oRun As LMPipeRun = Nothing
2547
                Try
2548
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
2549
                    Dim dResultCalc As Double = -1
2550
                    For Each objRep In oRun.Representations
2551
                        If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
2552
                            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
2553
                            For Each objConnectorVertex In objConnector.ConnectorVertices
2554
                                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
2555
                                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
2556
                                If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
2557
                                    oLMConnector = objConnector
2558
                                    d기준x = dConn_X
2559
                                    d기준y = dConn_Y
2560
                                    bConnectionFlag = True
2561
                                    Exit For
2562
                                End If
2563
                            Next
2564
                        End If
2565
                    Next
2566
                Catch ex As Exception
2567
                End Try
2568
            Next
2569
2570
        Catch ex As Exception
2571
2572
        End Try
2573
        Return bConnectionFlag
2574
    End Function
2575
2576
    Private Function CheckLineBranch(ByVal oLine_Dt As DataTable, ByRef dX As Double, ByRef dY As Double,
2577
                                     ByVal sDirection As String, ByRef oLMConnector As LMConnector) As Boolean
2578
2579
        Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And " &
2580
                                                                "[" & _XML_LINE_SPID & "] <> ''")
2581
2582
        Dim bConnectionFlag As Boolean = False
2583
        Try
2584
            For Each oModelrow In oModelingLineRows
2585
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
2586
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
2587
                Dim dModelStartX As Double
2588
                Dim dModelStartY As Double
2589
                Dim dModelEndX As Double
2590
                Dim dModelEndY As Double
2591
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
2592
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
2593
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
2594
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
2595
                Dim dGap As Double = 0.0002
2596
2597
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
2598
                    'Vertical
2599
                    If sDirection = "X" Then
2600
                        'x Direction Line
2601
                        If (dModelStartY + dGap >= dY And dModelEndY - dGap <= dY) Or
2602
                        (dModelStartY - dGap <= dY And dModelEndY + dGap >= dY) Then
2603
                            If (dX > dModelStartX And dX < dModelEndX) Or (dX > dModelEndX And dX < dModelStartX) Then
2604
                                If Math.Abs(dX - dModelStartX) > Math.Abs(dX - dModelEndX) Then
2605
                                    dX = dModelEndX
2606
                                Else
2607
                                    dX = dModelStartX
2608
                                End If
2609
                                Try
2610
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
2611
                                Catch ex As Exception
2612
2613
                                End Try
2614
                                bConnectionFlag = True
2615
                            End If
2616
                        End If
2617
                    End If
2618
                Else
2619
                    'Horizontal 
2620
                    If sDirection = "Y" Then
2621
                        If (dModelStartX + dGap >= dX And dModelEndX - dGap <= dX) Or
2622
                       (dModelStartX - dGap <= dX And dModelEndX + dGap >= dX) Then
2623
                            If (dY > dModelStartY And dY < dModelEndY) Or (dY > dModelEndY And dY < dModelStartY) Then
2624
                                If Math.Abs(dY - dModelStartY) > Math.Abs(dY - dModelEndY) Then
2625
                                    dY = dModelEndY
2626
                                Else
2627
                                    dY = dModelStartY
2628
                                End If
2629
                                Try
2630
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
2631
                                Catch ex As Exception
2632
                                End Try
2633
                                bConnectionFlag = True
2634
                            End If
2635
                        End If
2636
                    End If
2637
                End If
2638
            Next
2639
        Catch ex As Exception
2640
        End Try
2641
        Return bConnectionFlag
2642
    End Function
2643
    Private Function LineModeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sStartLineUid As String, ByVal sEndLineUid As String, ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double,
2644
                              ByVal sLineNoUid As String, ByVal sLineUid As String, ByVal sSystemPath As String, ByRef oLMConnector As LMConnector) As Boolean
2645 bb2a0c79 Gyusu
        Try
2646
            Dim oDatasource As Object = _Placement.PIDDataSource
2647 b08338e3 Gyusu
            Dim oPipeRun As LMPipeRun = Nothing
2648 bb2a0c79 Gyusu
            Dim objInputs As PlaceRunInputs
2649
            objInputs = New PlaceRunInputs
2650 b08338e3 Gyusu
            Dim objItem As LMAItem
2651
            '       Dim objConnector As LMConnector
2652
2653
            Dim oStartLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sStartLineUid & "' And " &
2654
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
2655
                                                                          "[" & _XML_LINE_SPID & "] <> ''")
2656
            If oStartLineRow.Length = 0 Then
2657
                oStartLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sStartLineUid & "' And " &
2658
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
2659
                                                                          "[" & _XML_LINE_SPID & "] <> ''")
2660
            End If
2661
            Dim oEndLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sEndLineUid & "' And " &
2662
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
2663
                                                                          "[" & _XML_LINE_SPID & "] <> ''")
2664
2665
            oEndLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sEndLineUid & "' And " &
2666
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
2667
                                                                          "[" & _XML_LINE_SPID & "] <> ''")
2668
            Dim sStartConnectionType As String = ""
2669
            Dim sEndConnectionType As String = ""
2670
2671
            Dim oStartLMConnector As LMConnector = Nothing
2672
            Dim oEndLMConnector As LMConnector = Nothing
2673
            Dim oDirectionLine As String = ""
2674
2675
            If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
2676
                oDirectionLine = "X"
2677
            Else
2678
                oDirectionLine = "Y"
2679
            End If
2680
2681
            Dim bCheckFlag As Boolean = False
2682
2683
            Dim bStartCheckFlag As Boolean = CheckConnectionLine(oStartLineRow, dStart_x, dStart_y, oStartLMConnector)
2684
            If bStartCheckFlag = False Then
2685
                bStartCheckFlag = CheckConnectionLine(oStartLineRow, dEnd_x, dEnd_y, oStartLMConnector)
2686
                bCheckFlag = True
2687
            End If
2688
            Dim bEndCheckFlag As Boolean = CheckConnectionLine(oEndLineRow, dEnd_x, dEnd_y, oEndLMConnector)
2689
2690
            If bEndCheckFlag = False Then
2691
2692
                bEndCheckFlag = CheckConnectionLine(oEndLineRow, dStart_x, dStart_y, oEndLMConnector)
2693
                bCheckFlag = True
2694
            End If
2695
2696
            If bStartCheckFlag = True And bEndCheckFlag = False Then
2697
                If bCheckFlag Then
2698
                    objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
2699
                    objInputs.AddPoint(dStart_x, dStart_y)
2700
                Else
2701
                    objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
2702
                    objInputs.AddPoint(dEnd_x, dEnd_y)
2703
                End If
2704
2705
            ElseIf bStartCheckFlag = False And bEndCheckFlag = True Then
2706
                If bCheckFlag Then
2707
2708
                    objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
2709
                    objInputs.AddPoint(dEnd_x, dEnd_y)
2710
                Else
2711
                    objInputs.AddPoint(dStart_x, dStart_y)
2712
                    objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
2713
                End If
2714
2715
            ElseIf bStartCheckFlag = True And bEndCheckFlag = True Then
2716
                objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
2717
                objInputs.AddConnectorTarget(oEndLMConnector, dEnd_x, dEnd_y)
2718
            Else
2719
                objInputs.AddPoint(dStart_x, dStart_y)
2720
                objInputs.AddPoint(dEnd_x, dEnd_y)
2721
            End If
2722
            SetListBoxItems(ListBox_Result, "Place Pipe..(" & dStart_x & "," & dStart_y & ") - (" & dEnd_x & "," & dEnd_y & ")..." & _iPipecnt & " count ")
2723
            _iPipecnt = _iPipecnt + 1
2724
            objItem = _Placement.PIDCreateItem(sSystemPath)
2725
            oLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2726
2727
            Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + sLineUid + "'")
2728
            If oUpdateRow.Length = 1 Then
2729
                oUpdateRow(0)(_XML_LINE_SPID) = oLMConnector.ModelItemID
2730
                oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = oLMConnector
2731
2732
                oUpdateRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
2733
            End If
2734
2735
            oPipeRun = oDatasource.GetPipeRun(oLMConnector.ModelItemID)
2736
2737
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2738
            If oAttributeRow.Length > 0 Then
2739
                For Each oAttribute In oAttributeRow
2740
                    Try
2741
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2742
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2743
                        If sPIDValue.Contains("'") Then
2744
                            sPIDValue = sPIDValue.Replace("'", """")
2745
                        End If
2746
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2747
                        oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
2748
                    Catch ex As Exception
2749
                    End Try
2750
                Next
2751
                oPipeRun.Commit()
2752
            End If
2753
            Dim sID_1 As String = ""
2754
            Dim sID_2 As String = ""
2755
            If oStartLMConnector IsNot Nothing Then
2756
                sID_1 = oStartLMConnector.ModelItemID
2757
                sID_2 = oLMConnector.ModelItemID
2758
            ElseIf oEndLMConnector IsNot Nothing Then
2759
                sID_1 = oEndLMConnector.ModelItemID
2760
                sID_2 = oLMConnector.ModelItemID
2761
            End If
2762
            If sID_1 <> "" And sID_2 <> "" Then
2763
                Dim objSurvivorItem As LMAItem = Nothing
2764
                Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
2765
                Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
2766
                _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
2767
            End If
2768
            Return True
2769
        Catch ex As Exception
2770
            Return False
2771
        End Try
2772
2773
    End Function
2774
2775
    Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
2776
                                        ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String,
2777
                                        ByRef oLMConnector As LMConnector) As String
2778
        Dim sReturnUid As String = ""
2779
        Try
2780
            Dim sLineUid As String = ""
2781
2782
            Dim iConnType As Integer = 0
2783
2784
            Dim sStartpoint As String = ""
2785
            Dim sEndpoint As String = ""
2786 bb2a0c79 Gyusu
            Dim dOriginalStart_x As Double = 0.0
2787
            Dim dOriginalStart_y As Double = 0.0
2788
            Dim dOriginalEnd_x As Double = 0.0
2789
            Dim dOriginalEnd_y As Double = 0.0
2790
2791 b08338e3 Gyusu
            Dim dStart_x As Double = 0
2792
            Dim dStart_y As Double = 0
2793
            Dim dEnd_x As Double = 0
2794
            Dim dEnd_y As Double = 0
2795
            Dim sStartLineUid As String = sConnLineUid
2796
            Dim sEndLineUid As String = ""
2797
            Dim sDirection As String = ""
2798
            Dim sSystemPath As String = GetPipeType(sType)
2799
2800
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
2801
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
2802
                                                                     "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
2803
                                                                     "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
2804
            If oPipeRow.Length > 0 Then
2805 bb2a0c79 Gyusu
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
2806
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
2807 e4000111 Gyusu
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2808
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2809 b08338e3 Gyusu
                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
2810
                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
2811
                If dStart_x = 0 And dStart_y = 0 Then
2812
                    dStart_x = dOriginalStart_x
2813
                    dStart_y = dOriginalStart_y
2814
                    dEnd_x = dOriginalEnd_x
2815
                    dEnd_y = dOriginalEnd_y
2816
                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2817
                        sDirection = "X"
2818
                    Else
2819
                        sDirection = "Y"
2820
                    End If
2821
                    oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
2822
                    sLineUid = sConnLineUid
2823
                End If
2824
            End If
2825 bb2a0c79 Gyusu
2826 b08338e3 Gyusu
            While True
2827
                sLineUid = ""
2828
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
2829 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
2830
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
2831
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
2832 b08338e3 Gyusu
2833
                If oPipeRow.Length = 0 Then
2834
                    oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
2835 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
2836
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
2837
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
2838 bb2a0c79 Gyusu
                Else
2839 b08338e3 Gyusu
                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
2840
                    'sConnLineUid = sLineUid
2841
                    sLineUid = sConnLineUid
2842
                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
2843
                    iConnType = 1
2844
                End If
2845
2846
                If oPipeRow.Length > 0 Then
2847
                    If sLineUid = "" Then
2848
                        'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
2849
                        'sConnLineUid = sLineUid
2850
                        sLineUid = sConnLineUid
2851
                        sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
2852
                        iConnType = 2
2853
                    End If
2854
                    If iConnType = 1 Then
2855
2856
                    ElseIf iConnType = 2 Then
2857
2858
                    End If
2859
                    sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
2860
                    sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
2861
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2862
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2863
                    ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
2864
                    ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
2865
2866
2867
2868
                    If dStart_x = 0 And dStart_y = 0 Then
2869
                        dStart_x = dOriginalStart_x
2870
                        dStart_y = dOriginalStart_y
2871
                        dEnd_x = dOriginalEnd_x
2872
                        dEnd_y = dOriginalEnd_y
2873
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2874
                            sDirection = "X"
2875
                        Else
2876
                            sDirection = "Y"
2877
                        End If
2878
                        sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
2879
                        sSystemPath = GetPipeType(sType)
2880
                    Else
2881
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2882
                            If sDirection = "Y" Then
2883
                                '방향이 바꼈음 Y - > X
2884
2885
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
2886
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
2887
                                dStart_x = dOriginalStart_x
2888
                                dStart_y = dOriginalStart_y
2889
                                dEnd_x = dOriginalEnd_x
2890
                                dEnd_y = dOriginalEnd_y
2891
                                sStartLineUid = sConnLineUid
2892
                            Else
2893
                                dEnd_x = dOriginalEnd_x
2894
                                dEnd_y = dOriginalEnd_y
2895
                            End If
2896
                            sDirection = "X"
2897
                        Else
2898
                            If sDirection = "X" Then
2899
                                '방향이 바꼈음 X - > Y
2900
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
2901
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
2902
                                dStart_x = dOriginalStart_x
2903
                                dStart_y = dOriginalStart_y
2904
                                dEnd_x = dOriginalEnd_x
2905
                                dEnd_y = dOriginalEnd_y
2906
                                sStartLineUid = sConnLineUid
2907
                            Else
2908
2909
                                dEnd_x = dOriginalEnd_x
2910
                                dEnd_y = dOriginalEnd_y
2911
                            End If
2912
                            sDirection = "Y"
2913
                        End If
2914
                    End If
2915
                    '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
2916
                Else
2917
                    If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
2918
                        LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
2919
                         sLineNoUid, sLineUid, sSystemPath, oLMConnector)
2920
                    End If
2921
                    sReturnUid = sConnLineUid
2922
                    Exit While
2923
                End If
2924
            End While
2925
2926
            If sStartLineUid <> "" And sEndLineUid <> "" Then
2927
                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
2928
                             sLineNoUid, sLineUid, sSystemPath, oLMConnector)
2929
                dStart_x = 0
2930
                dStart_y = 0
2931
                dEnd_x = 0
2932
                dEnd_y = 0
2933
            End If
2934
        Catch ex As Exception
2935
2936
        End Try
2937
2938
        Return sReturnUid
2939
    End Function
2940
2941
2942
    'Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
2943
    '                                    ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String) As String
2944
    '    Dim sReturnUid As String = ""
2945
    '    Try
2946
    '        Dim sLineUid As String = ""
2947
2948
    '        Dim iConnType As Integer = 0
2949
2950
    '        Dim sStartpoint As String = ""
2951
    '        Dim sEndpoint As String = ""
2952
    '        Dim dOriginalStart_x As Double = 0.0
2953
    '        Dim dOriginalStart_y As Double = 0.0
2954
    '        Dim dOriginalEnd_x As Double = 0.0
2955
    '        Dim dOriginalEnd_y As Double = 0.0
2956
2957
    '        Dim dStart_x As Double = 0
2958
    '        Dim dStart_y As Double = 0
2959
    '        Dim dEnd_x As Double = 0
2960
    '        Dim dEnd_y As Double = 0
2961
    '        Dim sStartLineUid As String = sConnLineUid
2962
    '        Dim sEndLineUid As String = ""
2963
    '        Dim sDirection As String = ""
2964
    '        Dim sSystemPath As String = GetPipeType(sType)
2965
2966
    '        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
2967
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
2968
    '                                                                 "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
2969
    '                                                                 "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
2970
    '        If oPipeRow.Length > 0 Then
2971
    '            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
2972
    '            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
2973
    '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2974
    '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2975
    '            ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
2976
    '            ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
2977
    '            If dStart_x = 0 And dStart_y = 0 Then
2978
    '                dStart_x = dOriginalStart_x
2979
    '                dStart_y = dOriginalStart_y
2980
    '                dEnd_x = dOriginalEnd_x
2981
    '                dEnd_y = dOriginalEnd_y
2982
    '                If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2983
    '                    sDirection = "X"
2984
    '                Else
2985
    '                    sDirection = "Y"
2986
    '                End If
2987
    '                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
2988
    '                sLineUid = sConnLineUid
2989
    '            End If
2990
    '        End If
2991
2992
    '        While True
2993
    '            sLineUid = ""
2994
    '            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
2995
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
2996
    '                                                                         "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
2997
    '                                                                         "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
2998
2999
    '            If oPipeRow.Length = 0 Then
3000
    '                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
3001
    '                                         "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
3002
    '                                       "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
3003
    '                                      "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
3004
    '            Else
3005
    '                'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3006
    '                'sConnLineUid = sLineUid
3007
    '                sLineUid = sConnLineUid
3008
    '                sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3009
    '                iConnType = 1
3010
    '            End If
3011
3012
    '            If oPipeRow.Length > 0 Then
3013
    '                If sLineUid = "" Then
3014
    '                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3015
    '                    'sConnLineUid = sLineUid
3016
    '                    sLineUid = sConnLineUid
3017
    '                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3018
    '                    iConnType = 2
3019
    '                End If
3020
    '                If iConnType = 1 Then
3021
3022
    '                ElseIf iConnType = 2 Then
3023
3024
    '                End If
3025
    '                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
3026
    '                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
3027
    '                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3028
    '                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3029
    '                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
3030
    '                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
3031
3032
3033
3034
    '                If dStart_x = 0 And dStart_y = 0 Then
3035
    '                    dStart_x = dOriginalStart_x
3036
    '                    dStart_y = dOriginalStart_y
3037
    '                    dEnd_x = dOriginalEnd_x
3038
    '                    dEnd_y = dOriginalEnd_y
3039
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
3040
    '                        sDirection = "X"
3041
    '                    Else
3042
    '                        sDirection = "Y"
3043
    '                    End If
3044
    '                    sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
3045
    '                    sSystemPath = GetPipeType(sType)
3046
    '                Else
3047
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
3048
    '                        If sDirection = "Y" Then
3049
    '                            '방향이 바꼈음 Y - > X
3050
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
3051
    '                            sLineNoUid, sLineUid, sSystemPath)
3052
    '                            dStart_x = dOriginalStart_x
3053
    '                            dStart_y = dOriginalStart_y
3054
    '                            dEnd_x = dOriginalEnd_x
3055
    '                            dEnd_y = dOriginalEnd_y
3056
    '                            sStartLineUid = sConnLineUid
3057
    '                        Else
3058
    '                            dEnd_x = dOriginalEnd_x
3059
    '                            dEnd_y = dOriginalEnd_y
3060
    '                        End If
3061
    '                        sDirection = "X"
3062
    '                    Else
3063
    '                        If sDirection = "X" Then
3064
    '                            '방향이 바꼈음 X - > Y
3065
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
3066
    '                            sLineNoUid, sLineUid, sSystemPath)
3067
    '                            dStart_x = dOriginalStart_x
3068
    '                            dStart_y = dOriginalStart_y
3069
    '                            dEnd_x = dOriginalEnd_x
3070
    '                            dEnd_y = dOriginalEnd_y
3071
    '                            sStartLineUid = sConnLineUid
3072
    '                        Else
3073
3074
    '                            dEnd_x = dOriginalEnd_x
3075
    '                            dEnd_y = dOriginalEnd_y
3076
    '                        End If
3077
    '                        sDirection = "Y"
3078
    '                    End If
3079
    '                End If
3080
    '                '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3081
    '            Else
3082
    '                If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
3083
    '                    LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
3084
    '                     sLineNoUid, sLineUid, sSystemPath)
3085
    '                End If
3086
3087
3088
    '                sReturnUid = sConnLineUid
3089
    '                Exit While
3090
    '            End If
3091
    '        End While
3092
3093
    '        If sStartLineUid <> "" And sEndLineUid <> "" Then
3094
    '            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
3095
    '                         sLineNoUid, sLineUid, sSystemPath)
3096
    '            dStart_x = 0
3097
    '            dStart_y = 0
3098
    '            dEnd_x = 0
3099
    '            dEnd_y = 0
3100
    '        End If
3101
    '    Catch ex As Exception
3102
3103
    '    End Try
3104
3105
    '    Return sReturnUid
3106
    'End Function
3107
3108
3109
    Private Function SymbolToLine_Modeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
3110
                                       ByVal sSymbolUid As String, ByVal oLMSymbol As LMSymbol) As String
3111
3112
3113
        Dim oDatasource As Object = _Placement.PIDDataSource
3114
        Dim oPipeRun As LMPipeRun = Nothing
3115
        Dim objItem As LMAItem
3116
        Dim objConnector As LMConnector
3117
        Dim objInputs As PlaceRunInputs
3118
        objInputs = New PlaceRunInputs
3119
3120
3121
        Dim sPipeUid As String = ""
3122
        Dim iConnType As Integer = 0
3123
        Dim sStartpoint As String = ""
3124
        Dim sEndpoint As String = ""
3125
        Dim dOriginalStart_x As Double = 0.0
3126
        Dim dOriginalStart_y As Double = 0.0
3127
        Dim dOriginalEnd_x As Double = 0.0
3128
        Dim dOriginalEnd_y As Double = 0.0
3129
        Dim dStart_x As Double = 0.0
3130
        Dim dStart_y As Double = 0.0
3131
        Dim dEnd_x As Double = 0.0
3132
        Dim dEnd_y As Double = 0.0
3133
3134
        Dim sReturnUid As String = ""
3135
        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sSymbolUid + "' And " &
3136
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3137
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
3138
        If oPipeRow.Length = 0 Then
3139
            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sSymbolUid + "' And " &
3140
                                     "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3141
                                    _XML_SYMBOL_Check & "] = 'TRUE'")
3142
        Else
3143
            sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3144
            iConnType = 1
3145
        End If
3146
3147
        If oPipeRow.Length = 1 Then
3148
            If sPipeUid = "" Then
3149
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3150
                iConnType = 2
3151
            End If
3152
            sReturnUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3153
            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
3154
            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
3155
            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3156
            dStart_x = dOriginalStart_x
3157
            dStart_y = dOriginalStart_y
3158
            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3159
            dEnd_x = dOriginalEnd_x
3160
            dEnd_y = dOriginalEnd_y
3161
            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3162
            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3163
            'OPC Connection Point가져와서 연결(2018-07-12)
3164
            If iConnType = 1 Then
3165
                FindNearPoint(oLMSymbol, dStart_x, dStart_y)
3166
                objInputs.AddSymbolTarget(oLMSymbol, dStart_x, dStart_y)
3167
                objInputs.AddPoint(dEnd_x, dEnd_y)
3168
            Else
3169
                FindNearPoint(oLMSymbol, dEnd_x, dEnd_y)
3170
                objInputs.AddSymbolTarget(oLMSymbol, dEnd_x, dEnd_y)
3171
                objInputs.AddPoint(dStart_x, dStart_y)
3172
            End If
3173
            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3174
3175
            Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
3176
            Dim sSystemPath As String = GetPipeType(sType)
3177
3178
3179
3180
3181
            objItem = _Placement.PIDCreateItem(sSystemPath)
3182
            objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
3183
            oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
3184
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
3185
            If oAttributeRow.Length > 0 Then
3186
                For Each oAttribute In oAttributeRow
3187
                    Try
3188
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3189
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3190
                        If sPIDValue.Contains("'") Then
3191
                            sPIDValue = sPIDValue.Replace("'", """")
3192
                        End If
3193
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3194
                        oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
3195
                    Catch ex As Exception
3196
                    End Try
3197
                Next
3198
                oPipeRun.Commit()
3199
            End If
3200
        End If
3201
        Return sReturnUid
3202
    End Function
3203
3204
    Private Function LineToSymbol_Modeling(ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
3205
                                       ByVal sLineUid As String, ByVal oLMConnector As LMConnector, ByRef oLMSymbol As LMSymbol) As String
3206
3207
3208
        Dim oDatasource As Object = _Placement.PIDDataSource
3209
        Dim objItem As LMAItem
3210
        Dim objConnector As LMConnector
3211
        Dim objInputs As PlaceRunInputs
3212
        objInputs = New PlaceRunInputs
3213
3214
3215
        Dim sSymbolUid As String = ""
3216
        Dim iConnType As Integer = 0
3217
        Dim dOriginalPoint_x As Double = 0.0
3218
        Dim dORiginalPoint_y As Double = 0.0
3219
        Dim dX As Double = 0.0
3220
        Dim dY As Double = 0.0
3221
        Dim sReturnUid As String = ""
3222
        Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn1_Uid & " = '" + sLineUid + "' And " &
3223
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3224
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
3225
        If oSymbolRow.Length = 0 Then
3226
            oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
3227
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3228
                                                                                 _XML_SYMBOL_Check & "] = 'TRUE'")
3229
            If oSymbolRow.Length = 0 Then
3230
                oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
3231
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3232
                                                                          _XML_SYMBOL_Check & "] = 'TRUE'")
3233
                If oSymbolRow.Length = 0 Then
3234
                    oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
3235
                                                   "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
3236
                                                            _XML_SYMBOL_Check & "] = 'TRUE'")
3237
                    If oSymbolRow.Length = 0 Then
3238
3239
                    Else
3240
                        sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3241
                        iConnType = 4
3242
                    End If
3243
                Else
3244
                    sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3245
                    iConnType = 3
3246
                End If
3247
            Else
3248
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3249
                iConnType = 2
3250
            End If
3251
3252
        Else
3253
            sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3254
            iConnType = 1
3255
        End If
3256
3257
        If oSymbolRow.Length = 1 Then
3258
            If sSymbolUid = "" Then
3259
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3260
                iConnType = 2
3261
            End If
3262
            sReturnUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
3263
            Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
3264
            ConvertPointBystring(sOriginalPoint, dOriginalPoint_x, dORiginalPoint_y)
3265
            dX = dOriginalPoint_x
3266
            dY = dORiginalPoint_y
3267
            ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
3268
            'OPC Connection Point가져와서 연결(2018-07-12)
3269
3270
            oSymbolRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3271
3272
            Dim sType As String = oSymbolRow(0)(_XML_LINE_TYPE).ToString()
3273
            Dim sSystemPath As String = GetPipeType(sType)
3274
3275
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, ExistingItem:=oLMConnector.AsLMAItem,
3276
          TargetItem:=oLMSymbol.AsLMAItem)
3277
3278
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
3279
            If oAttributeRow.Length > 0 Then
3280
                For Each oAttribute In oAttributeRow
3281
                    Try
3282
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3283
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3284
                        If sPIDValue.Contains("'") Then
3285
                            sPIDValue = sPIDValue.Replace("'", """")
3286
                        End If
3287
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3288
                        oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
3289
                    Catch ex As Exception
3290
                    End Try
3291
                Next
3292
            End If
3293
        End If
3294
        Return sReturnUid
3295
    End Function
3296
3297
3298
    Private Sub OPCTOLineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oOPCSymbol As LMSymbol,
3299
                            ByVal sOPCUid As String, ByVal sLineNoUid As String)
3300
        Try
3301
            Dim oDatasource As Object = _Placement.PIDDataSource
3302
            Dim objItem As LMAItem
3303
            Dim objConnector As LMConnector
3304
            Dim objInputs As PlaceRunInputs
3305
            objInputs = New PlaceRunInputs
3306
            Dim dOriginalStart_x As Double = 0.0
3307
            Dim dOriginalStart_y As Double = 0.0
3308
            Dim dOriginalEnd_x As Double = 0.0
3309
            Dim dOriginalEnd_y As Double = 0.0
3310
            Dim dStart_x As Double = 0.0
3311
            Dim dStart_y As Double = 0.0
3312
            Dim dEnd_x As Double = 0.0
3313
            Dim dEnd_y As Double = 0.0
3314
3315
            Dim oPipeRun As LMPipeRun = Nothing
3316
            Dim sStartpoint As String = ""
3317
            Dim sEndpoint As String = ""
3318
            Dim iConnType As Integer = 0
3319
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sOPCUid + "' And [" &
3320
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
3321
            Dim sPipeUid As String = ""
3322
            If oPipeRow.Length = 0 Then
3323
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sOPCUid + "' And [" &
3324
                        _XML_SYMBOL_Check & "] = 'TRUE'")
3325
            Else
3326
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3327
                iConnType = 1
3328
            End If
3329
            Dim oAddUid_List As New List(Of String)
3330
            If oPipeRow.Length = 1 Then
3331
                If sPipeUid = "" Then
3332
                    sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
3333
                    iConnType = 2
3334
                End If
3335
                oAddUid_List.Add(sPipeUid)
3336
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
3337
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
3338
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3339
                dStart_x = dOriginalStart_x
3340
                dStart_y = dOriginalStart_y
3341
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3342
                dEnd_x = dOriginalEnd_x
3343
                dEnd_y = dOriginalEnd_y
3344
                ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3345
                ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3346
3347
                'OPC Connection Point가져와서 연결(2018-07-12)
3348
                If iConnType = 1 Then
3349
                    FindNearPoint(oOPCSymbol, dStart_x, dStart_y)
3350
                    objInputs.AddSymbolTarget(oOPCSymbol, dStart_x, dStart_y)
3351
                    objInputs.AddPoint(dEnd_x, dEnd_y)
3352
                Else
3353
                    FindNearPoint(oOPCSymbol, dEnd_x, dEnd_y)
3354
                    objInputs.AddSymbolTarget(oOPCSymbol, dEnd_x, dEnd_y)
3355 bb2a0c79 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
3356
                End If
3357
                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3358
3359
                While True
3360
                    '    objInputs.Clear()
3361
                    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
3362
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
3363
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
3364
                    If oAddPipeRow.Length = 0 Then
3365
                        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
3366
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
3367
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
3368
                        sPipeUid = ""
3369
                    Else
3370
                        iConnType = 1
3371
                        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
3372
                    End If
3373
                    If oAddPipeRow.Length = 1 Then
3374
                        If sPipeUid = "" Then
3375
                            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
3376
                            iConnType = 2
3377
                        End If
3378
                        oAddUid_List.Add(sPipeUid)
3379
                        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
3380
                        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
3381
                        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3382
                        dStart_x = dOriginalStart_x
3383
                        dStart_y = dOriginalStart_y
3384
                        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3385
                        dEnd_x = dOriginalEnd_x
3386
                        dEnd_y = dOriginalEnd_y
3387
                        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3388
                        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3389
                        If iConnType = 1 Then
3390
                            objInputs.AddPoint(dEnd_x, dEnd_y)
3391
                            ' objInputs.AddPoint(dStart_x, dStart_y)
3392
                        Else
3393
                            'objInputs.AddConnectorTarget(objConnector, dStart_x, dStart_y)
3394
                            '  objInputs.AddPoint(dStart_x, dStart_y)
3395
                            '  objInputs.AddPoint(dEnd_x, dEnd_y)
3396
                            objInputs.AddPoint(dStart_x, dStart_y)
3397
                        End If
3398 e4000111 Gyusu
3399 bb2a0c79 Gyusu
                        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3400
                    Else
3401
                        Exit While
3402
                    End If
3403 e4000111 Gyusu
3404 bb2a0c79 Gyusu
                End While
3405
                Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
3406
                Dim sSystemPath As String = GetPipeType(sType)
3407 e4000111 Gyusu
3408 bb2a0c79 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
3409
                objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
3410
                For i = 0 To oAddUid_List.Count - 1
3411
                    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
3412
                    If oUpdateRow.Length = 1 Then
3413
                        oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
3414
                        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
3415
                    End If
3416
                Next
3417
3418
3419
                oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
3420
                Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
3421
                If oAttributeRow.Length > 0 Then
3422
                    For Each oAttribute In oAttributeRow
3423
                        Try
3424
                            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3425
                            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3426
                            If sPIDValue.Contains("'") Then
3427
                                sPIDValue = sPIDValue.Replace("'", """")
3428
                            End If
3429
                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3430
                            oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
3431
                        Catch ex As Exception
3432
                        End Try
3433
                    Next
3434
                    oPipeRun.Commit()
3435
                End If
3436
3437
            End If
3438
3439
        Catch ex As Exception
3440
        End Try
3441
    End Sub
3442
3443
    Private Function AddUidList중복체크(ByVal sUidList As List(Of String), ByVal sAddUid As String) As Boolean
3444 e4000111 Gyusu
3445 bb2a0c79 Gyusu
        For Each sUid In sUidList
3446
            If sUid = sAddUid Then
3447
                Return False
3448
            End If
3449
        Next
3450
        Return True
3451
    End Function
3452
3453 b08338e3 Gyusu
    Private Sub LineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String, ByVal sLineNoText As String)
3454 bb2a0c79 Gyusu
        Try
3455
            Dim oDatasource As Object = _Placement.PIDDataSource
3456
            Dim objItem As LMAItem
3457
            Dim objConnector As LMConnector
3458
            Dim objInputs As PlaceRunInputs
3459
            objInputs = New PlaceRunInputs
3460
            Dim dOriginalStart_x As Double = 0.0
3461
            Dim dOriginalStart_y As Double = 0.0
3462
            Dim dOriginalEnd_x As Double = 0.0
3463
            Dim dOriginalEnd_y As Double = 0.0
3464
            Dim dStart_x As Double = 0.0
3465
            Dim dStart_y As Double = 0.0
3466
            Dim dEnd_x As Double = 0.0
3467
            Dim dEnd_y As Double = 0.0
3468
            Dim oPipeRun As LMPipeRun = Nothing
3469
            Dim sStartpoint As String = ""
3470
            Dim sEndpoint As String = ""
3471
            Dim iConnType As Integer = 0
3472
            Dim pLMConnector As LMConnector = Nothing
3473
            For Each oLinerow In oLine_Dt.Rows
3474
                objInputs.Clear()
3475 b08338e3 Gyusu
                Dim sCheck As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
3476
                If sCheck = "FALSE" Then
3477
                    Dim sUid As String = oLinerow(_XML_LINE_UID).ToString()
3478
                    sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
3479
                    sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
3480
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3481
                    dStart_x = dOriginalStart_x
3482
                    dStart_y = dOriginalStart_y
3483
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3484
                    dEnd_x = dOriginalEnd_x
3485
                    dEnd_y = dOriginalEnd_y
3486
                    ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3487
                    ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3488 bb2a0c79 Gyusu
3489 b08338e3 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
3490
                    objInputs.AddPoint(dEnd_x, dEnd_y)
3491 bb2a0c79 Gyusu
                    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
3492
                    Dim sSystemPath As String = GetPipeType(sType)
3493
                    objItem = _Placement.PIDCreateItem(sSystemPath)
3494
                    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
3495 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
3496
3497
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
3498
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
3499
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oLinerow(_XML_SYMBOL_Conn1_Uid).ToString())
3500
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oLinerow(_XML_SYMBOL_Conn2_Uid).ToString())
3501
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
3502
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
3503
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
3504
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
3505
3506
                    _iPipecnt = _iPipecnt + 1
3507
                    oLinerow(_XML_LINE_SPID) = objConnector.ModelItemID
3508
                    oLinerow(_XML_LINE_LMCONNECTOR) = objConnector
3509
3510
                    oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
3511 bb2a0c79 Gyusu
                    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
3512
3513
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
3514
                    If oAttributeRow.Length > 0 Then
3515
                        For Each oAttribute In oAttributeRow
3516
                            Try
3517
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3518
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3519
                                If sPIDValue.Contains("'") Then
3520
                                    sPIDValue = sPIDValue.Replace("'", """")
3521
                                End If
3522
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3523
                                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
3524
                            Catch ex As Exception
3525
                            End Try
3526
                        Next
3527
                        oPipeRun.Commit()
3528
                    End If
3529
                End If
3530
3531
3532
3533
3534
3535 b08338e3 Gyusu
                'Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString()
3536
                'Dim sCheckModeling As Boolean = False
3537
                'objInputs.Clear()
3538
                'Dim oAddUid_List As New List(Of String)
3539
                'Try
3540
                '    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
3541
                '                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
3542
                '                                            _XML_SYMBOL_Check & "] = 'TRUE'")
3543
                '    If oAddPipeRow.Length = 0 Then
3544
                '        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
3545
                '                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
3546
                '                                        _XML_SYMBOL_Check & "] = 'TRUE'")
3547
                '        sPipeUid = ""
3548
                '    Else
3549
                '        iConnType = 1
3550
                '        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
3551
                '    End If
3552
                '    If oAddPipeRow.Length = 1 Then
3553
                '        sCheckModeling = True
3554
                '        If sPipeUid = "" Then
3555
                '            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
3556
                '            iConnType = 2
3557
                '        End If
3558
                '        If AddUidList중복체크(oAddUid_List, sPipeUid) Then
3559
                '            oAddUid_List.Add(sPipeUid)
3560
                '        End If
3561
                '        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
3562
                '        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
3563
                '        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3564
                '        dStart_x = dOriginalStart_x
3565
                '        dStart_y = dOriginalStart_y
3566
                '        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3567
                '        dEnd_x = dOriginalEnd_x
3568
                '        dEnd_y = dOriginalEnd_y
3569
                '        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3570
                '        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3571
                '        Dim sBranchType As String = ""
3572
                '        If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
3573
                '            Try
3574
                '                If pLMConnector Is Nothing Then
3575
                '                    objInputs.AddPoint(dStart_x, dStart_y)
3576
                '                    objInputs.AddPoint(dEnd_x, dEnd_y)
3577
                '                Else
3578
                '                    If sBranchType = "1" Then
3579
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
3580
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
3581
                '                    ElseIf sBranchType = "2" Then
3582
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
3583
                '                        objInputs.AddPoint(dStart_x, dStart_y)
3584
                '                    ElseIf sBranchType = "3" Then
3585
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
3586
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
3587
                '                    ElseIf sBranchType = "4" Then
3588
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
3589
                '                        objInputs.AddPoint(dStart_x, dStart_y)
3590
                '                    End If
3591
                '                End If
3592
                '            Catch ex As Exception
3593
                '            End Try
3594
                '        Else
3595
                '            objInputs.AddPoint(dStart_x, dStart_y)
3596
                '            objInputs.AddPoint(dEnd_x, dEnd_y)
3597
                '        End If
3598
                '        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
3599
                '    Else
3600
                '        Dim CheckTF As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
3601
                '        Dim CheckSelect As String = oLinerow(_XML_LINE_Check).ToString()
3602
                '        If CheckTF = "FALSE" And CheckSelect = "TRUE" Then
3603
                '            sPipeUid = oLinerow(_XML_LINE_UID).ToString()
3604
                '            oAddUid_List.Clear()
3605
                '            oAddUid_List.Add(sPipeUid)
3606
                '            sCheckModeling = True
3607
                '            sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
3608
                '            sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
3609
                '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
3610
                '            dStart_x = dOriginalStart_x
3611
                '            dStart_y = dOriginalStart_y
3612
                '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
3613
                '            dEnd_x = dOriginalEnd_x
3614
                '            dEnd_y = dOriginalEnd_y
3615
                '            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
3616
                '            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
3617
                '            Dim sBranchType As String = ""
3618
                '            If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
3619
                '                Try
3620
                '                    If sBranchType = "1" Then
3621
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
3622
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
3623
                '                    ElseIf sBranchType = "2" Then
3624
                '                        objInputs.AddPoint(dStart_x, dStart_y)
3625
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
3626
                '                    ElseIf sBranchType = "3" Then
3627
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
3628
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
3629
                '                    ElseIf sBranchType = "4" Then
3630
                '                        objInputs.AddPoint(dStart_x, dStart_y)
3631
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
3632
                '                    End If
3633
                '                Catch ex As Exception
3634
3635
                '                End Try
3636
                '            Else
3637
                '                objInputs.AddPoint(dStart_x, dStart_y)
3638
                '                objInputs.AddPoint(dEnd_x, dEnd_y)
3639
                '            End If
3640
                '            oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
3641
                '        End If
3642
                '    End If
3643
                'Catch ex As Exception
3644
                'End Try
3645
                'If sCheckModeling Then
3646
                '    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
3647
                '    Dim sSystemPath As String = GetPipeType(sType)
3648
                '    objItem = _Placement.PIDCreateItem(sSystemPath)
3649
                '    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
3650
                '    For i = 0 To oAddUid_List.Count - 1
3651
                '        Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
3652
                '        If oUpdateRow.Length = 1 Then
3653
                '            oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
3654
                '            oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
3655
                '        End If
3656
                '    Next
3657
3658
                '    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
3659
                '    oAddUid_List.Clear()
3660
3661
                '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
3662
                '    If oAttributeRow.Length > 0 Then
3663
                '        For Each oAttribute In oAttributeRow
3664
                '            Try
3665
                '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3666
                '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3667
                '                If sPIDValue.Contains("'") Then
3668
                '                    sPIDValue = sPIDValue.Replace("'", """")
3669
                '                End If
3670
                '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3671
                '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
3672
                '            Catch ex As Exception
3673
                '            End Try
3674
                '        Next
3675
                '        oPipeRun.Commit()
3676
                '    End If
3677
3678
                '    If pLMConnector IsNot Nothing Then
3679
                '        Dim sID_1 As String = pLMConnector.ModelItemID
3680
                '        Dim sID_2 As String = objConnector.ModelItemID
3681
                '        Dim objSurvivorItem As LMAItem = Nothing
3682
                '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
3683
                '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
3684
                '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
3685
                '        '     oDatasource.CommitTransaction()
3686
                '        '_Placement.PIDAutoJoin(oPipeRun1.AsLMAItem, AutoJoinEndConstants.autoJoin_End, objSurvivorItem)
3687
                '        'oPipeRun1.Commit()
3688
                '        'oDatasource.CommitTransaction()
3689
                '        'objSurvivorItem = Nothing
3690
                '        '_Placement.PIDAutoJoin(oPipeRun2.AsLMAItem, AutoJoinEndConstants.autoJoin_Start, objSurvivorItem)
3691
                '        'oPipeRun2.Commit()
3692
                '        'oDatasource.CommitTransaction()
3693
                '    End If
3694
                '    sCheckModeling = False
3695
                '  End If
3696
            Next
3697 bb2a0c79 Gyusu
        Catch ex As Exception
3698
        End Try
3699
    End Sub
3700 e4000111 Gyusu
3701 b08338e3 Gyusu
3702
    Private Sub SymbolModeling(ByVal CDrawing As Drawing, ByVal oLine_DT As DataTable, ByVal oSymbolRow As DataRow, ByVal oAttribute_Dt As DataTable,
3703
                               ByVal sLineNoText As String)
3704 bb2a0c79 Gyusu
        Try
3705 b08338e3 Gyusu
3706
            Dim sCheckModeling As String = oSymbolRow(_XML_SYMBOL_DRAWING_TF).ToString()
3707
            If sCheckModeling = "FALSE" Then
3708
                Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
3709
                Dim oSymbol As LMSymbol = Nothing
3710
                Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
3711
                Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
3712 bb2a0c79 Gyusu
                Dim oDatasource As Object = _Placement.PIDDataSource
3713
                Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
3714
                Dim dLocationX As Double = 0.0
3715
                Dim dLocationY As Double = 0.0
3716
                Dim dX As Double = 0.0
3717
                Dim dY As Double = 0.0
3718 b08338e3 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
3719
                ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
3720
                dX = dLocationX
3721
                dY = dLocationY
3722
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
3723
3724
                Dim dAngle As Double = oSymbolRow(_XML_SYMBOL_ANGLE)
3725
3726
3727
                'Dim oDatarow() As DataRow = oLine_DT.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sSymbolUid & "'")
3728
                'If oDatarow.Length = 0 Then
3729
                '    oDatarow = oLine_DT.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sSymbolUid & "'")
3730
                'End If
3731
                'Dim dFix_X As Double = 0.0
3732
                'Dim dFix_Y As Double = 0.0
3733
                'If oDatarow.Length > 0 Then
3734
                '    If dAngle <> 0 Then
3735
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
3736
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
3737
3738
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
3739
                '        dX = dLocationX
3740
                '    Else
3741
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
3742
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
3743
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
3744
                '        dY = dLocationY
3745
                '    End If
3746
3747
                'End If
3748
3749
3750
3751
                oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY,, dAngle)
3752
                SetListBoxItems(ListBox_Result, "Place Fitting.." & sSymbolUid & " (" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
3753
3754
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sSymbolUid)
3755
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
3756
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
3757
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
3758
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
3759
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
3760
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
3761
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
3762
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
3763
3764
3765
                _iFittingcnt = _iFittingcnt + 1
3766
                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
3767
                Dim oAttributeRow() As DataRow
3768
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
3769
                If oAttribute_Dt.Rows.Count > 0 Then
3770
3771 bb2a0c79 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
3772 b08338e3 Gyusu
                        Dim oInstrument As LMInstrument
3773
                        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
3774 bb2a0c79 Gyusu
                        Try
3775
                            If oAttributeRow.Length > 0 Then
3776
                                For Each oAttribute In oAttributeRow
3777
                                    Try
3778
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3779
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3780
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3781
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
3782
                                    Catch ex As Exception
3783
                                    End Try
3784
                                Next
3785
                                oInstrument.Commit()
3786
                            End If
3787
                        Catch ex As Exception
3788
                        End Try
3789
                    Else
3790 b08338e3 Gyusu
                        Try
3791
                            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
3792
                                For Each oAttribute In oAttributeRow
3793
                                    Try
3794
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
3795
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
3796 e4000111 Gyusu
3797 b08338e3 Gyusu
                                        If sPIDAttribute = "SIZE" Then
3798
3799
                                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
3800
                                            If sPIDValue.Contains("x") Then
3801
                                                Dim sSplitSize() As String = sPIDValue.Split("x")
3802
                                                If sSplitSize.Count > 1 Then
3803
                                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
3804
                                                    Dim oConnector_1 As LMConnector = Nothing
3805
                                                    Dim oConnector_2 As LMConnector = Nothing
3806
                                                    If oSymbol IsNot Nothing Then
3807
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
3808
                                                            For Each Tconnector In oSymbol.Connect1Connectors
3809
                                                                If Tconnector.ItemStatus = "Active" Then
3810
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
3811
                                                                        oConnector_1 = Tconnector
3812
                                                                    End If
3813
                                                                End If
3814
                                                            Next
3815
                                                        End If
3816
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
3817
                                                            For Each Tconnector In oSymbol.Connect1Connectors
3818
                                                                If Tconnector.ItemStatus = "Active" Then
3819
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
3820
                                                                        oConnector_2 = Tconnector
3821
                                                                    End If
3822
                                                                End If
3823
                                                            Next
3824
                                                        End If
3825
                                                    End If
3826
                                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
3827
                                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
3828
                                                    If dAngle = 3.14 Then
3829
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
3830
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
3831
                                                    Else
3832
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
3833
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
3834
                                                    End If
3835 e4000111 Gyusu
3836
3837 b08338e3 Gyusu
                                                End If
3838 e4000111 Gyusu
3839 b08338e3 Gyusu
                                            Else
3840
                                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3841
                                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
3842
                                            End If
3843
                                        Else
3844
                                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
3845
                                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
3846
                                        End If
3847 e4000111 Gyusu
3848 b08338e3 Gyusu
                                    Catch ex As Exception
3849
                                    End Try
3850
                                Next
3851
                                oSymbol.Commit()
3852
                            End If
3853
                        Catch ex As Exception
3854
                        End Try
3855
                    End If
3856
                End If
3857 e4000111 Gyusu
3858
3859
3860 b08338e3 Gyusu
            End If
3861 e4000111 Gyusu
3862
3863
3864 b08338e3 Gyusu
            'Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
3865
            'Dim sConnTypeNo As String = ""
3866
            '' Line과 연결되어있는 Symbol인지 확인
3867
            'Dim oLine_Dt As DataTable = GetPipeFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
3868
            ''Symbol과 연결되어 있는 Symbol인지 확인
3869
            'Dim oSymbol_Dt As DataTable = GetSymbolFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
3870
            'Dim oSymbol As LMSymbol = Nothing
3871
            'Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
3872
            'Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
3873
            'Dim oDatasource As Object = _Placement.PIDDataSource
3874
            'Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
3875 e4000111 Gyusu
3876 b08338e3 Gyusu
            'Dim dAngle As Double = 0.0
3877
            'If IsNumeric(oSymbolRow(_XML_SYMBOL_ANGLE).ToString()) Then
3878
            '    dAngle = Double.Parse(oSymbolRow(_XML_SYMBOL_ANGLE).ToString())
3879
            'End If
3880 e4000111 Gyusu
3881 b08338e3 Gyusu
            'Dim dLocationX As Double = 0.0
3882
            'Dim dLocationY As Double = 0.0
3883
            'Dim dX As Double = 0.0
3884
            'Dim dY As Double = 0.0
3885
            'Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
3886
            'ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
3887
            'dX = dLocationX
3888
            'dY = dLocationY
3889
            'ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
3890
            'Dim bCheckModeling As Boolean = False
3891
3892
            'If oLine_Dt.Rows.Count > 0 Then
3893
3894
            '    If sSPID <> "" Then
3895
            '        Dim dX1 As Double = 0
3896
            '        Dim dX2 As Double = 0
3897
            '        Dim dY1 As Double = 0
3898
            '        Dim dY2 As Double = 0
3899
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
3900
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3901
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3902
3903
            '        Dim dCalcPoint As Double = -1
3904
            '        Dim dModeling_X As Double = 0
3905
            '        Dim dModeling_Y As Double = 0
3906
            '        If dX1 <> 0 And dY1 <> 0 Then
3907
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
3908
            '            dModeling_X = dX1
3909
            '            dModeling_Y = dY1
3910
            '        End If
3911
            '        If dX2 <> 0 And dY2 <> 0 Then
3912 e4000111 Gyusu
3913 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
3914
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
3915
            '                dModeling_X = dX2
3916
            '                dModeling_Y = dY2
3917
            '            End If
3918
            '        End If
3919 e4000111 Gyusu
3920
3921
3922 b08338e3 Gyusu
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
3923
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
3924
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
3925
            '            bCheckModeling = True
3926
            '        End If
3927 e4000111 Gyusu
3928
3929 b08338e3 Gyusu
            '    End If
3930
            'End If
3931
            'If oSymbol_Dt.Rows.Count > 0 Then
3932
            '    If sSPID <> "" Then
3933
            '        Dim dX1 As Double = 0
3934
            '        Dim dX2 As Double = 0
3935
            '        Dim dX3 As Double = 0
3936
            '        Dim dX4 As Double = 0
3937
            '        Dim dY1 As Double = 0
3938
            '        Dim dY2 As Double = 0
3939
            '        Dim dY3 As Double = 0
3940
            '        Dim dY4 As Double = 0
3941
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
3942
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3943
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3944
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 3, dX3, dY3)
3945
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 4, dX4, dY4)
3946
3947
            '        Dim dCalcPoint As Double = -1
3948
            '        Dim dModeling_X As Double = 0
3949
            '        Dim dModeling_Y As Double = 0
3950
            '        If dX1 <> 0 And dY1 <> 0 Then
3951
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
3952
            '            dModeling_X = dX1
3953
            '            dModeling_Y = dY1
3954
            '        End If
3955
            '        If dX2 <> 0 And dY2 <> 0 Then
3956 41e4023e Gyusu
3957 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
3958
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
3959
            '                dModeling_X = dX2
3960
            '                dModeling_Y = dY2
3961
            '            End If
3962
            '        End If
3963
            '        If dX3 <> 0 And dY3 <> 0 Then
3964
            '            If (Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY) > dCalcPoint) Then
3965
            '                dCalcPoint = Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY)
3966
            '                dModeling_X = dX3
3967
            '                dModeling_Y = dY3
3968
            '            End If
3969
            '        End If
3970
            '        If dX4 <> 0 And dY4 <> 0 Then
3971
            '            If (Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY) > dCalcPoint) Then
3972
            '                dCalcPoint = Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY)
3973
            '                dModeling_X = dX4
3974
            '                dModeling_Y = dY4
3975
            '            End If
3976
            '        End If
3977
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
3978
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
3979
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
3980
            '            bCheckModeling = True
3981
            '        End If
3982 41e4023e Gyusu
3983 e4000111 Gyusu
3984 b08338e3 Gyusu
            '    End If
3985 e4000111 Gyusu
3986 b08338e3 Gyusu
            'End If
3987 e4000111 Gyusu
3988 b08338e3 Gyusu
            'If (oLine_Dt.Rows.Count = 0 And oSymbol_Dt.Rows.Count = 0) Or bCheckModeling = False Then
3989
            '    oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
3990
            '    SetListBoxItems(ListBox_Result, "Place Fittings..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
3991
            '    _iFittingcnt = _iFittingcnt + 1
3992
            'End If
3993
            'Dim oAttributeRow() As DataRow
3994
            'oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
3995
            'If oAttribute_Dt.Rows.Count > 0 Then
3996
3997
            '    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
3998
            '        Dim oInstrument As LMInstrument
3999
            '        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
4000
            '        Try
4001
            '            If oAttributeRow.Length > 0 Then
4002
            '                For Each oAttribute In oAttributeRow
4003
            '                    Try
4004
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4005
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4006
            '                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4007
            '                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
4008
            '                    Catch ex As Exception
4009
            '                    End Try
4010
            '                Next
4011
            '                oInstrument.Commit()
4012
            '            End If
4013
            '        Catch ex As Exception
4014
            '        End Try
4015
            '    Else
4016
            '        Try
4017
            '            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
4018
            '                For Each oAttribute In oAttributeRow
4019
            '                    Try
4020
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4021
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4022
4023
            '                        If sPIDAttribute = "SIZE" Then
4024
4025
            '                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
4026
            '                            If sPIDValue.Contains("x") Then
4027
            '                                Dim sSplitSize() As String = sPIDValue.Split("x")
4028
            '                                If sSplitSize.Count > 1 Then
4029
            '                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
4030
            '                                    Dim oConnector_1 As LMConnector = Nothing
4031
            '                                    Dim oConnector_2 As LMConnector = Nothing
4032
            '                                    If oSymbol IsNot Nothing Then
4033
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
4034
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
4035
            '                                                If Tconnector.ItemStatus = "Active" Then
4036
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
4037
            '                                                        oConnector_1 = Tconnector
4038
            '                                                    End If
4039
            '                                                End If
4040
            '                                            Next
4041
            '                                        End If
4042
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
4043
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
4044
            '                                                If Tconnector.ItemStatus = "Active" Then
4045
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
4046
            '                                                        oConnector_2 = Tconnector
4047
            '                                                    End If
4048
            '                                                End If
4049
            '                                            Next
4050
            '                                        End If
4051
            '                                    End If
4052
            '                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
4053
            '                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
4054
            '                                    If dAngle = 3.14 Then
4055
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
4056
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
4057
            '                                    Else
4058
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
4059
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
4060
            '                                    End If
4061
4062
4063
            '                                End If
4064
4065
            '                            Else
4066
            '                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4067
            '                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
4068
            '                            End If
4069
            '                        Else
4070
            '                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4071
            '                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
4072
            '                        End If
4073
4074
            '                    Catch ex As Exception
4075
            '                    End Try
4076
            '                Next
4077
            '                oSymbol.Commit()
4078
            '            End If
4079
            '        Catch ex As Exception
4080
            '        End Try
4081
            '    End If
4082
            'End If
4083
        Catch ex As Exception
4084
        End Try
4085
    End Sub
4086 e4000111 Gyusu
4087
4088
4089
    Private Function AutoModeling() As Boolean
4090
        Try
4091
            _CompleteConvert = False
4092
            Label_Progress.Text = "0%"
4093
            SetListBoxItems(ListBox_Result, " Auto converting 시작....")
4094 b08338e3 Gyusu
4095
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 시작....")
4096 e4000111 Gyusu
            Dim oDwg_Dt As DataTable = LoadAllDrawing()
4097 b08338e3 Gyusu
            _Log_File = "AutoConverting_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss")
4098 e4000111 Gyusu
            _allItem = GetAllCheckNodeCount()
4099
            '1.Equipment
4100
            '2.Piping OPC
4101
            '3.OPC 시작되는 Line
4102 bb2a0c79 Gyusu
            InitAutoRouting()
4103 e4000111 Gyusu
            EquipmentModeling(oDwg_Dt)
4104 bb2a0c79 Gyusu
            PipingModeling()
4105
4106
            '   PipeLine_Fitting_Modeling()
4107 e4000111 Gyusu
4108 171ac39d Gyusu
            SetProgressbar(ProgressBar_Status, 100)
4109 41e4023e Gyusu
            Label_Progress.Text = "100%"
4110 171ac39d Gyusu
            SetListBoxItems(ListBox_Result, " Auto converting 완료")
4111 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 완료")
4112 54b98e09 Gyusu
            _CompleteConvert = True
4113 171ac39d Gyusu
            Return True
4114
        Catch ex As Exception
4115
            Return False
4116
        End Try
4117
    End Function
4118
4119
4120
4121 54b98e09 Gyusu
    Private Sub ThreadConvert()
4122 559daf6d Gyusu
        If _DrawingsList IsNot Nothing Then
4123
            If _DrawingsList.Count > 0 Then
4124
                AutoModeling()
4125
            End If
4126 171ac39d Gyusu
        End If
4127 e282643f Gyusu
    End Sub
4128
4129 54b98e09 Gyusu
    Private Sub ThreadOPCRemove()
4130
        While _CompleteConvert = False
4131
            Dim oFindOPC As New FindOpc
4132
            oFindOPC.RemoveOPCDlg()
4133
        End While
4134 e282643f Gyusu
4135 54b98e09 Gyusu
    End Sub
4136 171ac39d Gyusu
4137 e282643f Gyusu
4138
    Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String
4139
        Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'")
4140
        Dim oPath As String = ""
4141
        If oRows.Length > 0 Then
4142
            oPath = oRows(0).Item("Path").ToString()
4143
        End If
4144
        Return oPath
4145
    End Function
4146
4147 272662f9 Gyusu
    Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click
4148 171ac39d Gyusu
        If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
4149 54b98e09 Gyusu
            LoadDB()
4150 171ac39d Gyusu
            LoadXmlItem(FolderBrowserDialog1.SelectedPath)
4151
        End If
4152
    End Sub
4153
    Private Sub LoadXmlItem(ByVal sFolderPath As String)
4154
        _DrawingsList = New List(Of Drawing)
4155
        Dim sfileEntries As String() = Directory.GetFiles(sFolderPath)
4156
        If Tree_Result.Nodes.Count > 0 Then
4157
            Tree_Result.Nodes(0).Nodes.Clear()
4158
            For Each sfileName In sfileEntries
4159
                Dim sExtension As String = Path.GetExtension(sfileName)
4160
                If sExtension = ".xml" Then
4161
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName)
4162
                    Dim sDwgPath As String = sfileName
4163
                    Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15)
4164
                    Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode)
4165 bb2a0c79 Gyusu
4166 171ac39d Gyusu
                    _DrawingsList.Add(oDwg)
4167
                End If
4168
            Next
4169
            Tree_Result.Nodes(0).Expand()
4170
        End If
4171
    End Sub
4172 272662f9 Gyusu
4173 e4000111 Gyusu
    Private Sub GenerateRelation(ByRef oDwg_Ds As Drawing)
4174
        Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
4175
        Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
4176
        Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
4177
        Dim oRelation As New GenerateRelation()
4178
        For Each oLinelist In oLineLists
4179 bb2a0c79 Gyusu
            oRelation.CalcLineConnectionItem_Equal(oLinelist.Dt_Line, oLineLists)
4180
            oRelation.CalcLineConnectionItem_NonEqual(oLinelist.Dt_Line, oLineLists)
4181
            oRelation.CalcSymbolConnectionItem_Equal(oLinelist.Dt_Symbol, oLineLists)
4182
            oRelation.CalcSymbolConnectionItem_NonEqual(oLinelist.Dt_Symbol, oLineLists)
4183 e4000111 Gyusu
        Next
4184
    End Sub
4185
4186
4187 20c84e05 Gyusu
    ''' <summary>
4188
    '''  XML Tree 구조 생성 
4189
    ''' </summary>
4190
    ''' <param name="sDwgPath"></param>
4191 171ac39d Gyusu
    Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing
4192
        Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath)
4193 e4000111 Gyusu
4194 b08338e3 Gyusu
        '  GenerateRelation(oDwg_Ds)
4195 e4000111 Gyusu
4196 54b98e09 Gyusu
        If oDwg_Ds IsNot Nothing Then
4197
            Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
4198
4199
            Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
4200 3acffcee Gyusu
4201
            Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
4202
4203 54b98e09 Gyusu
            Dim oPipe As Boolean = False
4204
            Dim oFitting As Boolean = False
4205
            'PipeLine 구분
4206
4207
            For Each oLinelist In oLineLists
4208
                Dim sLineNoUid As String = oLinelist.Uid
4209
                Dim sLineNo As String = oLinelist.Text
4210
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
4211
                For Each oLineRow In oLinelist.Dt_Line.Rows
4212
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
4213
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
4214
                    oPipeNode.Tag = sLineNoUid
4215
                Next
4216
                For Each oSymbolRow In oLinelist.Dt_Symbol.Rows
4217
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
4218
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
4219
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
4220
                    oSymbolNode.Tag = sLineNoUid
4221
                Next
4222
            Next
4223 3acffcee Gyusu
4224 54b98e09 Gyusu
            For Each oEqplist In oEqpLists
4225
                Dim sEqpUid As String = oEqplist.Uid
4226
                Dim sEqpNo As String = "EQUIPMENT"
4227
                Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo)
4228 d039e347 Gyusu
4229 54b98e09 Gyusu
4230
                For Each oSymbolRow In oEqplist.Dt_Equipment.Rows
4231
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
4232
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
4233
                    Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName)
4234
                    oSymbolNode.Tag = sEqpUid
4235
                Next
4236 171ac39d Gyusu
            Next
4237 3acffcee Gyusu
            Dim sTrimLine As String = "TrimLineNos"
4238
            Dim iTrimLinecnt As Integer = 1
4239
            For Each oTrimLinelist In oTrimLineLists
4240
                Dim sLineNoUid As String = oTrimLinelist.Uid
4241
                Dim sLineNo As String = sTrimLine & "_" & iTrimLinecnt
4242
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
4243
                For Each oLineRow In oTrimLinelist.Dt_Line.Rows
4244
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
4245
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
4246
                    oPipeNode.Tag = sLineNoUid
4247
                Next
4248
                For Each oSymbolRow In oTrimLinelist.Dt_Symbol.Rows
4249
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
4250
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
4251
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
4252
                    oSymbolNode.Tag = sLineNoUid
4253
                Next
4254
                iTrimLinecnt = iTrimLinecnt + 1
4255
            Next
4256
4257 54b98e09 Gyusu
        End If
4258
4259 171ac39d Gyusu
        Return oDwg_Ds
4260
    End Function
4261 272662f9 Gyusu
    Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck
4262
        If e.Node.Checked = True Then
4263
            For Each oNode As TreeNode In e.Node.Nodes
4264
                oNode.Checked = True
4265
            Next
4266
        Else
4267
            For Each oNode As TreeNode In e.Node.Nodes
4268
                oNode.Checked = False
4269
            Next
4270
        End If
4271
    End Sub
4272 171ac39d Gyusu
4273 559daf6d Gyusu
    Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click
4274
        Dim oSettings As Settings = New Settings()
4275
        oSettings.ShowDialog()
4276
    End Sub
4277 42c0013c Gyusu
4278
    Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click
4279
4280
        Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11"
4281
        Dim objVessel As LMVessel
4282
        objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID)
4283
        Dim oVesselLocation As LMLocations = objVessel.Locations
4284
        Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id)
4285
        Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value
4286
        Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value
4287
        symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01
4288
        symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01
4289
        symVessel.Commit()
4290
        Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0"
4291
        Dim objValve As LMSymbol
4292
        Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID)
4293
4294
        objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id)
4295
        objValve.Commit()
4296
        Dim dVesselX As Double = XCoordinate
4297
        Dim dVesselY As Double = YCoordinate
4298
        Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double
4299
4300
        _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1)
4301
4302
        _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2)
4303
4304
        Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym"
4305
        Dim dCalc_x As Double = 0
4306
        Dim dCalc_y As Double = 0
4307
4308
        If dVesselX - X2 > 0 Then
4309
            dCalc_x = dVesselX - (dVesselX - X2)
4310
        Else
4311
            dCalc_x = dVesselX + (X2 - dVesselX)
4312
        End If
4313
        If dVesselY - Y2 > 0 Then
4314
            dCalc_y = dVesselY - (dVesselY - Y2)
4315
        Else
4316
            dCalc_y = dVesselY + (Y2 - dVesselY)
4317
        End If
4318
4319
        Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y,
4320
            TargetItem:=symVessel.AsLMRepresentation)
4321
4322
        Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1)
4323
        blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1)
4324
4325
        objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem,
4326
          TargetItem:=objNozzle.AsLMRepresentation)
4327
4328
4329
4330
    End Sub
4331 39d43554 Gyusu
4332
    Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click
4333
        Dim oMapping As New Mapping(_PIDSymbol_DB)
4334
        oMapping.Show()
4335
    End Sub
4336 41e4023e Gyusu
4337
    Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click
4338
        Try
4339
            SetListBoxItems(ListBox_Result, " Auto converting 중지....")
4340 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 중지....")
4341 41e4023e Gyusu
            _Main_trd.Abort()
4342
            _Opc_trd.Abort()
4343
        Catch ex As Exception
4344
4345
        End Try
4346
    End Sub
4347 b08338e3 Gyusu
4348
    Private Sub AutoCheckTreeNode(ByVal iType As Integer, ByVal bCheck As Boolean)
4349
4350
        For Each oDrwing As TreeNode In Tree_Result.Nodes
4351
            For Each oDwgNode As TreeNode In oDrwing.Nodes
4352
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
4353
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
4354
                If CDrawing IsNot Nothing Then
4355
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
4356
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
4357
                    For Each oNode As TreeNode In oDwgNode.Nodes
4358
                        Dim iItemcnt As Integer = 0
4359
                        Dim sNodeUid As String = oNode.Name
4360
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
4361
4362
                        If iType = 0 Then 'Symbol
4363
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
4364
                            If CLineNo IsNot Nothing Then
4365
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
4366
                                For Each oSymbolRow In oSymbol_Dt.Rows
4367
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
4368
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
4369
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
4370
                                        If sSymbolNodeUid = sSymbolUid Then
4371
                                            oSymbolNode.Checked = bCheck
4372
                                            Exit For
4373
                                        End If
4374
                                    Next
4375
                                Next
4376
                            End If
4377
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
4378
                            If TrimLineNo IsNot Nothing Then
4379
                                Dim oSymbol_Dt As DataTable = TrimLineNo.Dt_Symbol
4380
                                For Each oSymbolRow In oSymbol_Dt.Rows
4381
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
4382
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
4383
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
4384
                                        If sSymbolNodeUid = sSymbolUid Then
4385
                                            oSymbolNode.Checked = bCheck
4386
                                            Exit For
4387
                                        End If
4388
                                    Next
4389
                                Next
4390
                            End If
4391
                        End If
4392
                        If iType = 1 Then 'Line
4393
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
4394
                            If CLineNo IsNot Nothing Then
4395
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
4396
                                For Each oLineRow In oLine_Dt.Rows
4397
                                    Dim sLineUid As String = oLineRow(_XML_LINE_UID).ToString()
4398
                                    For Each oLineNode As TreeNode In oNode.Nodes
4399
                                        Dim sLineNodeUid As String = oLineNode.Name
4400
                                        If sLineNodeUid = sLineUid Then
4401
                                            oLineNode.Checked = bCheck
4402
                                            Exit For
4403
                                        End If
4404
                                    Next
4405
                                Next
4406
                            End If
4407
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
4408
                            If TrimLineNo IsNot Nothing Then
4409
                                Dim oLine_Dt As DataTable = TrimLineNo.Dt_Line
4410
                                For Each oLineRow In oLine_Dt.Rows
4411
                                    Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID).ToString()
4412
                                    For Each oLineNode As TreeNode In oNode.Nodes
4413
                                        Dim sLineNodeUid As String = oLineNode.Name
4414
                                        If sLineNodeUid = sLineUid Then
4415
                                            oLineNode.Checked = bCheck
4416
                                            Exit For
4417
                                        End If
4418
                                    Next
4419
                                Next
4420
                            End If
4421
                        End If
4422
                        If iType = 2 Then 'Equipment
4423
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
4424
                            If CEqpNo IsNot Nothing Then
4425
                                Dim oEqp_Dt As DataTable = CEqpNo.Dt_Equipment
4426
                                For Each oEqpRow In oEqp_Dt.Rows
4427
                                    Dim sEqpUid As String = oEqpRow(_XML_LINE_UID).ToString()
4428
                                    For Each oEqpNode As TreeNode In oNode.Nodes
4429
                                        Dim sEqpNodeUid As String = oEqpNode.Name
4430
                                        If sEqpNodeUid = sEqpUid Then
4431
                                            oEqpNode.Checked = bCheck
4432
                                            Exit For
4433
                                        End If
4434
                                    Next
4435
                                Next
4436
                            End If
4437
                        End If
4438
                    Next
4439
                End If
4440
            Next
4441
        Next
4442
4443
4444
    End Sub
4445
4446
4447
4448
    Private Sub Chk_Symbol_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Symbol.CheckedChanged
4449
        AutoCheckTreeNode(0, Chk_Symbol.Checked)
4450
    End Sub
4451
4452
    Private Sub Chk_Line_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Line.CheckedChanged
4453
        AutoCheckTreeNode(1, Chk_Line.Checked)
4454
    End Sub
4455
4456
    Private Sub Chk_Equipment_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Equipment.CheckedChanged
4457
        AutoCheckTreeNode(2, Chk_Equipment.Checked)
4458
    End Sub
4459 e282643f Gyusu
End Class
4460
4461
4462
Public Class DrawingInfo
4463
    Public mDrawingName As String
4464
    Public mSpID As String
4465
    Public mPath As String
4466 4f359afa Gyusu
End Class
4467 e282643f Gyusu
4468
4469
4470
클립보드 이미지 추가 (최대 크기: 500 MB)