Currently, I am developing a VB .net script to retrieve the batch data via PI SDK PIBatchSearch function and display the result on the web. unfortunately, the result always return nothing. The code as follow:
VB Script 1
Dim PIServer As PISDK.Server
Dim pp As New PISDK.PISDK
Dim BatchDB As PISDK.PIBatchDB
Dim BatchList As PISDK.PIBatchList
Dim Batch As PISDK.PIBatch
Dim UnitBatchList As PISDK.PIUnitBatches
PIServer = pp.Servers.DefaultServer ' PI Server name = PIServer
BatchDB = PIServer.PIBatchDB
'get all batches within last two days
BatchList = BatchDB.PIBatchSearch("*-10000d", "*", "*", "*", "*")
For Each Batch In BatchList
UnitBatchList = Batch.PIUnitBatches
Note: Batch always return nothing
However, the batch result is retrievable if I import "PI BatchView OLE Control Module" as reference and develop the script based on "PI BatchView OLE Control Module". The code as follow:
VB Script 2
Public Class Form1
Public PIServer As PISDK.Server
Public PP As New PISDK.PISDK
Public BatchView As New PIBatchView
' Public Cxn As New PISDKDlg.Connections
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
.QueryKind = pibvQueryKind.pibvBatch
.Server = "PIServer"
.UnitCond = pibvTestCond.pibvLike
.ProdTest = "*"
.IDCond = pibvTestCond.pibvLike
.IDTest = "*"
.TimeFrom = "*-10000d"
.TimeTo = "*"
.Direction = pibvSearchDirection.pibvAll
.MustSelect = True
Note: The result will display in the "PI Batchview Search result" dialog box. However, I cannot use this approach because I need to display the Batch search result on the web.
- What is the difference between the 2 approaches above? Are they searching the same batch database?
- Is that any problem in the VB script 1? Is that any setting need to apply in order to allow VB script 1 to retrieve the PI Batch data from PI Server.