프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter / Main.vb @ 33cff95d

이력 | 보기 | 이력해설 | 다운로드 (305 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 76f465d0 Gyusu
    Dim _AllLine_DT As New DataTable()
19
    Dim _AllSymbol_DT As New DataTable()
20 e4000111 Gyusu
21 4f359afa Gyusu
    Dim _Placement As New Placement
22 e4000111 Gyusu
    Dim _DWG_X = 0.875 '0.695 '1 '
23
    Dim _DWG_Y = 0.617 '0.585 '0.8 '
24 c2c36314 Gyusu
    'Dim _DWG_X = 0.842 '0.695 '1 '
25
    'Dim _DWG_Y = 0.614 '0.585 '0.8 '
26 171ac39d Gyusu
    Dim _IMG_X = 0
27
    Dim _IMG_Y = 0
28
29
    Dim _Unit As String
30 4f359afa Gyusu
31 31d47a80 Gyusu
    'Drawing 전역변수
32
    Dim _objPIDADrawing As Object
33 e282643f Gyusu
    '현재선택한 폴더경로
34
    Dim _selectFolderPath As String
35
36
    Private _Main_trd As Thread
37 54b98e09 Gyusu
    Private _Opc_trd As Thread
38
39
    Private _CompleteConvert As Boolean = False
40 e282643f Gyusu
41 171ac39d Gyusu
    Private _DrawingsList As List(Of Drawing)
42 272662f9 Gyusu
43
44 9e1e7135 Gyusu
    Private _iPipeLineNocnt As Integer
45
    Private _iPipecnt As Integer
46
    Private _iFittingcnt As Integer
47
    Private _iValvecnt As Integer
48
    Private _iInstrumentcnt As Integer
49
    Private _iEquipmentcnt As Integer
50
    Private _iNozzlecnt As Integer
51 e4000111 Gyusu
    Private _iPipintOpccnt As Integer
52 9e1e7135 Gyusu
53 41e4023e Gyusu
    Private _allItem As Integer
54
    Private _Itemcnt As Integer
55 b08338e3 Gyusu
56
    Dim _Gembox As New CGembox()
57 4f359afa Gyusu
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
58 54b98e09 Gyusu
        LoadDB()
59
    End Sub
60 272662f9 Gyusu
61 54b98e09 Gyusu
    Private Sub LoadDB()
62 e282643f Gyusu
        If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then
63
            Dim sDBPath As String = My.Settings.DBPath
64 54b98e09 Gyusu
65
            _Gembox.isLoadFile(My.Settings.SymbolLibrary)
66
            _Mapping_DB = _Gembox.LoadFileFunc()
67 171ac39d Gyusu
            _Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE)
68 39d43554 Gyusu
            _PIDSymbol_DB = Load_DB(sDBPath, _DB_TABLE_SYMBOLNAME)
69 e4000111 Gyusu
            _ResultModeling_DT = ModelingResult_Dt()
70 e282643f Gyusu
        Else
71
            MessageBox.Show("설정값을 먼저 확인해주세요")
72
        End If
73
    End Sub
74 41e4023e Gyusu
75 1229ad76 Gyusu
76 171ac39d Gyusu
    Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String
77
        Dim sValue As String = ""
78 54b98e09 Gyusu
        For Each oDt As DataTable In _Mapping_DB.Tables
79
            If oDt.Rows.Count > 0 Then
80
                Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'")
81
                If oSelectRow.Length = 1 Then
82
                    If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then
83
                        sValue = oSelectRow(0).Item("SYM FILE NAME").ToString()
84
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH Then
85
                        sValue = "\" & oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
86
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_COMPTPYE Then
87
                        sValue = oSelectRow(0).Item("ITEM TYPE").ToString()
88
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_CLASS Then
89
                        sValue = oSelectRow(0).Item("CLASS").ToString()
90
                    Else
91
                        sValue = oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
92
                    End If
93
                End If
94 e282643f Gyusu
            End If
95 54b98e09 Gyusu
        Next
96 171ac39d Gyusu
        Return sValue
97 4f359afa Gyusu
    End Function
98
99 171ac39d Gyusu
    Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String
100
        Dim sSPPIDAttribute As String = ""
101
        If _Attribute_DB.Rows.Count > 0 Then
102
            Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'")
103
            If oSelectRow.Length = 1 Then
104
                sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString()
105
            End If
106
        End If
107
        Return sSPPIDAttribute
108
    End Function
109 e282643f Gyusu
110 6a6d8ab4 Gyusu
111
112 171ac39d Gyusu
    Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing
113 54b98e09 Gyusu
        Try
114
            ''  _TempSymbolDt = Symbol_Dt()
115
            Dim CDrawing As Drawing = New Drawing()
116
            Dim oDt As DataTable = LoadSymbol_DT()
117
            Dim oElement As XElement = XElement.Load(sXmlPath)
118 6a6d8ab4 Gyusu
119 54b98e09 Gyusu
            If oElement IsNot Nothing Then
120
                CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value
121
                CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value
122
                SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y)
123
                CDrawing.Unit = oElement.Element(_XML_UNIT).Value
124 171ac39d Gyusu
125 54b98e09 Gyusu
                Dim oLineno_list As New List(Of Line_no)
126
                Dim oEqp_list As New List(Of Eqp_no)
127 3acffcee Gyusu
                Dim oTrim_Lineno_list As New List(Of Line_no)
128
                oLineno_list = LoadLineNo(oElement, _XML_CATEGORY_LINENO)
129 54b98e09 Gyusu
                For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT)
130
                    Dim CEqp_no As Eqp_no = New Eqp_no()
131
                    Dim oSymbol_Dt As DataTable = Symbol_Dt()
132
                    Dim oAttribute_Dt As DataTable = Attribute_Dt()
133 b08338e3 Gyusu
                    Dim sUid As String = ""
134 54b98e09 Gyusu
                    For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL)
135
                        Try
136 b08338e3 Gyusu
                            Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
137 54b98e09 Gyusu
                            Dim oEleObj As XElement
138
                            Dim sName As String
139
                            Dim sLocation As String
140
                            Dim sSize As String
141
                            Dim sAngle As String
142 b08338e3 Gyusu
                            Dim sOriginalPoint As String = ""
143 e4000111 Gyusu
                            Dim sConnectionPoint As String = ""
144 b08338e3 Gyusu
                            Dim sConnectionUids As String = ""
145
                            Dim sConnArray As String()
146
                            Dim sConnPointArray As String()
147
148 54b98e09 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
149
                            sUid = oEleObj.Value
150
                            oEleObj = oSymbol.Element(_XML_SYMBOL_NAME)
151
                            sName = oEleObj.Value
152
                            oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
153
                            sLocation = oEleObj.Value
154
                            oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
155
                            sSize = oEleObj.Value
156
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
157
                            sAngle = oEleObj.Value
158 e4000111 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
159
                            sConnectionPoint = oEleObj.Value
160 b08338e3 Gyusu
                            sConnPointArray = sConnectionPoint.Split("/")
161
162 f9b63682 Gyusu
                            If sConnPointArray.Length > 4 Then
163
                                MessageBox.Show(sConnPointArray.Length)
164
                            End If
165
                            For i = 0 To sConnPointArray.Length - 1
166
                                If i = 0 Then
167
                                    oAddrow(_XML_SYMBOL_Conn1_Point) = sConnPointArray(i)
168
                                ElseIf i = 1 Then
169
                                    oAddrow(_XML_SYMBOL_Conn2_Point) = sConnPointArray(i)
170
                                ElseIf i = 2 Then
171
                                    oAddrow(_XML_SYMBOL_Conn3_Point) = sConnPointArray(i)
172
                                ElseIf i = 3 Then
173
                                    oAddrow(_XML_SYMBOL_Conn4_Point) = sConnPointArray(i)
174
                                End If
175
                            Next
176 b08338e3 Gyusu
177
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNS)
178
                            sConnectionUids = oEleObj.Value
179
                            sConnArray = sConnectionUids.Split(",")
180 54b98e09 Gyusu
                            Try
181
                                oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
182
                                sOriginalPoint = oEleObj.Value
183
                            Catch ex As Exception
184
                            End Try
185 b08338e3 Gyusu
186
187
188 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_UID) = sUid
189 b08338e3 Gyusu
                            oAddrow(_XML_SYMBOL_LINENOUID) = sUid
190 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_NAME) = sName
191
                            oAddrow(_XML_SYMBOL_LOCATION) = sLocation
192
                            oAddrow(_XML_SYMBOL_SIZE) = sSize
193
                            oAddrow(_XML_SYMBOL_ANGLE) = sAngle
194
                            oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
195
                            oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
196
                            oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
197 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
198 f9b63682 Gyusu
199 b08338e3 Gyusu
                            If sConnArray.Length > 4 Then
200
                                MessageBox.Show(sConnArray.Length)
201
                            End If
202
                            For i = 0 To sConnArray.Length - 1
203
                                If i = 0 Then
204
                                    oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
205
                                ElseIf i = 1 Then
206
                                    oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
207
                                ElseIf i = 2 Then
208
                                    oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
209
                                ElseIf i = 3 Then
210
                                    oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
211
                                End If
212
                            Next
213
214 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
215 54b98e09 Gyusu
                            oSymbol_Dt.Rows.Add(oAddrow)
216
                        Catch ex As Exception
217
218
                        End Try
219 d039e347 Gyusu
                    Next
220 54b98e09 Gyusu
                    For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE)
221
                        Try
222
                            Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
223
                            Dim oEleObj As XElement
224 41e4023e Gyusu
                            Dim sAttUid As String
225 54b98e09 Gyusu
                            Dim sName As String
226
                            Dim sValue As String
227
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
228 41e4023e Gyusu
                            sAttUid = oEleObj.Value
229 54b98e09 Gyusu
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
230
                            sName = oEleObj.Value
231
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
232
                            sValue = oEleObj.Value
233 41e4023e Gyusu
                            oAddrow(_XML_ATTRIBUTE_UID) = sAttUid
234 54b98e09 Gyusu
                            oAddrow(_XML_ATTRIBUTE_NAME) = sName
235
                            oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
236
                            oAttribute_Dt.Rows.Add(oAddrow)
237
                        Catch ex As Exception
238
                        End Try
239
                    Next
240 41e4023e Gyusu
                    CEqp_no.Uid = sUid
241 54b98e09 Gyusu
                    CEqp_no.Dt_Equipment = oSymbol_Dt
242
                    CEqp_no.Dt_Attribute = oAttribute_Dt
243
                    oEqp_list.Add(CEqp_no)
244 4f359afa Gyusu
                Next
245 3acffcee Gyusu
                oTrim_Lineno_list = LoadLineNo(oElement, _XML_CATEGORY_TRIM_LINENO)
246 54b98e09 Gyusu
                CDrawing.Line_nos = oLineno_list
247
                CDrawing.Eqp_nos = oEqp_list
248 3acffcee Gyusu
                CDrawing.TrimLine_nos = oTrim_Lineno_list
249
250 54b98e09 Gyusu
            End If
251
            Return CDrawing
252
        Catch ex As Exception
253
            Return Nothing
254
        End Try
255
256 4f359afa Gyusu
    End Function
257
258 76f465d0 Gyusu
    Private Function FindConnection(ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal sUid As String, ByVal dPos_x As Double, ByVal dPos_y As Double) As String
259
260
        Dim sReturnUid As String = ""
261
        Try
262
            Dim oFindLineRow As DataRow() = oLine_Dt.Select(
263
            "[" & _XML_LINE_DWG_STARTPOINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
264
            "[" & _XML_LINE_DWG_STARTPOINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
265
            "[" & _XML_LINE_DWG_STARTPOINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
266
            "[" & _XML_LINE_DWG_STARTPOINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
267
            "[" & _XML_LINE_UID & "] <> '" & sUid & "' And " &
268
            "[" & _XML_LINE_Conn1_Uid & "] = ''")
269
            If oFindLineRow.Length = 0 Then
270
                oFindLineRow = oLine_Dt.Select(
271
                "[" & _XML_LINE_DWG_ENDPOINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
272
                "[" & _XML_LINE_DWG_ENDPOINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
273
                "[" & _XML_LINE_DWG_ENDPOINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
274
                "[" & _XML_LINE_DWG_ENDPOINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
275
                "[" & _XML_LINE_UID & "] <> '" & sUid & "' And " &
276
                "[" & _XML_LINE_Conn2_Uid & "] = ''")
277
                If oFindLineRow.Length = 0 Then
278
                    oFindLineRow = oSymbol_Dt.Select(
279
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
280
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
281
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
282
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
283
              "[" & _XML_SYMBOL_UID & "] <> '" & sUid & "' And " &
284
              "[" & _XML_SYMBOL_Conn1_Uid & "] = ''")
285
                    If oFindLineRow.Length = 0 Then
286
                        oFindLineRow = oSymbol_Dt.Select(
287
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
288
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
289
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
290
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
291
                   "[" & _XML_SYMBOL_UID & "] <> '" & sUid & "' And " &
292
                   "[" & _XML_SYMBOL_Conn2_Uid & "] = ''")
293
                        If oFindLineRow.Length = 0 Then
294
                        Else
295
                            oFindLineRow(0)(_XML_SYMBOL_Conn2_Uid) = sUid
296
                            sReturnUid = oFindLineRow(0)(_XML_SYMBOL_UID).ToString()
297
                        End If
298
                    Else
299
                        oFindLineRow(0)(_XML_SYMBOL_Conn1_Uid) = sUid
300
                        sReturnUid = oFindLineRow(0)(_XML_SYMBOL_UID).ToString()
301
                    End If
302
                Else
303
                    oFindLineRow(0)(_XML_LINE_Conn2_Uid) = sUid
304
                    sReturnUid = oFindLineRow(0)(_XML_LINE_UID).ToString()
305
                End If
306
            Else
307
                oFindLineRow(0)(_XML_LINE_Conn1_Uid) = sUid
308
                sReturnUid = oFindLineRow(0)(_XML_LINE_UID).ToString()
309
            End If
310
        Catch ex As Exception
311
312
        End Try
313
314
        Return sReturnUid
315
    End Function
316
317
318
    Private Function SetConnectionInfo(ByRef oLine_Dt As DataTable, ByRef oSymbol_Dt As DataTable)
319
        Try
320
            For Each oLineInfo In oLine_Dt.Rows
321
                Dim sLineUid As String = oLineInfo(_XML_LINE_UID).ToString()
322
                Dim dStartPos_x As Double = oLineInfo(_XML_LINE_DWG_STARTPOINT_X)
323
                Dim dStartPos_y As Double = oLineInfo(_XML_LINE_DWG_STARTPOINT_Y)
324
                Dim dEndPos_x As Double = oLineInfo(_XML_LINE_DWG_ENDPOINT_X)
325
                Dim dEndPos_y As Double = oLineInfo(_XML_LINE_DWG_ENDPOINT_Y)
326
                Dim sConn1Uid As String = ""
327
                Dim sConn2Uid As String = ""
328
                sConn1Uid = FindConnection(oLine_Dt, oSymbol_Dt, sLineUid, dStartPos_x, dStartPos_y)
329
                If sConn1Uid <> "" Then
330
                    oLineInfo(_XML_LINE_Conn1_Uid) = sConn1Uid
331
                End If
332
                sConn2Uid = FindConnection(oLine_Dt, oSymbol_Dt, sLineUid, dEndPos_x, dEndPos_y)
333
                If sConn2Uid <> "" Then
334
                    oLineInfo(_XML_LINE_Conn2_Uid) = sConn2Uid
335
                End If
336
            Next
337
            For Each oSymbolInfo In oSymbol_Dt.Rows
338
                Dim sSymbolUid As String = oSymbolInfo(_XML_SYMBOL_UID).ToString()
339
                Dim dConn1Pos_x As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN1_POINT_X)
340
                Dim dConn1Pos_y As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN1_POINT_Y)
341
342
                Dim sConn1Uid As String = ""
343
                Dim sConn2Uid As String = ""
344
345
                sConn1Uid = FindConnection(oLine_Dt, oSymbol_Dt, sSymbolUid, dConn1Pos_x, dConn1Pos_y)
346
                If sConn1Uid <> "" Then
347
                    oSymbolInfo(_XML_SYMBOL_Conn1_Uid) = sConn1Uid
348
                End If
349
                Try
350
                    Dim dConn2Pos_x As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN2_POINT_X)
351
                    Dim dConn2Pos_y As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN2_POINT_Y)
352
                    sConn2Uid = FindConnection(oLine_Dt, oSymbol_Dt, sSymbolUid, dConn2Pos_x, dConn2Pos_y)
353
                    If sConn2Uid <> "" Then
354
                        oSymbolInfo(_XML_SYMBOL_Conn2_Uid) = sConn2Uid
355
                    End If
356
                Catch ex As Exception
357
                End Try
358
            Next
359
        Catch ex As Exception
360
        End Try
361
    End Function
362
363 76f5e1a8 Gyusu
    Private Function GetFlowDirection(ByRef dStart_x As Double, ByRef dStart_y As Double, ByRef dEnd_x As Double, ByRef dEnd_y As Double, ByRef sDirection As String, ByRef sFlowdirection As String) As Boolean
364
        Dim bValidLine As Boolean = True
365 76f465d0 Gyusu
        If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
366
            If dStart_x > dEnd_x Then
367
                sDirection = "X"
368
                sFlowdirection = "Left_x"
369
                If Math.Abs(dStart_y - dEnd_y) < 5 Then
370
                    dEnd_y = dStart_y
371
                End If
372
            Else
373
                sDirection = "X"
374
                sFlowdirection = "Right_x"
375
                If Math.Abs(dStart_y - dEnd_y) < 5 Then
376
                    dEnd_y = dStart_y
377
                End If
378
            End If
379 76f5e1a8 Gyusu
            If Math.Abs(dStart_x - dEnd_x) < 10 Then
380
                bValidLine = False
381
            End If
382 76f465d0 Gyusu
        Else
383
            If dStart_y > dEnd_y Then
384
                sDirection = "Y"
385
                sFlowdirection = "Down_y"
386
                If Math.Abs(dStart_x - dEnd_x) < 5 Then
387
                    dEnd_x = dStart_x
388
                End If
389
390
            Else
391
                sDirection = "Y"
392
                sFlowdirection = "Up_y"
393
                If Math.Abs(dStart_x - dEnd_x) < 5 Then
394
                    dEnd_x = dStart_x
395
                End If
396
            End If
397 76f5e1a8 Gyusu
            If Math.Abs(dStart_y - dEnd_y) < 10 Then
398
                bValidLine = False
399
            End If
400 76f465d0 Gyusu
        End If
401 76f5e1a8 Gyusu
        Return bValidLine
402 76f465d0 Gyusu
    End Function
403 4f359afa Gyusu
404 3acffcee Gyusu
    Private Function LoadLineNo(ByVal oElement As XElement, ByVal sLineType As String) As List(Of Line_no)
405
406
        Dim oLineno_list As New List(Of Line_no)
407
408
        For Each oLineNo As Object In oElement.Elements(sLineType)
409
410
            Dim CLineNo As Line_no = New Line_no()
411
            Try
412
                CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value
413
                CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value
414
                CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value
415
                CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value
416
                CLineNo.SystemPath = "\Piping\Labels - Piping Segments\Kemya Line Number.sym" 'GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
417
            Catch ex As Exception
418
            End Try
419
            Dim oLine_Dt As DataTable = Line_Dt()
420
            Dim oSymbol_Dt As DataTable = Symbol_Dt()
421
            Dim oAttribute_Dt As DataTable = Attribute_Dt()
422 76f465d0 Gyusu
            Dim iRunCnt As Integer = 0
423 3acffcee Gyusu
            For Each oRun As Object In oLineNo.Elements(_XML_CATEGORY_RUN)
424 76f465d0 Gyusu
                iRunCnt = iRunCnt + 1
425
                Dim sRunName As String = CLineNo.Text & "_" & iRunCnt
426
                For Each oMERGEDLine As Object In oRun.Elements(_XML_CATEGORY_MERGEDLINE)
427
                    For Each oLine As Object In oMERGEDLine.Elements(_XML_CATEGORY_LINE)
428
                        Try
429
                            Dim oAddrow As DataRow = oLine_Dt.NewRow()
430
                            Dim oEleObj As XElement
431
                            Dim sUid As String
432
                            Dim sStartpoint As String
433
                            Dim sEndpoint As String
434
                            Dim sType As String
435
                            Dim sConnectionUids As String = ""
436
                            Dim dStartPos_x As Double = 0.0
437
                            Dim dStartPos_y As Double = 0.0
438
                            Dim dEndPos_x As Double = 0.0
439
                            Dim dEndPos_y As Double = 0.0
440
                            Dim dDWG_StartPos_x As Double = 0.0
441
                            Dim dDWG_StartPos_y As Double = 0.0
442
                            Dim dDWG_EndPos_x As Double = 0.0
443
                            Dim dDWG_EndPos_y As Double = 0.0
444
                            oEleObj = oLine.Element(_XML_LINE_UID)
445
                            sUid = oEleObj.Value
446 b08338e3 Gyusu
447 76f465d0 Gyusu
                            If oLine_Dt.Select(_XML_LINE_UID & "='" & sUid & "'").Length = 0 Then
448
                                oEleObj = oLine.Element(_XML_LINE_STARTPOINT)
449
                                sStartpoint = oEleObj.Value
450
                                oEleObj = oLine.Element(_XML_LINE_ENDPOINT)
451
                                sEndpoint = oEleObj.Value
452
                                oEleObj = oLine.Element(_XML_LINE_TYPE)
453
                                sType = oEleObj.Value
454
                                'oEleObj = oLine.Element(_XML_LINE_CONNS)
455
                                'sConnectionUids = oEleObj.Value
456
                                'sConnArray = sConnectionUids.Split(",")
457
                                'For i = 0 To sConnArray.Length - 1
458
                                '    If i = 0 Then
459
                                '        oAddrow(_XML_LINE_Conn1_Uid) = sConnArray(i)
460
                                '    ElseIf i = 1 Then
461
                                '        oAddrow(_XML_LINE_Conn2_Uid) = sConnArray(i)
462
                                '    End If
463
                                'Next
464
                                'If sConnArray.Length > 2 Then
465
                                '    MessageBox.Show(sConnArray.Length)
466
                                'End If
467
                                oAddrow(_XML_LINE_Conn1_Uid) = ""
468
                                oAddrow(_XML_LINE_Conn2_Uid) = ""
469
                                oAddrow(_XML_LINE_UID) = sUid
470
                                oAddrow(_XML_LINE_RUNNAME) = sRunName
471
                                oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
472
                                oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
473
                                oAddrow(_XML_LINE_STARTPOINT) = sStartpoint
474
                                oAddrow(_XML_LINE_ENDPOINT) = sEndpoint
475
476
                                ConvertPointBystring(sStartpoint, dStartPos_x, dStartPos_y)
477
                                ConvertPointBystring(sEndpoint, dEndPos_x, dEndPos_y)
478
                                Dim sDirection As String = ""
479 76f5e1a8 Gyusu
                                Dim sFlowDirection As String = ""
480
                                Dim bValidLine As Boolean = GetFlowDirection(dStartPos_x, dStartPos_y, dEndPos_x, dEndPos_y, sDirection, sFlowDirection)
481
                                oAddrow(_XML_LINE_FlowDirection) = sFlowDirection
482 76f465d0 Gyusu
                                oAddrow(_XML_LINE_Direction) = sDirection
483 76f5e1a8 Gyusu
                                oAddrow(_XML_LINE_ValieLine) = bValidLine
484 76f465d0 Gyusu
                                dDWG_StartPos_x = dStartPos_x
485
                                dDWG_StartPos_y = dStartPos_y
486
                                ConvertPointByImage(dDWG_StartPos_x, dDWG_StartPos_y, _IMG_X, _IMG_Y)
487
                                dDWG_EndPos_x = dEndPos_x
488
                                dDWG_EndPos_y = dEndPos_y
489
                                ConvertPointByImage(dDWG_EndPos_x, dDWG_EndPos_y, _IMG_X, _IMG_Y)
490
491
                                oAddrow(_XML_LINE_STARTPOINT_X) = dStartPos_x
492
                                oAddrow(_XML_LINE_STARTPOINT_Y) = dStartPos_y
493
                                oAddrow(_XML_LINE_ENDPOINT_X) = dEndPos_x
494
                                oAddrow(_XML_LINE_ENDPOINT_Y) = dEndPos_y
495
496
                                oAddrow(_XML_LINE_DWG_STARTPOINT_X) = dDWG_StartPos_x
497
                                oAddrow(_XML_LINE_DWG_STARTPOINT_Y) = dDWG_StartPos_y
498
                                oAddrow(_XML_LINE_DWG_ENDPOINT_X) = dDWG_EndPos_x
499
                                oAddrow(_XML_LINE_DWG_ENDPOINT_Y) = dDWG_EndPos_y
500
501
                                oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
502
                                If oAddrow(_XML_LINE_SYSTEMPATH) = "" Then
503
                                    MessageBox.Show("")
504 b08338e3 Gyusu
                                End If
505 76f465d0 Gyusu
                                oAddrow(_XML_LINE_DRAWING_TF) = "FALSE"
506
                                oAddrow(_XML_LINE_TYPE) = sType
507
                                '  _AllLine_DT.Rows.Add(oAddrow)
508
                                oLine_Dt.Rows.Add(oAddrow)
509
                            Else
510 b08338e3 Gyusu
                            End If
511 76f465d0 Gyusu
                        Catch ex As Exception
512
                        End Try
513
                    Next
514 3acffcee Gyusu
                Next
515
516
                For Each oSymbol As Object In oRun.Elements(_XML_CATEGORY_SYMBOL)
517
                    Try
518 76f465d0 Gyusu
519 3acffcee Gyusu
                        Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
520
                        Dim oEleObj As XElement
521
                        Dim sUid As String
522
                        Dim sName As String
523
                        Dim sLocation As String
524
                        Dim sSize As String
525
                        Dim sAngle As String
526
                        Dim sOriginalPoint As String = ""
527 bb2a0c79 Gyusu
                        Dim sConnectionPoint As String = ""
528 b08338e3 Gyusu
                        Dim sConnectionUids As String = ""
529
                        Dim sConnArray As String()
530
531 76f465d0 Gyusu
                        Dim dCenterPos_x As Double = 0.0
532
                        Dim dCenterPos_y As Double = 0.0
533
                        Dim dDwgCenterPos_x As Double = 0.0
534
                        Dim dDwgCenterPos_y As Double = 0.0
535
536
537
                        Dim dConn1Pos_x As Double = 0.0
538
                        Dim dConn1Pos_y As Double = 0.0
539
                        Dim dConn2Pos_x As Double = 0.0
540
                        Dim dConn2Pos_y As Double = 0.0
541
                        Dim dConn3Pos_x As Double = 0.0
542
                        Dim dConn3Pos_y As Double = 0.0
543
                        Dim dConn4Pos_x As Double = 0.0
544
                        Dim dConn4Pos_y As Double = 0.0
545
546
                        Dim dDwg_Conn1Pos_x As Double = 0.0
547
                        Dim dDwg_Conn1Pos_y As Double = 0.0
548
                        Dim dDwg_Conn2Pos_x As Double = 0.0
549
                        Dim dDwg_Conn2Pos_y As Double = 0.0
550
                        Dim dDwg_Conn3Pos_x As Double = 0.0
551
                        Dim dDwg_Conn3Pos_y As Double = 0.0
552
                        Dim dDwg_Conn4Pos_x As Double = 0.0
553
                        Dim dDwg_Conn4Pos_y As Double = 0.0
554
555 3acffcee Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
556
                        sUid = oEleObj.Value
557
                        oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT)
558
                        sName = oEleObj.Value
559
                        oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
560
                        sLocation = oEleObj.Value
561
                        oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
562
                        sSize = oEleObj.Value
563
                        oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
564
                        sAngle = oEleObj.Value
565 bb2a0c79 Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
566
                        sConnectionPoint = oEleObj.Value
567 3acffcee Gyusu
                        Try
568
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
569
                            sOriginalPoint = oEleObj.Value
570
                        Catch ex As Exception
571
572
                        End Try
573 76f465d0 Gyusu
                        'oEleObj = oSymbol.Element(_XML_LINE_CONNS)
574
                        'sConnectionUids = oEleObj.Value
575
                        'sConnArray = sConnectionUids.Split(",")
576
                        'If sConnArray.Length > 4 Then
577
                        '    MessageBox.Show(sConnArray.Length)
578
                        'End If
579
                        'For i = 0 To sConnArray.Length - 1
580
                        '    If i = 0 Then
581
                        '        oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
582
                        '    ElseIf i = 1 Then
583
                        '        oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
584
                        '    ElseIf i = 2 Then
585
                        '        oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
586
                        '    ElseIf i = 3 Then
587
                        '        oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
588
                        '    End If
589
                        'Next
590
                        oAddrow(_XML_SYMBOL_Conn1_Uid) = ""
591
                        oAddrow(_XML_SYMBOL_Conn2_Uid) = ""
592
                        oAddrow(_XML_SYMBOL_Conn3_Uid) = ""
593
                        oAddrow(_XML_SYMBOL_Conn4_Uid) = ""
594
                        ConvertPointBystring(sOriginalPoint, dCenterPos_x, dCenterPos_y)
