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