hytos / DTI_PID / SPPIDConverter / Main.vb @ 5afca25c
이력 | 보기 | 이력해설 | 다운로드 (61.2 KB)
1 |
Imports System.IO |
---|---|
2 |
Imports System.Data.SqlClient |
3 |
Imports System.Data.SQLite |
4 |
Imports Plaice |
5 |
Imports Llama |
6 |
Imports PidA |
7 |
|
8 |
|
9 |
Imports System.Threading |
10 |
|
11 |
Public Class Main |
12 |
|
13 |
Dim _Mapping_DB As DataTable = New DataTable() |
14 |
Dim _Attribute_DB As DataTable = New DataTable() |
15 |
Dim _Placement As New Placement |
16 |
Dim _DWG_X = 0.84 '0.695 '1 ' |
17 |
Dim _DWG_Y = 0.594 '0.585 '0.8 ' |
18 |
|
19 |
Dim _IMG_X = 0 |
20 |
Dim _IMG_Y = 0 |
21 |
|
22 |
Dim _Unit As String |
23 |
|
24 |
'Drawing 전역변수 |
25 |
Dim _objPIDADrawing As Object |
26 |
'현재선택한 폴더경로 |
27 |
Dim _selectFolderPath As String |
28 |
|
29 |
Private _Main_trd As Thread |
30 |
|
31 |
Private _DrawingsList As List(Of Drawing) |
32 |
|
33 |
|
34 |
Private _iPipeLineNocnt As Integer |
35 |
Private _iPipecnt As Integer |
36 |
Private _iFittingcnt As Integer |
37 |
Private _iValvecnt As Integer |
38 |
Private _iInstrumentcnt As Integer |
39 |
Private _iEquipmentcnt As Integer |
40 |
Private _iNozzlecnt As Integer |
41 |
|
42 |
|
43 |
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load |
44 |
|
45 |
If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then |
46 |
Dim sDBPath As String = My.Settings.DBPath |
47 |
_Mapping_DB = Load_DB(sDBPath, _DB_TABLE_MAPPING) |
48 |
_Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE) |
49 |
'TestPID() |
50 |
Else |
51 |
MessageBox.Show("설정값을 먼저 확인해주세요") |
52 |
End If |
53 |
End Sub |
54 |
|
55 |
Public Function GetDrawingInfo(ByVal errorList As ArrayList) |
56 |
Dim ds As Llama.LMADataSource |
57 |
ds = New Llama.LMADataSource |
58 |
Dim lmaItem As Llama.LMAItem |
59 |
|
60 |
For i = 0 To errorList.Count - 1 |
61 |
lmaItem = ds.GetModelItem(errorList.Item(i).m_strSPID()).AsLMAItem |
62 |
Dim drawingInfo As DrawingInfo |
63 |
drawingInfo = GetDrawingName(lmaItem.ItemType, lmaItem.Id) |
64 |
errorList.Item(i).m_LMAItem = lmaItem |
65 |
errorList.Item(i).m_strDrawingName = drawingInfo.mDrawingName |
66 |
errorList.Item(i).m_strDrawingPath = drawingInfo.mPath |
67 |
Next |
68 |
End Function |
69 |
Private mDataSource As Object |
70 |
|
71 |
'Public Sub New() |
72 |
|
73 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
74 |
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
75 |
' 'm_Information = SPPIDClass.Information.GetInstance() |
76 |
|
77 |
' 'If m_Information.InfoProject.ProjectVersion = SPPIDClass.InfoProject.SPPID_43 Then |
78 |
' ' 'SPPID4.3용 |
79 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
80 |
' 'Else |
81 |
' ' 'SPPID2007, SPPID2009용 |
82 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
83 |
' 'End If |
84 |
|
85 |
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
86 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
87 |
' '#If LATE_BINDING Then |
88 |
' ' mInstruments = CreateObject("Llama.LMInstruments", "") |
89 |
' ' mPipingComps = CreateObject("Llama.LMPipingComps", "") |
90 |
' ' mVessels = CreateObject("Llama.LMVessels", "") |
91 |
' ' mDrawings = CreateObject("Llama.LMDrawings", "") |
92 |
' ' mEquipments = CreateObject("Llama.LMEquipments", "") |
93 |
' ' mExchangers = CreateObject("Llama.LMExchangers", "") |
94 |
' ' mMechanicals = CreateObject("Llama.LMMechanicals", "") |
95 |
' ' mNozzles = CreateObject("Llama.LMNozzles", "") |
96 |
' ' mPipeRuns = CreateObject("Llama.LMPipeRuns", "") |
97 |
' ' mEquipmentOthers = CreateObject("Llama.LMEquipmentOthers", "") |
98 |
' '#Else |
99 |
' ' mInstruments = New Llama.LMInstruments |
100 |
' ' mPipingComps = New Llama.LMPipingComps |
101 |
' ' mVessels = New Llama.LMVessels |
102 |
' ' mDrawings = New Llama.LMDrawings |
103 |
' ' mEquipments = New Llama.LMEquipments |
104 |
' ' mExchangers = New Llama.LMExchangers |
105 |
' ' mMechanicals = New Llama.LMMechanicals |
106 |
' ' mNozzles = New Llama.LMNozzles |
107 |
' ' mPipeRuns = New Llama.LMPipeRuns |
108 |
' ' mEquipmentOthers = New Llama.LMEquipmentOthers |
109 |
' '#End If |
110 |
'End Sub |
111 |
Public Function GetDrawingName(ByVal itemType As String, ByVal itemName As String) As DrawingInfo |
112 |
|
113 |
Dim objFilter As Object |
114 |
objFilter = CreateObject("Llama.LMAFilter", "") |
115 |
|
116 |
Dim drawingInfo As DrawingInfo |
117 |
drawingInfo = New DrawingInfo |
118 |
|
119 |
objFilter.Criteria.AddNew("FirstOne") |
120 |
objFilter.Criteria.Item("FirstOne").SourceAttributeName = "SP_ID" |
121 |
objFilter.Critedkria.Item("FirstOne").ValueAttribute = itemName |
122 |
|
123 |
objFilter.Criteria.Item("FirstOne").Operator = "=" |
124 |
objFilter.Criteria.AddNew("SecondOne") |
125 |
objFilter.Criteria.Item("SecondOne").SourceAttributeName = "ItemStatus" |
126 |
objFilter.Criteria.Item("SecondOne").ValueAttribute = 1 |
127 |
objFilter.Criteria.Item("SecondOne").Operator = "=" |
128 |
objFilter.Criteria.Item("SecondOne").Conjunctive = -1 |
129 |
objFilter.ItemType = itemType |
130 |
|
131 |
Dim PlantItems As Object |
132 |
PlantItems = CreateObject("Llama.LMPlantItems", "") |
133 |
PlantItems.Collect(mDataSource, Filter:=objFilter) |
134 |
|
135 |
If PlantItems.Count = 0 Then |
136 |
drawingInfo.mSpID = "PlantStockpile" |
137 |
End If |
138 |
|
139 |
For Each PlantItem In PlantItems |
140 |
|
141 |
'If Not PlantItem.Representations.Nth(1).DrawingID.Value.ToString().Equals("0") Then |
142 |
Try |
143 |
drawingInfo.mDrawingName = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Name").Value |
144 |
drawingInfo.mSpID = PlantItem.Representations.Nth(1).DrawingID |
145 |
drawingInfo.mPath = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Path").Value |
146 |
Debug.WriteLine("DrawingName : " & drawingInfo.mDrawingName & ", SPID : " & drawingInfo.mSpID & ", Path : " & drawingInfo.mPath) |
147 |
Catch ex As Exception |
148 |
|
149 |
End Try |
150 |
|
151 |
'End If |
152 |
|
153 |
Next |
154 |
|
155 |
Return drawingInfo |
156 |
|
157 |
End Function |
158 |
|
159 |
Private Sub TestPID() |
160 |
|
161 |
Try |
162 |
|
163 |
Dim datasource As LMADataSource |
164 |
Dim objPIDAutoApp As Object |
165 |
Dim objPIDADrawing As Object |
166 |
Dim objDrawing As LMDrawing |
167 |
Dim objDrawings As LMDrawings |
168 |
datasource = New LMADataSource |
169 |
|
170 |
|
171 |
Dim oObj As Object = Nothing |
172 |
objDrawing = datasource.GetDrawing(oObj) |
173 |
objDrawings = New LMDrawings |
174 |
objDrawings.Collect(datasource) |
175 |
objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application") |
176 |
For Each objDrawing In objDrawings |
177 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
178 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
179 |
If Not objPIDADrawing Is Nothing Then |
180 |
MessageBox.Show("Drawing " & objDrawing.Attributes("Name").Value & " is opened!") |
181 |
objPIDADrawing.CloseDrawing |
182 |
End If |
183 |
End If |
184 |
Next |
185 |
objPIDAutoApp.Quit |
186 |
objPIDAutoApp = Nothing |
187 |
objPIDADrawing = Nothing |
188 |
objDrawing = Nothing |
189 |
objDrawings = Nothing |
190 |
Catch ex As Exception |
191 |
|
192 |
End Try |
193 |
|
194 |
|
195 |
|
196 |
End Sub |
197 |
Public Function SetActiveSiteFromConfigInfo(ByVal strActiveSite As String) As Boolean |
198 |
|
199 |
On Error GoTo errHandler |
200 |
Dim objConfigInfo As Object 'interopigrConfigInfo412.igrConfigInfo |
201 |
objConfigInfo = CreateObject("interopigrConfigInfo412.igrConfigInfo", "") |
202 |
If Not objConfigInfo Is Nothing Then |
203 |
objConfigInfo.ApplicationName = "SmartPlantManager" |
204 |
objConfigInfo.SetConfigString(3, "SmartPlant Manager", "SiteServer", strActiveSite) |
205 |
SetActiveSiteFromConfigInfo = True |
206 |
End If |
207 |
objConfigInfo = Nothing |
208 |
|
209 |
Exit Function |
210 |
|
211 |
errHandler: |
212 |
' LogAndRaiseError ModuleName & "::GetConfigInfo " |
213 |
End Function |
214 |
|
215 |
Private Function CreateDwg(ByVal oDwgName As String) As Boolean |
216 |
Dim objPIDADrawing As Object = Nothing |
217 |
Dim objPIDAutoApp As Object = Nothing |
218 |
Dim datasource As LMADataSource = Nothing |
219 |
Try |
220 |
Dim DrawingNumber As String |
221 |
Dim DrawingName As String |
222 |
Dim sPlantGroupName As String = "Test" |
223 |
Dim sTemplateName As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\P&ID Reference Data\Template Files\Gazprom Project.pid" |
224 |
Dim objDrawing As LMDrawing |
225 |
Dim objDrawings As LMDrawings |
226 |
objDrawings = New LMDrawings |
227 |
datasource = New LMADataSource |
228 |
Debug.Print(datasource.ProjectNumber) |
229 |
Debug.Print(datasource.SiteNode) |
230 |
Debug.Print(datasource.IsSatellite) |
231 |
Debug.Print(datasource.GetSystemEditingToolbarSetting) |
232 |
objDrawings.Collect(datasource) |
233 |
Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
234 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
235 |
For Each objDrawing In objDrawings |
236 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
237 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(sPath) |
238 |
If Not objPIDADrawing Is Nothing Then |
239 |
|
240 |
objPIDADrawing.CloseDrawing |
241 |
End If |
242 |
End If |
243 |
Next |
244 |
|
245 |
Dim extension As String = Path.GetExtension(oDwgName) |
246 |
oDwgName = oDwgName.Replace(extension, "") |
247 |
|
248 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
249 |
|
250 |
'For Each objDrawing In objPIDAutoApp.Drawings |
251 |
' objDrawing.CloseDrawing(True) |
252 |
'Next |
253 |
|
254 |
objPIDAutoApp.Drawings.OpenDrawing(oDwgName + ".pid") |
255 |
|
256 |
objPIDAutoApp.ActiveWindow.Fit() |
257 |
|
258 |
Return True |
259 |
Catch ex As Exception |
260 |
If objPIDADrawing IsNot Nothing Then |
261 |
objPIDADrawing.CloseDrawing |
262 |
End If |
263 |
If objPIDAutoApp IsNot Nothing Then |
264 |
objPIDAutoApp.Quit |
265 |
End If |
266 |
datasource = Nothing |
267 |
objPIDAutoApp = Nothing |
268 |
objPIDADrawing = Nothing |
269 |
Return False |
270 |
End Try |
271 |
If objPIDADrawing IsNot Nothing Then |
272 |
objPIDADrawing.CloseDrawing |
273 |
End If |
274 |
|
275 |
End Function |
276 |
|
277 |
|
278 |
Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String |
279 |
Dim sValue As String = "" |
280 |
If _Mapping_DB.Rows.Count > 0 Then |
281 |
Dim oSelectRow() As DataRow = _Mapping_DB.Select("[pid_symbolname] = '" + sSymbolName + "'") |
282 |
If oSelectRow.Length = 1 Then |
283 |
sValue = oSelectRow(0).Item(sColumn).ToString() |
284 |
End If |
285 |
End If |
286 |
Return sValue |
287 |
End Function |
288 |
|
289 |
Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String |
290 |
Dim sSPPIDAttribute As String = "" |
291 |
If _Attribute_DB.Rows.Count > 0 Then |
292 |
Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'") |
293 |
If oSelectRow.Length = 1 Then |
294 |
sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString() |
295 |
End If |
296 |
End If |
297 |
Return sSPPIDAttribute |
298 |
End Function |
299 |
|
300 |
Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing |
301 |
Dim CDrawing As Drawing = New Drawing() |
302 |
Dim oDt As DataTable = LoadSymbol_DT() |
303 |
Dim oElement As XElement = XElement.Load(sXmlPath) |
304 |
|
305 |
If oElement IsNot Nothing Then |
306 |
CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value |
307 |
CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value |
308 |
SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y) |
309 |
CDrawing.Unit = oElement.Element(_XML_UNIT).Value |
310 |
|
311 |
Dim oLineno_list As New List(Of Line_no) |
312 |
|
313 |
For Each oLineNo As Object In oElement.Elements(_XML_CATEGORY_LINENO) |
314 |
Dim CLineNo As Line_no = New Line_no() |
315 |
CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value |
316 |
CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value |
317 |
CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value |
318 |
CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value |
319 |
CLineNo.SystemPath = GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
320 |
|
321 |
Dim oLine_Dt As DataTable = Line_Dt() |
322 |
Dim oSymbol_Dt As DataTable = Symbol_Dt() |
323 |
Dim oAttribute_Dt As DataTable = Attribute_Dt() |
324 |
|
325 |
For Each oLine As Object In oLineNo.Elements(_XML_CATEGORY_LINE) |
326 |
Dim oAddrow As DataRow = oLine_Dt.NewRow() |
327 |
Dim oEleObj As XElement |
328 |
Dim sUid As String |
329 |
Dim sStartpoint As String |
330 |
Dim sEndpoint As String |
331 |
oEleObj = oLine.Element(_XML_LINE_UID) |
332 |
sUid = oEleObj.Value |
333 |
oEleObj = oLine.Element(_XML_LINE_STARTPOINT) |
334 |
sStartpoint = oEleObj.Value |
335 |
oEleObj = oLine.Element(_XML_LINE_ENDPOINT) |
336 |
sEndpoint = oEleObj.Value |
337 |
|
338 |
oAddrow(_XML_LINE_UID) = sUid |
339 |
oAddrow(_XML_LINE_STARTPOINT) = sStartpoint |
340 |
oAddrow(_XML_LINE_ENDPOINT) = sEndpoint |
341 |
oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
342 |
oLine_Dt.Rows.Add(oAddrow) |
343 |
Next |
344 |
|
345 |
For Each oSymbol As Object In oLineNo.Elements(_XML_CATEGORY_SYMBOL) |
346 |
Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
347 |
Dim oEleObj As XElement |
348 |
Dim sUid As String |
349 |
Dim sName As String |
350 |
Dim sLocation As String |
351 |
Dim sSize As String |
352 |
Dim sAngle As String |
353 |
Dim sOriginalPoint As String |
354 |
oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
355 |
sUid = oEleObj.Value |
356 |
oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
357 |
sName = oEleObj.Value |
358 |
oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
359 |
sLocation = oEleObj.Value |
360 |
oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
361 |
sSize = oEleObj.Value |
362 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
363 |
sAngle = oEleObj.Value |
364 |
Try |
365 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
366 |
sOriginalPoint = oEleObj.Value |
367 |
Catch ex As Exception |
368 |
|
369 |
End Try |
370 |
|
371 |
|
372 |
|
373 |
oAddrow(_XML_SYMBOL_UID) = sUid |
374 |
oAddrow(_XML_SYMBOL_NAME) = sName |
375 |
oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
376 |
oAddrow(_XML_SYMBOL_SIZE) = sSize |
377 |
oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
378 |
oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
379 |
oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
380 |
oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
381 |
|
382 |
oSymbol_Dt.Rows.Add(oAddrow) |
383 |
Next |
384 |
|
385 |
For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
386 |
|
387 |
Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
388 |
Dim oEleObj As XElement |
389 |
Dim sUid As String |
390 |
Dim sName As String |
391 |
Dim sValue As String |
392 |
|
393 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
394 |
sUid = oEleObj.Value |
395 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
396 |
sName = oEleObj.Value |
397 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
398 |
sValue = oEleObj.Value |
399 |
|
400 |
oAddrow(_XML_ATTRIBUTE_UID) = sUid |
401 |
oAddrow(_XML_ATTRIBUTE_NAME) = sName |
402 |
oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
403 |
oAttribute_Dt.Rows.Add(oAddrow) |
404 |
Next |
405 |
CLineNo.Dt_Line = oLine_Dt |
406 |
CLineNo.Dt_Symbol = oSymbol_Dt |
407 |
CLineNo.Dt_Attribute = oAttribute_Dt |
408 |
|
409 |
|
410 |
'For Each oSymbol As Object In oLineNo.Elements(_XML_CATEGORY_SYMBOL) |
411 |
|
412 |
' Dim oAddrow As DataRow = oDt.NewRow() |
413 |
|
414 |
' Dim oObj As XElement = oSymbol.Element(_XML_SYMBOL_NAME) |
415 |
' Dim oName As String = oObj.Value |
416 |
|
417 |
' oObj = oSymbol.Element(_XML_SYMBOL_UID) |
418 |
' Dim oUid = oObj.Value |
419 |
|
420 |
' ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym" |
421 |
' Dim oSymbolPath As String = GetSymbolMapping(oName) |
422 |
|
423 |
' oObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
424 |
' Dim sOriginPoint = oObj.Value |
425 |
|
426 |
' oObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
427 |
' Dim oAngle = oObj.Value |
428 |
|
429 |
' Dim oSplitPos As String() = sOriginPoint.Split(",") |
430 |
' Dim oX As Double = 0.0 |
431 |
' Dim oY As Double = 0.0 |
432 |
' If IsNumeric(oSplitPos(0)) Then |
433 |
' oX = Double.Parse(oSplitPos(0)) |
434 |
' End If |
435 |
' If IsNumeric(oSplitPos(1)) Then |
436 |
' oY = Double.Parse(oSplitPos(1)) |
437 |
' End If |
438 |
' ConvertPoint(oX, oY, _IMG_X, _IMG_Y) |
439 |
' oAddrow("x") = oX '+ 0.05 |
440 |
' oAddrow("Y") = oY |
441 |
' oAddrow("Angle") = oAngle |
442 |
' oAddrow("SystemPath") = oSymbolPath |
443 |
' oAddrow("Name") = oName |
444 |
' oAddrow("uid") = |
445 |
' oDt.Rows.Add(oAddrow) |
446 |
'Next |
447 |
|
448 |
|
449 |
oLineno_list.Add(CLineNo) |
450 |
Next |
451 |
|
452 |
CDrawing.Line_nos = oLineno_list |
453 |
End If |
454 |
Return CDrawing |
455 |
End Function |
456 |
|
457 |
|
458 |
|
459 |
'Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable |
460 |
' Try |
461 |
' Dim oDt As DataTable = LoadPipe_DT() |
462 |
' Dim oElement As XElement = XElement.Load(sXmlPath) |
463 |
' If oElement IsNot Nothing Then |
464 |
' Dim DWGElement As XElement = oElement.Element("DWGNAME") |
465 |
' Dim DWGNAME = DWGElement.Value |
466 |
' Dim sXY As XElement = oElement.Element("SIZE") |
467 |
' Dim sSize = sXY.Value |
468 |
' Dim oSplitDWGPos As String() = sSize.Split(", ") |
469 |
|
470 |
' If IsNumeric(oSplitDWGPos(0)) Then |
471 |
' _IMG_X = Double.Parse(oSplitDWGPos(0)) |
472 |
' End If |
473 |
' If IsNumeric(oSplitDWGPos(1)) Then |
474 |
' _IMG_Y = Double.Parse(oSplitDWGPos(1)) |
475 |
' End If |
476 |
|
477 |
' For Each pipes As Object In oElement.Elements("IMGLINES") |
478 |
' For Each pipe As Object In pipes.Elements("IMGLINE") |
479 |
' Dim oAddrow As DataRow = oDt.NewRow() |
480 |
' Dim oObj As XElement = pipe.Element("ITEM") |
481 |
' Dim oItem = oObj.Value |
482 |
' ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym" |
483 |
' Dim oSymbolPath As String = GetSystemPathFromMappingDB(oItem) |
484 |
' oObj = pipe.Element("START") |
485 |
' Dim oStartPoint = oObj.Value |
486 |
' Dim oSplitPos As String() = oStartPoint.Split(", ") |
487 |
' Dim oStartpos_X As Double = 0.0 |
488 |
' Dim oStartpos_Y As Double = 0.0 |
489 |
' If IsNumeric(oSplitPos(0)) Then |
490 |
' oStartpos_X = Double.Parse(oSplitPos(0)) |
491 |
' End If |
492 |
' If IsNumeric(oSplitPos(1)) Then |
493 |
' oStartpos_Y = Double.Parse(oSplitPos(1)) |
494 |
' End If |
495 |
|
496 |
' ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y) |
497 |
' oObj = pipe.Element("End") |
498 |
' Dim oEndPoint = oObj.Value |
499 |
' oSplitPos = oEndPoint.Split(", ") |
500 |
' Dim oEndpos_X As Double = 0.0 |
501 |
' Dim oEndpos_Y As Double = 0.0 |
502 |
' If IsNumeric(oSplitPos(0)) Then |
503 |
' oEndpos_X = Double.Parse(oSplitPos(0)) |
504 |
' End If |
505 |
' If IsNumeric(oSplitPos(1)) Then |
506 |
' oEndpos_Y = Double.Parse(oSplitPos(1)) |
507 |
' End If |
508 |
' ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y) |
509 |
|
510 |
' oAddrow("start_x") = oStartpos_X '+ 0.05 |
511 |
' oAddrow("start_y") = oStartpos_Y |
512 |
' oAddrow("end_x") = oEndpos_X |
513 |
' oAddrow("end_y") = oEndpos_Y |
514 |
' oAddrow("SystemPath") = oSymbolPath |
515 |
' oDt.Rows.Add(oAddrow) |
516 |
' Next |
517 |
' Next |
518 |
|
519 |
' End If |
520 |
|
521 |
|
522 |
' Return oDt |
523 |
' Catch ex As Exception |
524 |
' Return Nothing |
525 |
' End Try |
526 |
'End Function |
527 |
|
528 |
|
529 |
Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double) |
530 |
|
531 |
Dim calcx As Double = 0 |
532 |
Dim calcy As Double = 0 |
533 |
calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2) |
534 |
calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2) |
535 |
dX = calcx |
536 |
dY = calcy |
537 |
End Sub |
538 |
|
539 |
|
540 |
'@brief Convert To SPPID |
541 |
'@author : Gyusu Park |
542 |
'@date : 2018-04-10 |
543 |
'@history: |
544 |
|
545 |
Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double) |
546 |
|
547 |
Dim opointstr As String() = Split(sLocation, ",") |
548 |
If (opointstr.Length > 1) Then |
549 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
550 |
dX = opointstr(0) |
551 |
dY = opointstr(1) |
552 |
End If |
553 |
End If |
554 |
|
555 |
End Sub |
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal oTreeNode As TreeNode) As Boolean |
563 |
Dim iTotalCount As Double = oPipe_Dt.Rows.Count + oSymbol_Dt.Rows.Count |
564 |
Dim iSymbolcount As Double = 0 |
565 |
|
566 |
Dim lobjDatasource As Object = _Placement.PIDDataSource |
567 |
|
568 |
' lobjDatasource.BeginTransaction() |
569 |
' datasource = objPlacement.PIDDataSource |
570 |
'Dim iPipecnt As Integer = 0 |
571 |
SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
572 |
|
573 |
Dim iPipeCnt As Integer = 0 |
574 |
If oPipe_Dt IsNot Nothing Then |
575 |
For Each oRow As DataRow In oPipe_Dt.Rows |
576 |
Dim oposition As String = oRow("position").ToString() |
577 |
Dim oSymbol As String = oRow("SystemPath").ToString() |
578 |
|
579 |
Dim objConnector As LMConnector |
580 |
Dim objInputs As PlaceRunInputs |
581 |
objInputs = New PlaceRunInputs |
582 |
Dim oSplitStr As String() = Split(oposition, " ") |
583 |
For Each sposition As String In oSplitStr |
584 |
Dim opointstr As String() = Split(sposition, ", ") |
585 |
|
586 |
If (opointstr.Length > 1) Then |
587 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
588 |
Dim ox As Double = opointstr(0) |
589 |
Dim oy As Double = opointstr(1) |
590 |
ConvertPointByImage(ox, oy, _IMG_X, _IMG_Y) |
591 |
objInputs.AddPoint(ox, oy) |
592 |
End If |
593 |
End If |
594 |
Next |
595 |
Dim objItem As LMAItem |
596 |
objItem = _Placement.PIDCreateItem(oSymbol) |
597 |
objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
598 |
SetListBoxItems(ListBox_Result, " Place PipeLine...." & "(" & (iPipeCnt + 1) & "/" & oPipe_Dt.Rows.Count) |
599 |
'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID) |
600 |
'objPipeRun.Attributes("OperFluidCode").Value = "AFS" |
601 |
'objPipeRun.Commit() |
602 |
iSymbolcount = iSymbolcount + 1 |
603 |
iPipeCnt = iPipeCnt + 1 |
604 |
Next |
605 |
End If |
606 |
|
607 |
SetListBoxItems(ListBox_Result, " Place PipeLine....완료") |
608 |
|
609 |
Dim iAllInstrumentCnt As Integer = oSymbol_Dt.Select("Name = 'INSTRUMENTATION'").Length |
610 |
Dim iValveCnt As Integer = oSymbol_Dt.Select("Class = 'VALVES'").Length |
611 |
Dim iInstrumentCnt As Integer = 1 |
612 |
Dim iFittingsCnt As Integer = 1 |
613 |
|
614 |
Dim oInsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Instruments", True)(0) |
615 |
Dim oValveNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Valves", True)(0) |
616 |
Dim oFittingsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Fittings", True)(0) |
617 |
For Each oRow As DataRow In oSymbol_Dt.Rows |
618 |
|
619 |
Try |
620 |
|
621 |
Dim sSystemPath As String = oRow("SystemPath").ToString() |
622 |
Dim sName As String = oRow("Name").ToString() |
623 |
Dim sType As String = oRow("Type").ToString() |
624 |
Dim sText As String = oRow("Text").ToString() |
625 |
Dim sClass As String = oRow("Class").ToString() |
626 |
Dim sItem As String = oRow("Item").ToString() |
627 |
|
628 |
Dim oX As Double = 0.0 |
629 |
Dim oY As Double = 0.0 |
630 |
If IsNumeric(oRow("x").ToString()) Then |
631 |
oX = Double.Parse(oRow("x").ToString()) |
632 |
End If |
633 |
If IsNumeric(oRow("y").ToString()) Then |
634 |
oY = Double.Parse(oRow("y").ToString()) |
635 |
End If |
636 |
Dim oAngle As Double = 0.0 |
637 |
If IsNumeric(oRow("Angle").ToString()) Then |
638 |
oAngle = Double.Parse(oRow("Angle").ToString()) |
639 |
End If |
640 |
' oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym" |
641 |
If sSystemPath <> "" Then |
642 |
If sName = _TYPE_Instumentation Then |
643 |
|
644 |
Dim sTagsuffix As String = "" |
645 |
Dim sTagSequenceNo As String = "" |
646 |
Dim sMeasuredVariableCode As String = "" |
647 |
Dim sInstrumentTypeModifier As String = "" |
648 |
|
649 |
If sText <> "" Then |
650 |
If sText.Contains(",") Then |
651 |
Dim splitstr() As String = sText.Split(",") |
652 |
For i = 0 To splitstr.Count - 1 |
653 |
If i = 0 Then |
654 |
sMeasuredVariableCode = Mid(splitstr(i), 1, 1) |
655 |
sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i))) |
656 |
Else |
657 |
If Len(splitstr(i)) = 1 Then |
658 |
sInstrumentTypeModifier = splitstr(i) |
659 |
ElseIf Len(splitstr(i)) = 0 Then |
660 |
|
661 |
ElseIf Len(splitstr(i)) > 1 Then |
662 |
sInstrumentTypeModifier = Mid(splitstr(i), 1, 1) |
663 |
sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i))) |
664 |
End If |
665 |
End If |
666 |
Next |
667 |
Else |
668 |
sMeasuredVariableCode = Mid(sText, 1, 1) |
669 |
sTagSequenceNo = Mid(sText, 2, Len(sText)) |
670 |
End If |
671 |
|
672 |
End If |
673 |
|
674 |
Dim objInstrSym As LMSymbol |
675 |
objInstrSym = _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
676 |
SetListBoxItems(ListBox_Result, " Place Instrument...." & "(" & (iInstrumentCnt + 1) & "/" & iAllInstrumentCnt & ")") |
677 |
|
678 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sTagSequenceNo) |
679 |
Dim action As Action = Sub() |
680 |
oInsNode.Nodes.Add(sClass & "-" & iInstrumentCnt) |
681 |
oInsNode.ExpandAll() |
682 |
End Sub |
683 |
oInsNode.TreeView.Invoke(action) |
684 |
|
685 |
|
686 |
Dim objInstr As LMInstrument |
687 |
objInstr = lobjDatasource.GetInstrument(objInstrSym.ModelItemID) |
688 |
|
689 |
Dim objItem As LMAItem |
690 |
objItem = _Placement.PIDCreateItem(sSystemPath) |
691 |
|
692 |
|
693 |
objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode |
694 |
objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier |
695 |
objInstr.Attributes("TagSuffix").Value = sTagsuffix |
696 |
objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo |
697 |
objInstr.Commit() |
698 |
iInstrumentCnt = iInstrumentCnt + 1 |
699 |
ElseIf sName = "GATE VALVE WITH PLUG" Then |
700 |
|
701 |
ElseIf sName = "MEDIUM 1D 1TO1" Then |
702 |
|
703 |
ElseIf sClass = "VALVES" Then |
704 |
Dim action As Action = Sub() |
705 |
oValveNode.ExpandAll() |
706 |
oValveNode.Nodes.Add(sClass & "-" & iValveCnt) |
707 |
End Sub |
708 |
oValveNode.TreeView.Invoke(action) |
709 |
|
710 |
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
711 |
|
712 |
iValveCnt = iValveCnt + 1 |
713 |
Else |
714 |
Dim action As Action = Sub() |
715 |
oFittingsNode.ExpandAll() |
716 |
oFittingsNode.Nodes.Add(sClass & "-" & iFittingsCnt) |
717 |
End Sub |
718 |
oFittingsNode.TreeView.Invoke(action) |
719 |
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
720 |
|
721 |
iFittingsCnt = iFittingsCnt + 1 |
722 |
|
723 |
End If |
724 |
iSymbolcount = iSymbolcount + 1 |
725 |
Else |
726 |
End If |
727 |
Catch ex As Exception |
728 |
|
729 |
End Try |
730 |
Dim dCalcProgressValue As Double = (iSymbolcount / iTotalCount) * 100 |
731 |
SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
732 |
' ProgressBar_Status.Value = (iSymbolcount / iTotalCount) * 100 |
733 |
|
734 |
Next |
735 |
|
736 |
MsgBox("Complete AutoConverting") |
737 |
SetListBoxItems(ListBox_Result, "Place Instrument....변환완료") |
738 |
SetListBoxItems(ListBox_Result, "총 symbol: " & iSymbolcount & "개 변환완료") |
739 |
SetProgressbar(ProgressBar_Status, 100) |
740 |
' MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료") |
741 |
End Function |
742 |
|
743 |
|
744 |
Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) |
745 |
If e.Node.Checked = True Then |
746 |
For Each oNode As TreeNode In e.Node.Nodes |
747 |
oNode.Checked = True |
748 |
Next |
749 |
Else |
750 |
For Each oNode As TreeNode In e.Node.Nodes |
751 |
oNode.Checked = False |
752 |
Next |
753 |
End If |
754 |
End Sub |
755 |
|
756 |
Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable |
757 |
|
758 |
Try |
759 |
Dim oDt As New DataTable |
760 |
Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
761 |
Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
762 |
conn.Open() |
763 |
Dim sQuery As String = "Select * from " & sTableName |
764 |
Dim cmd As SQLiteCommand = conn.CreateCommand() |
765 |
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
766 |
Dim oDataSet As DataSet = New DataSet() |
767 |
adapter.Fill(oDataSet) |
768 |
oDt = oDataSet.Tables(0) |
769 |
Return oDt |
770 |
Catch ex As Exception |
771 |
Return Nothing |
772 |
End Try |
773 |
|
774 |
|
775 |
End Function |
776 |
|
777 |
Private Sub Load_AttributeDB(ByVal sDBPath As String) |
778 |
|
779 |
Try |
780 |
Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
781 |
Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
782 |
conn.Open() |
783 |
Dim sQuery As String = "Select * from Attribute" |
784 |
Dim cmd As SQLiteCommand = conn.CreateCommand() |
785 |
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
786 |
Dim oDataSet As DataSet = New DataSet() |
787 |
adapter.Fill(oDataSet) |
788 |
_Attribute_DB = oDataSet.Tables(0) |
789 |
Catch ex As Exception |
790 |
|
791 |
End Try |
792 |
|
793 |
|
794 |
End Sub |
795 |
|
796 |
'Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect |
797 |
' If first_start = False Then Exit Sub |
798 |
' Dim pa = e.Node.FullPath.ToString |
799 |
|
800 |
' printfilesfolders_here(pa, e.Node) |
801 |
|
802 |
' displayfiles(pa) |
803 |
|
804 |
' Dim coco As String = "" |
805 |
' coco = pa.ToString |
806 |
' coco = coco.Replace("\\", "\") |
807 |
' Me.Text = coco |
808 |
' folders_path = coco |
809 |
'End Sub |
810 |
|
811 |
Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode) |
812 |
|
813 |
Dim foldername As String |
814 |
Dim filename As String |
815 |
itree.Nodes.Clear() |
816 |
On Error GoTo eee |
817 |
For Each foldername In Directory.GetDirectories(path) |
818 |
On Error GoTo eee |
819 |
Dim jj = foldername.LastIndexOf("\") |
820 |
Dim jj1 = foldername.Length - jj |
821 |
Dim foldr = foldername.Substring((jj + 1), (jj1 - 1)) |
822 |
itree.Nodes.Add(foldr, foldr) |
823 |
Next ' if you put this next at the end of procedure recursive will be done on first folder only |
824 |
Exit Sub |
825 |
eee: |
826 |
End Sub |
827 |
|
828 |
|
829 |
|
830 |
' Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove |
831 |
' first_start = True |
832 |
' End Sub |
833 |
|
834 |
' Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged |
835 |
' Dim indexes As ListView.SelectedIndexCollection = |
836 |
' Me.ListView_File.SelectedIndices |
837 |
' Dim index As Integer |
838 |
|
839 |
' For Each index In indexes |
840 |
' 'On Error Resume Next |
841 |
' If folders_path.EndsWith("\") = True Then |
842 |
' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
843 |
' 'On Error Resume Next |
844 |
' Else |
845 |
' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
846 |
' End If |
847 |
|
848 |
' Dim infoReader As System.IO.FileInfo |
849 |
' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
850 |
' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
851 |
' Next |
852 |
' End Sub |
853 |
|
854 |
' Private Sub Procees() |
855 |
' Dim indexes As ListView.SelectedIndexCollection = |
856 |
' Me.ListView_File.SelectedIndices |
857 |
' Dim index As Integer |
858 |
|
859 |
' For Each index In indexes |
860 |
' 'On Error Resume Next |
861 |
' If folders_path.EndsWith("\") = True Then |
862 |
' On Error GoTo out |
863 |
' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
864 |
' On Error GoTo out |
865 |
' 'On Error Resume Next |
866 |
' Else |
867 |
' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
868 |
' On Error GoTo out |
869 |
' End If |
870 |
|
871 |
' Dim infoReader As System.IO.FileInfo |
872 |
' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
873 |
' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
874 |
' On Error GoTo out |
875 |
' MsgBox(Me.Status_Main.Items(0).Text + " is processed") |
876 |
' On Error GoTo out |
877 |
' Next |
878 |
' Exit Sub |
879 |
'out: |
880 |
' MsgBox(Err.Description) |
881 |
'End Sub |
882 |
|
883 |
Private Function LoadAllDrawing() As DataTable |
884 |
|
885 |
|
886 |
SetListBoxItems(ListBox_Result, "도면정보 로드중....") |
887 |
|
888 |
Dim oDt As DataTable = Drawing_Dt() |
889 |
Dim sHierarchy As String = My.Settings.Plant_Hierarchy |
890 |
|
891 |
|
892 |
Dim files() As String |
893 |
files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories) |
894 |
For Each FileName As String In files |
895 |
Dim sName As String = FileName |
896 |
Dim oAddRow As DataRow = oDt.NewRow() |
897 |
oAddRow("Name") = Path.GetFileNameWithoutExtension(sName) |
898 |
oAddRow("Path") = FileName |
899 |
oDt.Rows.Add(oAddRow) |
900 |
Next |
901 |
Return oDt |
902 |
End Function |
903 |
|
904 |
Private Function LoadAllDrawing2() As DataTable |
905 |
Dim datasource As LMADataSource |
906 |
Dim objPIDAutoApp As Object |
907 |
Dim objPIDADrawing As Object |
908 |
Dim objDrawing As Object 'Drawing |
909 |
'Dim objDrawing As LMDrawing |
910 |
'Dim objDrawings As LMDrawings |
911 |
|
912 |
datasource = New LMADataSource |
913 |
|
914 |
' objDrawings = New LMDrawings |
915 |
'objDrawings.Collect(datasource) |
916 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
917 |
|
918 |
For Each objDrawing In objPIDAutoApp.Drawings |
919 |
objDrawing.CloseDrawing(True) |
920 |
Next |
921 |
Try |
922 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("UY1-K-2000_P1_300dpi_0321_TEST_1") |
923 |
Catch ex As Exception |
924 |
Process.Start("\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
925 |
End Try |
926 |
|
927 |
|
928 |
|
929 |
Dim sType As Type = objPIDAutoApp.GetType() |
930 |
Dim iCount As Integer = 0 |
931 |
' Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
932 |
|
933 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("1") |
934 |
|
935 |
For Each objDrawing In objPIDAutoApp.Drawings |
936 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
937 |
Try |
938 |
|
939 |
Dim sName As String = objDrawing.Attributes("Name").Value |
940 |
|
941 |
iCount = iCount + 1 |
942 |
If sName = "UY1-K-2000_P1_300dpi_0321_TEST_1" Then |
943 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
944 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
945 |
If Not objPIDADrawing Is Nothing Then |
946 |
objPIDADrawing.CloseDrawing() |
947 |
End If |
948 |
End If |
949 |
|
950 |
|
951 |
Catch ex As Exception |
952 |
|
953 |
End Try |
954 |
|
955 |
End If |
956 |
Next |
957 |
objPIDAutoApp.Quit |
958 |
objPIDAutoApp = Nothing |
959 |
objPIDADrawing = Nothing |
960 |
objDrawing = Nothing |
961 |
' objDrawings = Nothing |
962 |
End Function |
963 |
|
964 |
Dim _XMLList As ListView = New ListView() |
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
Private Function CheckOpenDrawing() As Boolean |
972 |
Try |
973 |
|
974 |
Dim lobjDatasource As Object |
975 |
_Placement = CreateObject("Plaice.Placement", "") |
976 |
lobjDatasource = _Placement.PIDDataSource |
977 |
Return True |
978 |
Catch ex As Exception |
979 |
Return False |
980 |
End Try |
981 |
|
982 |
End Function |
983 |
|
984 |
|
985 |
Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click |
986 |
|
987 |
Main_Tab.SelectedIndex = 1 |
988 |
ListBox_Result.Items.Clear() |
989 |
' DataGrid_Result.DataSource = New DataTable() |
990 |
Me.ProgressBar_Status.Visible = True |
991 |
ProgressBar_Status.Maximum = 100 |
992 |
ProgressBar_Status.Value = 0 |
993 |
' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\") |
994 |
_Main_trd = New Thread(AddressOf ThreadTask) |
995 |
_Main_trd.IsBackground = True |
996 |
_Main_trd.Start() |
997 |
|
998 |
End Sub |
999 |
'Private Sub ThreadTask() |
1000 |
|
1001 |
|
1002 |
' If _XMLList.Items.Count > 0 Then |
1003 |
|
1004 |
' Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1005 |
' Dim iDwgCnt As Integer = 0 |
1006 |
' Dim objPIDAutoApp As Object |
1007 |
' objPIDAutoApp = CreateObject("PIDAutomation.Application") |
1008 |
|
1009 |
|
1010 |
' Dim myList = DirectCast(Invoke(New GetListViewDelegate(AddressOf GetListViewItems), _XMLList), List(Of String)) |
1011 |
' For i = 0 To myList.Count - 1 |
1012 |
|
1013 |
' Dim sDwgName As String = Path.GetFileNameWithoutExtension(myList(i)) |
1014 |
' Txt_Status.Text = sDwgName & "..(" & i + 1 & "/" & myList.Count & ")" |
1015 |
' SetListBoxItems(ListBox_Result, Txt_Status.Text & " 처리중....") |
1016 |
' Dim sDwgNo As String = myList(i) |
1017 |
' Dim oDwgPath As String = "" |
1018 |
' oDwgPath = _selectFolderPath + "\" + sDwgNo |
1019 |
|
1020 |
' Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1021 |
' If sPath <> "" Then |
1022 |
|
1023 |
' Process.Start(sPath) |
1024 |
|
1025 |
' Dim bCheckOpenDrawing As Boolean = False |
1026 |
' While (True) |
1027 |
' bCheckOpenDrawing = CheckOpenDrawing() |
1028 |
' If bCheckOpenDrawing = True Then |
1029 |
' Exit While |
1030 |
' Else |
1031 |
' Thread.Sleep(2000) |
1032 |
' End If |
1033 |
' End While |
1034 |
|
1035 |
' If bCheckOpenDrawing Then |
1036 |
' SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
1037 |
' Dim oPipe_Dt As DataTable = New DataTable() 'LoadPipeInXml(oDwgPath) |
1038 |
|
1039 |
' Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath) |
1040 |
' Dim oTreeNode As New TreeNode 'SetTreeViewItems(Tree_Result, Tree_Result.Nodes, sDwgName, sDwgName) |
1041 |
' 'oTreeNode = Tree_Result.Nodes.Find(sDwgName, True)(0) |
1042 |
' Dim action As Action = Sub() |
1043 |
' oTreeNode = Tree_Result.Nodes.Add(sDwgName, sDwgName) |
1044 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Instruments", "Instuments") |
1045 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Pipes", "Pipes") |
1046 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Valves", "Valves") |
1047 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Fittings", "Fittings") |
1048 |
' oTreeNode.ExpandAll() |
1049 |
' End Sub |
1050 |
' Tree_Result.Invoke(action) |
1051 |
|
1052 |
|
1053 |
' ' oTreeNode.Expand() |
1054 |
' SetListBoxItems(ListBox_Result, sDwgName & " Auto converting 대기....") |
1055 |
' AutoConverting(oPipe_Dt, oSymbol_Dt, oTreeNode) |
1056 |
|
1057 |
' End If |
1058 |
|
1059 |
' End If |
1060 |
' ''도면 생성 |
1061 |
' 'If CreateDwg(sDwgName) Then |
1062 |
' ' 'AutoConverting |
1063 |
|
1064 |
' 'End If |
1065 |
|
1066 |
' Next |
1067 |
' End If |
1068 |
'End Sub |
1069 |
|
1070 |
Dim _objPIDAutoApp As Object |
1071 |
|
1072 |
Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean |
1073 |
Dim bCheckOpen As Boolean = False |
1074 |
' Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath) |
1075 |
SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
1076 |
_objPIDAutoApp = CreateObject("PIDAutomation.Application") |
1077 |
|
1078 |
Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1079 |
If sPath <> "" Then |
1080 |
Process.Start(sPath) |
1081 |
Else |
1082 |
Return bCheckOpen |
1083 |
End If |
1084 |
|
1085 |
Dim bCheckOpenDrawing As Boolean = False |
1086 |
While (True) |
1087 |
bCheckOpenDrawing = CheckOpenDrawing() |
1088 |
If bCheckOpenDrawing = True Then |
1089 |
bCheckOpen = True |
1090 |
Exit While |
1091 |
Else |
1092 |
Thread.Sleep(2000) |
1093 |
End If |
1094 |
End While |
1095 |
|
1096 |
|
1097 |
Return bCheckOpen |
1098 |
End Function |
1099 |
|
1100 |
Private Function GetDrawing(ByVal sDwgName As String) As Drawing |
1101 |
For Each CDrawing In _DrawingsList |
1102 |
If CDrawing.DwgName = sDwgName Then |
1103 |
Return CDrawing |
1104 |
End If |
1105 |
Next |
1106 |
Return Nothing |
1107 |
End Function |
1108 |
|
1109 |
Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no |
1110 |
For Each CLineNo In CDrawing.Line_nos |
1111 |
If CLineNo.Uid = sLineNoUid Then |
1112 |
Return CLineNo |
1113 |
End If |
1114 |
Next |
1115 |
Return Nothing |
1116 |
End Function |
1117 |
|
1118 |
Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean |
1119 |
Try |
1120 |
Dim opointstr As String() = Split(sPoint, ",") |
1121 |
If (opointstr.Length > 1) Then |
1122 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
1123 |
dX = opointstr(0) |
1124 |
dY = opointstr(1) |
1125 |
|
1126 |
Else |
1127 |
dX = 0 |
1128 |
dY = 0 |
1129 |
Return False |
1130 |
End If |
1131 |
End If |
1132 |
Return True |
1133 |
Catch ex As Exception |
1134 |
Return False |
1135 |
End Try |
1136 |
End Function |
1137 |
|
1138 |
Private Function DrawLine(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable) As LMPipeRun |
1139 |
Try |
1140 |
Dim oPipeRun As LMPipeRun |
1141 |
Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" + sUid + "'") |
1142 |
Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
1143 |
|
1144 |
If oPipeRow.Length > 0 Then |
1145 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1146 |
Dim objItem As LMAItem |
1147 |
Dim objConnector As LMConnector |
1148 |
Dim objInputs As PlaceRunInputs |
1149 |
objInputs = New PlaceRunInputs |
1150 |
Dim dOriginalStart_x As Double = 0.0 |
1151 |
Dim dOriginalStart_y As Double = 0.0 |
1152 |
Dim dOriginalEnd_x As Double = 0.0 |
1153 |
Dim dOriginalEnd_y As Double = 0.0 |
1154 |
|
1155 |
Dim dStart_x As Double = 0.0 |
1156 |
Dim dStart_y As Double = 0.0 |
1157 |
Dim dEnd_x As Double = 0.0 |
1158 |
Dim dEnd_y As Double = 0.0 |
1159 |
Dim sSystempath As String = oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString() |
1160 |
Dim sStartpoint As String = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString() |
1161 |
Dim sEndpoint As String = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString() |
1162 |
ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
1163 |
dStart_x = dOriginalStart_x |
1164 |
dStart_y = dOriginalStart_y |
1165 |
ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y) |
1166 |
If ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) Then |
1167 |
dEnd_x = dOriginalEnd_x |
1168 |
dEnd_y = dOriginalEnd_y |
1169 |
ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y) |
1170 |
If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then |
1171 |
objInputs.AddPoint(dStart_x, dStart_y) |
1172 |
objInputs.AddPoint(dEnd_x, dEnd_y) |
1173 |
objItem = _Placement.PIDCreateItem(sSystempath) |
1174 |
_iPipecnt = _iPipecnt + 1 |
1175 |
SetListBoxItems(ListBox_Result, "Draw PipeLine..(" & dOriginalStart_x & "," & dOriginalStart_y & ")..." & _iPipecnt & " count ") |
1176 |
objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
1177 |
oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID) |
1178 |
If oAttributeRow.Length > 0 Then |
1179 |
For Each oAttribute In oAttributeRow |
1180 |
Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
1181 |
Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
1182 |
Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
1183 |
oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue |
1184 |
Next |
1185 |
oPipeRun.Commit() |
1186 |
End If |
1187 |
End If |
1188 |
End If |
1189 |
|
1190 |
|
1191 |
End If |
1192 |
Return oPipeRun |
1193 |
Catch ex As Exception |
1194 |
Return Nothing |
1195 |
End Try |
1196 |
End Function |
1197 |
|
1198 |
Private Function DrawSymbol(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable) As Boolean |
1199 |
Try |
1200 |
|
1201 |
Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'") |
1202 |
Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
1203 |
If oSymbolRow.Length > 0 Then |
1204 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1205 |
Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString() |
1206 |
Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString() |
1207 |
Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString() |
1208 |
Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString() |
1209 |
Dim dAngle As Double = 0.0 |
1210 |
If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then |
1211 |
dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) |
1212 |
End If |
1213 |
|
1214 |
Dim objSymbol As LMSymbol |
1215 |
Dim dLocationX As Double = 0.0 |
1216 |
Dim dLocationY As Double = 0.0 |
1217 |
Dim dX As Double = 0.0 |
1218 |
Dim dY As Double = 0.0 |
1219 |
|
1220 |
If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
1221 |
dX = dLocationX |
1222 |
dY = dLocationY |
1223 |
ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1224 |
Dim oInstrument As LMInstrument |
1225 |
If sSymbolCompType = _SYMBOL_INSTUMENT Then |
1226 |
_iInstrumentcnt = _iInstrumentcnt + 1 |
1227 |
objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1228 |
SetListBoxItems(ListBox_Result, "Draw Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ") |
1229 |
oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID) |
1230 |
If oAttributeRow.Length > 0 Then |
1231 |
For Each oAttribute In oAttributeRow |
1232 |
Dim sPIDAttribute As String = oAttribute(0)(_XML_ATTRIBUTE_NAME).ToString() |
1233 |
Dim sPIDValue As String = oAttribute(0)(_XML_ATTRIBUTE_VALUE).ToString() |
1234 |
Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
1235 |
oInstrument.Attributes(0)(sSPPIDAttribute).Value = sPIDValue |
1236 |
Next |
1237 |
oInstrument.Commit() |
1238 |
End If |
1239 |
|
1240 |
ElseIf sSymbolCompType = _SYMBOL_VALVES Then |
1241 |
_iValvecnt = _iValvecnt + 1 |
1242 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1243 |
SetListBoxItems(ListBox_Result, "Draw Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ") |
1244 |
|
1245 |
ElseIf sSymbolCompType = _SYMBOL_FITTINGS Then |
1246 |
_iFittingcnt = _iFittingcnt + 1 |
1247 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1248 |
SetListBoxItems(ListBox_Result, "Draw Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1249 |
Else |
1250 |
_iFittingcnt = _iFittingcnt + 1 |
1251 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1252 |
SetListBoxItems(ListBox_Result, "Draw Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1253 |
|
1254 |
End If |
1255 |
|
1256 |
End If |
1257 |
|
1258 |
End If |
1259 |
|
1260 |
Catch ex As Exception |
1261 |
Return False |
1262 |
End Try |
1263 |
End Function |
1264 |
|
1265 |
Private Function DrawLineNo(ByVal oPiperun As LMPipeRun, ByVal CLine_No As Line_no) As Boolean |
1266 |
Try |
1267 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1268 |
Dim sLocation = CLine_No.Location |
1269 |
Dim dLocationx As Double = 0.0 |
1270 |
Dim dLocationy As Double = 0.0 |
1271 |
|
1272 |
Dim dX As Double = 0.0 |
1273 |
Dim dY As Double = 0.0 |
1274 |
If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then |
1275 |
dX = dLocationx |
1276 |
dY = dLocationy |
1277 |
ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1278 |
Dim dLineNoLocation(2) As Double |
1279 |
dLineNoLocation(1) = dX |
1280 |
dLineNoLocation(2) = dY |
1281 |
'Label |
1282 |
Dim sSystemPath As String = CLine_No.SystemPath |
1283 |
Dim dAngle As Double = CLine_No.Angle |
1284 |
Dim labelpersist As LMLabelPersist |
1285 |
|
1286 |
For Each representation In oPiperun.Representations |
1287 |
If representation.RepresentationType = "Connector" Then |
1288 |
labelpersist = _Placement.PIDPlaceLabel(sSystemPath, |
1289 |
dLineNoLocation,, dAngle, LabeledItem:=representation) |
1290 |
_iPipeLineNocnt = _iPipeLineNocnt + 1 |
1291 |
SetListBoxItems(ListBox_Result, "Draw PipeLineNo Label..(" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ") |
1292 |
End If |
1293 |
Next |
1294 |
Return True |
1295 |
Else |
1296 |
Return False |
1297 |
End If |
1298 |
|
1299 |
Catch ex As Exception |
1300 |
Return False |
1301 |
End Try |
1302 |
End Function |
1303 |
|
1304 |
|
1305 |
Private Sub InitItemCount() |
1306 |
_iPipeLineNocnt = 0 |
1307 |
_iPipecnt = 0 |
1308 |
_iFittingcnt = 0 |
1309 |
_iValvecnt = 0 |
1310 |
_iInstrumentcnt = 0 |
1311 |
_iEquipmentcnt = 0 |
1312 |
_iNozzlecnt = 0 |
1313 |
End Sub |
1314 |
|
1315 |
Private Function AutoModeling() As Boolean |
1316 |
Try |
1317 |
|
1318 |
SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
1319 |
Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1320 |
For Each oDrwing As TreeNode In Tree_Result.Nodes |
1321 |
For Each oDwgNode As TreeNode In oDrwing.Nodes |
1322 |
|
1323 |
Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
1324 |
Dim CDrawing As Drawing = GetDrawing(sDwgName) |
1325 |
If CDrawing IsNot Nothing Then |
1326 |
If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then |
1327 |
InitItemCount() |
1328 |
Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode) |
1329 |
Dim iLineNoCount As Integer = 0 ' GetCheckNodeCount(oLinenoNode) |
1330 |
SetListBoxItems(ListBox_Result, "Draw " & CDrawing.DwgName & "....") |
1331 |
|
1332 |
For Each oLinenoNode As TreeNode In oDwgNode.Nodes |
1333 |
|
1334 |
Dim sLineNoUid As String = oLinenoNode.Name |
1335 |
Dim CLineNo As Line_no = GetLineNo(CDrawing, sLineNoUid) |
1336 |
|
1337 |
If CLineNo IsNot Nothing Then |
1338 |
Dim oPipeRun As LMPipeRun |
1339 |
Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
1340 |
Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol |
1341 |
Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
1342 |
Dim oDrawLinenoLabel As Boolean = False |
1343 |
For Each oLineNode As TreeNode In oLinenoNode.Nodes |
1344 |
Dim sLineUid As String = oLineNode.Name |
1345 |
If oLineNode.Checked Then |
1346 |
Dim sUid As String = oLineNode.Name |
1347 |
oPipeRun = DrawLine(sUid, sLineNoUid, oLine_Dt, oAttribute_Dt) |
1348 |
If oDrawLinenoLabel = False Then |
1349 |
DrawLineNo(oPipeRun, CLineNo) |
1350 |
oDrawLinenoLabel = True |
1351 |
End If |
1352 |
|
1353 |
End If |
1354 |
Next |
1355 |
|
1356 |
For Each oSymbolNode As TreeNode In oLinenoNode.Nodes |
1357 |
If oSymbolNode.Checked Then |
1358 |
Dim sUid As String = oSymbolNode.Name |
1359 |
DrawSymbol(sUid, sLineNoUid, oSymbol_Dt, oAttribute_Dt) |
1360 |
End If |
1361 |
Next |
1362 |
End If |
1363 |
iLineNoCount = iLineNoCount + 1 |
1364 |
' Dim dCalcProgressValue As Double = (iLineNoCount / iLineNoCount) * 100 |
1365 |
'SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
1366 |
Next |
1367 |
|
1368 |
End If |
1369 |
End If |
1370 |
|
1371 |
Next |
1372 |
|
1373 |
|
1374 |
|
1375 |
Next |
1376 |
SetProgressbar(ProgressBar_Status, 100) |
1377 |
SetListBoxItems(ListBox_Result, " Auto converting 완료") |
1378 |
Return True |
1379 |
Catch ex As Exception |
1380 |
Return False |
1381 |
End Try |
1382 |
End Function |
1383 |
|
1384 |
|
1385 |
|
1386 |
Private Sub ThreadTask() |
1387 |
|
1388 |
If _DrawingsList.Count > 0 Then |
1389 |
AutoModeling() |
1390 |
End If |
1391 |
End Sub |
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String |
1397 |
Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'") |
1398 |
Dim oPath As String = "" |
1399 |
If oRows.Length > 0 Then |
1400 |
oPath = oRows(0).Item("Path").ToString() |
1401 |
End If |
1402 |
Return oPath |
1403 |
End Function |
1404 |
|
1405 |
Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click |
1406 |
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then |
1407 |
LoadXmlItem(FolderBrowserDialog1.SelectedPath) |
1408 |
End If |
1409 |
End Sub |
1410 |
Private Sub LoadXmlItem(ByVal sFolderPath As String) |
1411 |
_DrawingsList = New List(Of Drawing) |
1412 |
Dim sfileEntries As String() = Directory.GetFiles(sFolderPath) |
1413 |
If Tree_Result.Nodes.Count > 0 Then |
1414 |
Tree_Result.Nodes(0).Nodes.Clear() |
1415 |
For Each sfileName In sfileEntries |
1416 |
Dim sExtension As String = Path.GetExtension(sfileName) |
1417 |
If sExtension = ".xml" Then |
1418 |
Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName) |
1419 |
Dim sDwgPath As String = sfileName |
1420 |
Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15) |
1421 |
Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode) |
1422 |
_DrawingsList.Add(oDwg) |
1423 |
End If |
1424 |
Next |
1425 |
Tree_Result.Nodes(0).Expand() |
1426 |
End If |
1427 |
End Sub |
1428 |
|
1429 |
|
1430 |
''' <summary> |
1431 |
''' XML Tree 구조 생성 |
1432 |
''' </summary> |
1433 |
''' <param name="sDwgPath"></param> |
1434 |
Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing |
1435 |
Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath) |
1436 |
|
1437 |
Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos |
1438 |
'PipeLine 구분 |
1439 |
|
1440 |
For Each oLinelist In oLineLists |
1441 |
Dim sLineNoUid As String = oLinelist.Uid |
1442 |
Dim sLineNo As String = oLinelist.Text |
1443 |
Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo) |
1444 |
For Each oLineRow In oLinelist.Dt_Line.Rows |
1445 |
Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
1446 |
Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe") |
1447 |
oPipeNode.Tag = sLineNoUid |
1448 |
Next |
1449 |
|
1450 |
For Each oSymbolRow In oLinelist.Dt_Symbol.Rows |
1451 |
Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
1452 |
Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
1453 |
Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName) |
1454 |
oSymbolNode.Tag = sLineNoUid |
1455 |
Next |
1456 |
Next |
1457 |
|
1458 |
Return oDwg_Ds |
1459 |
End Function |
1460 |
Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck |
1461 |
If e.Node.Checked = True Then |
1462 |
For Each oNode As TreeNode In e.Node.Nodes |
1463 |
oNode.Checked = True |
1464 |
Next |
1465 |
Else |
1466 |
For Each oNode As TreeNode In e.Node.Nodes |
1467 |
oNode.Checked = False |
1468 |
Next |
1469 |
End If |
1470 |
End Sub |
1471 |
|
1472 |
End Class |
1473 |
|
1474 |
|
1475 |
Public Class DrawingInfo |
1476 |
Public mDrawingName As String |
1477 |
Public mSpID As String |
1478 |
Public mPath As String |
1479 |
End Class |
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|