595
                        dDwgCenterPos_x = dCenterPos_x
596
                        dDwgCenterPos_y = dCenterPos_y
597
                        ConvertPointByImage(dDwgCenterPos_x, dDwgCenterPos_y, _IMG_X, _IMG_Y)
598
599
                        oAddrow(_XML_SYMBOL_CENTERPOINT_X) = dCenterPos_x
600
                        oAddrow(_XML_SYMBOL_CENTERPOINT_Y) = dCenterPos_y
601
                        oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_X) = dDwgCenterPos_x
602
                        oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_Y) = dDwgCenterPos_y
603
                        sConnArray = sConnectionPoint.Split("/")
604 b08338e3 Gyusu
                        If sConnArray.Length > 4 Then
605
                            MessageBox.Show(sConnArray.Length)
606
                        End If
607
                        For i = 0 To sConnArray.Length - 1
608
                            If i = 0 Then
609 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn1_Point) = sConnArray(i)
610
                                ConvertPointBystring(sConnArray(i), dConn1Pos_x, dConn1Pos_y)
611
                                dDwg_Conn1Pos_x = dConn1Pos_x
612
                                dDwg_Conn1Pos_y = dConn1Pos_y
613
                                ConvertPointByImage(dDwg_Conn1Pos_x, dDwg_Conn1Pos_y, _IMG_X, _IMG_Y)
614
615
                                oAddrow(_XML_SYMBOL_CONN1_POINT_X) = dConn1Pos_x
616
                                oAddrow(_XML_SYMBOL_CONN1_POINT_Y) = dConn1Pos_y
617
                                oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_X) = dDwg_Conn1Pos_x
618
                                oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_Y) = dDwg_Conn1Pos_y
619 b08338e3 Gyusu
                            ElseIf i = 1 Then
620 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn2_Point) = sConnArray(i)
621
                                ConvertPointBystring(sConnArray(i), dConn2Pos_x, dConn2Pos_y)
622
                                dDwg_Conn2Pos_x = dConn2Pos_x
623
                                dDwg_Conn2Pos_y = dConn2Pos_y
624
                                ConvertPointByImage(dDwg_Conn2Pos_x, dDwg_Conn2Pos_y, _IMG_X, _IMG_Y)
625
                                oAddrow(_XML_SYMBOL_CONN2_POINT_X) = dConn2Pos_x
626
                                oAddrow(_XML_SYMBOL_CONN2_POINT_Y) = dConn2Pos_y
627
                                oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_X) = dDwg_Conn2Pos_x
628
                                oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_Y) = dDwg_Conn2Pos_y
629 b08338e3 Gyusu
                            ElseIf i = 2 Then
630 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn3_Point) = sConnArray(i)
631
                                ConvertPointBystring(sConnArray(i), dConn3Pos_x, dConn3Pos_y)
632
                                dDwg_Conn3Pos_x = dConn3Pos_x
633
                                dDwg_Conn3Pos_y = dConn3Pos_y
634
                                ConvertPointByImage(dDwg_Conn3Pos_x, dDwg_Conn3Pos_y, _IMG_X, _IMG_Y)
635
                                oAddrow(_XML_SYMBOL_CONN3_POINT_X) = dConn3Pos_x
636
                                oAddrow(_XML_SYMBOL_CONN3_POINT_Y) = dConn3Pos_y
637
                                oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_X) = dDwg_Conn3Pos_x
638
                                oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_Y) = dDwg_Conn3Pos_y
639 b08338e3 Gyusu
                            ElseIf i = 3 Then
640 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn4_Point) = sConnArray(i)
641
                                ConvertPointBystring(sConnArray(i), dConn4Pos_x, dConn4Pos_y)
642
                                dDwg_Conn4Pos_x = dConn4Pos_x
643
                                dDwg_Conn4Pos_y = dConn4Pos_y
644
                                ConvertPointByImage(dDwg_Conn4Pos_x, dDwg_Conn4Pos_y, _IMG_X, _IMG_Y)
645
                                oAddrow(_XML_SYMBOL_CONN4_POINT_X) = dConn4Pos_x
646
                                oAddrow(_XML_SYMBOL_CONN4_POINT_Y) = dConn4Pos_y
647
                                oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_X) = dDwg_Conn4Pos_x
648
                                oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_Y) = dDwg_Conn4Pos_y
649 b08338e3 Gyusu
                            End If
650
                        Next
651
652 3acffcee Gyusu
                        oAddrow(_XML_SYMBOL_UID) = sUid
653 b08338e3 Gyusu
                        oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
654 76f465d0 Gyusu
                        oAddrow(_XML_SYMBOL_RUNNAME) = sRunName
655 b08338e3 Gyusu
                        oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
656 3acffcee Gyusu
                        oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME))
657
                        oAddrow(_XML_SYMBOL_LOCATION) = sLocation
658
                        oAddrow(_XML_SYMBOL_SIZE) = sSize
659
                        oAddrow(_XML_SYMBOL_ANGLE) = sAngle
660
                        oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
661
                        oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
662
                        oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_CLASS)
663
                        oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
664 76f465d0 Gyusu
665 bb2a0c79 Gyusu
                        oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
666 e4000111 Gyusu
                        oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
667 76f465d0 Gyusu
                        '   _AllSymbol_DT.Rows.Add(oAddrow)
668 3acffcee Gyusu
                        oSymbol_Dt.Rows.Add(oAddrow)
669
                    Catch ex As Exception
670
                    End Try
671
                Next
672
673
                For Each oAtrribute As Object In oRun.Elements(_XML_CATEGORY_ATTRIBUTE)
674
                    Try
675
                        Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
676
                        Dim oEleObj As XElement
677
                        Dim sUid As String
678
                        Dim sName As String
679
                        Dim sValue As String
680
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
681
                        sUid = oEleObj.Value
682
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
683
                        sName = oEleObj.Value
684
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
685
                        sValue = oEleObj.Value
686
                        oAddrow(_XML_ATTRIBUTE_UID) = sUid
687
                        oAddrow(_XML_ATTRIBUTE_NAME) = sName
688
                        oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
689
                        oAttribute_Dt.Rows.Add(oAddrow)
690
                    Catch ex As Exception
691
                    End Try
692
                Next
693
            Next
694
            'Line No Attribute
695
            For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE)
696
                Try
697
                    Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
698
                    Dim oEleObj As XElement
699
                    Dim sUid As String = ""
700
                    Dim sName As String
701
                    Dim sValue As String
702
703
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
704
                    sUid = oEleObj.Value
705
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
706
                    sName = oEleObj.Value
707
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
708
                    sValue = oEleObj.Value
709
                    oAddrow(_XML_ATTRIBUTE_UID) = sUid
710
                    oAddrow(_XML_ATTRIBUTE_NAME) = sName
711
                    oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
712
                    oAttribute_Dt.Rows.Add(oAddrow)
713
                Catch ex As Exception
714
                End Try
715
            Next
716 76f465d0 Gyusu
717
            SetConnectionInfo(oLine_Dt, oSymbol_Dt)
718
            _AllLine_DT.Merge(oLine_Dt)
719
            _AllSymbol_DT.Merge(oSymbol_Dt)
720 3acffcee Gyusu
            CLineNo.Dt_Line = oLine_Dt
721
            CLineNo.Dt_Symbol = oSymbol_Dt
722
            CLineNo.Dt_Attribute = oAttribute_Dt
723
            oLineno_list.Add(CLineNo)
724
        Next
725
        Return oLineno_list
726
    End Function
727
728 4f359afa Gyusu
729 9e1e7135 Gyusu
    Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double)
730 4f359afa Gyusu
731
        Dim calcx As Double = 0
732
        Dim calcy As Double = 0
733
        calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
734 76f465d0 Gyusu
        'calcx = Math.Round(calcx, 4, MidpointRounding.)
735
        calcx = Math.Truncate(calcx * 1000) / 1000
736 171ac39d Gyusu
        calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
737 76f465d0 Gyusu
        '   calcy = Math.Round(calcy, 4)
738
        calcy = Math.Truncate(calcy * 1000) / 1000
739 4f359afa Gyusu
        dX = calcx
740
        dY = calcy
741
    End Sub
742
743 e1cde8f2 Gyusu
744
    '@brief Convert To SPPID
745
    '@author : Gyusu Park
746
    '@date : 2018-04-10
747
    '@history:
748
749 171ac39d Gyusu
    Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double)
750
751
        Dim opointstr As String() = Split(sLocation, ",")
752
        If (opointstr.Length > 1) Then
753
            If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
754
                dX = opointstr(0)
755
                dY = opointstr(1)
756
            End If
757
        End If
758
759
    End Sub
760
761
    Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable
762 4f359afa Gyusu
763
        Try
764 171ac39d Gyusu
            Dim oDt As New DataTable
765 4f359afa Gyusu
            Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;"
766
            Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring)
767
            conn.Open()
768 171ac39d Gyusu
            Dim sQuery As String = "Select * from " & sTableName
769 4f359afa Gyusu
            Dim cmd As SQLiteCommand = conn.CreateCommand()
770
            Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn)
771
            Dim oDataSet As DataSet = New DataSet()
772
            adapter.Fill(oDataSet)
773 171ac39d Gyusu
            oDt = oDataSet.Tables(0)
774
            Return oDt
775 4f359afa Gyusu
        Catch ex As Exception
776 171ac39d Gyusu
            Return Nothing
777 4f359afa Gyusu
        End Try
778
779
780 171ac39d Gyusu
    End Function
781 4f359afa Gyusu
782 31d47a80 Gyusu
    Private Function LoadAllDrawing() As DataTable
783 e282643f Gyusu
784
785 e1cde8f2 Gyusu
        SetListBoxItems(ListBox_Result, "도면정보 로드중....")
786 b08338e3 Gyusu
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "도면정보 로드중....")
787 31d47a80 Gyusu
        Dim oDt As DataTable = Drawing_Dt()
788 e282643f Gyusu
        Dim sHierarchy As String = My.Settings.Plant_Hierarchy
789
790
791
        Dim files() As String
792
        files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories)
793
        For Each FileName As String In files
794
            Dim sName As String = FileName
795 31d47a80 Gyusu
            Dim oAddRow As DataRow = oDt.NewRow()
796 e282643f Gyusu
            oAddRow("Name") = Path.GetFileNameWithoutExtension(sName)
797
            oAddRow("Path") = FileName
798 31d47a80 Gyusu
            oDt.Rows.Add(oAddRow)
799
        Next
800
        Return oDt
801
    End Function
802
803 e282643f Gyusu
804 272662f9 Gyusu
    Dim _XMLList As ListView = New ListView()
805 e282643f Gyusu
806 272662f9 Gyusu
807
808 e1cde8f2 Gyusu
809 171ac39d Gyusu
810
811
    Private Function CheckOpenDrawing() As Boolean
812
        Try
813
814
            Dim lobjDatasource As Object
815
            _Placement = CreateObject("Plaice.Placement", "")
816
            lobjDatasource = _Placement.PIDDataSource
817
            Return True
818
        Catch ex As Exception
819
            Return False
820
        End Try
821
822
    End Function
823
824
825
    Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click
826
827
        Main_Tab.SelectedIndex = 1
828
        ListBox_Result.Items.Clear()
829 9e1e7135 Gyusu
        ' DataGrid_Result.DataSource = New DataTable()
830 171ac39d Gyusu
        Me.ProgressBar_Status.Visible = True
831
        ProgressBar_Status.Maximum = 100
832
        ProgressBar_Status.Value = 0
833 b08338e3 Gyusu
        InitItemCount()
834 171ac39d Gyusu
        ' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\")
835 54b98e09 Gyusu
        _Main_trd = New Thread(AddressOf ThreadConvert)
836 171ac39d Gyusu
        _Main_trd.IsBackground = True
837
        _Main_trd.Start()
838 54b98e09 Gyusu
        FineOPCForm()
839
    End Sub
840 171ac39d Gyusu
841 54b98e09 Gyusu
    Private Sub FineOPCForm()
842
        _Opc_trd = New Thread(AddressOf ThreadOPCRemove)
843
        _Opc_trd.IsBackground = True
844
        _Opc_trd.Start()
845 171ac39d Gyusu
    End Sub
846 54b98e09 Gyusu
847 31d47a80 Gyusu
848 b08338e3 Gyusu
    Dim _objPIDAutoApp As Object
849 e282643f Gyusu
850 b08338e3 Gyusu
    Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean
851
        Dim bCheckOpen As Boolean = False
852
        '   Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath)
853
        SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....")
854
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, sDwgName & " 도면 Open....")
855
        _objPIDAutoApp = CreateObject("PIDAutomation.Application")
856 e1cde8f2 Gyusu
857 b08338e3 Gyusu
        Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName)
858
        If sPath <> "" Then
859
            Process.Start(sPath)
860
        Else
861
            Return bCheckOpen
862
        End If
863 171ac39d Gyusu
864
            Dim bCheckOpenDrawing As Boolean = False
865
            While (True)
866
                bCheckOpenDrawing = CheckOpenDrawing()
867
                If bCheckOpenDrawing = True Then
868
                    bCheckOpen = True
869
                    Exit While
870
                Else
871
                    Thread.Sleep(2000)
872
                End If
873
            End While
874
875
876
            Return bCheckOpen
877
    End Function
878
879
    Private Function GetDrawing(ByVal sDwgName As String) As Drawing
880
        For Each CDrawing In _DrawingsList
881 559daf6d Gyusu
            If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then
882 171ac39d Gyusu
                Return CDrawing
883
            End If
884
        Next
885
        Return Nothing
886
    End Function
887
888
    Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
889
        For Each CLineNo In CDrawing.Line_nos
890
            If CLineNo.Uid = sLineNoUid Then
891
                Return CLineNo
892
            End If
893
        Next
894
        Return Nothing
895
    End Function
896
897 3acffcee Gyusu
    Private Function GetTrimLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
898
        For Each CLineNo In CDrawing.TrimLine_nos
899
            If CLineNo.Uid = sLineNoUid Then
900
                Return CLineNo
901
            End If
902
        Next
903
        Return Nothing
904
    End Function
905
906
907 bb2a0c79 Gyusu
908
    Private Function GetPipeFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
909 6a6d8ab4 Gyusu
        For Each CLineNo In CDrawing.Line_nos
910
            Dim odt As DataTable = CLineNo.Dt_Line
911
            If odt.Rows.Count > 0 Then
912 bb2a0c79 Gyusu
                If odt.Rows(0)(_XML_LINE_Conn1_Uid).ToString = sSymbolUid Then
913
                    sConnTypeNo = "1"
914
                    Return odt
915
                ElseIf odt.Rows(0)(_XML_LINE_Conn2_Uid).ToString() = sSymbolUid Then
916
                    sConnTypeNo = "2"
917
                    Return odt
918 6a6d8ab4 Gyusu
                End If
919
            End If
920
        Next
921 bb2a0c79 Gyusu
        Return New DataTable
922 6a6d8ab4 Gyusu
    End Function
923
924 bb2a0c79 Gyusu
    Private Function GetSymbolFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
925
        For Each CLineNo In CDrawing.Line_nos
926
            Dim odt As DataTable = CLineNo.Dt_Symbol
927
            If odt.Rows.Count > 0 Then
928
                If odt.Rows(0)(_XML_SYMBOL_Conn1_Uid).ToString = sSymbolUid Then
929
                    sConnTypeNo = "1"
930
                    Return odt
931
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn2_Uid).ToString() = sSymbolUid Then
932
                    sConnTypeNo = "2"
933
                    Return odt
934
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn3_Uid).ToString() = sSymbolUid Then
935
                    sConnTypeNo = "3"
936
                    Return odt
937
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn4_Uid).ToString() = sSymbolUid Then
938
                    sConnTypeNo = "4"
939
                    Return odt
940
                End If
941
            End If
942
        Next
943
        Return New DataTable
944
    End Function
945 6a6d8ab4 Gyusu
946
    Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no
947
        For Each CEqpNo In CDrawing.Eqp_nos
948
            If CEqpNo.Uid = sEqpUid Then
949
                Return CEqpNo
950
            End If
951
        Next
952
        Return Nothing
953
    End Function
954 9e1e7135 Gyusu
    Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean
955 171ac39d Gyusu
        Try
956
            Dim opointstr As String() = Split(sPoint, ",")
957
            If (opointstr.Length > 1) Then
958
                If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
959
                    dX = opointstr(0)
960
                    dY = opointstr(1)
961 9e1e7135 Gyusu
962 171ac39d Gyusu
                Else
963
                    dX = 0
964
                    dY = 0
965
                    Return False
966
                End If
967
            End If
968 e1cde8f2 Gyusu
            Return True
969
        Catch ex As Exception
970
            Return False
971
        End Try
972 171ac39d Gyusu
    End Function
973
974 54b98e09 Gyusu
975
    Dim _DrawLine_Dt As DataTable = DrawLind_Dt()
976
977 e1cde8f2 Gyusu
978 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)
979 54b98e09 Gyusu
        Dim oAddRow = _DrawLine_Dt.NewRow()
980 41e4023e Gyusu
        oAddRow(_XML_LINE_UID) = sUid
981 54b98e09 Gyusu
        oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x
982
        oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y
983
        oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x
984
        oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y
985
        _DrawLine_Dt.Rows.Add(oAddRow)
986
    End Sub
987
988
989
990 b08338e3 Gyusu
    Private Sub PlaceEquipment(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sEqpName As String)
991 41e4023e Gyusu
        Try
992
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
993
            Dim oAttributeRow() As DataRow
994
            If oAttribute_Dt.Rows.Count > 0 Then
995
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
996
            End If
997
            If oSymbolRow.Length > 0 Then
998
                Dim oDatasource As Object = _Placement.PIDDataSource
999
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
1000
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
1001
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
1002
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
1003
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
1004
                Dim dAngle As Double = 0.0
1005
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
1006
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
1007
                End If
1008
                Dim dLocationX As Double = 0.0
1009
                Dim dLocationY As Double = 0.0
1010
                Dim dX As Double = 0.0
1011
                Dim dY As Double = 0.0
1012
1013
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1014
                    dX = dLocationX
1015
                    dY = dLocationY
1016
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1017
                    _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1018 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Equipment.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iEquipmentcnt & " count ")
1019
1020
                    _iEquipmentcnt = _iEquipmentcnt + 1
1021
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Equipment : " & sUid)
1022
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Name : " & sEqpName)
1023
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1024
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
1025
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Count : " & _iEquipmentcnt)
1026
1027
1028 41e4023e Gyusu
                End If
1029
            End If
1030
        Catch ex As Exception
1031
1032
        End Try
1033
1034
1035
    End Sub
1036 54b98e09 Gyusu
1037 b08338e3 Gyusu
    Private Function PlacePipingOPC(ByVal sUid As String, ByVal oOPCRow As DataRow, ByVal oAttribute_Dt As DataTable, ByVal sLineNoText As String) As LMSymbol
1038 e4000111 Gyusu
        Try
1039
            Dim oAttributeRow() As DataRow
1040
            If oAttribute_Dt.Rows.Count > 0 Then
1041
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1042
            End If
1043
            Dim oDatasource As Object = _Placement.PIDDataSource
1044
            Dim sSymbolCompType As String = oOPCRow(_XML_SYMBOL_TYPE).ToString()
1045
            Dim sSystemPath As String = oOPCRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1046
            Dim sClass As String = oOPCRow(_XML_SYMBOL_CLASS).ToString()
1047
            Dim sLocation As String = oOPCRow(_XML_SYMBOL_LOCATION).ToString()
1048
            Dim sOriginalPoint As String = oOPCRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1049
            Dim dAngle As Double = 0.0
1050
            If IsNumeric(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) Then
1051
                dAngle = Double.Parse(oOPCRow(_XML_SYMBOL_ANGLE).ToString())
1052
            End If
1053
1054
            Dim dLocationX As Double = 0.0
1055
            Dim dLocationY As Double = 0.0
1056
            Dim dX As Double = 0.0
1057
            Dim dY As Double = 0.0
1058 bb2a0c79 Gyusu
            Dim oLMSymbol As LMSymbol = Nothing
1059 e4000111 Gyusu
            If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1060
                dX = dLocationX
1061
                dY = dLocationY
1062
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1063
                _iPipintOpccnt = _iPipintOpccnt + 1
1064 bb2a0c79 Gyusu
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1065 e4000111 Gyusu
                '모델링된 형상은 Drawing True 로 처리
1066 bb2a0c79 Gyusu
                oOPCRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
1067 b08338e3 Gyusu
                SetListBoxItems(ListBox_Result, "Place Piping OPC.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iPipintOpccnt & " count ")
1068
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Piping OPC : " & sUid & "")
1069
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1070
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oOPCRow(_XML_SYMBOL_Conn1_Uid).ToString())
1071
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oOPCRow(_XML_SYMBOL_Conn2_Uid).ToString())
1072
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1073
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
1074
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OPC Count : " & _iPipintOpccnt)
1075 e4000111 Gyusu
1076
                Dim dConn_X1 As Double, dConn_Y1 As Double, dConn_X2 As Double, dConn_Y2 As Double
1077
                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dConn_X1, dConn_Y1)
1078
                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dConn_X2, dConn_Y2)
1079
1080 bb2a0c79 Gyusu
                'Dim oAddrow As DataRow = _ResultModeling_DT.NewRow()
1081
                'oAddrow(_Modeling_Uid) = sUid
1082
                'oAddrow(_Modeling_Location_X) = dLocationX
1083
                'oAddrow(_Modeling_Location_Y) = dLocationY
1084
                'oAddrow(_Modeling_LineNoUid) = sLineUid
1085
                'oAddrow(_Modeling_Type) = sSymbolCompType
1086
                'oAddrow(_Modeling_Connection1_X) = dConn_X1
1087
                'oAddrow(_Modeling_Connection1_Y) = dConn_Y1
1088
                'oAddrow(_Modeling_Connection2_X) = dConn_X2
1089
                'oAddrow(_Modeling_Connection2_X) = dConn_Y2
1090
                'oAddrow(_Modeling_LMSymbol) = oLMSymbol
1091
1092
                '_ResultModeling_DT.Rows.Add(oAddrow)
1093 e4000111 Gyusu
            End If
1094
            _Itemcnt = _Itemcnt + 1
1095
            Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1096
            SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1097
            Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1098 bb2a0c79 Gyusu
            Return oLMSymbol
1099 e4000111 Gyusu
        Catch ex As Exception
1100
1101
        End Try
1102 bb2a0c79 Gyusu
        Return Nothing
1103 e4000111 Gyusu
1104 bb2a0c79 Gyusu
    End Function
1105 e4000111 Gyusu
1106 76f465d0 Gyusu
    Private Sub AddProgress()
1107
        _Itemcnt = _Itemcnt + 1
1108
        Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1109
        SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1110
        Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1111
    End Sub
1112 e4000111 Gyusu
    Private Function DrawSymbol(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean
1113 171ac39d Gyusu
        Try
1114 e282643f Gyusu
1115 171ac39d Gyusu
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
1116 b08338e3 Gyusu
                Dim oAttributeRow() As DataRow
1117 6a6d8ab4 Gyusu
            If oAttribute_Dt.Rows.Count > 0 Then
1118 460d6abd Gyusu
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1119 6a6d8ab4 Gyusu
            End If
1120
1121 171ac39d Gyusu
            If oSymbolRow.Length > 0 Then
1122
                Dim oDatasource As Object = _Placement.PIDDataSource
1123
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
1124
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
1125 54b98e09 Gyusu
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
1126 171ac39d Gyusu
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
1127 9e1e7135 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
1128 171ac39d Gyusu
                Dim dAngle As Double = 0.0
1129
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
1130
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
1131
                End If
1132
1133
                Dim objSymbol As LMSymbol
1134 9e1e7135 Gyusu
                Dim dLocationX As Double = 0.0
1135
                Dim dLocationY As Double = 0.0
1136 171ac39d Gyusu
                Dim dX As Double = 0.0
1137
                Dim dY As Double = 0.0
1138
1139 9e1e7135 Gyusu
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1140
                    dX = dLocationX
1141
                    dY = dLocationY
1142 54b98e09 Gyusu
                    If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then
1143
                        FindConnectionLine(oLine_Dt, dX, dY)
1144
                    End If
1145
1146 9e1e7135 Gyusu
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1147 e4000111 Gyusu
                    Dim oInstrument As LMInstrument
1148 54b98e09 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
1149 9e1e7135 Gyusu
                        _iInstrumentcnt = _iInstrumentcnt + 1
1150 171ac39d Gyusu
                        objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1151 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ")
1152 171ac39d Gyusu
                        oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID)
1153 6a6d8ab4 Gyusu
                        Try
1154
                            If oAttributeRow.Length > 0 Then
1155
                                For Each oAttribute In oAttributeRow
1156 54b98e09 Gyusu
                                    Try
1157
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1158
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1159
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1160
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
1161
                                    Catch ex As Exception
1162
1163
                                    End Try
1164
1165 6a6d8ab4 Gyusu
                                Next
1166
                                oInstrument.Commit()
1167
                            End If
1168
                        Catch ex As Exception
1169
                        End Try
1170 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then
1171 9e1e7135 Gyusu
                        _iValvecnt = _iValvecnt + 1
1172 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1173 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ")
1174 171ac39d Gyusu
1175 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then
1176 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1177 d039e347 Gyusu
                        If sSystemPath.Contains(",") Then
1178
1179
                            Dim sDuplicatePath As String() = sSystemPath.Split(",")
1180
                            Dim sMainSymbol As String = ""
1181
                            Dim sSubSymbol As String = ""
1182
                            For Each sPath In sDuplicatePath
1183
                                If sMainSymbol = "" Then
1184
                                    sMainSymbol = sPath.Replace(vbLf, "")
1185
                                Else
1186
                                    sSubSymbol = sPath.Replace(vbLf, "")
1187
                                End If
1188
                            Next
1189
                            Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1190
                            Dim dConnpos_x As Double = 0.0
1191
                            Dim dConnpos_y As Double = 0.0
1192
                            _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y)
1193
                            '   _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation)
1194
                            _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle)
1195
1196
                        Else
1197
                            _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1198
                        End If
1199
1200
1201 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1202 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then
1203 d039e347 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1204
                        Dim sDuplicatePath As String() = sSystemPath.Split(",")
1205
                        Dim sMainSymbol As String = ""
1206
                        Dim sSubSymbol As String = ""
1207
                        For Each sPath In sDuplicatePath
1208
                            If sMainSymbol = "" Then
1209
                                sMainSymbol = sPath.Replace(vbLf, "")
1210
                            Else
1211
                                sSubSymbol = sPath.Replace(vbLf, "")
1212
                            End If
1213
                        Next
1214
                        Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1215
                        Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate
1216
                        Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate
1217
                        _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem)
1218
1219 171ac39d Gyusu
                    Else
1220 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1221 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1222 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1223 171ac39d Gyusu
                    End If
1224 e4000111 Gyusu
1225
                End If
1226 41e4023e Gyusu
                _Itemcnt = _Itemcnt + 1
1227
                Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1228
                SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1229
                Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1230
            End If
1231 171ac39d Gyusu
1232 54b98e09 Gyusu
        Catch ex As Exception
1233
            Return False
1234
        End Try
1235
    End Function
1236
1237
1238
    Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double)
1239
1240
        Try
1241
            For Each oRow In oLine_Dt.Rows
1242
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1243
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1244
                Dim d기준s_x As Double = 0
1245
                Dim d기준s_y As Double = 0
1246
                Dim d기준e_x As Double = 0
1247
                Dim d기준e_y As Double = 0
1248
                ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1249
                ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1250
                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
1251
                    dx = d기준s_x
1252
                    dy = d기준s_y
1253
                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
1254
                    dx = d기준e_x
1255
                    dy = d기준e_y
1256
                End If
1257
            Next
1258
        Catch ex As Exception
1259
        End Try
1260
    End Sub
1261
1262
1263
    Dim _라인보정기준값 As Integer = 10
1264
1265
    Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1266
                                      ByRef dex As Double, ByRef dey As Double)
1267
        Try
1268
            Dim bCheck라인 As Boolean = False
1269
            '일치하는 Line 찾기
1270
            For Each oRow In oLine_Dt.Rows
1271
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1272
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1273
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1274
                If sBUid <> sUid Then
1275
                    Dim d기준s_x As Double = 0
1276
                    Dim d기준s_y As Double = 0
1277
                    Dim d기준e_x As Double = 0
1278
                    Dim d기준e_y As Double = 0
1279
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1280
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1281
1282
                    If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or
1283
                       (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then
1284
                        bCheck라인 = True
1285
                    End If
1286
                End If
1287
            Next
1288
1289
            If bCheck라인 = False Then
1290
                For Each oRow In oLine_Dt.Rows
1291
                    Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1292
                    Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1293
                    Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1294
                    If sBUid <> sUid Then
1295
                        Dim d기준s_x As Double = 0
1296
                        Dim d기준s_y As Double = 0
1297
                        Dim d기준e_x As Double = 0
1298
                        Dim d기준e_y As Double = 0
1299
                        ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1300
                        ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1301
                        If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then
1302
                            oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy
1303
                            bCheck라인 = True
1304
                            Exit For
1305
                        ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then
1306
                            oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy
1307
                            bCheck라인 = True
1308
                            Exit For
1309
                        ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then
1310
                            oRow(_XML_LINE_STARTPOINT) = dex & "," & dey
1311
                            bCheck라인 = True
1312
                            Exit For
1313
                        ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then
1314
                            oRow(_XML_LINE_ENDPOINT) = dex & "," & dey
1315
                            bCheck라인 = True
1316
                            Exit For
1317
                        End If
1318
1319
                    End If
1320
                Next
1321 171ac39d Gyusu
            End If
1322
1323 54b98e09 Gyusu
            Return bCheck라인
1324 171ac39d Gyusu
        Catch ex As Exception
1325
            Return False
1326
        End Try
1327 54b98e09 Gyusu
1328
1329 171ac39d Gyusu
    End Function
1330
1331 460d6abd Gyusu
    Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1332
                                      ByRef dex As Double, ByRef dey As Double)
