프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ d7ddc5c0

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