|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 4 Location: Kingsport, TN USA
|
I'll try not to be too long-winded here. My company has corporate application developers, but my department also has its own development group for specialized reporting and applications. The corporate developers create all of their applications to use the default PI server which makes it very simple to switch between production and testing environments without modifying the code. I have done this myself as well. It makes sense. The applications/processbooks in use in our department are a mixed bag of API and SDK.
I have inherited a VB6-based menu system that, among other things, takes care of setting up PI connections in both SDK and API. For the API setting, it calls piut_setdefaultservernode. This does work, however, it makes a background connection to the PI server without using any login credentials. I think this is referred to as default user access or something like that. From what I've been told, the default user access is disabled in the newest revision of PI Server and my application will fail.
Bottom line is, my application doesn't actually read or write any PI data. It only needs to setup the server connections and be able to switch default among those servers. The program was creating them with API and SDK calls. In working on the security issue, I have discovered that I only need to create the connections using SDK and they will also show up in the API connections list. Unfortunately, the default server in the API list does not change when I change the default server using SDK.
Does anyone have an opinion on the best way to mange this? Is there a way to set the default PI server using SDK that will affect both sets of connections? Thanks.
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Hello, So both your code for PISDK and PIAPI are only used to set up a client machines conenction to relevant PI servers, then you have another application (& reports) that deals with connecting on the default server? Do your applications/reports use PIAPI methods for data retrieval? The default server for PIAPI is stored in the "...\PIPC\dat\pilogin.ini" file in the "[defaults]" section's "PIServer" key/value pair. You could just change the value of the setting in the ini file directly. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 4 Location: Kingsport, TN USA
|
That is correct. We only seek to set the default server for the logged on user without actually making a connection, and the other VB applications, Excel spreadsheets, and Access Databases make their own connections to PI. Everything new that we write uses SDK, and we are slowly migrating old stuff from API to SDK. We are about 65/35 SDK/API. Of course calling piut_setdefaultservernode makes the non-secure background connection to one of our servers. I can programmatically edit the default server in the ini file, but we are predominantly on Vista/Win7. I think users without admin privs would end up having a modified pilogin.ini in the "Virtual Store" under their user folder. I'm not sure how the apps using API calls handle that. It's probably worth testing.
Is pilogin.ini always expected to be in "c:\Program Files\PIPC\dat\", or is there an order of places it is searched for? (i.e. 1st Documents, 2nd Windows\System32, 3rd PIPC\Dat, etc).
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
The PIPC directory is known as "PIHOME" and can be anywhere you set it to during install. There is an ini file installed in the windows directory called "PIPC.INI" that sets the PIHOME directory. When the software is distributed to your client machines, the distribution mechanism should have unlocked the file to allow PIAPI to be able to update it. Let us know how you get on. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 4 Location: Kingsport, TN USA
|
Here is where we ended up. We removed all PI-API calls from the code other than what is needed to log on. If the user doesn't have a connection to the desired server, we add it using SDK. To set the default server, we first set it using SDK: Code: 'Set default server using SDK Set Servers.DefaultServer = Servers(strSrvrName)
Then we set it for API using a direct write to pilogin.ini as you suggested. Code: 'set default server for API using a direct write to pilogin.ini If SetDefPISrvr_INI(strSrvrName) = False Then MsgBox "Error setting " & strSrvrName & " as default PI server for API. Blah...Blah...Blah...", vbCritical, "SetDefPISrvr" End If 'Login to the server using API just to make sure the pilogin.ini file is populated with servers added via SDK 'Register application with PI DLL file lngDefServer = pilg_registerapp("piapi32.dll") 'Make a connection to the desired server via api lngDefServer = pilg_login(lnghWnd, PIUser, strSrvrName, PIPassword, lgPnt)
The function SetDefPISrvr_INI is in a code module that uses the Windows API calls GetPrivateProfileSection, GetPrivateProfileString, and WritePrivateProfileString to read/write to pilogin.ini. Making the connection via API causes the API to read the SDK servers list and add any that are not included in pilogin.ini. So far this works great. There have been a handful of folks who had to delete all server connections and let this program add them back. Other than that, it has been golden. It even works on Win7, so that's a bonus. Thank you for the guidance!!!
|
|
|
|
Guest
|