1333
        Try
1334
            Dim bCheckOverlap As Boolean = False
1335
            For Each oRow In oLine_Dt.Rows
1336
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1337
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1338
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1339
                If sBUid <> sUid Then
1340
                    Dim d기준s_x As Double = 0
1341
                    Dim d기준s_y As Double = 0
1342
                    Dim d기준e_x As Double = 0
1343
                    Dim d기준e_y As Double = 0
1344
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1345
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1346 54b98e09 Gyusu
                    If (d기준s_x <= dsx And d기준e_x >= dex And
1347
                        d기준s_y <= dsy And d기준e_y >= dey) Then
1348 460d6abd Gyusu
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1349
                        If dsy - d기준s_y > d기준e_y - dey Then
1350
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1351
                            If dResultCalc < 10 Then
1352
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1353
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1354
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1355
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1356
                                If dCalcStartY = 0 Then
1357
                                    dey = d기준e_y
1358
                                Else
1359
                                    dey = dCalcStartY
1360
                                End If
1361
                            End If
1362
                        Else
1363 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1364
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1365 460d6abd Gyusu
                            If dResultCalc < 10 Then
1366
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1367
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1368
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1369
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1370
                                If dCalcStartY = 0 Then
1371
                                    dsy = d기준s_y
1372
                                Else
1373
                                    dsy = dCalcStartY
1374
                                End If
1375
                            End If
1376
                        End If
1377
                        bCheckOverlap = True
1378
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1379
                            d기준s_y <= dey And d기준e_y >= dsy Then
1380
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1381
                        If dey - d기준s_y > d기준e_y - dsy Then
1382
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1383
                            If dResultCalc < 10 Then
1384
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1385
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1386
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1387
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1388
                                If dCalcStartY = 0 Then
1389 abb01e6c Gyusu
                                    dsy = d기준e_y
1390 460d6abd Gyusu
                                Else
1391 abb01e6c Gyusu
                                    dsy = dCalcStartY
1392 460d6abd Gyusu
                                End If
1393
1394
                            End If
1395
                            '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1396
                        Else
1397 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100
1398
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1399 460d6abd Gyusu
                            If dResultCalc < 10 Then
1400
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1401
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1402
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1403
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1404
                                If dCalcStartY = 0 Then
1405 abb01e6c Gyusu
                                    dey = d기준e_y
1406 460d6abd Gyusu
                                Else
1407 abb01e6c Gyusu
                                    dey = dCalcStartY
1408 460d6abd Gyusu
                                End If
1409
                            End If
1410
                        End If
1411
                        bCheckOverlap = True
1412
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1413
                            d기준s_y <= dey And d기준e_y >= dsy Then
1414
1415
                        If dsx - d기준s_x > d기준e_x - dex Then
1416
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1417
                            If dResultCalc < 10 Then
1418
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1419
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1420
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1421
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1422
                                If dCalcStartX = 0 Then
1423
                                    dex = d기준e_x
1424
                                Else
1425
                                    dex = dCalcStartX
1426
                                End If
1427
                            End If
1428
                        Else
1429 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1430
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1431 460d6abd Gyusu
                            If dResultCalc < 10 Then
1432
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1433
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1434
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1435
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1436
                                If dCalcStartX = 0 Then
1437
                                    dsx = d기준s_x
1438
                                Else
1439
                                    dsx = dCalcStartX
1440
                                End If
1441
                            End If
1442
                        End If
1443
                        bCheckOverlap = True
1444
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1445
                            d기준s_y <= dey And d기준e_y >= dsy Then
1446
1447
                        If dex - d기준s_x > d기준e_x - dsx Then
1448
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1449
                            If dResultCalc < 10 Then
1450
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1451
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1452
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1453
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1454
                                If dCalcStartX = 0 Then
1455 abb01e6c Gyusu
                                    dsx = d기준e_x
1456 460d6abd Gyusu
                                Else
1457 abb01e6c Gyusu
                                    dsx = dCalcStartX
1458 460d6abd Gyusu
                                End If
1459
                            End If
1460
                        Else
1461 abb01e6c Gyusu
                            ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1462
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1463 460d6abd Gyusu
                            If dResultCalc < 10 Then
1464
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1465
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1466
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1467
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1468
                                If dCalcStartX = 0 Then
1469 abb01e6c Gyusu
                                    dex = d기준s_x
1470 460d6abd Gyusu
                                Else
1471 abb01e6c Gyusu
                                    dex = dCalcStartX
1472 460d6abd Gyusu
                                End If
1473
                            End If
1474
1475
                        End If
1476
                        bCheckOverlap = True
1477
                    End If
1478
                End If
1479
            Next
1480 3acffcee Gyusu
1481 460d6abd Gyusu
            Return bCheckOverlap
1482
        Catch ex As Exception
1483
            Return False
1484
        End Try
1485
    End Function
1486
1487
    Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double,
1488
                                      ByRef dEndX As Double, ByRef dEndY As Double)
1489
        Try
1490 54b98e09 Gyusu
            Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기
1491 460d6abd Gyusu
            If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
1492 54b98e09 Gyusu
                Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1
1493 460d6abd Gyusu
                If dStartX > dEndX Then
1494
                    dStartX = dStartX + dCalc_x
1495
                    dEndX = dEndX - dCalc_x
1496
                Else
1497
                    dEndX = dEndX + dCalc_x
1498
                    dStartX = dStartX - dCalc_x
1499
                End If
1500
            Else
1501 54b98e09 Gyusu
                Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1
1502 460d6abd Gyusu
                If dStartY > dEndY Then
1503
                    dStartY = dStartY + dCalc_y
1504
                    dEndY = dEndY - dCalc_y
1505
                Else
1506
                    dEndY = dEndY + dCalc_y
1507
                    dStartY = dStartY - dCalc_y
1508
                End If
1509
            End If
1510
1511
        Catch ex As Exception
1512
1513
        End Try
1514
1515
1516
    End Sub
1517
1518 3acffcee Gyusu
    Private Function DrawLineNo(ByVal oPipeRun_Dt As DataTable, ByVal CLine_No As Line_no) As Boolean
1519 171ac39d Gyusu
        Try
1520
            Dim oDatasource As Object = _Placement.PIDDataSource
1521
            Dim sLocation = CLine_No.Location
1522 9e1e7135 Gyusu
            Dim dLocationx As Double = 0.0
1523
            Dim dLocationy As Double = 0.0
1524
1525 171ac39d Gyusu
            Dim dX As Double = 0.0
1526
            Dim dY As Double = 0.0
1527 9e1e7135 Gyusu
            If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then
1528
                dX = dLocationx
1529
                dY = dLocationy
1530 3acffcee Gyusu
1531
                For Each oRow In oPipeRun_Dt.Rows
1532
                    Dim dStartx As Double = Double.Parse(oRow("startx").ToString())
1533
                    Dim dStarty As Double = Double.Parse(oRow("starty").ToString())
1534
                    Dim dEndx As Double = Double.Parse(oRow("endx").ToString())
1535
                    Dim dEndy As Double = Double.Parse(oRow("endy").ToString())
1536
1537
                    Dim dStartSum As Double = Math.Abs(dStartx - dLocationx) + Math.Abs(dStarty - dLocationy)
1538
                    Dim dEndSum As Double = Math.Abs(dEndx - dLocationx) + Math.Abs(dEndy - dLocationy)
1539
                    If dStartSum > dEndSum Then
1540
                        oRow("value") = dEndSum
1541
                    Else
1542
                        oRow("value") = dStartSum
1543 171ac39d Gyusu
                    End If
1544 3acffcee Gyusu
1545 171ac39d Gyusu
                Next
1546 3acffcee Gyusu
                Dim dataView As New DataView(oPipeRun_Dt)
1547
                dataView.Sort = " value asc"
1548
                Dim oDt As DataTable = dataView.ToTable()
1549
                If oDt.Rows.Count > 0 Then
1550
                    Try
1551
                        Dim oPiperun As LMPipeRun = CType(oDt.Rows(0)("Piperun"), LMPipeRun)
1552
                        ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1553
                        Dim dLineNoLocation(2) As Double
1554
                        dLineNoLocation(1) = dX
1555
                        dLineNoLocation(2) = dY
1556
                        'Label
1557
                        Dim sSystemPath As String = CLine_No.SystemPath
1558
                        Dim dAngle As Double = CLine_No.Angle
1559
                        Dim labelpersist As LMLabelPersist
1560
1561
                        For Each representation In oPiperun.Representations
1562
                            If representation.RepresentationType = "Connector" Then
1563
                                labelpersist = _Placement.PIDPlaceLabel(sSystemPath,
1564
                                dLineNoLocation,, dAngle, LabeledItem:=representation)
1565
                                _iPipeLineNocnt = _iPipeLineNocnt + 1
1566 b08338e3 Gyusu
                                SetListBoxItems(ListBox_Result, "Place PipeLineNo Label.." & CLine_No.Uid & " (" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ")
1567
1568
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & CLine_No.Uid & "")
1569
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & CLine_No.Text)
1570
                                'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1571
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Origina lPoint : " & dLocationx & "," & dLocationy)
1572
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "PipeLineNo Count : " & _iPipeLineNocnt)
1573 3acffcee Gyusu
                            End If
1574
                        Next
1575
                    Catch ex As Exception
1576
1577
                    End Try
1578
1579
1580
                End If
1581
1582
1583
1584 171ac39d Gyusu
                Return True
1585
            Else
1586
                Return False
1587
            End If
1588
1589
        Catch ex As Exception
1590
            Return False
1591
        End Try
1592
    End Function
1593
1594 9e1e7135 Gyusu
1595
    Private Sub InitItemCount()
1596
        _iPipeLineNocnt = 0
1597 b08338e3 Gyusu
        _iPipecnt = 1
1598
        _iFittingcnt = 1
1599 9e1e7135 Gyusu
        _iValvecnt = 0
1600
        _iInstrumentcnt = 0
1601
        _iEquipmentcnt = 0
1602 3acffcee Gyusu
        _iNozzlecnt = 1
1603 e4000111 Gyusu
        _iPipintOpccnt = 0
1604 3acffcee Gyusu
1605 9e1e7135 Gyusu
    End Sub
1606 171ac39d Gyusu
1607 41e4023e Gyusu
    Private Function GetAllCheckNodeCount() As Integer
1608
        _allItem = 0
1609
        For i = 0 To Tree_Result.Nodes.Count - 1
1610
            For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1
1611
                For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1
1612
                    For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1
1613
                        If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then
1614
                            _allItem = _allItem + 1
1615
                        End If
1616
                    Next
1617
                Next
1618
            Next
1619
        Next
1620
        Return _allItem
1621
    End Function
1622 54b98e09 Gyusu
1623
1624 e4000111 Gyusu
    ''' <summary>
1625
    ''' Equipment 모델링
