I am trying to synchronize source and destination PI-AF servers using AF-SDK v2.10.1 (from 2018).
I do this by first exporting the source server's Database and importing it to the destination server using the new AF-SDK import mode : PIImportMode.PreserveUniqueIDs.
After that I import changes made to the source and import them as xml files to the destination server.
When I import an updated xml of AFEventFrame object to the destination server, and that EventFrame has "Categories" (Element categories) added to it for the first time through the source PSE, the import succeeds, but when trying to refresh the PI System Explorer or export the EventFrames from the PSE, I am encountering the following error received from the PI-AF server:
Error occurred near 'AFElementCategoryRef' while processing Event Frame 'e': Unexpected Server Error: 'Data is Null. This method or property cannot be called on Null values.'.
Use Event Viewer to see the PI AF Server log file for more information.
When looking at the Event viewer, the PI AF server log file displays the message:
Function OSIsoft.AF.Service.dcEventFrame GetEventFrame(Int32, OSIsoft.AF.Service.dcObjectIdentity, Boolean, System.String, OSIsoft.AF.Service.dcObjectIdentity ByRef, OSIsoft.AF.Service.dcServerError ByRef) at line: 0 in file
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
at System.Data.SqlClient.SqlDataReader.GetGuid(Int32 i)
at OSIsoft.AF.Service.AFService.GetEventFrameSQL(SqlConnection objConnection, SqlTransaction objTransaction, CallContext callContext, dcObjectIdentity objectID, Boolean checkOut, Boolean checkIn)
at OSIsoft.AF.Service.AFService.GetEventFrame(Int32 clientVersion, dcObjectIdentity objectID, Boolean checkOut, String machineName, dcObjectIdentity& checkedOutObjects, dcServerError& err)
After that first import, further import attempts for the EventFrame object results in the same error and the import fails. And not only import fails but also when just trying to search that EventFrame on the destination server using the method: AFEventFrame.FindEventFrame(myPISystem, Guid) results in error:
"Unexpected Server Error: 'Data is Null. This method or property cannot be called on Null values."
A very odd behavior occurs when I close the PSE and reopen it to see the state of that EvetFrame:
The PSE displays on the EventFrame the added category in the EventFrame "General" tab, but then when trying to refresh it the error displayed again.
and when clicking on other EventFrame on the PSE and then clicking back to the EventFrame where the categorie was added, that category disappears from view and the error remains.
To clarify: When exporting the source and destination EventFrames object and matching GUIDs of objects, I see that the GUIDs are identical (as I expected by using the PIImportMode.PreserveUniqueIDs flag).
I do not understand what may cause these errors on the destination server and that odd behavior on the PSE I will be grateful for any advice.