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