1626
    ''' </summary>
1627
    Private Sub EquipmentModeling(ByVal oDwg_Dt As DataTable)
1628
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1629
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1630
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
1631
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
1632
                If CDrawing IsNot Nothing Then
1633
                    If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then
1634 b08338e3 Gyusu
1635 e4000111 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
1636
                            Dim iItemcnt As Integer = 0
1637
                            Dim sNodeUid As String = oNode.Name
1638
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
1639
                            '1.Equipment
1640
                            '2.Piping OPC
1641
                            '3.OPC 시작되는 Line
1642
                            'Equipment 생성
1643
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
1644
                            If CEqpNo IsNot Nothing Then
1645
                                Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment
1646
                                Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute
1647
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1648
                                    If oSymbolNode.Checked Then
1649
                                        Dim sUid As String = oSymbolNode.Name
1650 b08338e3 Gyusu
                                        PlaceEquipment(sUid, oSymbol_Dt, oAttribute_Dt, CEqpNo.Text)
1651 e4000111 Gyusu
                                    End If
1652
                                Next
1653
                            End If
1654
                        Next
1655
                    End If
1656
                End If
1657
            Next
1658
        Next
1659
    End Sub
1660
1661 bb2a0c79 Gyusu
    Private Sub ManualCheckNode(ByRef oDt As DataTable)
1662
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1663
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1664
                For Each oNode As TreeNode In oDwgNode.Nodes
1665
                    For Each oSymbolNode As TreeNode In oNode.Nodes
1666
                        Dim sUid As String = oSymbolNode.Name
1667 76f465d0 Gyusu
                        'Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid &
1668 3b7a4470 Gyusu
                        '                                      "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'")
1669
                        If oSymbolNode.Checked Then
1670
                            Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid & "'")
1671
                            If oSelectRows.Length = 1 Then
1672
                                oSelectRows(0)(_XML_SYMBOL_DRAWING_TF) = "FALSE"
1673 76f465d0 Gyusu
1674 3b7a4470 Gyusu
                                If oSymbolNode.Checked Then
1675
1676
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "TRUE"
1677
                                Else
1678
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "FALSE"
1679
                                End If
1680 bb2a0c79 Gyusu
                            End If
1681 3b7a4470 Gyusu
1682 bb2a0c79 Gyusu
                        End If
1683
1684
                    Next
1685
                Next
1686
            Next
1687
        Next
1688
1689
    End Sub
1690 b08338e3 Gyusu
1691 f9b63682 Gyusu
    Private Function FinalSymbolModeling(ByVal oCurrentSymbolRow As DataRow, ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
1692
                                  ByVal oAttribute_Dt As DataTable) As String
1693
        Dim sReturnUid As String = ""
1694
        Dim sOriginalPoint As String = ""
1695
        Dim dOriginal_x As Double = 0.0
1696
        Dim dOriginal_y As Double = 0.0
1697
1698
        Dim dConn1_x As Double = 0.0
1699
        Dim dConn1_y As Double = 0.0
1700
        Dim dConn2_x As Double = 0.0
1701
        Dim dConn2_y As Double = 0.0
1702
        Dim dConn3_x As Double = 0.0
1703
        Dim dConn3_y As Double = 0.0
1704
        Dim dConn4_x As Double = 0.0
1705
        Dim dConn4_y As Double = 0.0
1706
1707
        Dim sUid As String = oCurrentSymbolRow(_XML_SYMBOL_UID)
1708
        Dim sSystemPath As String = oCurrentSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1709
        Dim dAngle As Double = oCurrentSymbolRow(_XML_SYMBOL_ANGLE)
1710
        Dim sLineNoText As String = oCurrentSymbolRow(_XML_LINENO_TEXT)
1711
        Dim sLineNoUid As String = oCurrentSymbolRow(_XML_LINE_LINENOUID).ToString()
1712
        sOriginalPoint = oCurrentSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1713 76f465d0 Gyusu
        Dim sSymbolCompType As String = oCurrentSymbolRow(_XML_SYMBOL_TYPE).ToString()
1714 f9b63682 Gyusu
        ConvertPointBystring(sOriginalPoint, dOriginal_x, dOriginal_y)
1715
        ConvertPointByImage(dOriginal_x, dOriginal_y, _IMG_X, _IMG_Y)
1716
1717
        'Connection 정보 체크, 모델링 되어 있는지 유무
1718
        '양 커넥션의 모델링 유무를 체크한다.
1719
        Dim sConn1Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString()
1720
        Dim sConn2Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString()
1721
        Dim sConn3Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString()
1722
        Dim sConn4Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString()
1723
1724
        Dim sConn1Type As String = ""
1725
        Dim sConn2Type As String = ""
1726
        Dim sConn3Type As String = ""
1727
        Dim sConn4Type As String = ""
1728
1729
        Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
1730
        If oConn1Rows.Length = 0 Then
1731
            oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
1732
            If oConn1Rows.Length = 1 Then
1733
                sConn1Type = "Line"
1734 b08338e3 Gyusu
            End If
1735 f9b63682 Gyusu
        Else
1736
            sConn1Type = "Symbol"
1737
        End If
1738 b08338e3 Gyusu
1739 f9b63682 Gyusu
        Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
1740
        If oConn2Rows.Length = 0 Then
1741
            oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
1742
            If oConn2Rows.Length = 1 Then
1743
                sConn2Type = "Line"
1744 b08338e3 Gyusu
            End If
1745 f9b63682 Gyusu
        Else
1746
            sConn2Type = "Symbol"
1747
        End If
1748 b08338e3 Gyusu
1749 f9b63682 Gyusu
        Dim oConn3Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn3Uid & "'")
1750
        If oConn3Rows.Length = 0 Then
1751
            oConn3Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn3Uid & "'")
1752
            If oConn3Rows.Length = 1 Then
1753
                sConn3Type = "Line"
1754 b08338e3 Gyusu
            End If
1755 f9b63682 Gyusu
        Else
1756
            sConn3Type = "Symbol"
1757
        End If
1758 b08338e3 Gyusu
1759 f9b63682 Gyusu
        Dim oConn4Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn4Uid & "'")
1760
        If oConn4Rows.Length = 0 Then
1761
            oConn4Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn4Uid & "'")
1762
            If oConn4Rows.Length = 1 Then
1763
                sConn4Type = "Line"
1764 b08338e3 Gyusu
            End If
1765 f9b63682 Gyusu
        Else
1766
            sConn4Type = "Symbol"
1767
        End If
1768 b08338e3 Gyusu
1769 f9b63682 Gyusu
        Dim oStartLMConnector As LMConnector = Nothing
1770
        Dim oEndLMConnector As LMConnector = Nothing
1771
        Dim objInputs As PlaceRunInputs
1772
        objInputs = New PlaceRunInputs
1773
        Dim iModelingType As Integer = 0
1774 76f465d0 Gyusu
        If sConn1Type <> "" Then
1775
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1776 f9b63682 Gyusu
        End If
1777 76f465d0 Gyusu
        If sConn2Type <> "" Then
1778
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1779 f9b63682 Gyusu
        End If
1780 76f465d0 Gyusu
        If sConn3Type <> "" Then
1781
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1782 f9b63682 Gyusu
        End If
1783 76f465d0 Gyusu
        If sConn4Type <> "" Then
1784
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1785 f9b63682 Gyusu
        End If
1786 b08338e3 Gyusu
1787 76f465d0 Gyusu
        'If sConn1Type = "Line" Then
1788
        '    Dim sStartpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn1_Point).ToString()
1789
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1790
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1791
        'ElseIf sConn1Type = "Symbol" Then
1792
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1793
        'End If
1794
1795
        'If sConn2Type = "Line" Then
1796
        '    Dim sEndpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn2_Point).ToString()
1797
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1798
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1799
        'ElseIf sConn2Type = "Symbol" Then
1800
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1801
        'End If
1802
1803
        'If sConn3Type = "Line" Then
1804
        '    Dim sStartpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn3_Point).ToString()
1805
        '    ConvertPointBystring(sStartpoint, dConn3_x, dConn3_y)
1806
        '    ConvertPointByImage(dConn3_x, dConn3_y, _IMG_X, _IMG_Y)
1807
        'ElseIf sConn3Type = "Symbol" Then
1808
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1809
        'End If
1810
1811
        'If sConn4Type = "Line" Then
1812
        '    Dim sEndpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn4_Point).ToString()
1813
        '    ConvertPointBystring(sEndpoint, dConn4_x, dConn4_y)
1814
        '    ConvertPointByImage(dConn4_x, dConn4_y, _IMG_X, _IMG_Y)
1815
        'ElseIf sConn4Type = "Symbol" Then
1816
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1817
        'End If
1818
1819 b08338e3 Gyusu
1820
1821 f9b63682 Gyusu
        'If sConn1Type = "Line" And sConn2Type = "Line" Then
1822
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1823
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1824
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1825
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1826
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1827
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1828
1829
        'ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
1830
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1831
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1832
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1833
1834
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1835
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
1836
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1837
1838
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1839
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1840
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1841
1842
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
1843
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1844
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1845
        'ElseIf sConn1Type = "Line" And sConn2Type = "" Then
1846
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1847
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1848
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1849
1850
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
1851
        '    iModelingType = 6
1852
        'ElseIf sConn1Type = "" And sConn2Type = "Line" Then
1853
        '    iModelingType = 7
1854
        'ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
1855
        '    iModelingType = 8
1856
        'ElseIf sConn3Type = "Line" And sConn4Type = "Line" Then
1857
        '        iModelingType = 4
1858
        '    ElseIf sConn3Type = "Line" And sConn4Type = "Symbol" Then
1859
        '        iModelingType = 4
1860
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Line" Then
1861
        '        iModelingType = 4
1862
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Symbol" Then
1863
        '        iModelingType = 4
1864
        '    ElseIf sConn3Type = "Line" And sConn4Type = "" Then
1865
        '        iModelingType = 5
1866
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "" Then
1867
        '        iModelingType = 5
1868
        '    ElseIf sConn3Type = "" And sConn4Type = "Line" Then
1869
        '        iModelingType = 6
1870
        '    ElseIf sConn3Type = "" And sConn4Type = "Symbol" Then
1871
        '        iModelingType = 6
1872
        '    Else
1873
        '        iModelingType = 7
1874
        '    End If
1875
1876
        'If iModelingType = 1 Then
1877
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1878
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1879
        '    ElseIf iModelingType = 2 Then
1880
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1881
        '    ElseIf iModelingType = 3 Then
1882
        '        ConvertPoint(oConn2Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1883
        '    ElseIf iModelingType = 4 Then
1884
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1885
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1886
        '    ElseIf iModelingType = 5 Then
1887
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1888
        '    ElseIf iModelingType = 6 Then
1889
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1890
        '    End If
1891
        Dim sFirstUid As String = ""
1892
        Dim sSecondUid As String = ""
1893
        Dim oLMSymbol As LMSymbol = Nothing
1894 76f465d0 Gyusu
        Dim dPreConn_x As Double = 0
1895
        Dim dPreConn_y As Double = 0
1896 f9b63682 Gyusu
        If sConn1Type <> "" And sConn2Type <> "" Then
1897 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1898
                CheckConnectionLine(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector, dPreConn_x, dPreConn_y)
1899
            Else
1900
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
1901
            End If
1902
1903
            If sConn2Type = "Line" Then
1904
                CheckConnectionLine(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector, dPreConn_x, dPreConn_y)
1905
            Else
1906
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
1907
            End If
1908
1909 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1910
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1911 76f465d0 Gyusu
            If oStartLMConnector IsNot Nothing Then
1912
                dOriginal_x = dConn1_x
1913
                dOriginal_y = dConn1_y
1914
            Else
1915
                dOriginal_x = dConn2_x
1916
                dOriginal_y = dConn2_y
1917
            End If
1918
1919 f9b63682 Gyusu
        ElseIf sConn1Type <> "" And sConn2Type = "" Then
1920 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1921
                CheckConnectionLine(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector, dPreConn_x, dPreConn_y)
1922
            Else
1923
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
1924
            End If
1925
1926 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1927
            dOriginal_x = dConn1_x
1928
            dOriginal_y = dConn1_y
1929
        ElseIf sConn1Type = "" And sConn2Type <> "" Then
1930 76f465d0 Gyusu
1931
            If sConn1Type = "Line" Then
1932
                CheckConnectionLine(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector, dPreConn_x, dPreConn_y)
1933
            Else
1934
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
1935
            End If
1936 f9b63682 Gyusu
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1937
            dOriginal_x = dConn2_x
1938
            dOriginal_y = dConn2_y
1939
        ElseIf sConn3Type <> "" And sConn4Type <> "" Then
1940 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1941
                CheckConnectionLine(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector, dPreConn_x, dPreConn_y)
1942
            Else
1943
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
1944
            End If
1945
1946
            If sConn2Type = "Line" Then
1947
                CheckConnectionLine(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector, dPreConn_x, dPreConn_y)
1948
            Else
1949
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
1950
            End If
1951
1952 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn3Rows(0))
1953
            sSecondUid = CheckExistModeling(oConn4Rows(0))
1954 76f465d0 Gyusu
            If oStartLMConnector IsNot Nothing Then
1955
                dOriginal_x = dConn3_x
1956
                dOriginal_y = dConn3_y
1957
            Else
1958
                dOriginal_x = dConn4_x
1959
                dOriginal_y = dConn4_y
1960
            End If
1961
1962 f9b63682 Gyusu
        ElseIf sConn3Type <> "" And sConn4Type = "" Then
1963 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1964
                CheckConnectionLine(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector, dPreConn_x, dPreConn_y)
1965
            Else
1966
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
1967
            End If
1968
1969 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn3Rows(0))
1970
            dOriginal_x = dConn3_x
1971
            dOriginal_y = dConn3_y
1972
        ElseIf sConn3Type = "" And sConn4Type <> "" Then
1973 76f465d0 Gyusu
            If sConn2Type = "Line" Then
1974
                CheckConnectionLine(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector, dPreConn_x, dPreConn_y)
1975
            Else
1976
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
1977
            End If
1978
1979 f9b63682 Gyusu
            sSecondUid = CheckExistModeling(oConn4Rows(0))
1980
            dOriginal_x = dConn4_x
1981
            dOriginal_y = dConn4_y
1982
        Else
1983 76f465d0 Gyusu
            '      oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
1984 f9b63682 Gyusu
        End If
1985 b08338e3 Gyusu
1986 f9b63682 Gyusu
        If sFirstUid <> "" And sSecondUid <> "" Then
1987
            sReturnUid = sSecondUid
1988
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1989
            sReturnUid = sFirstUid
1990
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
1991
            sReturnUid = sFirstUid
1992 76f465d0 Gyusu
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
1993
            sReturnUid = sSecondUid
1994
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
1995
            sReturnUid = sSecondUid
1996 f9b63682 Gyusu
        Else
1997
            sReturnUid = ""
1998
        End If
1999 b08338e3 Gyusu
2000 76f465d0 Gyusu
        If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
2001 f9b63682 Gyusu
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2002 76f465d0 Gyusu
            oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2003
        Else
2004
            If oStartLMConnector IsNot Nothing And oEndLMConnector IsNot Nothing Then
2005
                'oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle, ExistingItem:=oStartLMConnector.AsLMAItem,
2006
                '            TargetItem:=oEndLMConnector.AsLMAItem)
2007
                'oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2008
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2009
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2010
            ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2011
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2012
                            TargetItem:=oStartLMConnector.AsLMAItem)
2013
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2014
            ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2015
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2016
                TargetItem:=oEndLMConnector.AsLMAItem)
2017
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2018
            Else
2019
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2020
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2021
            End If
2022 b08338e3 Gyusu
        End If
2023 76f465d0 Gyusu
        AddProgress()
2024 b08338e3 Gyusu
2025 f9b63682 Gyusu
        SetListBoxItems(ListBox_Result, "Place Fitting.." & sUid & " (" & dOriginal_x & "," & dOriginal_y & ")..." & _iFittingcnt & " count ")
2026
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sUid)
2027
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2028
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "ModelingType : " & iModelingType)
2029
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn1_Point : " & dConn1_x & "," & dConn1_y)
2030
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn2_Point : " & dConn2_x & "," & dConn2_y)
2031
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn3_Point : " & dConn3_x & "," & dConn3_y)
2032
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn4_Point : " & dConn4_x & "," & dConn4_y)
2033
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
2034
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
2035
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
2036
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
2037
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2038
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dOriginal_x & "," & dOriginal_y)
2039
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
2040
        _iFittingcnt = _iFittingcnt + 1
2041
        oCurrentSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
2042 76f465d0 Gyusu
        Dim oAttributeRow() As DataRow
2043
        oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
2044
        If oAttribute_Dt.Rows.Count > 0 Then
2045 f9b63682 Gyusu
2046 76f465d0 Gyusu
            If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
2047
                Dim oInstrument As LMInstrument
2048
                oInstrument = _Placement.PIDDataSource.GetInstrument(oLMSymbol.ModelItemID)
2049
                Try
2050
                    If oAttributeRow.Length > 0 Then
2051
                        For Each oAttribute In oAttributeRow
2052
                            Try
2053
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2054
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2055
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2056
                                oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
2057
                            Catch ex As Exception
2058
                            End Try
2059
                        Next
2060
                        oInstrument.Commit()
2061
                    End If
2062
                Catch ex As Exception
2063
                End Try
2064
            Else
2065 f9b63682 Gyusu
                Try
2066 76f465d0 Gyusu
                    If oAttributeRow.Length > 0 And oLMSymbol IsNot Nothing Then
2067
                        For Each oAttribute In oAttributeRow
2068
                            Try
2069
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2070
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2071
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2072
                                oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
2073
2074
                            Catch ex As Exception
2075
                            End Try
2076
                        Next
2077
                        oLMSymbol.Commit()
2078 f9b63682 Gyusu
                    End If
2079
                Catch ex As Exception
2080
                End Try
2081 76f465d0 Gyusu
            End If
2082 f9b63682 Gyusu
        End If
2083 76f465d0 Gyusu
        'Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2084
        'If oAttributeRow.Length > 0 Then
2085
        '    For Each oAttribute In oAttributeRow
2086
        '        Try
2087
        '            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2088
        '            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2089
        '            If sPIDValue.Contains("'") Then
2090
        '                sPIDValue = sPIDValue.Replace("'", """")
2091
        '            End If
2092
        '            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2093
        '            oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
2094
        '        Catch ex As Exception
2095
        '        End Try
2096
        '    Next
2097
        'End If
2098 b08338e3 Gyusu
2099 f9b63682 Gyusu
        Return sReturnUid
2100 b08338e3 Gyusu
2101
2102 f9b63682 Gyusu
        '현재 Uid 모델링
2103
    End Function
2104 b08338e3 Gyusu
2105 f9b63682 Gyusu
    Private Function CheckExistModeling(ByVal oRow As DataRow) As String
2106
        If oRow(_XML_LINE_DRAWING_TF).ToString() = "FALSE" And oRow(_XML_LINE_Check).ToString() = "TRUE" Then
2107
            Return oRow(_XML_LINE_UID).ToString()
2108
        End If
2109
        Return String.Empty
2110
    End Function
2111 b08338e3 Gyusu
2112
2113 f9b63682 Gyusu
    Private Sub ConvertPoint(ByVal sOriginalPoint As String, ByRef dConn1_x As Double, ByRef dConn1_y As Double)
2114
        ConvertPointBystring(sOriginalPoint, dConn1_x, dConn1_y)
2115
        ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
2116
    End Sub
2117 b08338e3 Gyusu
2118 76f465d0 Gyusu
2119
2120
2121
    'Dim _StartPos_X As Double = 0
2122
    'Dim _StartPos_Y As Double = 0
2123
    'Dim _EndPos_X As Double = 0
2124
    'Dim _EndPos_Y As Double = 0
2125
    'Dim _StartUid As String = ""
2126
    'Dim _EndUid As String = ""
2127
    'Dim _objInputs As PlaceRunInputs
2128
    'Dim _ListPos As New List(Of String)
2129
    'Dim _Direction As String = ""
2130
    'Private Function FinalLineModeling(ByVal oCurrentLineRow As DataRow,
2131
    '                          ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
2132
    '                              ByVal oAttribute_Dt As DataTable) As String
2133
    '    Dim sReturnUid As String = ""
2134
    '    '현재 Uid  모델링 여부 체크
2135
    '    Dim sStartpoint As String = ""
2136
    '    Dim sEndpoint As String = ""
2137
2138
    '    Dim dOriginalStart_x As Double = 0.0
2139
    '    Dim dOriginalStart_y As Double = 0.0
2140
    '    Dim dOriginalEnd_x As Double = 0.0
2141
    '    Dim dOriginalEnd_y As Double = 0.0
2142
2143
    '    Dim dConvertStart_x As Double = 0
2144
    '    Dim dConvertStart_y As Double = 0
2145
    '    Dim dConvertEnd_x As Double = 0
2146
    '    Dim dConvertEnd_y As Double = 0
2147
2148
2149
    '    Dim dCenterPos_x As Double = 0.0
2150
    '    Dim dCenterPos_y As Double = 0.0
2151
    '    Dim objItem As LMAItem
2152
2153
    '    Dim sUid As String = oCurrentLineRow(_XML_LINE_UID).ToString()
2154
    '    Dim sLineType As String = oCurrentLineRow(_XML_LINE_TYPE).ToString()
2155
    '    Dim sSystemPath As String = GetPipeType(sLineType)
2156
    '    Dim sLineNoText As String = oCurrentLineRow(_XML_LINENO_TEXT).ToString()
2157
    '    Dim sLineNoUid As String = oCurrentLineRow(_XML_LINE_LINENOUID).ToString()
2158
    '    sStartpoint = oCurrentLineRow(_XML_LINE_STARTPOINT).ToString()
2159
    '    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2160
    '    ConvertPointByImage(dConvertStart_x, dConvertStart_y, _IMG_X, _IMG_Y)
2161
    '    sEndpoint = oCurrentLineRow(_XML_LINE_ENDPOINT).ToString()
2162
    '    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2163
    '    ConvertPointByImage(dConvertEnd_x, dConvertEnd_y, _IMG_X, _IMG_Y)
2164
2165
    '    dCenterPos_x = Math.Abs(dOriginalStart_x + dOriginalEnd_x) / 2
2166
    '    dCenterPos_y = Math.Abs(dOriginalStart_y + dOriginalEnd_y) / 2
2167
2168
    '    If _Direction = "" Then
2169
    '        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2170
    '            _Direction = "X"
2171
    '        Else
2172
    '            _Direction = "Y"
2173
    '        End If
2174
    '    Else
2175
    '        If _Direction = "X" Then
2176
    '            If Math.Abs(dOriginalStart_x - dOriginalEnd_x) < Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2177
2178
    '            End If
2179
    '        Else
2180
    '            If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
2181
2182
    '            End If
2183
    '        End If
2184
    '    End If
2185
2186
2187
    '    'Connection 정보 체크, 모델링 되어 있는지 유무
2188
    '    '양 커넥션의 모델링 유무를 체크한다.
2189
    '    Dim sConn1Uid As String = oCurrentLineRow(_XML_LINE_Conn1_Uid).ToString()
2190
    '    Dim sConn2Uid As String = oCurrentLineRow(_XML_LINE_Conn2_Uid).ToString()
2191
    '    Dim sConn1Type As String = ""
2192
    '    Dim sConn2Type As String = ""
2193
2194
    '    Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'" &
2195
    '                                                    " And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'" &
2196
    '                                                    " And [" & _XML_SYMBOL_Check & "] = 'True'")
2197
    '    If oConn1Rows.Length = 0 Then
2198
    '        oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'" &
2199
    '                                                    " And [" & _XML_LINE_DRAWING_TF & "] = 'False'" &
2200
    '                                                    " And [" & _XML_LINE_Check & "] = 'True'")
2201
    '        If oConn1Rows.Length = 1 Then
2202
    '            sConn1Type = "Line"
2203
    '        End If
2204
    '    Else
2205
    '        sConn1Type = "Symbol"
2206
    '    End If
2207
2208
    '    Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'" &
2209
    '                                                    " And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'" &
2210
    '                                                    " And [" & _XML_SYMBOL_Check & "] = 'True'")
2211
    '    If oConn2Rows.Length = 0 Then
2212
    '        oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'" &
2213
    '                                                    " And [" & _XML_LINE_DRAWING_TF & "] = 'False'" &
2214
    '                                                    " And [" & _XML_LINE_Check & "] = 'True'")
2215
    '        If oConn2Rows.Length = 1 Then
2216
    '            sConn2Type = "Line"
2217
    '        End If
2218
    '    Else
2219
    '        sConn2Type = "Symbol"
2220
    '    End If
2221
2222
2223
    '    If _StartPos_X = 0 And _StartPos_Y = 0 Then
2224
    '        _StartPos_X = dOriginalStart_x
2225
    '        _StartPos_Y = dOriginalStart_y
2226
    '        _ListPos.Add(_StartPos_X & "," & _StartPos_Y)
2227
    '    End If
2228
    '    Dim iModelingType As Integer = 0
2229
    '    If sConn1Type = "Line" And sConn2Type = "Line" Then
2230
    '        sReturnUid = sConn2Uid
2231
    '    ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
2232
    '        sReturnUid = sConn2Uid
2233
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
2234
    '        sReturnUid = sConn2Uid
2235
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
2236
    '        sReturnUid = sConn2Uid
2237
    '    ElseIf sConn1Type = "Line" And sConn2Type = "" Then
2238
    '        sReturnUid = sConn1Uid
2239
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
2240
    '        sReturnUid = sConn1Uid
2241
    '    ElseIf sConn1Type = "" And sConn2Type = "Line" Then
2242
    '        sReturnUid = sConn2Uid
2243
    '    ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
2244
    '        sReturnUid = sConn2Uid
2245
    '    Else
2246
    '        sReturnUid = ""
2247
    '        _EndPos_X = dOriginalEnd_x
2248
    '        _EndPos_Y = dOriginalEnd_y
2249
    '    End If
2250
2251
2252
    '    Dim sConn1LineNo As String = ""
2253
    '    If oConn1Rows.Length = 1 Then
2254
2255
    '    End If
2256
    '    Dim sConn2LineNo As String = ""
2257
    '    If oConn2Rows.Length = 1 Then
2258
2259
    '    End If
2260
    '    Dim oStartLMConnector As LMConnector = Nothing
2261
    '    Dim oEndLMConnector As LMConnector = Nothing
2262
    '    Dim oLMSymbol1 As LMSymbol = Nothing
2263
    '    Dim oLMSymbol2 As LMSymbol = Nothing
2264
    '    Dim objInputs As PlaceRunInputs
2265
    '    objInputs = New PlaceRunInputs
2266
2267
    '    If sConn1Type = "Line" And sConn2Type = "Line" Then
2268
    '        iModelingType = 1
2269
    '    ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
2270
    '        iModelingType = 1
2271
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
2272
    '        iModelingType = 1
2273
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
2274
    '        iModelingType = 1
2275
    '    ElseIf sConn1Type = "Line" And sConn2Type = "" Then
2276
    '        iModelingType = 2
2277
    '    ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
2278
    '        iModelingType = 2
2279
    '    ElseIf sConn1Type = "" And sConn2Type = "Line" Then
2280
    '        iModelingType = 3
2281
    '    ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
2282
    '        iModelingType = 3
2283
    '    Else
2284
    '        iModelingType = 4
2285
    '    End If
2286
2287
    '    If iModelingType = 1 Then
2288
    '        If sConn1Type = "Line" Then
2289
    '            CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2290
    '        Else
2291
    '            oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2292
    '        End If
2293
    '        If sConn1Type = "Line" Then
2294
    '            CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2295
    '        Else
2296
    '            oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2297
    '        End If
2298
    '        'CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2299
    '        'CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2300
    '    ElseIf iModelingType = "2" Then
2301
    '        If sConn1Type = "Line" Then
2302
    '            CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2303
    '        Else
2304
    '            oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2305
    '        End If
2306
    '        ' CheckConnectionLine(oConn2Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2307
    '    ElseIf iModelingType = "3" Then
2308
    '        If sConn1Type = "Line" Then
2309
    '            CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2310
    '        Else
2311
    '            oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2312
    '        End If
2313
    '        ' CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oStartLMConnector)
2314
2315
    '    Else
2316
    '        'objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2317
    '        'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2318
    '    End If
2319
2320
    '    Dim sFirstUid As String = ""
2321
    '    Dim sSecondUid As String = ""
2322
2323
    '    If oStartLMConnector Is Nothing And oEndLMConnector Is Nothing Then
2324
    '        objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2325
    '        objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2326
    '        'sFirstUid = CheckExistModeling(oConn1Rows(0))
2327
    '        'sSecondUid = CheckExistModeling(oConn2Rows(0))
2328
    '    ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2329
    '        If sConn1Type = "Line" Then
2330
    '            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
2331
    '        Else
2332
    '            objInputs.AddSymbolTarget(oLMSymbol1, dOriginalStart_x, dOriginalStart_y)
2333
    '        End If
2334
2335
    '        objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2336
    '        '    sSecondUid = CheckExistModeling(oConn2Rows(0))
2337
    '    ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2338
    '        If sConn2Type = "Line" Then
2339
    '            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalEnd_x, dOriginalEnd_y)
2340
    '        Else
2341
    '            objInputs.AddSymbolTarget(oLMSymbol2, dOriginalEnd_x, dOriginalEnd_y)
2342
    '        End If
2343
2344
    '        objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2345
2346
    '        'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2347
2348
    '        '   sFirstUid = CheckExistModeling(oConn1Rows(0))
2349
    '    Else
2350
    '        If sConn1Type = "Line" Then
2351
    '            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
2352
    '        Else
2353
    '            objInputs.AddSymbolTarget(oLMSymbol1, dOriginalStart_x, dOriginalStart_y)
2354
    '        End If
2355
    '        If sConn2Type = "Line" Then
2356
    '            objInputs.AddConnectorTarget(oStartLMConnector, dOriginalEnd_x, dOriginalEnd_y)
2357
    '        Else
2358
    '            objInputs.AddSymbolTarget(oLMSymbol2, dOriginalEnd_x, dOriginalEnd_y)
2359
    '        End If
2360
    '        'objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
2361
    '        'objInputs.AddConnectorTarget(oEndLMConnector, dOriginalEnd_x, dOriginalEnd_y)
2362
    '    End If
2363
    '    If sConn1Type <> "" And sConn2Type <> "" Then
2364
    '        sFirstUid = CheckExistModeling(oConn1Rows(0))
2365
    '        sSecondUid = CheckExistModeling(oConn2Rows(0))
2366
    '    ElseIf sConn1Type <> "" And sConn2Type = "" Then
2367
    '        sFirstUid = CheckExistModeling(oConn1Rows(0))
2368
    '    ElseIf sConn1Type = "" And sConn2Type <> "" Then
2369
    '        sSecondUid = CheckExistModeling(oConn2Rows(0))
2370
    '    End If
2371
2372
    '    If sFirstUid <> "" And sSecondUid <> "" Then
2373
    '        sReturnUid = sSecondUid
2374
    '    ElseIf sFirstUid = "" And sSecondUid <> "" Then
2375
    '        sReturnUid = sSecondUid
2376
    '    ElseIf sFirstUid <> "" And sSecondUid = "" Then
2377
    '        sReturnUid = sFirstUid
2378
    '    Else
2379
    '        sReturnUid = ""
2380
    '    End If
2381
    '    _iPipecnt = _iPipecnt + 1
2382
    '    Dim oCurrentConnector As LMConnector
2383
2384
    '    objItem = _Placement.PIDCreateItem(sSystemPath)
2385
    '    Try
2386
    '        objInputs.Clear()
2387
    '        objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2388
    '        objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2389
    '        oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2390
    '    Catch ex As Exception
2391
2392
    '    End Try
2393
2394
    '    oCurrentLineRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
2395
    '    oCurrentLineRow(_XML_LINE_DRAWING_TF) = "TRUE"
2396
2397
    '    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
2398
2399
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
2400
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2401
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentLineRow(_XML_SYMBOL_Conn1_Uid).ToString())
2402
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentLineRow(_XML_SYMBOL_Conn2_Uid).ToString())
2403
    '    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2404
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
2405
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
2406
    '    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
2407
2408
    '    Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(oCurrentConnector.ModelItemID)
2409
    '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2410
    '    If oAttributeRow.Length > 0 Then
2411
    '        For Each oAttribute In oAttributeRow
2412
    '            Try
2413
    '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2414
    '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2415
    '                If sPIDValue.Contains("'") Then
2416
    '                    sPIDValue = sPIDValue.Replace("'", """")
2417
    '                End If
2418
    '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2419
    '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
2420
    '            Catch ex As Exception
2421
    '            End Try
2422
    '        Next
2423
    '        oPipeRun.Commit()
2424
    '    End If
2425
2426
    '    Dim sID_1 As String = ""
2427
    '    Dim sID_2 As String = ""
2428
    '    If oStartLMConnector IsNot Nothing Then
2429
    '        sID_1 = oStartLMConnector.ModelItemID
2430
    '        sID_2 = oCurrentConnector.ModelItemID
2431
    '    ElseIf oEndLMConnector IsNot Nothing Then
2432
    '        sID_1 = oEndLMConnector.ModelItemID
2433
    '        sID_2 = oCurrentConnector.ModelItemID
2434
    '    End If
2435
    '    If sID_1 <> "" And sID_2 <> "" Then
2436
    '        '        Dim objSurvivorItem As LMAItem = Nothing
2437
    '        '        Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
2438
    '        '        Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
2439
    '        '      _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
2440
    '    End If
2441
    '    Return sReturnUid
2442
    '    '현재 Uid 모델링
2443
    'End Function
2444 f9b63682 Gyusu
    Private Function FinalLineModeling(ByVal oCurrentLineRow As DataRow,
2445
                              ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
2446
                                  ByVal oAttribute_Dt As DataTable) As String
2447
        Dim sReturnUid As String = ""
2448 76f465d0 Gyusu
        Try
2449 f9b63682 Gyusu
2450 76f465d0 Gyusu
            '현재 Uid  모델링 여부 체크
2451
            'Dim sStartpoint As String = ""
2452
            'Dim sEndpoint As String = ""
2453
            'Dim dOriginalStart_x As Double = 0.0
2454
            'Dim dOriginalStart_y As Double = 0.0
2455
            'Dim dOriginalEnd_x As Double = 0.0
2456
            'Dim dOriginalEnd_y As Double = 0.0
2457
            Dim dCenterPos_x As Double = 0.0
2458
            Dim dCenterPos_y As Double = 0.0
2459
            Dim objItem As LMAItem
2460 f9b63682 Gyusu
2461 76f465d0 Gyusu
            Dim sUid As String = oCurrentLineRow(_XML_LINE_UID).ToString()
2462
            Dim sLineType As String = oCurrentLineRow(_XML_LINE_TYPE).ToString()
2463
            Dim sSystemPath As String = GetPipeType(sLineType)
2464
            Dim sLineNoText As String = oCurrentLineRow(_XML_LINENO_TEXT).ToString()
2465
            Dim sLineNoUid As String = oCurrentLineRow(_XML_LINE_LINENOUID).ToString()
2466
            'sStartpoint = oCurrentLineRow(_XML_LINE_STARTPOINT).ToString()
2467
            'ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2468
            'ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
2469
            'sEndpoint = oCurrentLineRow(_XML_LINE_ENDPOINT).ToString()
2470
            'ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2471
            'ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
2472 f9b63682 Gyusu
2473 76f465d0 Gyusu
2474
            Dim dStart_Dwg_x As Double = oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_X)
2475
            Dim dStart_Dwg_y As Double = oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_Y)
2476
            Dim dEnd_Dwg_x As Double = oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_X)
2477
            Dim dEnd_Dwg_y As Double = oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_Y)
2478
            Dim sPreFlowDirection As String = ""
2479
            Dim sFlowDirection As String = oCurrentLineRow(_XML_LINE_FlowDirection)
2480
2481
            Dim sPreConn1Direction As String = ""
2482
            Dim sPreConn2Direction As String = ""
2483
            Dim sDirection As String = oCurrentLineRow(_XML_LINE_Direction)
2484
2485
            dCenterPos_x = Math.Abs(dStart_Dwg_x + dEnd_Dwg_x) / 2
2486
            dCenterPos_y = Math.Abs(dStart_Dwg_y + dEnd_Dwg_y) / 2
2487
2488
2489
            Dim oPidDataSource As LMADataSource = Nothing
2490
2491
            Try
2492
                oPidDataSource = _Placement.PIDDataSource
2493
            Catch ex As Exception
2494
                CheckOpenDrawing()
2495
                oPidDataSource = _Placement.PIDDataSource
2496
            End Try
2497
2498
            'Connection 정보 체크, 모델링 되어 있는지 유무
2499
            '양 커넥션의 모델링 유무를 체크한다.
2500
            Dim sConn1Uid As String = oCurrentLineRow(_XML_LINE_Conn1_Uid).ToString()
2501
            Dim sConn2Uid As String = oCurrentLineRow(_XML_LINE_Conn2_Uid).ToString()
2502
            Dim sConn1Type As String = ""
2503
            Dim sConn2Type As String = ""
2504
2505
            Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
2506
            If oConn1Rows.Length = 0 Then
2507
                oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
2508
                If oConn1Rows.Length = 1 Then
2509
                    sConn1Type = "Line"
2510
                    'sPreConn1Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2511
                    'If sDirection = sPreConn1Direction Then
2512
                    '    If sDirection = "X" Then
2513
                    '        dStart_Dwg_y = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2514
                    '        dEnd_Dwg_y = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2515
                    '    Else
2516
                    '        dStart_Dwg_x = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2517
                    '        dEnd_Dwg_x = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2518
                    '    End If
2519
                    'End If
2520
2521
                End If
2522
            Else
2523
                sConn1Type = "Symbol"
2524
            End If
2525
2526
            Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
2527
            If oConn2Rows.Length = 0 Then
2528
                oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
2529
                If oConn2Rows.Length = 1 Then
2530
                    sConn2Type = "Line"
2531
                    'sPreConn2Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2532
                    'If sDirection = sPreConn2Direction Then
2533
                    '    If sDirection = "X" Then
2534
                    '        dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2535
                    '        dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2536
                    '    Else
2537
                    '        dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2538
                    '        dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2539
                    '    End If
2540
                    'End If
2541
                End If
2542
            Else
2543
                sConn2Type = "Symbol"
2544
            End If
2545
2546
2547
2548
2549
            Dim sConn1LineNo As String = ""
2550
            Dim sConn2LineNo As String = ""
2551 3b7a4470 Gyusu
            Dim oLMConnector As LMConnector = Nothing
2552 76f465d0 Gyusu
            Dim oStartLMConnector As LMConnector = Nothing
2553
            Dim oEndLMConnector As LMConnector = Nothing
2554
            Dim oLMSymbol1 As LMSymbol = Nothing
2555
            Dim oLMSymbol2 As LMSymbol = Nothing
2556
            Dim objInputs As PlaceRunInputs
2557
            objInputs = New PlaceRunInputs
2558
            Dim iModelingType As Integer = 0
2559
            If sConn1Type = "Line" And sConn2Type = "Line" Then
2560
                iModelingType = 1
2561
            ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
2562
                iModelingType = 1
2563
            ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
2564
                iModelingType = 1
2565
            ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
2566
                iModelingType = 1
2567
            ElseIf sConn1Type = "Line" And sConn2Type = "" Then
2568
                iModelingType = 2
2569
            ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
2570
                iModelingType = 2
2571
            ElseIf sConn1Type = "" And sConn2Type = "Line" Then
2572
                iModelingType = 3
2573
            ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
2574
                iModelingType = 3
2575
            Else
2576
                iModelingType = 4
2577
            End If
2578
2579
            Dim dPreConnX As Double = 0
2580
            Dim dPreConnY As Double = 0
2581
2582 3b7a4470 Gyusu
2583
            Dim sTargetDirection As String = CheckBranchLine(oLine_Dt.Rows, dStart_Dwg_x, dStart_Dwg_y, dEnd_Dwg_x, dEnd_Dwg_y, oLMConnector)
2584
2585
            If sTargetDirection = "" Then
2586
                CheckConnectionLine(oConn1Rows, dStart_Dwg_x, dStart_Dwg_y, oStartLMConnector, dPreConnX, dPreConnY)
2587
2588
                If oStartLMConnector Is Nothing Then
2589
2590
                    oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dStart_Dwg_x, dStart_Dwg_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2591
                    If oLMSymbol1 IsNot Nothing Then
2592
                        sConn1Type = "Symbol"
2593 76f465d0 Gyusu
                    Else
2594 3b7a4470 Gyusu
                        sConn1Type = ""
2595
                    End If
2596
                Else
2597
                    sConn1Type = "Line"
2598
                    sPreConn1Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2599
                    If sDirection = sPreConn1Direction Then
2600
                        If sDirection = "X" Then
2601
                            dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2602
                            dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2603
                        Else
2604
                            dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2605
                            dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2606
                        End If
2607 76f465d0 Gyusu
                    End If
2608
2609
                End If
2610 3b7a4470 Gyusu
                CheckConnectionLine(oConn2Rows, dEnd_Dwg_x, dEnd_Dwg_y, oEndLMConnector, dPreConnX, dPreConnY)
2611
                If oEndLMConnector Is Nothing Then
2612
                    oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dEnd_Dwg_x, dEnd_Dwg_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2613
                    If oLMSymbol2 IsNot Nothing Then
2614
                        sConn2Type = "Symbol"
2615
                    End If
2616
                Else
2617
                    sConn2Type = "Line"
2618
                    sPreConn2Direction = oConn2Rows(0)(_XML_LINE_Direction).ToString()
2619
                    If sDirection = sPreConn2Direction Then
2620
                        If sDirection = "X" Then
2621
                            dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2622
                            dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2623
                        Else
2624
                            dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2625
                            dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2626
                        End If
2627 76f465d0 Gyusu
                    End If
2628
                End If
2629 3b7a4470 Gyusu
            Else
2630
                If sTargetDirection = "START" Then
2631
                    oStartLMConnector = oLMConnector
2632
                    sConn1Type = "Line"
2633
                ElseIf sTargetDirection = "END" Then
2634
                    oEndLMConnector = oLMConnector
2635
                    sConn2Type = "Line"
2636
                End If
2637 b08338e3 Gyusu
            End If
2638 3b7a4470 Gyusu
2639 76f465d0 Gyusu
            'If iModelingType = 1 Then
2640
            '    If sConn1Type = "Line" Then
2641
            '        CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2642
            '    Else
2643
            '        oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2644
            '    End If
2645
            '    If sConn1Type = "Line" Then
2646
            '        CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2647
            '    Else
2648
            '        oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2649
            '    End If
2650
            '    'CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2651
            '    'CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2652
            'ElseIf iModelingType = "2" Then
2653
            '    If sConn1Type = "Line" Then
2654
            '        CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2655
            '    Else
2656
            '        oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2657
            '    End If
2658
            '    ' CheckConnectionLine(oConn2Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2659
            'ElseIf iModelingType = "3" Then
2660
            '    If sConn1Type = "Line" Then
2661
            '        CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2662
            '    Else
2663
            '        oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2664
            '    End If
2665
            '    ' CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oStartLMConnector)
2666 b08338e3 Gyusu
2667 76f465d0 Gyusu
            'Else
2668
            '    'objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2669
            '    'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2670
            'End If
2671 b08338e3 Gyusu
2672 76f465d0 Gyusu
            Dim sFirstUid As String = ""
2673
            Dim sSecondUid As String = ""
2674
            Try
2675
                If oStartLMConnector Is Nothing And oEndLMConnector Is Nothing Then
2676
                    objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2677
                    objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2678
                    'sFirstUid = CheckExistModeling(oConn1Rows(0))
2679
                    'sSecondUid = CheckExistModeling(oConn2Rows(0))
2680
                ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2681
                    If sConn1Type = "Line" Then
2682
                        objInputs.AddConnectorTarget(oStartLMConnector, dStart_Dwg_x, dStart_Dwg_y)
2683
                    Else
2684
                        objInputs.AddSymbolTarget(oLMSymbol1, dStart_Dwg_x, dStart_Dwg_y)
2685
                    End If
2686 b08338e3 Gyusu
2687 76f465d0 Gyusu
                    objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2688
                    '    sSecondUid = CheckExistModeling(oConn2Rows(0))
2689
                ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2690
                    If sConn2Type = "Line" Then
2691
                        objInputs.AddConnectorTarget(oEndLMConnector, dEnd_Dwg_x, dEnd_Dwg_y)
2692
                    Else
2693
                        objInputs.AddSymbolTarget(oLMSymbol2, dEnd_Dwg_x, dEnd_Dwg_y)
2694
                    End If
2695 b08338e3 Gyusu
2696 76f465d0 Gyusu
                    objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2697 f9b63682 Gyusu
2698 76f465d0 Gyusu
                    'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2699 b08338e3 Gyusu
2700 76f465d0 Gyusu
                    '   sFirstUid = CheckExistModeling(oConn1Rows(0))
2701
                Else
2702
                    If sConn1Type = "Line" Then
2703
                        objInputs.AddConnectorTarget(oStartLMConnector, dStart_Dwg_x, dStart_Dwg_y)
2704
                    Else
2705
                        objInputs.AddSymbolTarget(oLMSymbol1, dStart_Dwg_x, dStart_Dwg_y)
2706
                    End If
2707
                    If sConn2Type = "Line" Then
2708
                        objInputs.AddConnectorTarget(oStartLMConnector, dEnd_Dwg_x, dEnd_Dwg_y)
2709
                    Else
2710
                        objInputs.AddSymbolTarget(oLMSymbol2, dEnd_Dwg_x, dEnd_Dwg_y)
2711
                    End If
2712
                    'objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
2713
                    'objInputs.AddConnectorTarget(oEndLMConnector, dEnd_Dwg_x, dOriginalEnd_y)
2714
                End If
2715
                If sConn1Type <> "" And sConn2Type <> "" Then
2716 73bfb231 Gyusu
                    If oConn1Rows.Count > 0 Then
2717
                        sFirstUid = CheckExistModeling(oConn1Rows(0))
2718
                    End If
2719
                    If oConn2Rows.Count > 0 Then
2720
                        sSecondUid = CheckExistModeling(oConn2Rows(0))
2721
                    End If
2722
2723 76f465d0 Gyusu
                ElseIf sConn1Type <> "" And sConn2Type = "" Then
2724 73bfb231 Gyusu
                    If oConn1Rows.Count > 0 Then
2725
                        sFirstUid = CheckExistModeling(oConn1Rows(0))
2726
                    End If
2727
2728 76f465d0 Gyusu
                ElseIf sConn1Type = "" And sConn2Type <> "" Then
2729 73bfb231 Gyusu
                    If oConn2Rows.Count > 0 Then
2730
                        sSecondUid = CheckExistModeling(oConn2Rows(0))
2731
                    End If
2732
2733 76f465d0 Gyusu
                End If
2734 f9b63682 Gyusu
2735 76f465d0 Gyusu
                If sFirstUid <> "" And sSecondUid <> "" Then
2736
                    sReturnUid = sSecondUid
2737
                ElseIf sFirstUid = "" And sSecondUid <> "" Then
2738
                    sReturnUid = sSecondUid
2739
                ElseIf sFirstUid <> "" And sSecondUid = "" Then
2740
                    sReturnUid = sFirstUid
2741
                Else
2742
                    sReturnUid = ""
2743
                End If
2744
                _iPipecnt = _iPipecnt + 1
2745
                Dim oCurrentConnector As LMConnector = Nothing
2746 f9b63682 Gyusu
2747 76f465d0 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
2748 f9b63682 Gyusu
                Try
2749 76f465d0 Gyusu
                    If Chk_OnlyPoint.Checked Then
2750
                        objInputs.Clear()
2751
                        objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2752
                        objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2753
                        oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2754
                    Else
2755
                        oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2756 f9b63682 Gyusu
                    End If
2757 76f465d0 Gyusu
                    AddProgress()
2758
2759 f9b63682 Gyusu
                Catch ex As Exception
2760 76f465d0 Gyusu
2761 f9b63682 Gyusu
                End Try
2762 76f465d0 Gyusu
                If oCurrentConnector IsNot Nothing Then
2763
                    oCurrentLineRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
2764
                    oCurrentLineRow(_XML_LINE_DRAWING_TF) = "TRUE"
2765
2766
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dStart_Dwg_x & "," & dStart_Dwg_y & ") - (" & dEnd_Dwg_x & "," & dEnd_Dwg_y & ")..." & _iPipecnt & " count ")
2767
2768
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
2769
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2770
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentLineRow(_XML_SYMBOL_Conn1_Uid).ToString())
2771
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentLineRow(_XML_SYMBOL_Conn2_Uid).ToString())
2772
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2773
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dStart_Dwg_x & "," & dStart_Dwg_y)
2774
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dEnd_Dwg_x & "," & dEnd_Dwg_y)
2775
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
2776
2777
                    Dim oPipeRun As LMPipeRun = oPidDataSource.GetPipeRun(oCurrentConnector.ModelItemID)
2778
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2779
                    If oAttributeRow.Length > 0 Then
2780
                        For Each oAttribute In oAttributeRow
2781
                            Try
2782
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2783
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2784
                                If sPIDValue.Contains("'") Then
2785
                                    sPIDValue = sPIDValue.Replace("'", """")
2786
                                End If
2787
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2788
                                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
2789
                            Catch ex As Exception
2790
                            End Try
2791
                        Next
2792
                        oPipeRun.Commit()
2793
                    End If
2794
2795
                    Dim sID_1 As String = ""
2796
                    Dim sID_2 As String = ""
2797
                    If oStartLMConnector IsNot Nothing Then
2798
                        sID_1 = oStartLMConnector.ModelItemID
2799
                        sID_2 = oCurrentConnector.ModelItemID
2800
                    ElseIf oEndLMConnector IsNot Nothing Then
2801
                        sID_1 = oEndLMConnector.ModelItemID
2802
                        sID_2 = oCurrentConnector.ModelItemID
2803
                    End If
2804
                    If sID_1 <> "" And sID_2 <> "" Then
2805 73bfb231 Gyusu
                        Dim objSurvivorItem As LMAItem = Nothing
2806
                        Dim oPipeRun1 As LMPipeRun = oPidDataSource.GetPipeRun(sID_1)
2807
                        Dim oPipeRun2 As LMPipeRun = oPidDataSource.GetPipeRun(sID_2)
2808
                        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
2809 76f465d0 Gyusu
                    End If
2810
                Else
2811
                    sReturnUid = ""
2812
                End If
2813
            Catch ex As Exception
2814
2815
            End Try
2816
2817
2818
        Catch ex As Exception
2819
2820
        End Try
2821
2822 b08338e3 Gyusu
2823 f9b63682 Gyusu
        Return sReturnUid
2824 b08338e3 Gyusu
        '현재 Uid 모델링
2825 f9b63682 Gyusu
    End Function
2826 bb2a0c79 Gyusu
2827
    Private Sub PipingModeling()
2828 e4000111 Gyusu
2829 171ac39d Gyusu
        Try
2830
            For Each oDrwing As TreeNode In Tree_Result.Nodes
2831
                For Each oDwgNode As TreeNode In oDrwing.Nodes
2832
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
2833 54b98e09 Gyusu
                    Dim CDrawing As Drawing = GetDrawing(sDwgName)
2834
                    If CDrawing IsNot Nothing Then
2835 e4000111 Gyusu
                        Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
2836
                        Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
2837
                        For Each oNode As TreeNode In oDwgNode.Nodes
2838
                            Dim iItemcnt As Integer = 0
2839
                            Dim sNodeUid As String = oNode.Name
2840
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2841
                            '1.Equipment
2842
                            '2.Piping OPC
2843
                            '3.OPC 시작되는 Line
2844
                            'Equipment 생성
2845
                            'If sNodeUid <> "PipeLineNo" Then
2846
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2847 b08338e3 Gyusu
2848 e4000111 Gyusu
                            If CLineNo IsNot Nothing Then
2849
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2850
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2851
                                Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2852
                                Dim oDrawLinenoLabel As Boolean = False
2853 b08338e3 Gyusu
                                Try
2854
                                    ManualCheckNode(oLine_Dt)
2855
                                    ManualCheckNode(oSymbol_Dt)
2856
                                Catch ex As Exception
2857
                                End Try
2858 e4000111 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2859
                                    If oSymbolNode.Checked Then
2860 b08338e3 Gyusu
                                        Try
2861
                                            Dim sUid As String = oSymbolNode.Name
2862 3b7a4470 Gyusu
                                            If sUid = "152b5931-e7ed-4fe9-bed8-6c01303567b7" Then
2863
                                                MessageBox.Show("")
2864
                                            End If
2865 b08338e3 Gyusu
                                            Dim sLineNoUid As String = CLineNo.Uid
2866 76f465d0 Gyusu
                                            Dim sReturnUid = sUid
2867
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2868
                                            While True
2869
                                                Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2870
                                                                   _XML_SYMBOL_Check & "] = 'TRUE'")
2871
                                                If oLineRows.Count > 0 Then
2872
                                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2873
                                                Else
2874
                                                    sReturnUid = ""
2875 b08338e3 Gyusu
                                                End If
2876 76f465d0 Gyusu
                                                If sReturnUid = "" Then
2877
                                                    Exit While
2878
                                                End If
2879
                                            End While
2880 b08338e3 Gyusu
                                        Catch ex As Exception
2881
                                        End Try
2882 6a6d8ab4 Gyusu
                                    End If
2883 e4000111 Gyusu
                                Next
2884 76f465d0 Gyusu
                            End If
2885
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2886
                            If CTrimLineNo IsNot Nothing Then
2887
                                Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line
2888
                                Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol
2889
                                Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute
2890
                                Dim oDrawLinenoLabel As Boolean = False
2891
                                Try
2892
                                    ManualCheckNode(oLine_Dt)
2893
                                    ManualCheckNode(oSymbol_Dt)
2894
                                Catch ex As Exception
2895
                                End Try
2896 f9b63682 Gyusu
2897 bb2a0c79 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2898
                                    If oSymbolNode.Checked Then
2899 b08338e3 Gyusu
                                        Try
2900
                                            Dim sUid As String = oSymbolNode.Name
2901 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CTrimLineNo.Uid
2902 f9b63682 Gyusu
                                            Dim sReturnUid = sUid
2903 76f465d0 Gyusu
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2904 f9b63682 Gyusu
                                            While True
2905
                                                Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2906
                                                                   _XML_SYMBOL_Check & "] = 'TRUE'")
2907
                                                If oLineRows.Count > 0 Then
2908
                                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2909 76f465d0 Gyusu
                                                Else
2910
                                                    sReturnUid = ""
2911 f9b63682 Gyusu
                                                End If
2912
                                                If sReturnUid = "" Then
2913
                                                    Exit While
2914
                                                End If
2915
                                            End While
2916 b08338e3 Gyusu
                                        Catch ex As Exception
2917
                                        End Try
2918 bb2a0c79 Gyusu
                                    End If
2919
                                Next
2920 f9b63682 Gyusu
                                'For Each oSymbolNode As TreeNode In oNode.Nodes
2921
                                '    If oSymbolNode.Checked Then
2922
                                '        Try
2923
                                '            Dim sUid As String = oSymbolNode.Name
2924
                                '            Dim sLineNoUid As String = CLineNo.Uid
2925 76f465d0 Gyusu
                                '            Dim sReturnUid = sUid
2926
                                '            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2927
                                '            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2928
                                '                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
2929
                                '            If oSymbolRows.Count > 0 Then
2930
                                '                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2931
                                '            Else
2932
                                '                sReturnUid = ""
2933
                                '            End If
2934
                                '            If sReturnUid = "" Then
2935 f9b63682 Gyusu
                                '            End If
2936
                                '        Catch ex As Exception
2937
                                '        End Try
2938
                                '    End If
2939
                                'Next
2940 e4000111 Gyusu
                            End If
2941 76f465d0 Gyusu
                        Next
2942 3acffcee Gyusu
2943
2944 76f465d0 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
2945
                            Dim iItemcnt As Integer = 0
2946
                            Dim sNodeUid As String = oNode.Name
2947
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2948
                            '1.Equipment
2949
                            '2.Piping OPC
2950
                            '3.OPC 시작되는 Line
2951
                            'Equipment 생성
2952
                            'If sNodeUid <> "PipeLineNo" Then
2953
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2954 bb2a0c79 Gyusu
2955 76f465d0 Gyusu
                            If CLineNo IsNot Nothing Then
2956
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2957
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2958
                                Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2959 b08338e3 Gyusu
                                Dim oDrawLinenoLabel As Boolean = False
2960
                                Try
2961
                                    ManualCheckNode(oLine_Dt)
2962
                                    ManualCheckNode(oSymbol_Dt)
2963
                                Catch ex As Exception
2964
                                End Try
2965
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2966
                                    If oSymbolNode.Checked Then
2967
                                        Try
2968
                                            Dim sUid As String = oSymbolNode.Name
2969 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CLineNo.Uid
2970
                                            Dim sReturnUid = sUid
2971
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2972 3b7a4470 Gyusu
                                            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'FALSE' And [" &
2973 76f465d0 Gyusu
                                                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
2974 3b7a4470 Gyusu
2975 76f465d0 Gyusu
                                            If oSymbolRows.Count > 0 Then
2976
                                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2977
                                            Else
2978
                                                sReturnUid = ""
2979
                                            End If
2980
                                            If sReturnUid = "" Then
2981 b08338e3 Gyusu
                                            End If
2982
                                        Catch ex As Exception
2983
                                        End Try
2984
                                    End If
2985
                                Next
2986 76f465d0 Gyusu
                            End If
2987
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2988
                            If CTrimLineNo IsNot Nothing Then
2989
                                Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line
2990
                                Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol
2991
                                Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute
2992
                                Dim oDrawLinenoLabel As Boolean = False
2993
                                Try
2994
                                    ManualCheckNode(oLine_Dt)
2995
                                    ManualCheckNode(oSymbol_Dt)
2996
                                Catch ex As Exception
2997
                                End Try
2998 b08338e3 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2999 76f465d0 Gyusu
                                    If oSymbolNode.Checked Then
3000
                                        Try
3001 b08338e3 Gyusu
                                            Dim sUid As String = oSymbolNode.Name
3002 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CTrimLineNo.Uid
3003
                                            Dim sReturnUid = sUid
3004
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
3005
                                            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
3006
                                                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
3007
                                            If oSymbolRows.Count > 0 Then
3008
                                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
3009
                                            Else
3010
                                                sReturnUid = ""
3011 b08338e3 Gyusu
                                            End If
3012 76f465d0 Gyusu
                                            If sReturnUid = "" Then
3013 b08338e3 Gyusu
                                            End If
3014 76f465d0 Gyusu
                                        Catch ex As Exception
3015
                                        End Try
3016
                                    End If
3017 b08338e3 Gyusu
                                Next
3018
                            End If
3019
                        Next
3020
                    End If
3021
                Next
3022
            Next
3023
        Catch ex As Exception
3024
3025
        End Try
3026
    End Sub
3027
3028
3029
    Private Sub FindNearPoint(ByVal oOPCSymbol As LMSymbol, ByRef dNear_x As Double, ByRef dNear_y As Double)
3030
        Dim oConnectionPoints_x(4) As Double
3031
        Dim oConnectionPoints_y(4) As Double
3032
3033
        Try
3034
            _Placement.PIDConnectPointLocation(oOPCSymbol, 1, oConnectionPoints_x(0), oConnectionPoints_y(0))
3035
            _Placement.PIDConnectPointLocation(oOPCSymbol, 2, oConnectionPoints_x(1), oConnectionPoints_y(1))
3036
            _Placement.PIDConnectPointLocation(oOPCSymbol, 3, oConnectionPoints_x(2), oConnectionPoints_y(2))
3037
            _Placement.PIDConnectPointLocation(oOPCSymbol, 4, oConnectionPoints_x(3), oConnectionPoints_y(3))
3038
            Dim iNearPoint As Integer = 0
3039
            Dim dGap As Double = 0
3040
            For i = 0 To 3
3041
                If dGap = 0 Then
3042
                    iNearPoint = i
3043
                    dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
3044
                Else
3045
                    If dGap >= Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y) Then
3046
                        iNearPoint = i
3047
                        dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
3048
                    End If
3049
                End If
3050
            Next
3051
            dNear_x = oConnectionPoints_x(iNearPoint)
3052
            dNear_y = oConnectionPoints_y(iNearPoint)
3053
        Catch ex As Exception
3054 e4000111 Gyusu
3055 bb2a0c79 Gyusu
        End Try
3056 e4000111 Gyusu
3057 bb2a0c79 Gyusu
    End Sub
3058
3059
    Private Function GetPipeType(ByVal sType As String) As String
3060
        Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString()
3061
        If sType.ToUpper() = "ELECTRIC" Then
3062
            sSystempath = "\Instrumentation\Signal Line\Electric.sym"
3063
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
3064
            sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym"
3065
        Else
3066
        End If
3067
        Return sSystempath
3068
    End Function
3069
3070
    Private Sub InitAutoRouting()
3071
        For Each oDrwing As TreeNode In Tree_Result.Nodes
3072
            For Each oDwgNode As TreeNode In oDrwing.Nodes
3073
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
3074
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
3075
                If CDrawing IsNot Nothing Then
3076
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
3077
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
3078
                    SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....")
3079 b08338e3 Gyusu
3080 bb2a0c79 Gyusu
                    For Each oNode As TreeNode In oDwgNode.Nodes
3081
                        Dim iItemcnt As Integer = 0
3082
                        Dim sNodeUid As String = oNode.Name
3083
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
3084
                        Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
3085
                        If CLineNo IsNot Nothing Then
3086
                            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
3087
                            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
3088
3089
                            For Each oLineRow In oLine_Dt.Rows
3090 76f465d0 Gyusu
                                ' oLineRow(_XML_LINE_UID) = ""
3091
                                oLineRow(_XML_LINE_SPID) = ""
3092
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
3093
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
3094
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
3095
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
3096 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
3097 76f465d0 Gyusu
                            Next
3098
                            For Each oSymbolRow In oSymbol_Dt.Rows
3099
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
3100
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
3101
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
3102
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
3103
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
3104
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
3105
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
3106 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
3107 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
3108
3109
                            Next
3110
3111
                        End If
3112
3113
                        Dim CTRIMLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
3114
                        If CTRIMLineNo IsNot Nothing Then
3115
                            Dim oLine_Dt As DataTable = CTRIMLineNo.Dt_Line
3116
                            Dim oSymbol_Dt As DataTable = CTRIMLineNo.Dt_Symbol
3117
3118
                            For Each oLineRow In oLine_Dt.Rows
3119
                                ' oLineRow(_XML_LINE_UID) = ""
3120 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_SPID) = ""
3121 76f465d0 Gyusu
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
3122
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
3123
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
3124 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
3125 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
3126 bb2a0c79 Gyusu
                            Next
3127
                            For Each oSymbolRow In oSymbol_Dt.Rows
3128 76f465d0 Gyusu
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
3129 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
3130 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
3131
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
3132
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
3133
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
3134
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
3135 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
3136 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
3137 76f465d0 Gyusu
3138 bb2a0c79 Gyusu
                            Next
3139
3140
                        End If
3141
                    Next
3142
                End If
3143
            Next
3144
        Next
3145
    End Sub
3146
3147
3148
3149
3150
3151
3152
    Private Function CheckBranchLine(ByVal oLine_Dt As DataTable, ByVal dStartX As Double, ByVal dStartY As Double,
3153
                                ByRef dEndX As Double, ByRef dEndY As Double, ByRef sBranchType As String, ByRef oLMConnector As LMConnector) As Boolean
3154
3155
        Try
3156
            Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And [" & _XML_LINE_SPID & "] <> ''")
3157
            For Each oModelrow In oModelingLineRows
3158
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
3159
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
3160
                Dim dModelStartX As Double
3161
                Dim dModelStartY As Double
3162
                Dim dModelEndX As Double
3163
                Dim dModelEndY As Double
3164
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
3165
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
3166
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
3167
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
3168
                Dim dGap As Double = 0.0002
3169
                Dim d기준x As Double = (dModelStartX + dModelEndX) / 2
3170
                Dim d기준y As Double = (dModelStartY + dModelEndY) / 2
3171
                Try
3172
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3173
                Catch ex As Exception
3174
3175
                End Try
3176
                Dim oRun As LMPipeRun = Nothing
3177
                Try
3178
3179
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
3180
                    Dim dResultCalc As Double = -1
3181
                    For Each objRep In oRun.Representations
3182
                        If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
3183
                            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3184
                            For Each objConnectorVertex In objConnector.ConnectorVertices
3185
                                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3186
                                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3187
                                Dim dStartCalc As Double = Math.Abs(dStartX - dConn_X) + Math.Abs(dStartY - dConn_Y)
3188
3189
                                If dResultCalc > dStartCalc Or dResultCalc = -1 Then
3190
                                    dResultCalc = dStartCalc
3191
                                    oLMConnector = objConnector
3192
                                    d기준x = dConn_X
3193
                                    d기준y = dConn_Y
3194
                                End If
3195
                                Dim dEndCalc As Double = Math.Abs(dEndX - dConn_X) + Math.Abs(dEndY - dConn_Y)
3196
                                If dResultCalc > dEndCalc Then
3197
                                    dResultCalc = dEndCalc
3198
                                    oLMConnector = objConnector
3199
                                    d기준x = dConn_X
3200
                                    d기준y = dConn_Y
3201
                                End If
3202
                            Next
3203
                        End If
3204
                    Next
3205
                    '        _Placement.PIDConnectPointLocation(oRun, 1, dModelStartX, dModelEndX)
3206
                    '       _Placement.PIDConnectPointLocation(oRun, 2, dModelEndX, dModelEndY)
3207
                Catch ex As Exception
3208
                End Try
3209
3210
3211
                'Dim sSPID As String = oModelrow(_XML_LINE_SPID).ToString()
3212
                'Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.Get PipeRun(sSPID)
3213
                'If dModelStartX + dGap > dStartX And dModelStartX - dGap < dStartX And
3214
                '        dModelStartY + dGap > dStartY And dModelStartY - dGap < dStartY Then
3215
                '    dStartX = dModelStartX
3216
                '    dStartY = dModelStartY
3217
                'ElseIf dModelEndX + dGap > dStartX And dModelEndX - dGap < dStartX And
3218
                '        dModelEndY + dGap > dStartY And dModelEndY - dGap < dStartY Then
3219
                '    dStartX = dModelEndX
3220
                '    dStartY = dModelEndY
3221
                'End If
3222
3223
                'Vetical
3224
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
3225
                    If Math.Abs(dStartX - dEndX) >= Math.Abs(dStartY - dEndY) Then
3226
                        'Horizontal 
3227
                        ' dGap = 0.0002 'Math.Abs(dStartX - dEndX) / 20
3228
                        '기준선의 Y범위안에 가로선이 포함되어야됨
3229
                        If (dModelStartY + dGap >= dStartY And dModelEndY - dGap <= dStartY) Or
3230
                            (dModelStartY - dGap <= dStartY And dModelEndY + dGap >= dStartY) And
3231
                            (dModelStartY + dGap >= dEndY And dModelEndY - dGap <= dEndY) Or
3232
                            (dModelStartY - dGap <= dEndY And dModelEndY + dGap >= dEndY) Then
3233
                            '기준선보다 왼쪽에 가로선이 있을때
3234
                            If d기준x >= dStartX And d기준x >= dEndX Then
3235
                                If dStartX >= dEndX Then
3236
                                    'dStartX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3237
                                    If dStartX + dGap >= d기준x Then
3238
                                        dStartX = d기준x
3239
                                        sBranchType = "1"
3240
                                        Return True
3241
                                    End If
3242
                                Else
3243
                                    'dEndX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3244
                                    If dEndX + dGap >= d기준x Then
3245
                                        dEndX = d기준x
3246
                                        sBranchType = "2"
3247
                                        Return True
3248
                                    End If
3249
                                End If
3250
                                '기준선보다 오른쪽에 가로선이 있을때
3251
                            ElseIf d기준x <= dStartX And d기준x <= dEndX Then
3252
                                If dStartX >= dEndX Then
3253
                                    'dEndX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3254
                                    If dEndX - dGap <= d기준x Then
3255
                                        dEndX = d기준x
3256
                                        sBranchType = "2"
3257
                                        Return True
3258
                                    End If
3259
                                Else
3260
                                    'dStartX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3261
                                    If dStartX - dGap <= d기준x Then
3262
                                        dStartX = d기준x
3263
                                        sBranchType = "1"
3264
                                        Return True
3265
                                    End If
3266
                                End If
3267
                            Else
3268
                                '기준선과 세로선이 겹칠때
3269
                                If (d기준x >= dStartX And d기준x <= dEndX) Or
3270
                                        (d기준x <= dStartX And d기준x >= dEndX) Then
3271
                                    If (dModelStartY <= dStartY And dModelEndY >= dEndY) Or
3272
                                        (dModelStartY >= dStartY And dModelEndY <= dEndY) Then
3273
                                        '기준선이 dStartX와 dEndX중 어느쪽에 가까운지 확인
3274
                                        '가로선의 왼쪽점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
3275
                                        '가로선의 오른쪽점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
3276
                                        If Math.Abs(d기준x - dStartX) >= Math.Abs(d기준x - dEndX) Then
3277
                                            'EndX점이 기준선과 더 가까이 있음
3278
                                            If dStartX >= dEndX Then
3279
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3280
                                                If dEndX - dGap <= d기준x Then
3281
                                                    dEndX = d기준x
3282
                                                    sBranchType = "4"
3283
                                                    Return True
3284
                                                End If
3285
                                            Else
3286
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3287
                                                If dEndX + dGap >= d기준x Then
3288
                                                    dEndX = d기준x
3289
                                                    sBranchType = "4"
3290
                                                    Return True
3291
                                                End If
3292
3293
                                            End If
3294
                                        Else
3295
                                            'dStartX점이 기준선과 더 가까이 있음
3296
                                            If dStartX >= dEndX Then
3297
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3298
                                                If dStartX + dGap >= d기준x Then
3299
                                                    dStartX = d기준x
3300
                                                    sBranchType = "3"
3301
                                                    Return True
3302
                                                End If
3303
3304
                                            Else
3305
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3306
                                                If dStartX - dGap <= d기준x Then
3307
                                                    dStartX = d기준x
3308
                                                    sBranchType = "3"
3309
                                                    Return True
3310
                                                End If
3311
                                            End If
3312
                                        End If
3313
                                    End If
3314
3315
                                End If
3316
                            End If
3317
                        End If
3318
3319
                    End If
3320
                    Else
3321
                    'Horizontal
3322
                    If Math.Abs(dModelStartX - dModelEndX) >= Math.Abs(dModelStartY - dModelEndY) Then
3323
                        'Vertical
3324
                        If Math.Abs(dStartX - dEndX) <= Math.Abs(dStartY - dEndY) Then
3325
                            '  dGap = 0.0015 'Math.Abs(dStartY - dEndY) / 80
3326
3327
                            '기준선의 X범위안에 세로선이 포함되어야됨
3328
                            If ((dModelStartX + dGap >= dStartX And dModelEndX - dGap <= dStartX) Or
3329
                            (dModelStartX - dGap <= dStartX And dModelEndX + dGap >= dStartX)) And
3330
                            ((dModelStartX + dGap >= dEndX And dModelEndX - dGap <= dEndX) Or
3331
                            (dModelStartX - dGap <= dEndX And dModelEndX + dGap >= dEndX)) Then
3332
3333
                                '가로선보다 아래에 세로선이 있을때
3334
                                If d기준y >= dStartY And d기준y >= dEndY Then
3335
                                    If dStartY >= dEndY Then
3336
                                        'dStartY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3337
                                        If dStartY + dGap >= d기준y Then
3338
                                            dStartY = d기준y
3339
                                            sBranchType = "3"
3340
                                            Return True
3341
                                        End If
3342
                                    Else
3343
                                        'dEndY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3344
                                        If dEndY + dGap >= d기준y Then
3345
                                            dEndY = d기준y
3346
3347
                                            If Math.Abs(dEndX - dModelStartX) > Math.Abs(dEndX - dModelEndX) Then
3348
                                                dEndX = dModelEndX
3349
                                            Else
3350
                                                dEndX = dModelStartX
3351
                                            End If
3352
3353
                                            sBranchType = "4"
3354
                                            Return True
3355
                                        End If
3356
                                    End If
3357
                                    '기준선보다 위에 세로선이 있을때
3358
                                ElseIf d기준y <= dStartY And d기준y <= dEndY Then
3359
                                    If dStartY >= dEndY Then
3360
                                        'dEndY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3361
                                        If dEndY - dGap <= d기준y Then
3362
                                            dEndY = d기준y
3363
                                            sBranchType = "4"
3364
                                            Return True
3365
                                        End If
3366
                                    Else
3367
                                        'dStartY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3368
                                        If dStartY - dGap <= d기준y Then
3369
                                            dStartY = d기준y
3370
                                            sBranchType = "3"
3371
                                            Return True
3372
                                        End If
3373
                                    End If
3374
                                Else
3375
                                    '기준선과 세로선이 겹칠때
3376
                                    If (d기준y >= dStartY And d기준y <= dEndY) Or
3377
                                            (d기준y <= dStartY And d기준y >= dEndY) Then
3378
                                        '기준선이 dStartY와 dEndY중 어느쪽에 가까운지 확인
3379
                                        '세로선의 윗점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
3380
                                        '세로선의 아래점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
3381
                                        If (dModelStartX <= dStartX And dModelEndX >= dEndX) Or
3382
                                            (dModelStartX >= dStartX And dModelEndX <= dEndX) Then
3383
                                            If Math.Abs(d기준y - dStartY) >= Math.Abs(d기준y - dEndY) Then
3384
                                                'Endy점이 기준선과 더 가까이 있음
3385
                                                If dStartY >= dEndY Then
3386
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3387
                                                    If dEndY + dGap >= d기준y Then
3388
                                                        dEndY = d기준y
3389
                                                        sBranchType = "4"
3390
                                                        Return True
3391
                                                    End If
3392
                                                Else
3393
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3394
                                                    If dEndY - dGap <= d기준y Then
3395
                                                        dEndY = d기준y
3396
                                                        sBranchType = "4"
3397
                                                        Return True
3398
                                                    End If
3399
                                                End If
3400
                                            Else
3401
                                                'dStartY점이 기준선과 더 가까이 있음
3402
                                                If dStartY >= dEndY Then
3403
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3404
                                                    If dStartY - dGap <= d기준y Then
3405
                                                        dStartY = d기준y
3406
                                                        sBranchType = "3"
3407
                                                        Return True
3408
                                                    End If
3409
                                                Else
3410
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3411
                                                    If dStartY + dGap >= d기준y Then
3412
                                                        dStartY = d기준y
3413
                                                        sBranchType = "3"
3414
                                                        Return True
3415
                                                    End If
3416
                                                End If
3417
                                            End If
3418
                                        End If
3419
3420
                                    End If
3421
                                End If
3422
                            End If
3423
                        End If
3424
                    End If
3425
                End If
3426
            Next
3427
        Catch ex As Exception
3428
3429
        End Try
3430
        oLMConnector = Nothing
3431
        Return False
3432
    End Function
3433
3434 76f465d0 Gyusu
    Private Function CheckConnectionSymbolToSymbol(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3435
                                  ByRef oLMConnector As LMConnector) As Boolean
3436
        Dim bConnectionFlag As Boolean = False
3437
        Try
3438
            For Each oModelrow In oModelingLineRows
3439
                Dim d기준x As Double = dX
3440
                Dim d기준y As Double = dY
3441
                Dim dGap As Double = 0.0002
3442
                Dim oRun As LMPipeRun = Nothing
3443
                Try
3444
                    Dim oLMSymbol As LMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3445
                    Dim dX1 As Double = 0.0
3446
                    Dim dY1 As Double = 0.0
3447
                    Dim dX2 As Double = 0.0
3448
                    Dim dY2 As Double = 0.0
3449
                    For Each oConnector In oLMSymbol.Connect1Connectors
3450
                        oLMConnector = oConnector
3451
                    Next
3452
                    '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3453
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3454
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3455
                    If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap Then
3456
                        dX = dX1
3457
                        dY = dY1
3458
                        bConnectionFlag = True
3459
                        Exit For
3460
                    End If
3461
                    If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap Then
3462
                        dX = dX2
3463
                        dY = dY2
3464
                        bConnectionFlag = True
3465
                        Exit For
3466
                    End If
3467
3468
                    'For Each oConnector In oLMSymbol.Connect1Connectors
3469
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3470
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3471
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3472
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3473
                    '            oLMConnector = oConnector
3474
                    '            dX = dConn_X
3475
                    '            dY = dConn_Y
3476
                    '            bConnectionFlag = True
3477
                    '            Exit For
3478
                    '        End If
3479
                    '    Next
3480
                    'Next
3481
3482
                    'For Each oConnector In oLMSymbol.Connect2Connectors
3483
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3484
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3485
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3486
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3487
                    '            oLMConnector = oConnector
3488
                    '            dX = dConn_X
3489
                    '            dY = dConn_Y
3490
                    '            bConnectionFlag = True
3491
                    '            Exit For
3492
                    '        End If
3493
                    '    Next
3494
                    'Next
3495
3496
3497
                    'If oRun IsNot Nothing Then
3498
                    '    Dim dResultCalc As Double = -1
3499
                    '    For Each objRep In oRun.Representations
3500
                    '        Dim sRepresentationType As String = objRep.Attributes("RepresentationType").Value
3501
                    '        If objRep.Attributes("RepresentationType").Value = "Connector" Or
3502
                    '            objRep.Attributes("RepresentationType").Value = "Symbol" And
3503
                    '             objRep.Attributes("ItemStatus").Value = "Active" Then
3504
                    '            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3505
                    '            For Each objConnectorVertex In objConnector.ConnectorVertices
3506
                    '                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3507
                    '                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3508
                    '                If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3509
                    '                    oLMConnector = objConnector
3510
                    '                    d기준x = dConn_X
3511
                    '                    d기준y = dConn_Y
3512
                    '                    bConnectionFlag = True
3513
                    '                    Exit For
3514
                    '                End If
3515
                    '            Next
3516
                    '        End If
3517
                    '    Next
3518
                    'End If
3519
3520
                Catch ex As Exception
3521
                End Try
3522
            Next
3523
3524
        Catch ex As Exception
3525
3526
        End Try
3527
        Return bConnectionFlag
3528
    End Function
3529
3530
    Private Function CheckConnectionSymbolToLine(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3531
ByVal dCenterX As Double, ByVal dCenterY As Double, ByRef oLMConnector As LMConnector) As LMSymbol
3532
        Dim bConnectionFlag As Boolean = False
3533
        Dim oLMSymbol As LMSymbol = Nothing
3534
        Try
3535
3536
            For Each oModelrow In oModelingLineRows
3537
                Dim d기준x As Double = dCenterX
3538
                Dim d기준y As Double = dCenterY
3539
                Dim dGap As Double = 0.001
3540
                Dim oRun As LMPipeRun = Nothing
3541
                Dim dCheckGap As Double = 0
3542
                Try
3543
3544
                    Dim dX1 As Double = 0.0
3545
                    Dim dY1 As Double = 0.0
3546
                    Dim dX2 As Double = 0.0
3547
                    Dim dY2 As Double = 0.0
3548
                    '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3549
                    oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3550
                    For Each oConnector In oLMSymbol.Connect1Connectors
3551
                        oLMConnector = oConnector
3552
                    Next
3553
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3554
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3555
                    '  If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap And
3556
                    If Math.Abs(d기준x - dX1) < dCheckGap And Math.Abs(d기준y - dY1) < dCheckGap Or dCheckGap = 0 Then
3557
                        dX = dX1
3558
                        dY = dY1
3559
                        bConnectionFlag = True
3560
                        dCheckGap = Math.Abs(d기준x - dX1) + Math.Abs(d기준y - dY1)
3561
                    End If
3562
                    'If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap And
3563
                    '  Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2 < dCheckGap) Or dCheckGap = 0 Then
3564
                    If Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2) < dCheckGap Or dCheckGap = 0 Then
3565
                        dX = dX2
3566
                        dY = dY2
3567
                        bConnectionFlag = True
3568
                    End If
3569
3570
                Catch ex As Exception
3571
                End Try
3572
                If bConnectionFlag Then
3573
                    oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3574
                Else
3575
                    oLMSymbol = Nothing
3576
                End If
3577
            Next
3578 b08338e3 Gyusu
3579 76f465d0 Gyusu
        Catch ex As Exception
3580 b08338e3 Gyusu
3581 76f465d0 Gyusu
        End Try
3582 b08338e3 Gyusu
3583 76f465d0 Gyusu
        Return oLMSymbol
3584
    End Function
3585 b08338e3 Gyusu
3586 3b7a4470 Gyusu
    ''' <summary>
3587
    ''' 라인과 라인이 만나는점이 브런치점인지 확인, 오차범위내 라인보정
3588
    ''' </summary>
3589
    ''' <param name="oModelingLineRows"></param>
3590
    ''' <param name="dStartX"></param>
3591
    ''' <param name="dStartY"></param>
3592
    ''' <param name="dEndX"></param>
3593
    ''' <param name="dEndY"></param>
3594
    ''' <param name="oLMConnector"></param>
3595
    ''' <returns></returns>
3596
    Private Function CheckBranchLine(ByVal oModelingLineRows As DataRowCollection, ByRef dStartX As Double, ByRef dStartY As Double,
3597
                                     ByRef dEndX As Double, ByRef dEndY As Double, ByRef oLMConnector As LMConnector) As String
3598
        Dim bConnectionFlag As Boolean = False
3599
        Dim sBranchDirection As String = ""
3600
        Try
3601
            For Each oModelrow In oModelingLineRows
3602
                Dim dModelStartX As Double
3603
                Dim dModelStartY As Double
3604
                Dim dModelEndX As Double
3605
                Dim dModelEndY As Double
3606 73bfb231 Gyusu
                Dim dGap As Double = 0.002
3607 3b7a4470 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3608
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3609
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3610
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3611
3612
                '기존라인이 X축방향이라면 현재선은 Y축방향이 되어야됨
3613
                If Math.Abs(dModelStartX - dModelEndX) > Math.Abs(dModelStartY - dModelEndY) And
3614
                    Math.Abs(dStartX - dEndX) < Math.Abs(dStartY - dEndY) Then
3615
3616
                    '기본라인의 X축영역안에 현재선이 있어야됨
3617
                    '      If dModelEndY > dModelStartY Then
3618
                    If (dStartX < dModelEndX And dStartX > dModelStartX) Or
3619
                            (dStartX > dModelEndX And dStartX < dModelStartX) Then
3620
                        '[오차범위 수정]
3621
                        '현재선의 Y축방향이 기존라인의 X축방향을 통과하는지 확인
3622
                        If dStartY < dEndY Then
3623
                            If dEndY > dModelStartY And dModelStartY > dStartY Then
3624
                                If dEndY - dModelStartY > dModelStartY - dStartY Then
3625
                                    '위쪽으로 라인이 나와있을때
3626
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3627
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3628 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3629 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3630
                                        dEndY = dEndY + dAddPoint
3631
                                        dStartY = dModelStartY
3632
                                        sBranchDirection = "START"
3633 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3634
                                        Exit For
3635 3b7a4470 Gyusu
                                    End If
3636
                                Else
3637
                                    '아래쪽으로 라인이 나와있을때
3638
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3639
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3640 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3641 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3642
                                        dStartY = dStartY - dAddPoint
3643
                                        dEndY = dModelStartY
3644
                                        sBranchDirection = "END"
3645 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3646
                                        Exit For
3647 3b7a4470 Gyusu
                                    End If
3648
                                End If
3649
                            Else
3650
                                '현재선의 Y축방향이 기존라인의 X축방향에 못미치는지 확인
3651
                                If dStartY > dModelStartY Then
3652
                                    '기존라인보다 위쪽에 현재선이 있을때
3653 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3654 3b7a4470 Gyusu
                                        '오차범위만큼 작은 y좌표를 뺐을때 기존라인보다 아래쪽에 있을경우 오차보정
3655
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3656
                                        dEndY = dEndY - dAddPoint
3657
                                        dStartY = dModelStartY
3658
                                        sBranchDirection = "START"
3659 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3660
                                        Exit For
3661 3b7a4470 Gyusu
                                    End If
3662
                                Else
3663
                                    '기존라인보다 아래쪽에 현재선이 있을때
3664 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3665 3b7a4470 Gyusu
                                        '오차범위만큼 큰 y좌표를 더했을때 기존라인보다 위쪽에 있을경우 오차보정
3666
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3667
                                        dEndY = dModelStartY
3668
                                        dStartY = dStartY + dAddPoint
3669
                                        sBranchDirection = "END"
3670 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3671
                                        Exit For
3672 3b7a4470 Gyusu
                                    End If
3673
                                End If
3674
                            End If
3675
                        Else
3676
                            If dEndY < dModelStartY And dModelStartY < dStartY Then
3677
                                If dModelStartY - dEndY < dStartY - dModelStartY Then
3678
                                    '위쪽으로 라인이 나와있을때
3679
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3680
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3681 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3682 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3683
                                        dStartY = dStartY + dAddPoint
3684
                                        dEndY = dModelStartY
3685
                                        sBranchDirection = "END"
3686 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3687
                                        Exit For
3688 3b7a4470 Gyusu
                                    End If
3689
                                Else
3690
                                    '아래쪽으로 라인이 나와있을때
3691
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3692
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3693 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3694 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3695
                                        dEndY = dEndY - dAddPoint
3696
                                        dStartY = dModelStartY
3697
                                        sBranchDirection = "START"
3698 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3699
                                        Exit For
3700 3b7a4470 Gyusu
                                    End If
3701
                                End If
3702
                            Else
3703
                                If dEndY > dModelStartY Then
3704
                                    '기존라인보다 우측에 현재선이 있을때
3705 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3706 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3707
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3708
                                        dStartY = dStartY - dAddPoint
3709
                                        dEndY = dModelStartY
3710
                                        sBranchDirection = "END"
3711 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3712
                                        Exit For
3713 3b7a4470 Gyusu
                                    End If
3714
                                Else
3715
                                    '기존라인보다 좌측에 현재선이 있을때
3716 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3717 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3718
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3719
                                        dStartY = dModelStartY
3720
                                        dEndY = dEndY + dAddPoint
3721
                                        sBranchDirection = "START"
3722 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3723
                                        Exit For
3724 3b7a4470 Gyusu
                                    End If
3725
                                End If
3726
                            End If
3727
                        End If
3728
                    End If
3729
                    '기존라인이 Y축방향이라면 현재선은 X축방향이 되어야됨
3730
                ElseIf Math.Abs(dModelStartX - dModelEndX) < Math.Abs(dModelStartY - dModelEndY) And
3731
                Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
3732
3733
                    '기본라인의 Y축영역안에 현재선이 있어야됨
3734
                    '      If dModelEndY > dModelStartY Then
3735
                    If (dStartY < dModelEndY And dStartY > dModelStartY) Or
3736
                            (dStartY > dModelEndY And dStartY < dModelStartY) Then
3737
                        '[오차범위 수정]
3738
                        '현재선의 X축방향이 기존라인의 Y축방향을 통과하는지 확인
3739
                        If dStartX < dEndX Then
3740
                            If dEndX > dModelStartX And dModelStartX > dStartX Then
3741
                                If dEndX - dModelStartX > dModelStartX - dStartX Then
3742
                                    '우측으로 라인이 나와있을때
3743
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3744
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌표에 더한다.
3745 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3746 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3747
                                        dEndX = dEndX + dAddPoint
3748
                                        dStartX = dModelStartX
3749
                                        sBranchDirection = "START"
3750 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3751
                                        Exit For
3752 3b7a4470 Gyusu
                                    End If
3753
                                Else
3754
                                    '좌측으로 라인이 나와있을때
3755
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3756
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3757 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3758 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3759
                                        dStartX = dStartX - dAddPoint
3760
                                        dEndX = dModelStartX
3761
                                        sBranchDirection = "END"
3762 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3763
                                        Exit For
3764 3b7a4470 Gyusu
                                    End If
3765
                                End If
3766
                            Else
3767
                                '현재선의 X축방향이 기존라인의 Y축방향에 못미치는지 확인
3768
                                If dStartX > dModelStartX Then
3769
                                    '기존라인보다 우측에 현재선이 있을때
3770 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3771 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3772
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3773
                                        dEndX = dEndX - dAddPoint
3774
                                        dStartX = dModelStartX
3775
                                        sBranchDirection = "START"
3776 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3777
                                        Exit For
3778 3b7a4470 Gyusu
                                    End If
3779
                                Else
3780
                                    '기존라인보다 좌측에 현재선이 있을때
3781 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3782 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3783
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3784
                                        dEndX = dModelStartX
3785
                                        dStartX = dStartX + dAddPoint
3786
                                        sBranchDirection = "END"
3787 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3788
                                        Exit For
3789 3b7a4470 Gyusu
                                    End If
3790
                                End If
3791
                            End If
3792
                        Else
3793
                            If dEndX < dModelStartX And dModelStartX < dStartX Then
3794
                                If dModelStartX - dEndX < dStartX - dModelStartX Then
3795
                                    '우측으로 라인이 나와있을때
3796
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3797
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌에 더한다.
3798 73bfb231 Gyusu
                                    If Math.Abs(dModelStartX - dEndX) <= dGap Then
3799 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3800
                                        dStartX = dStartX + dAddPoint
3801
                                        dEndX = dModelStartX
3802
                                        sBranchDirection = "END"
3803 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3804
                                        Exit For
3805 3b7a4470 Gyusu
                                    End If
3806
                                Else
3807
                                    '좌측으로 라인이 나와있을때
3808
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3809
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3810 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3811 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3812
                                        dEndX = dEndX - dAddPoint
3813
                                        dStartX = dModelStartX
3814
                                        sBranchDirection = "START"
3815 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3816
                                        Exit For
3817 3b7a4470 Gyusu
                                    End If
3818
3819
                                End If
3820
                            Else
3821
                                If dEndX > dModelStartX Then
3822
                                    '기존라인보다 우측에 현재선이 있을때
3823 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3824 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3825
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3826
                                        dStartX = dStartX - dAddPoint
3827
                                        dEndX = dModelStartX
3828
                                        sBranchDirection = "END"
3829 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3830
                                        Exit For
3831 3b7a4470 Gyusu
                                    End If
3832
                                Else
3833
                                    '기존라인보다 좌측에 현재선이 있을때
3834 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3835 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3836
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3837
                                        dStartX = dModelStartX
3838
                                        dEndX = dEndX + dAddPoint
3839
                                        sBranchDirection = "START"
3840 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3841
                                        Exit For
3842 3b7a4470 Gyusu
                                    End If
3843
                                End If
3844
                            End If
3845
                        End If
3846
                    End If
3847
                End If
3848
            Next
3849
        Catch ex As Exception
3850
            bConnectionFlag = False
3851
            oLMConnector = Nothing
3852
        End Try
3853
        Return sBranchDirection
3854
3855
    End Function
3856
3857
    ''' <summary>
3858
    ''' 라인과 특정 포인트에 커넥션을 확인하는 메서드
3859
    ''' </summary>
3860
    ''' <param name="oModelingLineRows"></param>
3861
    ''' <param name="dX"></param>
3862
    ''' <param name="dY"></param>
3863
    ''' <param name="oLMConnector"></param>
3864
    ''' <param name="dPreConnX"></param>
3865
    ''' <param name="dPreConnY"></param>
3866
    ''' <returns></returns>
3867
3868
3869 b08338e3 Gyusu
    Private Function CheckConnectionLine(ByVal oModelingLineRows() As DataRow, ByVal dX As Double, ByVal dY As Double,
3870 76f465d0 Gyusu
                                  ByRef oLMConnector As LMConnector, ByRef dPreConnX As Double, ByRef dPreConnY As Double) As Boolean
3871 b08338e3 Gyusu
        Dim bConnectionFlag As Boolean = False
3872 76f465d0 Gyusu
        Dim iGapCheck As Integer = 0
3873 b08338e3 Gyusu
        Try
3874
            For Each oModelrow In oModelingLineRows
3875 76f465d0 Gyusu
                Dim d기준x As Double = dX
3876
                Dim d기준y As Double = dY
3877
                Dim dGap As Double = 0.0002
3878
                Dim oRun As LMPipeRun = Nothing
3879
                'Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
3880 3b7a4470 Gyusu
                'Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
3881 b08338e3 Gyusu
                Dim dModelStartX As Double
3882
                Dim dModelStartY As Double
3883
                Dim dModelEndX As Double
3884
                Dim dModelEndY As Double
3885 3b7a4470 Gyusu
                'ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
3886
                'ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
3887
                'ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
3888 76f465d0 Gyusu
                'ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
3889
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3890
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3891
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3892
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3893
                d기준x = (dModelStartX + dModelEndX) / 2
3894
                d기준y = (dModelStartY + dModelEndY) / 2
3895 b08338e3 Gyusu
                Try
3896
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3897 76f465d0 Gyusu
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
3898 b08338e3 Gyusu
                Catch ex As Exception
3899
                End Try
3900
                Try
3901 76f465d0 Gyusu
                    If oRun IsNot Nothing Then
3902
                        Dim dResultCalc As Double = -1
3903
                        For Each objRep In oRun.Representations
3904
                            If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
3905
                                Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3906
                                For Each objConnectorVertex In objConnector.ConnectorVertices
3907
                                    Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3908
                                    Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3909
                                    If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3910
                                        oLMConnector = objConnector
3911
                                        dPreConnX = dConn_X
3912
                                        dPreConnY = dConn_Y
3913
                                        bConnectionFlag = True
3914
                                    End If
3915
                                Next
3916
                            End If
3917
                        Next
3918
                    End If
3919 b08338e3 Gyusu
                Catch ex As Exception
3920
                End Try
3921
            Next
3922
        Catch ex As Exception
3923 76f465d0 Gyusu
            bConnectionFlag = False
3924
            oLMConnector = Nothing
3925 b08338e3 Gyusu
        End Try
3926
        Return bConnectionFlag
3927
    End Function
3928
3929
    Private Function CheckLineBranch(ByVal oLine_Dt As DataTable, ByRef dX As Double, ByRef dY As Double,
3930
                                     ByVal sDirection As String, ByRef oLMConnector As LMConnector) As Boolean
3931
3932
        Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And " &
3933
                                                                "[" & _XML_LINE_SPID & "] <> ''")
3934
3935
        Dim bConnectionFlag As Boolean = False
3936
        Try
3937
            For Each oModelrow In oModelingLineRows
3938
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
3939
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
3940
                Dim dModelStartX As Double
3941
                Dim dModelStartY As Double
3942
                Dim dModelEndX As Double
3943
                Dim dModelEndY As Double
3944
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
3945
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
3946
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
3947
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
3948
                Dim dGap As Double = 0.0002
3949
3950
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
3951
                    'Vertical
3952
                    If sDirection = "X" Then
3953
                        'x Direction Line
3954
                        If (dModelStartY + dGap >= dY And dModelEndY - dGap <= dY) Or
3955
                        (dModelStartY - dGap <= dY And dModelEndY + dGap >= dY) Then
3956
                            If (dX > dModelStartX And dX < dModelEndX) Or (dX > dModelEndX And dX < dModelStartX) Then
3957
                                If Math.Abs(dX - dModelStartX) > Math.Abs(dX - dModelEndX) Then
3958
                                    dX = dModelEndX
3959
                                Else
3960
                                    dX = dModelStartX
3961
                                End If
3962
                                Try
3963
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3964
                                Catch ex As Exception
3965
3966
                                End Try
3967
                                bConnectionFlag = True
3968
                            End If
3969
                        End If
3970
                    End If
3971
                Else
3972
                    'Horizontal 
3973
                    If sDirection = "Y" Then
3974
                        If (dModelStartX + dGap >= dX And dModelEndX - dGap <= dX) Or
3975
                       (dModelStartX - dGap <= dX And dModelEndX + dGap >= dX) Then
3976
                            If (dY > dModelStartY And dY < dModelEndY) Or (dY > dModelEndY And dY < dModelStartY) Then
3977
                                If Math.Abs(dY - dModelStartY) > Math.Abs(dY - dModelEndY) Then
3978
                                    dY = dModelEndY
3979
                                Else
3980
                                    dY = dModelStartY
3981
                                End If
3982
                                Try
3983
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3984
                                Catch ex As Exception
3985
                                End Try
3986
                                bConnectionFlag = True
3987
                            End If
3988
                        End If
3989
                    End If
3990
                End If
3991
            Next
3992
        Catch ex As Exception
3993
        End Try
3994
        Return bConnectionFlag
3995
    End Function
3996
    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,
3997
                              ByVal sLineNoUid As String, ByVal sLineUid As String, ByVal sSystemPath As String, ByRef oLMConnector As LMConnector) As Boolean
3998 76f465d0 Gyusu
        'Try
3999
        '    Dim oDatasource As Object = _Placement.PIDDataSource
4000
        '    Dim oPipeRun As LMPipeRun = Nothing
4001
        '    Dim objInputs As PlaceRunInputs
4002
        '    objInputs = New PlaceRunInputs
4003
        '    Dim objItem As LMAItem
4004
        '    '       Dim objConnector As LMConnector
4005
4006
        '    Dim oStartLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sStartLineUid & "' And " &
4007
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4008
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4009
        '    If oStartLineRow.Length = 0 Then
4010
        '        oStartLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sStartLineUid & "' And " &
4011
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4012
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4013
        '    End If
4014
        '    Dim oEndLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sEndLineUid & "' And " &
4015
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4016
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4017
4018
        '    oEndLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sEndLineUid & "' And " &
4019
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4020
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4021
        '    Dim sStartConnectionType As String = ""
4022
        '    Dim sEndConnectionType As String = ""
4023
4024
        '    Dim oStartLMConnector As LMConnector = Nothing
4025
        '    Dim oEndLMConnector As LMConnector = Nothing
4026
        '    Dim oDirectionLine As String = ""
4027
4028
        '    If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
4029
        '        oDirectionLine = "X"
4030
        '    Else
4031
        '        oDirectionLine = "Y"
4032
        '    End If
4033 b08338e3 Gyusu
4034 76f465d0 Gyusu
        '    Dim bCheckFlag As Boolean = False
4035 b08338e3 Gyusu
4036 76f465d0 Gyusu
        '    Dim bStartCheckFlag As Boolean = CheckConnectionLine(oStartLineRow, dStart_x, dStart_y, oStartLMConnector)
4037
        '    If bStartCheckFlag = False Then
4038
        '        bStartCheckFlag = CheckConnectionLine(oStartLineRow, dEnd_x, dEnd_y, oStartLMConnector)
4039
        '        bCheckFlag = True
4040
        '    End If
4041
        '    Dim bEndCheckFlag As Boolean = CheckConnectionLine(oEndLineRow, dEnd_x, dEnd_y, oEndLMConnector)
4042 b08338e3 Gyusu
4043 76f465d0 Gyusu
        '    If bEndCheckFlag = False Then
4044 b08338e3 Gyusu
4045 76f465d0 Gyusu
        '        bEndCheckFlag = CheckConnectionLine(oEndLineRow, dStart_x, dStart_y, oEndLMConnector)
4046
        '        bCheckFlag = True
4047
        '    End If
4048 b08338e3 Gyusu
4049 76f465d0 Gyusu
        '    If bStartCheckFlag = True And bEndCheckFlag = False Then
4050
        '        If bCheckFlag Then
4051
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4052
        '            objInputs.AddPoint(dStart_x, dStart_y)
4053
        '        Else
4054
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4055
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4056
        '        End If
4057
4058
        '    ElseIf bStartCheckFlag = False And bEndCheckFlag = True Then
4059
        '        If bCheckFlag Then
4060
4061
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4062
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4063
        '        Else
4064
        '            objInputs.AddPoint(dStart_x, dStart_y)
4065
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4066
        '        End If
4067
4068
        '    ElseIf bStartCheckFlag = True And bEndCheckFlag = True Then
4069
        '        objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4070
        '        objInputs.AddConnectorTarget(oEndLMConnector, dEnd_x, dEnd_y)
4071
        '    Else
4072
        '        objInputs.AddPoint(dStart_x, dStart_y)
4073
        '        objInputs.AddPoint(dEnd_x, dEnd_y)
4074
        '    End If
4075
        '    SetListBoxItems(ListBox_Result, "Place Pipe..(" & dStart_x & "," & dStart_y & ") - (" & dEnd_x & "," & dEnd_y & ")..." & _iPipecnt & " count ")
4076
        '    _iPipecnt = _iPipecnt + 1
4077
        '    objItem = _Placement.PIDCreateItem(sSystemPath)
4078
        '    oLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4079 b08338e3 Gyusu
4080 76f465d0 Gyusu
        '    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + sLineUid + "'")
4081
        '    If oUpdateRow.Length = 1 Then
4082
        '        oUpdateRow(0)(_XML_LINE_SPID) = oLMConnector.ModelItemID
4083
        '        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = oLMConnector
4084 b08338e3 Gyusu
4085 76f465d0 Gyusu
        '        oUpdateRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4086
        '    End If
4087 b08338e3 Gyusu
4088 76f465d0 Gyusu
        '    oPipeRun = oDatasource.GetPipeRun(oLMConnector.ModelItemID)
4089
4090
        '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4091
        '    If oAttributeRow.Length > 0 Then
4092
        '        For Each oAttribute In oAttributeRow
4093
        '            Try
4094
        '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4095
        '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4096
        '                If sPIDValue.Contains("'") Then
4097
        '                    sPIDValue = sPIDValue.Replace("'", """")
4098
        '                End If
4099
        '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4100
        '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4101
        '            Catch ex As Exception
4102
        '            End Try
4103
        '        Next
4104
        '        oPipeRun.Commit()
4105
        '    End If
4106
        '    Dim sID_1 As String = ""
4107
        '    Dim sID_2 As String = ""
4108
        '    If oStartLMConnector IsNot Nothing Then
4109
        '        sID_1 = oStartLMConnector.ModelItemID
4110
        '        sID_2 = oLMConnector.ModelItemID
4111
        '    ElseIf oEndLMConnector IsNot Nothing Then
4112
        '        sID_1 = oEndLMConnector.ModelItemID
4113
        '        sID_2 = oLMConnector.ModelItemID
4114
        '    End If
4115
        '    If sID_1 <> "" And sID_2 <> "" Then
4116
        '        Dim objSurvivorItem As LMAItem = Nothing
4117
        '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
4118
        '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
4119
        '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
4120
        '    End If
4121
        '    Return True
4122
        'Catch ex As Exception
4123
        '    Return False
4124
        'End Try
4125 b08338e3 Gyusu
4126
    End Function
4127
4128
    Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4129
                                        ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String,
4130
                                        ByRef oLMConnector As LMConnector) As String
4131
        Dim sReturnUid As String = ""
4132
        Try
4133
            Dim sLineUid As String = ""
4134
4135
            Dim iConnType As Integer = 0
4136
4137
            Dim sStartpoint As String = ""
4138
            Dim sEndpoint As String = ""
4139 bb2a0c79 Gyusu
            Dim dOriginalStart_x As Double = 0.0
4140
            Dim dOriginalStart_y As Double = 0.0
4141
            Dim dOriginalEnd_x As Double = 0.0
4142
            Dim dOriginalEnd_y As Double = 0.0
4143
4144 b08338e3 Gyusu
            Dim dStart_x As Double = 0
4145
            Dim dStart_y As Double = 0
4146
            Dim dEnd_x As Double = 0
4147
            Dim dEnd_y As Double = 0
4148
            Dim sStartLineUid As String = sConnLineUid
4149
            Dim sEndLineUid As String = ""
4150
            Dim sDirection As String = ""
4151
            Dim sSystemPath As String = GetPipeType(sType)
4152
4153
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4154
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4155
                                                                     "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4156
                                                                     "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4157
            If oPipeRow.Length > 0 Then
4158 bb2a0c79 Gyusu
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4159
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4160 e4000111 Gyusu
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4161
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4162 b08338e3 Gyusu
                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4163
                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4164
                If dStart_x = 0 And dStart_y = 0 Then
4165
                    dStart_x = dOriginalStart_x
4166
                    dStart_y = dOriginalStart_y
4167
                    dEnd_x = dOriginalEnd_x
4168
                    dEnd_y = dOriginalEnd_y
4169
                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4170
                        sDirection = "X"
4171
                    Else
4172
                        sDirection = "Y"
4173
                    End If
4174
                    oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4175
                    sLineUid = sConnLineUid
4176
                End If
4177
            End If
4178 bb2a0c79 Gyusu
4179 b08338e3 Gyusu
            While True
4180
                sLineUid = ""
4181
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4182 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4183
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4184
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4185 b08338e3 Gyusu
4186
                If oPipeRow.Length = 0 Then
4187
                    oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4188 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4189
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4190
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4191 bb2a0c79 Gyusu
                Else
4192 b08338e3 Gyusu
                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4193
                    'sConnLineUid = sLineUid
4194
                    sLineUid = sConnLineUid
4195
                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4196
                    iConnType = 1
4197
                End If
4198
4199
                If oPipeRow.Length > 0 Then
4200
                    If sLineUid = "" Then
4201
                        'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4202
                        'sConnLineUid = sLineUid
4203
                        sLineUid = sConnLineUid
4204
                        sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4205
                        iConnType = 2
4206
                    End If
4207
                    If iConnType = 1 Then
4208
4209
                    ElseIf iConnType = 2 Then
4210
4211
                    End If
4212
                    sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4213
                    sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4214
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4215
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4216
                    ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4217
                    ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4218
4219
4220
4221
                    If dStart_x = 0 And dStart_y = 0 Then
4222
                        dStart_x = dOriginalStart_x
4223
                        dStart_y = dOriginalStart_y
4224
                        dEnd_x = dOriginalEnd_x
4225
                        dEnd_y = dOriginalEnd_y
4226
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4227
                            sDirection = "X"
4228
                        Else
4229
                            sDirection = "Y"
4230
                        End If
4231
                        sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4232
                        sSystemPath = GetPipeType(sType)
4233
                    Else
4234
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4235
                            If sDirection = "Y" Then
4236
                                '방향이 바꼈음 Y - > X
4237
4238
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4239
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4240
                                dStart_x = dOriginalStart_x
4241
                                dStart_y = dOriginalStart_y
4242
                                dEnd_x = dOriginalEnd_x
4243
                                dEnd_y = dOriginalEnd_y
4244
                                sStartLineUid = sConnLineUid
4245
                            Else
4246
                                dEnd_x = dOriginalEnd_x
4247
                                dEnd_y = dOriginalEnd_y
4248
                            End If
4249
                            sDirection = "X"
4250
                        Else
4251
                            If sDirection = "X" Then
4252
                                '방향이 바꼈음 X - > Y
4253
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4254
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4255
                                dStart_x = dOriginalStart_x
4256
                                dStart_y = dOriginalStart_y
4257
                                dEnd_x = dOriginalEnd_x
4258
                                dEnd_y = dOriginalEnd_y
4259
                                sStartLineUid = sConnLineUid
4260
                            Else
4261
4262
                                dEnd_x = dOriginalEnd_x
4263
                                dEnd_y = dOriginalEnd_y
4264
                            End If
4265
                            sDirection = "Y"
4266
                        End If
4267
                    End If
4268
                    '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4269
                Else
4270
                    If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4271
                        LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4272
                         sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4273
                    End If
4274
                    sReturnUid = sConnLineUid
4275
                    Exit While
4276
                End If
4277
            End While
4278
4279
            If sStartLineUid <> "" And sEndLineUid <> "" Then
4280
                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4281
                             sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4282
                dStart_x = 0
4283
                dStart_y = 0
4284
                dEnd_x = 0
4285
                dEnd_y = 0
4286
            End If
4287
        Catch ex As Exception
4288
4289
        End Try
4290
4291
        Return sReturnUid
4292
    End Function
4293
4294
4295
    'Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4296
    '                                    ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String) As String
4297
    '    Dim sReturnUid As String = ""
4298
    '    Try
4299
    '        Dim sLineUid As String = ""
4300
4301
    '        Dim iConnType As Integer = 0
4302
4303
    '        Dim sStartpoint As String = ""
4304
    '        Dim sEndpoint As String = ""
4305
    '        Dim dOriginalStart_x As Double = 0.0
4306
    '        Dim dOriginalStart_y As Double = 0.0
4307
    '        Dim dOriginalEnd_x As Double = 0.0
4308
    '        Dim dOriginalEnd_y As Double = 0.0
4309
4310
    '        Dim dStart_x As Double = 0
4311
    '        Dim dStart_y As Double = 0
4312
    '        Dim dEnd_x As Double = 0
4313
    '        Dim dEnd_y As Double = 0
4314
    '        Dim sStartLineUid As String = sConnLineUid
4315
    '        Dim sEndLineUid As String = ""
4316
    '        Dim sDirection As String = ""
4317
    '        Dim sSystemPath As String = GetPipeType(sType)
4318
4319
    '        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4320
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4321
    '                                                                 "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4322
    '                                                                 "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4323
    '        If oPipeRow.Length > 0 Then
4324
    '            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4325
    '            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4326
    '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4327
    '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4328
    '            ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4329
    '            ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4330
    '            If dStart_x = 0 And dStart_y = 0 Then
4331
    '                dStart_x = dOriginalStart_x
4332
    '                dStart_y = dOriginalStart_y
4333
    '                dEnd_x = dOriginalEnd_x
4334
    '                dEnd_y = dOriginalEnd_y
4335
    '                If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4336
    '                    sDirection = "X"
4337
    '                Else
4338
    '                    sDirection = "Y"
4339
    '                End If
4340
    '                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4341
    '                sLineUid = sConnLineUid
4342
    '            End If
4343
    '        End If
4344
4345
    '        While True
4346
    '            sLineUid = ""
4347
    '            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4348
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4349
    '                                                                         "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4350
    '                                                                         "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4351
4352
    '            If oPipeRow.Length = 0 Then
4353
    '                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4354
    '                                         "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4355
    '                                       "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4356
    '                                      "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4357
    '            Else
4358
    '                'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4359
    '                'sConnLineUid = sLineUid
4360
    '                sLineUid = sConnLineUid
4361
    '                sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4362
    '                iConnType = 1
4363
    '            End If
4364
4365
    '            If oPipeRow.Length > 0 Then
4366
    '                If sLineUid = "" Then
4367
    '                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4368
    '                    'sConnLineUid = sLineUid
4369
    '                    sLineUid = sConnLineUid
4370
    '                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4371
    '                    iConnType = 2
4372
    '                End If
4373
    '                If iConnType = 1 Then
4374
4375
    '                ElseIf iConnType = 2 Then
4376
4377
    '                End If
4378
    '                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4379
    '                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4380
    '                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4381
    '                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4382
    '                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4383
    '                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4384
4385
4386
4387
    '                If dStart_x = 0 And dStart_y = 0 Then
4388
    '                    dStart_x = dOriginalStart_x
4389
    '                    dStart_y = dOriginalStart_y
4390
    '                    dEnd_x = dOriginalEnd_x
4391
    '                    dEnd_y = dOriginalEnd_y
4392
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4393
    '                        sDirection = "X"
4394
    '                    Else
4395
    '                        sDirection = "Y"
4396
    '                    End If
4397
    '                    sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4398
    '                    sSystemPath = GetPipeType(sType)
4399
    '                Else
4400
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4401
    '                        If sDirection = "Y" Then
4402
    '                            '방향이 바꼈음 Y - > X
4403
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4404
    '                            sLineNoUid, sLineUid, sSystemPath)
4405
    '                            dStart_x = dOriginalStart_x
4406
    '                            dStart_y = dOriginalStart_y
4407
    '                            dEnd_x = dOriginalEnd_x
4408
    '                            dEnd_y = dOriginalEnd_y
4409
    '                            sStartLineUid = sConnLineUid
4410
    '                        Else
4411
    '                            dEnd_x = dOriginalEnd_x
4412
    '                            dEnd_y = dOriginalEnd_y
4413
    '                        End If
4414
    '                        sDirection = "X"
4415
    '                    Else
4416
    '                        If sDirection = "X" Then
4417
    '                            '방향이 바꼈음 X - > Y
4418
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4419
    '                            sLineNoUid, sLineUid, sSystemPath)
4420
    '                            dStart_x = dOriginalStart_x
4421
    '                            dStart_y = dOriginalStart_y
4422
    '                            dEnd_x = dOriginalEnd_x
4423
    '                            dEnd_y = dOriginalEnd_y
4424
    '                            sStartLineUid = sConnLineUid
4425
    '                        Else
4426
4427
    '                            dEnd_x = dOriginalEnd_x
4428
    '                            dEnd_y = dOriginalEnd_y
4429
    '                        End If
4430
    '                        sDirection = "Y"
4431
    '                    End If
4432
    '                End If
4433
    '                '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4434
    '            Else
4435
    '                If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4436
    '                    LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4437
    '                     sLineNoUid, sLineUid, sSystemPath)
4438
    '                End If
4439
4440
4441
    '                sReturnUid = sConnLineUid
4442
    '                Exit While
4443
    '            End If
4444
    '        End While
4445
4446
    '        If sStartLineUid <> "" And sEndLineUid <> "" Then
4447
    '            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4448
    '                         sLineNoUid, sLineUid, sSystemPath)
4449
    '            dStart_x = 0
4450
    '            dStart_y = 0
4451
    '            dEnd_x = 0
4452
    '            dEnd_y = 0
4453
    '        End If
4454
    '    Catch ex As Exception
4455
4456
    '    End Try
4457
4458
    '    Return sReturnUid
4459
    'End Function
4460
4461
4462
    Private Function SymbolToLine_Modeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4463
                                       ByVal sSymbolUid As String, ByVal oLMSymbol As LMSymbol) As String
4464
4465
4466
        Dim oDatasource As Object = _Placement.PIDDataSource
4467
        Dim oPipeRun As LMPipeRun = Nothing
4468
        Dim objItem As LMAItem
4469
        Dim objConnector As LMConnector
4470
        Dim objInputs As PlaceRunInputs
4471
        objInputs = New PlaceRunInputs
4472
4473
4474
        Dim sPipeUid As String = ""
4475
        Dim iConnType As Integer = 0
4476
        Dim sStartpoint As String = ""
4477
        Dim sEndpoint As String = ""
4478
        Dim dOriginalStart_x As Double = 0.0
4479
        Dim dOriginalStart_y As Double = 0.0
4480
        Dim dOriginalEnd_x As Double = 0.0
4481
        Dim dOriginalEnd_y As Double = 0.0
4482
        Dim dStart_x As Double = 0.0
4483
        Dim dStart_y As Double = 0.0
4484
        Dim dEnd_x As Double = 0.0
4485
        Dim dEnd_y As Double = 0.0
4486
4487
        Dim sReturnUid As String = ""
4488
        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sSymbolUid + "' And " &
4489
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4490
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4491
        If oPipeRow.Length = 0 Then
4492
            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sSymbolUid + "' And " &
4493
                                     "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4494
                                    _XML_SYMBOL_Check & "] = 'TRUE'")
4495
        Else
4496
            sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4497
            iConnType = 1
4498
        End If
4499
4500
        If oPipeRow.Length = 1 Then
4501
            If sPipeUid = "" Then
4502
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4503
                iConnType = 2
4504
            End If
4505
            sReturnUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4506
            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4507
            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4508
            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4509
            dStart_x = dOriginalStart_x
4510
            dStart_y = dOriginalStart_y
4511
            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4512
            dEnd_x = dOriginalEnd_x
4513
            dEnd_y = dOriginalEnd_y
4514
            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4515
            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4516
            'OPC Connection Point가져와서 연결(2018-07-12)
4517
            If iConnType = 1 Then
4518
                FindNearPoint(oLMSymbol, dStart_x, dStart_y)
4519
                objInputs.AddSymbolTarget(oLMSymbol, dStart_x, dStart_y)
4520
                objInputs.AddPoint(dEnd_x, dEnd_y)
4521
            Else
4522
                FindNearPoint(oLMSymbol, dEnd_x, dEnd_y)
4523
                objInputs.AddSymbolTarget(oLMSymbol, dEnd_x, dEnd_y)
4524
                objInputs.AddPoint(dStart_x, dStart_y)
4525
            End If
4526
            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4527
4528
            Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4529
            Dim sSystemPath As String = GetPipeType(sType)
4530
4531
4532
4533
4534
            objItem = _Placement.PIDCreateItem(sSystemPath)
4535
            objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4536
            oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4537
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4538
            If oAttributeRow.Length > 0 Then
4539
                For Each oAttribute In oAttributeRow
4540
                    Try
4541
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4542
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4543
                        If sPIDValue.Contains("'") Then
4544
                            sPIDValue = sPIDValue.Replace("'", """")
4545
                        End If
4546
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4547
                        oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4548
                    Catch ex As Exception
4549
                    End Try
4550
                Next
4551
                oPipeRun.Commit()
4552
            End If
4553
        End If
4554
        Return sReturnUid
4555
    End Function
4556
4557
    Private Function LineToSymbol_Modeling(ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4558
                                       ByVal sLineUid As String, ByVal oLMConnector As LMConnector, ByRef oLMSymbol As LMSymbol) As String
4559
4560
4561
        Dim oDatasource As Object = _Placement.PIDDataSource
4562
        Dim objItem As LMAItem
4563
        Dim objConnector As LMConnector
4564
        Dim objInputs As PlaceRunInputs
4565
        objInputs = New PlaceRunInputs
4566
4567
4568
        Dim sSymbolUid As String = ""
4569
        Dim iConnType As Integer = 0
4570
        Dim dOriginalPoint_x As Double = 0.0
4571
        Dim dORiginalPoint_y As Double = 0.0
4572
        Dim dX As Double = 0.0
4573
        Dim dY As Double = 0.0
4574
        Dim sReturnUid As String = ""
4575
        Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn1_Uid & " = '" + sLineUid + "' And " &
4576
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4577
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4578
        If oSymbolRow.Length = 0 Then
4579
            oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4580
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4581
                                                                                 _XML_SYMBOL_Check & "] = 'TRUE'")
4582
            If oSymbolRow.Length = 0 Then
4583
                oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4584
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4585
                                                                          _XML_SYMBOL_Check & "] = 'TRUE'")
4586
                If oSymbolRow.Length = 0 Then
4587
                    oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4588
                                                   "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4589
                                                            _XML_SYMBOL_Check & "] = 'TRUE'")
4590
                    If oSymbolRow.Length = 0 Then
4591
4592
                    Else
4593
                        sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4594
                        iConnType = 4
4595
                    End If
4596
                Else
4597
                    sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4598
                    iConnType = 3
4599
                End If
4600
            Else
4601
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4602
                iConnType = 2
4603
            End If
4604
4605
        Else
4606
            sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4607
            iConnType = 1
4608
        End If
4609
4610
        If oSymbolRow.Length = 1 Then
4611
            If sSymbolUid = "" Then
4612
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4613
                iConnType = 2
4614
            End If
4615
            sReturnUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4616
            Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
4617
            ConvertPointBystring(sOriginalPoint, dOriginalPoint_x, dORiginalPoint_y)
4618
            dX = dOriginalPoint_x
4619
            dY = dORiginalPoint_y
4620
            ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
4621
            'OPC Connection Point가져와서 연결(2018-07-12)
4622
4623
            oSymbolRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4624
4625
            Dim sType As String = oSymbolRow(0)(_XML_LINE_TYPE).ToString()
4626
            Dim sSystemPath As String = GetPipeType(sType)
4627
4628
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, ExistingItem:=oLMConnector.AsLMAItem,
4629
          TargetItem:=oLMSymbol.AsLMAItem)
4630
4631
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4632
            If oAttributeRow.Length > 0 Then
4633
                For Each oAttribute In oAttributeRow
4634
                    Try
4635
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4636
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4637
                        If sPIDValue.Contains("'") Then
4638
                            sPIDValue = sPIDValue.Replace("'", """")
4639
                        End If
4640
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4641
                        oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
4642
                    Catch ex As Exception
4643
                    End Try
4644
                Next
4645
            End If
4646
        End If
4647
        Return sReturnUid
4648
    End Function
4649
4650
4651
    Private Sub OPCTOLineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oOPCSymbol As LMSymbol,
4652
                            ByVal sOPCUid As String, ByVal sLineNoUid As String)
4653
        Try
4654
            Dim oDatasource As Object = _Placement.PIDDataSource
4655
            Dim objItem As LMAItem
4656
            Dim objConnector As LMConnector
4657
            Dim objInputs As PlaceRunInputs
4658
            objInputs = New PlaceRunInputs
4659
            Dim dOriginalStart_x As Double = 0.0
4660
            Dim dOriginalStart_y As Double = 0.0
4661
            Dim dOriginalEnd_x As Double = 0.0
4662
            Dim dOriginalEnd_y As Double = 0.0
4663
            Dim dStart_x As Double = 0.0
4664
            Dim dStart_y As Double = 0.0
4665
            Dim dEnd_x As Double = 0.0
4666
            Dim dEnd_y As Double = 0.0
4667
4668
            Dim oPipeRun As LMPipeRun = Nothing
4669
            Dim sStartpoint As String = ""
4670
            Dim sEndpoint As String = ""
4671
            Dim iConnType As Integer = 0
4672
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sOPCUid + "' And [" &
4673
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4674
            Dim sPipeUid As String = ""
4675
            If oPipeRow.Length = 0 Then
4676
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sOPCUid + "' And [" &
4677
                        _XML_SYMBOL_Check & "] = 'TRUE'")
4678
            Else
4679
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4680
                iConnType = 1
4681
            End If
4682
            Dim oAddUid_List As New List(Of String)
4683
            If oPipeRow.Length = 1 Then
4684
                If sPipeUid = "" Then
4685
                    sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4686
                    iConnType = 2
4687
                End If
4688
                oAddUid_List.Add(sPipeUid)
4689
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4690
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4691
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4692
                dStart_x = dOriginalStart_x
4693
                dStart_y = dOriginalStart_y
4694
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4695
                dEnd_x = dOriginalEnd_x
4696
                dEnd_y = dOriginalEnd_y
4697
                ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4698
                ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4699
4700
                'OPC Connection Point가져와서 연결(2018-07-12)
4701
                If iConnType = 1 Then
4702
                    FindNearPoint(oOPCSymbol, dStart_x, dStart_y)
4703
                    objInputs.AddSymbolTarget(oOPCSymbol, dStart_x, dStart_y)
4704
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4705
                Else
4706
                    FindNearPoint(oOPCSymbol, dEnd_x, dEnd_y)
4707
                    objInputs.AddSymbolTarget(oOPCSymbol, dEnd_x, dEnd_y)
4708 bb2a0c79 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4709
                End If
4710
                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4711
4712
                While True
4713
                    '    objInputs.Clear()
4714
                    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
4715
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4716
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4717
                    If oAddPipeRow.Length = 0 Then
4718
                        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
4719
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4720
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4721
                        sPipeUid = ""
4722
                    Else
4723
                        iConnType = 1
4724
                        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4725
                    End If
4726
                    If oAddPipeRow.Length = 1 Then
4727
                        If sPipeUid = "" Then
4728
                            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4729
                            iConnType = 2
4730
                        End If
4731
                        oAddUid_List.Add(sPipeUid)
4732
                        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4733
                        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4734
                        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4735
                        dStart_x = dOriginalStart_x
4736
                        dStart_y = dOriginalStart_y
4737
                        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4738
                        dEnd_x = dOriginalEnd_x
4739
                        dEnd_y = dOriginalEnd_y
4740
                        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4741
                        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4742
                        If iConnType = 1 Then
4743
                            objInputs.AddPoint(dEnd_x, dEnd_y)
4744
                            ' objInputs.AddPoint(dStart_x, dStart_y)
4745
                        Else
4746
                            'objInputs.AddConnectorTarget(objConnector, dStart_x, dStart_y)
4747
                            '  objInputs.AddPoint(dStart_x, dStart_y)
4748
                            '  objInputs.AddPoint(dEnd_x, dEnd_y)
4749
                            objInputs.AddPoint(dStart_x, dStart_y)
4750
                        End If
4751 e4000111 Gyusu
4752 bb2a0c79 Gyusu
                        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4753
                    Else
4754
                        Exit While
4755
                    End If
4756 e4000111 Gyusu
4757 bb2a0c79 Gyusu
                End While
4758
                Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4759
                Dim sSystemPath As String = GetPipeType(sType)
4760 e4000111 Gyusu
4761 bb2a0c79 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
4762
                objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4763
                For i = 0 To oAddUid_List.Count - 1
4764
                    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
4765
                    If oUpdateRow.Length = 1 Then
4766
                        oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
4767
                        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
4768
                    End If
4769
                Next
4770
4771
4772
                oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4773
                Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4774
                If oAttributeRow.Length > 0 Then
4775
                    For Each oAttribute In oAttributeRow
4776
                        Try
4777
                            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4778
                            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4779
                            If sPIDValue.Contains("'") Then
4780
                                sPIDValue = sPIDValue.Replace("'", """")
4781
                            End If
4782
                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4783
                            oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4784
                        Catch ex As Exception
4785
                        End Try
4786
                    Next
4787
                    oPipeRun.Commit()
4788
                End If
4789
4790
            End If
4791
4792
        Catch ex As Exception
4793
        End Try
4794
    End Sub
4795
4796
    Private Function AddUidList중복체크(ByVal sUidList As List(Of String), ByVal sAddUid As String) As Boolean
4797 e4000111 Gyusu
4798 bb2a0c79 Gyusu
        For Each sUid In sUidList
4799
            If sUid = sAddUid Then
4800
                Return False
4801
            End If
4802
        Next
4803
        Return True
4804
    End Function
4805
4806 b08338e3 Gyusu
    Private Sub LineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String, ByVal sLineNoText As String)
4807 bb2a0c79 Gyusu
        Try
4808
            Dim oDatasource As Object = _Placement.PIDDataSource
4809
            Dim objItem As LMAItem
4810
            Dim objConnector As LMConnector
4811
            Dim objInputs As PlaceRunInputs
4812
            objInputs = New PlaceRunInputs
4813
            Dim dOriginalStart_x As Double = 0.0
4814
            Dim dOriginalStart_y As Double = 0.0
4815
            Dim dOriginalEnd_x As Double = 0.0
4816
            Dim dOriginalEnd_y As Double = 0.0
4817
            Dim dStart_x As Double = 0.0
4818
            Dim dStart_y As Double = 0.0
4819
            Dim dEnd_x As Double = 0.0
4820
            Dim dEnd_y As Double = 0.0
4821
            Dim oPipeRun As LMPipeRun = Nothing
4822
            Dim sStartpoint As String = ""
4823
            Dim sEndpoint As String = ""
4824
            Dim iConnType As Integer = 0
4825
            Dim pLMConnector As LMConnector = Nothing
4826
            For Each oLinerow In oLine_Dt.Rows
4827
                objInputs.Clear()
4828 b08338e3 Gyusu
                Dim sCheck As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
4829
                If sCheck = "FALSE" Then
4830
                    Dim sUid As String = oLinerow(_XML_LINE_UID).ToString()
4831
                    sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
4832
                    sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
4833
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4834
                    dStart_x = dOriginalStart_x
4835
                    dStart_y = dOriginalStart_y
4836
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4837
                    dEnd_x = dOriginalEnd_x
4838
                    dEnd_y = dOriginalEnd_y
4839
                    ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4840
                    ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4841 bb2a0c79 Gyusu
4842 b08338e3 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4843
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4844 bb2a0c79 Gyusu
                    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
4845
                    Dim sSystemPath As String = GetPipeType(sType)
4846
                    objItem = _Placement.PIDCreateItem(sSystemPath)
4847
                    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4848 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
4849
4850
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
4851
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
4852
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oLinerow(_XML_SYMBOL_Conn1_Uid).ToString())
4853
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oLinerow(_XML_SYMBOL_Conn2_Uid).ToString())
4854
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
4855
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
4856
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
4857
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
4858
4859
                    _iPipecnt = _iPipecnt + 1
4860
                    oLinerow(_XML_LINE_SPID) = objConnector.ModelItemID
4861
                    oLinerow(_XML_LINE_LMCONNECTOR) = objConnector
4862
4863
                    oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
4864 bb2a0c79 Gyusu
                    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4865
4866
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4867
                    If oAttributeRow.Length > 0 Then
4868
                        For Each oAttribute In oAttributeRow
4869
                            Try
4870
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4871
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4872
                                If sPIDValue.Contains("'") Then
4873
                                    sPIDValue = sPIDValue.Replace("'", """")
4874
                                End If
4875
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4876
                                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4877
                            Catch ex As Exception
4878
                            End Try
4879
                        Next
4880
                        oPipeRun.Commit()
4881
                    End If
4882
                End If
4883
4884
4885
4886
4887
4888 b08338e3 Gyusu
                'Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString()
4889
                'Dim sCheckModeling As Boolean = False
4890
                'objInputs.Clear()
4891
                'Dim oAddUid_List As New List(Of String)
4892
                'Try
4893
                '    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
4894
                '                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4895
                '                                            _XML_SYMBOL_Check & "] = 'TRUE'")
4896
                '    If oAddPipeRow.Length = 0 Then
4897
                '        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
4898
                '                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4899
                '                                        _XML_SYMBOL_Check & "] = 'TRUE'")
4900
                '        sPipeUid = ""
4901
                '    Else
4902
                '        iConnType = 1
4903
                '        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4904
                '    End If
4905
                '    If oAddPipeRow.Length = 1 Then
4906
                '        sCheckModeling = True
4907
                '        If sPipeUid = "" Then
4908
                '            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4909
                '            iConnType = 2
4910
                '        End If
4911
                '        If AddUidList중복체크(oAddUid_List, sPipeUid) Then
4912
                '            oAddUid_List.Add(sPipeUid)
4913
                '        End If
4914
                '        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4915
                '        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4916
                '        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4917
                '        dStart_x = dOriginalStart_x
4918
                '        dStart_y = dOriginalStart_y
4919
                '        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4920
                '        dEnd_x = dOriginalEnd_x
4921
                '        dEnd_y = dOriginalEnd_y
4922
                '        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4923
                '        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4924
                '        Dim sBranchType As String = ""
4925
                '        If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
4926
                '            Try
4927
                '                If pLMConnector Is Nothing Then
4928
                '                    objInputs.AddPoint(dStart_x, dStart_y)
4929
                '                    objInputs.AddPoint(dEnd_x, dEnd_y)
4930
                '                Else
4931
                '                    If sBranchType = "1" Then
4932
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
4933
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
4934
                '                    ElseIf sBranchType = "2" Then
4935
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
4936
                '                        objInputs.AddPoint(dStart_x, dStart_y)
4937
                '                    ElseIf sBranchType = "3" Then
4938
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
4939
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
4940
                '                    ElseIf sBranchType = "4" Then
4941
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
4942
                '                        objInputs.AddPoint(dStart_x, dStart_y)
4943
                '                    End If
4944
                '                End If
4945
                '            Catch ex As Exception
4946
                '            End Try
4947
                '        Else
4948
                '            objInputs.AddPoint(dStart_x, dStart_y)
4949
                '            objInputs.AddPoint(dEnd_x, dEnd_y)
4950
                '        End If
4951
                '        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4952
                '    Else
4953
                '        Dim CheckTF As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
4954
                '        Dim CheckSelect As String = oLinerow(_XML_LINE_Check).ToString()
4955
                '        If CheckTF = "FALSE" And CheckSelect = "TRUE" Then
4956
                '            sPipeUid = oLinerow(_XML_LINE_UID).ToString()
4957
                '            oAddUid_List.Clear()
4958
                '            oAddUid_List.Add(sPipeUid)
4959
                '            sCheckModeling = True
4960
                '            sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
4961
                '            sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
4962
                '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4963
                '            dStart_x = dOriginalStart_x
4964
                '            dStart_y = dOriginalStart_y
4965
                '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4966
                '            dEnd_x = dOriginalEnd_x
4967
                '            dEnd_y = dOriginalEnd_y
4968
                '            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4969
                '            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4970
                '            Dim sBranchType As String = ""
4971
                '            If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
4972
                '                Try
4973
                '                    If sBranchType = "1" Then
4974
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
4975
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
4976
                '                    ElseIf sBranchType = "2" Then
4977
                '                        objInputs.AddPoint(dStart_x, dStart_y)
4978
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
4979
                '                    ElseIf sBranchType = "3" Then
4980
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
4981
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
4982
                '                    ElseIf sBranchType = "4" Then
4983
                '                        objInputs.AddPoint(dStart_x, dStart_y)
4984
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
4985
                '                    End If
4986
                '                Catch ex As Exception
4987
4988
                '                End Try
4989
                '            Else
4990
                '                objInputs.AddPoint(dStart_x, dStart_y)
4991
                '                objInputs.AddPoint(dEnd_x, dEnd_y)
4992
                '            End If
4993
                '            oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
4994
                '        End If
4995
                '    End If
4996
                'Catch ex As Exception
4997
                'End Try
4998
                'If sCheckModeling Then
4999
                '    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
5000
                '    Dim sSystemPath As String = GetPipeType(sType)
5001
                '    objItem = _Placement.PIDCreateItem(sSystemPath)
5002
                '    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
5003
                '    For i = 0 To oAddUid_List.Count - 1
5004
                '        Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
5005
                '        If oUpdateRow.Length = 1 Then
5006
                '            oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
5007
                '            oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
5008
                '        End If
5009
                '    Next
5010
5011
                '    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
5012
                '    oAddUid_List.Clear()
5013
5014
                '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
5015
                '    If oAttributeRow.Length > 0 Then
5016
                '        For Each oAttribute In oAttributeRow
5017
                '            Try
5018
                '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5019
                '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5020
                '                If sPIDValue.Contains("'") Then
5021
                '                    sPIDValue = sPIDValue.Replace("'", """")
5022
                '                End If
5023
                '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5024
                '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
5025
                '            Catch ex As Exception
5026
                '            End Try
5027
                '        Next
5028
                '        oPipeRun.Commit()
5029
                '    End If
5030
5031
                '    If pLMConnector IsNot Nothing Then
5032
                '        Dim sID_1 As String = pLMConnector.ModelItemID
5033
                '        Dim sID_2 As String = objConnector.ModelItemID
5034
                '        Dim objSurvivorItem As LMAItem = Nothing
5035
                '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
5036
                '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
5037
                '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
5038
                '        '     oDatasource.CommitTransaction()
5039
                '        '_Placement.PIDAutoJoin(oPipeRun1.AsLMAItem, AutoJoinEndConstants.autoJoin_End, objSurvivorItem)
5040
                '        'oPipeRun1.Commit()
5041
                '        'oDatasource.CommitTransaction()
5042
                '        'objSurvivorItem = Nothing
5043
                '        '_Placement.PIDAutoJoin(oPipeRun2.AsLMAItem, AutoJoinEndConstants.autoJoin_Start, objSurvivorItem)
5044
                '        'oPipeRun2.Commit()
5045
                '        'oDatasource.CommitTransaction()
5046
                '    End If
5047
                '    sCheckModeling = False
5048
                '  End If
5049
            Next
5050 bb2a0c79 Gyusu
        Catch ex As Exception
5051
        End Try
5052
    End Sub
5053 e4000111 Gyusu
5054 b08338e3 Gyusu
5055
    Private Sub SymbolModeling(ByVal CDrawing As Drawing, ByVal oLine_DT As DataTable, ByVal oSymbolRow As DataRow, ByVal oAttribute_Dt As DataTable,
5056
                               ByVal sLineNoText As String)
5057 bb2a0c79 Gyusu
        Try
5058 b08338e3 Gyusu
5059
            Dim sCheckModeling As String = oSymbolRow(_XML_SYMBOL_DRAWING_TF).ToString()
5060
            If sCheckModeling = "FALSE" Then
5061
                Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5062
                Dim oSymbol As LMSymbol = Nothing
5063
                Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5064
                Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5065 bb2a0c79 Gyusu
                Dim oDatasource As Object = _Placement.PIDDataSource
5066
                Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5067
                Dim dLocationX As Double = 0.0
5068
                Dim dLocationY As Double = 0.0
5069
                Dim dX As Double = 0.0
5070
                Dim dY As Double = 0.0
5071 b08338e3 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5072
                ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5073
                dX = dLocationX
5074
                dY = dLocationY
5075
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5076
5077
                Dim dAngle As Double = oSymbolRow(_XML_SYMBOL_ANGLE)
5078
5079
5080
                'Dim oDatarow() As DataRow = oLine_DT.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sSymbolUid & "'")
5081
                'If oDatarow.Length = 0 Then
5082
                '    oDatarow = oLine_DT.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sSymbolUid & "'")
5083
                'End If
5084
                'Dim dFix_X As Double = 0.0
5085
                'Dim dFix_Y As Double = 0.0
5086
                'If oDatarow.Length > 0 Then
5087
                '    If dAngle <> 0 Then
5088
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5089
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5090
5091
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5092
                '        dX = dLocationX
5093
                '    Else
5094
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5095
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5096
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5097
                '        dY = dLocationY
5098
                '    End If
5099
5100
                'End If
5101
5102
5103
5104
                oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY,, dAngle)
5105
                SetListBoxItems(ListBox_Result, "Place Fitting.." & sSymbolUid & " (" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5106
5107
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sSymbolUid)
5108
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
5109
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
5110
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
5111
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
5112
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
5113
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
5114
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
5115
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
5116
5117
5118
                _iFittingcnt = _iFittingcnt + 1
5119
                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
5120
                Dim oAttributeRow() As DataRow
5121
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5122
                If oAttribute_Dt.Rows.Count > 0 Then
5123
5124 bb2a0c79 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5125 b08338e3 Gyusu
                        Dim oInstrument As LMInstrument
5126
                        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5127 bb2a0c79 Gyusu
                        Try
5128
                            If oAttributeRow.Length > 0 Then
5129
                                For Each oAttribute In oAttributeRow
5130
                                    Try
5131
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5132
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5133
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5134
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5135
                                    Catch ex As Exception
5136
                                    End Try
5137
                                Next
5138
                                oInstrument.Commit()
5139
                            End If
5140
                        Catch ex As Exception
5141
                        End Try
5142
                    Else
5143 b08338e3 Gyusu
                        Try
5144
                            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5145
                                For Each oAttribute In oAttributeRow
5146
                                    Try
5147
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5148
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5149 e4000111 Gyusu
5150 b08338e3 Gyusu
                                        If sPIDAttribute = "SIZE" Then
5151
5152
                                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5153
                                            If sPIDValue.Contains("x") Then
5154
                                                Dim sSplitSize() As String = sPIDValue.Split("x")
5155
                                                If sSplitSize.Count > 1 Then
5156
                                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5157
                                                    Dim oConnector_1 As LMConnector = Nothing
5158
                                                    Dim oConnector_2 As LMConnector = Nothing
5159
                                                    If oSymbol IsNot Nothing Then
5160
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5161
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5162
                                                                If Tconnector.ItemStatus = "Active" Then
5163
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5164
                                                                        oConnector_1 = Tconnector
5165
                                                                    End If
5166
                                                                End If
5167
                                                            Next
5168
                                                        End If
5169
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5170
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5171
                                                                If Tconnector.ItemStatus = "Active" Then
5172
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5173
                                                                        oConnector_2 = Tconnector
5174
                                                                    End If
5175
                                                                End If
5176
                                                            Next
5177
                                                        End If
5178
                                                    End If
5179
                                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5180
                                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5181
                                                    If dAngle = 3.14 Then
5182
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5183
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5184
                                                    Else
5185
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5186
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5187
                                                    End If
5188 e4000111 Gyusu
5189
5190 b08338e3 Gyusu
                                                End If
5191 e4000111 Gyusu
5192 b08338e3 Gyusu
                                            Else
5193
                                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5194
                                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5195
                                            End If
5196
                                        Else
5197
                                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5198
                                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5199
                                        End If
5200 e4000111 Gyusu
5201 b08338e3 Gyusu
                                    Catch ex As Exception
5202
                                    End Try
5203
                                Next
5204
                                oSymbol.Commit()
5205
                            End If
5206
                        Catch ex As Exception
5207
                        End Try
5208
                    End If
5209
                End If
5210 e4000111 Gyusu
5211
5212
5213 b08338e3 Gyusu
            End If
5214 e4000111 Gyusu
5215
5216
5217 b08338e3 Gyusu
            'Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5218
            'Dim sConnTypeNo As String = ""
5219
            '' Line과 연결되어있는 Symbol인지 확인
5220
            'Dim oLine_Dt As DataTable = GetPipeFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5221
            ''Symbol과 연결되어 있는 Symbol인지 확인
5222
            'Dim oSymbol_Dt As DataTable = GetSymbolFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5223
            'Dim oSymbol As LMSymbol = Nothing
5224
            'Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5225
            'Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5226
            'Dim oDatasource As Object = _Placement.PIDDataSource
5227
            'Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5228 e4000111 Gyusu
5229 b08338e3 Gyusu
            'Dim dAngle As Double = 0.0
5230
            'If IsNumeric(oSymbolRow(_XML_SYMBOL_ANGLE).ToString()) Then
5231
            '    dAngle = Double.Parse(oSymbolRow(_XML_SYMBOL_ANGLE).ToString())
5232
            'End If
5233 e4000111 Gyusu
5234 b08338e3 Gyusu
            'Dim dLocationX As Double = 0.0
5235
            'Dim dLocationY As Double = 0.0
5236
            'Dim dX As Double = 0.0
5237
            'Dim dY As Double = 0.0
5238
            'Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5239
            'ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5240
            'dX = dLocationX
5241
            'dY = dLocationY
5242
            'ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5243
            'Dim bCheckModeling As Boolean = False
5244
5245
            'If oLine_Dt.Rows.Count > 0 Then
5246
5247
            '    If sSPID <> "" Then
5248
            '        Dim dX1 As Double = 0
5249
            '        Dim dX2 As Double = 0
5250
            '        Dim dY1 As Double = 0
5251
            '        Dim dY2 As Double = 0
5252
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5253
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5254
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5255
5256
            '        Dim dCalcPoint As Double = -1
5257
            '        Dim dModeling_X As Double = 0
5258
            '        Dim dModeling_Y As Double = 0
5259
            '        If dX1 <> 0 And dY1 <> 0 Then
5260
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5261
            '            dModeling_X = dX1
5262
            '            dModeling_Y = dY1
5263
            '        End If
5264
            '        If dX2 <> 0 And dY2 <> 0 Then
5265 e4000111 Gyusu
5266 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5267
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5268
            '                dModeling_X = dX2
5269
            '                dModeling_Y = dY2
5270
            '            End If
5271
            '        End If
5272 e4000111 Gyusu
5273
5274
5275 b08338e3 Gyusu
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5276
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5277
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5278
            '            bCheckModeling = True
5279
            '        End If
5280 e4000111 Gyusu
5281
5282 b08338e3 Gyusu
            '    End If
5283
            'End If
5284
            'If oSymbol_Dt.Rows.Count > 0 Then
5285
            '    If sSPID <> "" Then
5286
            '        Dim dX1 As Double = 0
5287
            '        Dim dX2 As Double = 0
5288
            '        Dim dX3 As Double = 0
5289
            '        Dim dX4 As Double = 0
5290
            '        Dim dY1 As Double = 0
5291
            '        Dim dY2 As Double = 0
5292
            '        Dim dY3 As Double = 0
5293
            '        Dim dY4 As Double = 0
5294
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5295
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5296
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5297
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 3, dX3, dY3)
5298
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 4, dX4, dY4)
5299
5300
            '        Dim dCalcPoint As Double = -1
5301
            '        Dim dModeling_X As Double = 0
5302
            '        Dim dModeling_Y As Double = 0
5303
            '        If dX1 <> 0 And dY1 <> 0 Then
5304
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5305
            '            dModeling_X = dX1
5306
            '            dModeling_Y = dY1
5307
            '        End If
5308
            '        If dX2 <> 0 And dY2 <> 0 Then
5309 41e4023e Gyusu
5310 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5311
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5312
            '                dModeling_X = dX2
5313
            '                dModeling_Y = dY2
5314
            '            End If
5315
            '        End If
5316
            '        If dX3 <> 0 And dY3 <> 0 Then
5317
            '            If (Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY) > dCalcPoint) Then
5318
            '                dCalcPoint = Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY)
5319
            '                dModeling_X = dX3
5320
            '                dModeling_Y = dY3
5321
            '            End If
5322
            '        End If
5323
            '        If dX4 <> 0 And dY4 <> 0 Then
5324
            '            If (Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY) > dCalcPoint) Then
5325
            '                dCalcPoint = Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY)
5326
            '                dModeling_X = dX4
5327
            '                dModeling_Y = dY4
5328
            '            End If
5329
            '        End If
5330
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5331
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5332
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5333
            '            bCheckModeling = True
5334
            '        End If
5335 41e4023e Gyusu
5336 e4000111 Gyusu
5337 b08338e3 Gyusu
            '    End If
5338 e4000111 Gyusu
5339 b08338e3 Gyusu
            'End If
5340 e4000111 Gyusu
5341 b08338e3 Gyusu
            'If (oLine_Dt.Rows.Count = 0 And oSymbol_Dt.Rows.Count = 0) Or bCheckModeling = False Then
5342
            '    oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
5343
            '    SetListBoxItems(ListBox_Result, "Place Fittings..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5344
            '    _iFittingcnt = _iFittingcnt + 1
5345
            'End If
5346
            'Dim oAttributeRow() As DataRow
5347
            'oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5348
            'If oAttribute_Dt.Rows.Count > 0 Then
5349
5350
            '    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5351
            '        Dim oInstrument As LMInstrument
5352
            '        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5353
            '        Try
5354
            '            If oAttributeRow.Length > 0 Then
5355
            '                For Each oAttribute In oAttributeRow
5356
            '                    Try
5357
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5358
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5359
            '                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5360
            '                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5361
            '                    Catch ex As Exception
5362
            '                    End Try
5363
            '                Next
5364
            '                oInstrument.Commit()
5365
            '            End If
5366
            '        Catch ex As Exception
5367
            '        End Try
5368
            '    Else
5369
            '        Try
5370
            '            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5371
            '                For Each oAttribute In oAttributeRow
5372
            '                    Try
5373
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5374
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5375
5376
            '                        If sPIDAttribute = "SIZE" Then
5377
5378
            '                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5379
            '                            If sPIDValue.Contains("x") Then
5380
            '                                Dim sSplitSize() As String = sPIDValue.Split("x")
5381
            '                                If sSplitSize.Count > 1 Then
5382
            '                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5383
            '                                    Dim oConnector_1 As LMConnector = Nothing
5384
            '                                    Dim oConnector_2 As LMConnector = Nothing
5385
            '                                    If oSymbol IsNot Nothing Then
5386
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5387
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5388
            '                                                If Tconnector.ItemStatus = "Active" Then
5389
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5390
            '                                                        oConnector_1 = Tconnector
5391
            '                                                    End If
5392
            '                                                End If
5393
            '                                            Next
5394
            '                                        End If
5395
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5396
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5397
            '                                                If Tconnector.ItemStatus = "Active" Then
5398
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5399
            '                                                        oConnector_2 = Tconnector
5400
            '                                                    End If
5401
            '                                                End If
5402
            '                                            Next
5403
            '                                        End If
5404
            '                                    End If
5405
            '                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5406
            '                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5407
            '                                    If dAngle = 3.14 Then
5408
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5409
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5410
            '                                    Else
5411
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5412
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5413
            '                                    End If
5414
5415
5416
            '                                End If
5417
5418
            '                            Else
5419
            '                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5420
            '                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5421
            '                            End If
5422
            '                        Else
5423
            '                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5424
            '                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5425
            '                        End If
5426
5427
            '                    Catch ex As Exception
5428
            '                    End Try
5429
            '                Next
5430
            '                oSymbol.Commit()
5431
            '            End If
5432
            '        Catch ex As Exception
5433
            '        End Try
5434
            '    End If
5435
            'End If
5436
        Catch ex As Exception
5437
        End Try
5438
    End Sub
5439 e4000111 Gyusu
5440
5441
5442
    Private Function AutoModeling() As Boolean
5443
        Try
5444 76f465d0 Gyusu
            _AllLine_DT = Line_Dt()
5445
            _AllSymbol_DT = Symbol_Dt()
5446
5447 e4000111 Gyusu
            _CompleteConvert = False
5448
            Label_Progress.Text = "0%"
5449
            SetListBoxItems(ListBox_Result, " Auto converting 시작....")
5450 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 시작....")
5451 e4000111 Gyusu
            Dim oDwg_Dt As DataTable = LoadAllDrawing()
5452 b08338e3 Gyusu
            _Log_File = "AutoConverting_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss")
5453 e4000111 Gyusu
            _allItem = GetAllCheckNodeCount()
5454 76f465d0 Gyusu
            _Itemcnt = 0
5455 e4000111 Gyusu
            '1.Equipment
5456
            '2.Piping OPC
5457
            '3.OPC 시작되는 Line
5458 bb2a0c79 Gyusu
            InitAutoRouting()
5459 e4000111 Gyusu
            EquipmentModeling(oDwg_Dt)
5460 bb2a0c79 Gyusu
            PipingModeling()
5461
5462
            '   PipeLine_Fitting_Modeling()
5463 e4000111 Gyusu
5464 171ac39d Gyusu
            SetProgressbar(ProgressBar_Status, 100)
5465 41e4023e Gyusu
            Label_Progress.Text = "100%"
5466 171ac39d Gyusu
            SetListBoxItems(ListBox_Result, " Auto converting 완료")
5467 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 완료")
5468 54b98e09 Gyusu
            _CompleteConvert = True
5469 171ac39d Gyusu
            Return True
5470
        Catch ex As Exception
5471
            Return False
5472
        End Try
5473
    End Function
5474
5475
5476
5477 54b98e09 Gyusu
    Private Sub ThreadConvert()
5478 559daf6d Gyusu
        If _DrawingsList IsNot Nothing Then
5479
            If _DrawingsList.Count > 0 Then
5480
                AutoModeling()
5481
            End If
5482 171ac39d Gyusu
        End If
5483 e282643f Gyusu
    End Sub
5484
5485 54b98e09 Gyusu
    Private Sub ThreadOPCRemove()
5486
        While _CompleteConvert = False
5487
            Dim oFindOPC As New FindOpc
5488
            oFindOPC.RemoveOPCDlg()
5489
        End While
5490 e282643f Gyusu
5491 54b98e09 Gyusu
    End Sub
5492 171ac39d Gyusu
5493 e282643f Gyusu
5494
    Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String
5495
        Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'")
5496
        Dim oPath As String = ""
5497
        If oRows.Length > 0 Then
5498
            oPath = oRows(0).Item("Path").ToString()
5499
        End If
5500
        Return oPath
5501
    End Function
5502
5503 272662f9 Gyusu
    Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click
5504 3b7a4470 Gyusu
5505 171ac39d Gyusu
        If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
5506 54b98e09 Gyusu
            LoadDB()
5507 171ac39d Gyusu
            LoadXmlItem(FolderBrowserDialog1.SelectedPath)
5508
        End If
5509
    End Sub
5510
    Private Sub LoadXmlItem(ByVal sFolderPath As String)
5511
        _DrawingsList = New List(Of Drawing)
5512
        Dim sfileEntries As String() = Directory.GetFiles(sFolderPath)
5513
        If Tree_Result.Nodes.Count > 0 Then
5514
            Tree_Result.Nodes(0).Nodes.Clear()
5515
            For Each sfileName In sfileEntries
5516
                Dim sExtension As String = Path.GetExtension(sfileName)
5517
                If sExtension = ".xml" Then
5518
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName)
5519
                    Dim sDwgPath As String = sfileName
5520
                    Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15)
5521
                    Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode)
5522 bb2a0c79 Gyusu
5523 171ac39d Gyusu
                    _DrawingsList.Add(oDwg)
5524
                End If
5525
            Next
5526
            Tree_Result.Nodes(0).Expand()
5527
        End If
5528
    End Sub
5529 272662f9 Gyusu
5530 e4000111 Gyusu
    Private Sub GenerateRelation(ByRef oDwg_Ds As Drawing)
5531
        Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5532
        Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5533
        Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5534
        Dim oRelation As New GenerateRelation()
5535
        For Each oLinelist In oLineLists
5536 bb2a0c79 Gyusu
            oRelation.CalcLineConnectionItem_Equal(oLinelist.Dt_Line, oLineLists)
5537
            oRelation.CalcLineConnectionItem_NonEqual(oLinelist.Dt_Line, oLineLists)
5538
            oRelation.CalcSymbolConnectionItem_Equal(oLinelist.Dt_Symbol, oLineLists)
5539
            oRelation.CalcSymbolConnectionItem_NonEqual(oLinelist.Dt_Symbol, oLineLists)
5540 e4000111 Gyusu
        Next
5541
    End Sub
5542
5543
5544 20c84e05 Gyusu
    ''' <summary>
5545
    '''  XML Tree 구조 생성 
5546
    ''' </summary>
5547
    ''' <param name="sDwgPath"></param>
5548 171ac39d Gyusu
    Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing
5549
        Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath)
5550 e4000111 Gyusu
5551 76f465d0 Gyusu
        'SetConnectionInfo()
5552 b08338e3 Gyusu
        '  GenerateRelation(oDwg_Ds)
5553 e4000111 Gyusu
5554 54b98e09 Gyusu
        If oDwg_Ds IsNot Nothing Then
5555
            Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5556
5557
            Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5558 3acffcee Gyusu
5559
            Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5560
5561 54b98e09 Gyusu
            Dim oPipe As Boolean = False
5562
            Dim oFitting As Boolean = False
5563
            'PipeLine 구분
5564
5565
            For Each oLinelist In oLineLists
5566
                Dim sLineNoUid As String = oLinelist.Uid
5567
                Dim sLineNo As String = oLinelist.Text
5568
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5569
                For Each oLineRow In oLinelist.Dt_Line.Rows
5570
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5571
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5572 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5573
                    If bValidLine = False Then
5574
                        oLineNoNode.ForeColor = Color.Red
5575
                        oPipeNode.ForeColor = Color.Red
5576
                    End If
5577 54b98e09 Gyusu
                    oPipeNode.Tag = sLineNoUid
5578
                Next
5579
                For Each oSymbolRow In oLinelist.Dt_Symbol.Rows
5580
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5581
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5582
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5583
                    oSymbolNode.Tag = sLineNoUid
5584
                Next
5585
            Next
5586 3acffcee Gyusu
5587 54b98e09 Gyusu
            For Each oEqplist In oEqpLists
5588
                Dim sEqpUid As String = oEqplist.Uid
5589
                Dim sEqpNo As String = "EQUIPMENT"
5590
                Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo)
5591 d039e347 Gyusu
5592 54b98e09 Gyusu
5593
                For Each oSymbolRow In oEqplist.Dt_Equipment.Rows
5594
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5595
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5596
                    Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName)
5597
                    oSymbolNode.Tag = sEqpUid
5598
                Next
5599 171ac39d Gyusu
            Next
5600 3acffcee Gyusu
            Dim sTrimLine As String = "TrimLineNos"
5601
            Dim iTrimLinecnt As Integer = 1
5602
            For Each oTrimLinelist In oTrimLineLists
5603
                Dim sLineNoUid As String = oTrimLinelist.Uid
5604
                Dim sLineNo As String = sTrimLine & "_" & iTrimLinecnt
5605
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5606
                For Each oLineRow In oTrimLinelist.Dt_Line.Rows
5607
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5608
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5609 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5610
                    If bValidLine = False Then
5611
                        oLineNoNode.ForeColor = Color.Red
5612
                        oPipeNode.ForeColor = Color.Red
5613
                    End If
5614 3acffcee Gyusu
                    oPipeNode.Tag = sLineNoUid
5615
                Next
5616
                For Each oSymbolRow In oTrimLinelist.Dt_Symbol.Rows
5617
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5618
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5619
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5620
                    oSymbolNode.Tag = sLineNoUid
5621
                Next
5622
                iTrimLinecnt = iTrimLinecnt + 1
5623
            Next
5624
5625 54b98e09 Gyusu
        End If
5626
5627 171ac39d Gyusu
        Return oDwg_Ds
5628
    End Function
5629 272662f9 Gyusu
    Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck
5630
        If e.Node.Checked = True Then
5631
            For Each oNode As TreeNode In e.Node.Nodes
5632
                oNode.Checked = True
5633
            Next
5634
        Else
5635
            For Each oNode As TreeNode In e.Node.Nodes
5636
                oNode.Checked = False
5637
            Next
5638
        End If
5639
    End Sub
5640 171ac39d Gyusu
5641 559daf6d Gyusu
    Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click
5642
        Dim oSettings As Settings = New Settings()
5643
        oSettings.ShowDialog()
5644
    End Sub
5645 42c0013c Gyusu
5646
    Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click
5647
5648
        Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11"
5649
        Dim objVessel As LMVessel
5650
        objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID)
5651
        Dim oVesselLocation As LMLocations = objVessel.Locations
5652
        Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id)
5653
        Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value
5654
        Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value
5655
        symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01
5656
        symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01
5657
        symVessel.Commit()
5658
        Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0"
5659
        Dim objValve As LMSymbol
5660
        Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID)
5661
5662
        objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id)
5663
        objValve.Commit()
5664
        Dim dVesselX As Double = XCoordinate
5665
        Dim dVesselY As Double = YCoordinate
5666
        Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double
5667
5668
        _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1)
5669
5670
        _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2)
5671
5672
        Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym"
5673
        Dim dCalc_x As Double = 0
5674
        Dim dCalc_y As Double = 0
5675
5676
        If dVesselX - X2 > 0 Then
5677
            dCalc_x = dVesselX - (dVesselX - X2)
5678
        Else
5679
            dCalc_x = dVesselX + (X2 - dVesselX)
5680
        End If
5681
        If dVesselY - Y2 > 0 Then
5682
            dCalc_y = dVesselY - (dVesselY - Y2)
5683
        Else
5684
            dCalc_y = dVesselY + (Y2 - dVesselY)
5685
        End If
5686
5687
        Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y,
5688
            TargetItem:=symVessel.AsLMRepresentation)
5689
5690
        Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1)
5691
        blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1)
5692
5693
        objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem,
5694
          TargetItem:=objNozzle.AsLMRepresentation)
5695
5696
5697
5698
    End Sub
5699 39d43554 Gyusu
5700
    Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click
5701
        Dim oMapping As New Mapping(_PIDSymbol_DB)
5702
        oMapping.Show()
5703
    End Sub
5704 41e4023e Gyusu
5705
    Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click
5706
        Try
5707
            SetListBoxItems(ListBox_Result, " Auto converting 중지....")
5708 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 중지....")
5709 41e4023e Gyusu
            _Main_trd.Abort()
5710
            _Opc_trd.Abort()
5711
        Catch ex As Exception
5712
5713
        End Try
5714
    End Sub
5715 b08338e3 Gyusu
5716
    Private Sub AutoCheckTreeNode(ByVal iType As Integer, ByVal bCheck As Boolean)
5717
5718
        For Each oDrwing As TreeNode In Tree_Result.Nodes
5719
            For Each oDwgNode As TreeNode In oDrwing.Nodes
5720
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
5721
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
5722
                If CDrawing IsNot Nothing Then
5723
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
5724
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
5725
                    For Each oNode As TreeNode In oDwgNode.Nodes
5726
                        Dim iItemcnt As Integer = 0
5727
                        Dim sNodeUid As String = oNode.Name
5728
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
5729
5730
                        If iType = 0 Then 'Symbol
5731
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5732
                            If CLineNo IsNot Nothing Then
5733
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
5734
                                For Each oSymbolRow In oSymbol_Dt.Rows
5735
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5736
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5737
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5738
                                        If sSymbolNodeUid = sSymbolUid Then
5739
                                            oSymbolNode.Checked = bCheck
5740
                                            Exit For
5741
                                        End If
5742
                                    Next
5743
                                Next
5744
                            End If
5745
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5746
                            If TrimLineNo IsNot Nothing Then
5747
                                Dim oSymbol_Dt As DataTable = TrimLineNo.Dt_Symbol
5748
                                For Each oSymbolRow In oSymbol_Dt.Rows
5749
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5750
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5751
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5752
                                        If sSymbolNodeUid = sSymbolUid Then
5753
                                            oSymbolNode.Checked = bCheck
5754
                                            Exit For
5755
                                        End If
5756
                                    Next
5757
                                Next
5758
                            End If
5759
                        End If
5760
                        If iType = 1 Then 'Line
5761
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5762
                            If CLineNo IsNot Nothing Then
5763
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
5764
                                For Each oLineRow In oLine_Dt.Rows
5765
                                    Dim sLineUid As String = oLineRow(_XML_LINE_UID).ToString()
5766
                                    For Each oLineNode As TreeNode In oNode.Nodes
5767
                                        Dim sLineNodeUid As String = oLineNode.Name
5768
                                        If sLineNodeUid = sLineUid Then
5769
                                            oLineNode.Checked = bCheck
5770
                                            Exit For
5771
                                        End If
5772
                                    Next
5773
                                Next
5774
                            End If
5775
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5776
                            If TrimLineNo IsNot Nothing Then
5777
                                Dim oLine_Dt As DataTable = TrimLineNo.Dt_Line
5778
                                For Each oLineRow In oLine_Dt.Rows
5779
                                    Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID).ToString()
5780
                                    For Each oLineNode As TreeNode In oNode.Nodes
5781
                                        Dim sLineNodeUid As String = oLineNode.Name
5782
                                        If sLineNodeUid = sLineUid Then
5783
                                            oLineNode.Checked = bCheck
5784
                                            Exit For
5785
                                        End If
5786
                                    Next
5787
                                Next
5788
                            End If
5789
                        End If
5790
                        If iType = 2 Then 'Equipment
5791
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
5792
                            If CEqpNo IsNot Nothing Then
5793
                                Dim oEqp_Dt As DataTable = CEqpNo.Dt_Equipment
5794
                                For Each oEqpRow In oEqp_Dt.Rows
5795
                                    Dim sEqpUid As String = oEqpRow(_XML_LINE_UID).ToString()
5796
                                    For Each oEqpNode As TreeNode In oNode.Nodes
5797
                                        Dim sEqpNodeUid As String = oEqpNode.Name
5798
                                        If sEqpNodeUid = sEqpUid Then
5799
                                            oEqpNode.Checked = bCheck
5800
                                            Exit For
5801
                                        End If
5802
                                    Next
5803
                                Next
5804
                            End If
5805
                        End If
5806
                    Next
5807
                End If
5808
            Next
5809
        Next
5810
5811
5812
    End Sub
5813
5814
5815
5816
    Private Sub Chk_Symbol_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Symbol.CheckedChanged
5817
        AutoCheckTreeNode(0, Chk_Symbol.Checked)
5818
    End Sub
5819
5820
    Private Sub Chk_Line_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Line.CheckedChanged
5821
        AutoCheckTreeNode(1, Chk_Line.Checked)
5822
    End Sub
5823
5824
    Private Sub Chk_Equipment_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Equipment.CheckedChanged
5825
        AutoCheckTreeNode(2, Chk_Equipment.Checked)
5826
    End Sub
5827 e282643f Gyusu
End Class
5828
5829
5830
Public Class DrawingInfo
5831
    Public mDrawingName As String
5832
    Public mSpID As String
5833
    Public mPath As String
5834 4f359afa Gyusu
End Class
5835 e282643f Gyusu
5836
5837
5838
클립보드 이미지 추가 (최대 크기: 500 MB)