AFDatabase.FindChangedItems Method (Boolean, AFTime, AFTime)
- Last UpdatedJan 12, 2026
- 5 minute read
- PI System
- AF SDK 3.2.0
- Developer
Note: This API is now obsolete.
Find all the items that have changed in the AFDatabase.
Namespace: OSIsoft.AF
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7
Syntax
[BrowsableAttribute(false)] [ObsoleteAttribute("This method has been replaced with FindChangedItems(bool,int,object,out object).")] public IList<AFChangeInfo> FindChangedItems( bool searchSandbox, AFTime sinceTime, out AFTime lastUpdateTime )
<BrowsableAttribute(false)> <ObsoleteAttribute("This method has been replaced with FindChangedItems(bool,int,object,out object).")> Public Function FindChangedItems ( searchSandbox As Boolean, sinceTime As AFTime, <OutAttribute> ByRef lastUpdateTime As AFTime ) As IList(Of AFChangeInfo) Dim instance As AFDatabase Dim searchSandbox As Boolean Dim sinceTime As AFTime Dim lastUpdateTime As AFTime Dim returnValue As IList(Of AFChangeInfo) returnValue = instance.FindChangedItems(searchSandbox, sinceTime, lastUpdateTime)
public: [BrowsableAttribute(false)] [ObsoleteAttribute(L"This method has been replaced with FindChangedItems(bool,int,object,out object).")] IList<AFChangeInfo>^ FindChangedItems( bool searchSandbox, AFTime sinceTime, [OutAttribute] AFTime% lastUpdateTime )
[<BrowsableAttribute(false)>] [<ObsoleteAttribute("This method has been replaced with FindChangedItems(bool,int,object,out object).")>] member FindChangedItems : searchSandbox : bool * sinceTime : AFTime * lastUpdateTime : AFTime byref -> IList<AFChangeInfo>
Parameters
- searchSandbox
- Type: SystemBoolean
If , then items saved to the sandbox but not checked into the server are also searched. Setting this value to is a slower operation, therefore set this parameter to unless you need changed items from the sandbox to be checked. - sinceTime
- Type: OSIsoft.AF.TimeAFTime
Check for changes since this specified time. Use the lastUpdateTime returned in a previous call to this method. For the first call, use code similar to this: AFTime.Now.UtcTime.AddMinutes(-5); as the value for this parameter. If there are a large number of changes since the specified time, then all changes may not be returned and multiple calls may be necessary to retrieve all changes. This is indicated when the number of items returned is greater than or equal to 1000. - lastUpdateTime
- Type: OSIsoft.AF.TimeAFTime
The time returned from the server. This can be used in the next call to this method as the sinceTime parameter to get all changes since the last call.
Return Value
Type: IListAFChangeInfoReturns a list of AFChangeInfo structures which represent the items that have changed in the server.
Remarks
This method can be used to determine what objects have changed on the server since
a specified time. Changes to the sandbox using ApplyChanges
are not included unless searchSandbox is set to .
The AFChangeInfoFindObject or Refresh(PISystem, IEnumerableAFChangeInfo)
methods can be used to find the actual object represented by the returned AFChangeInfo structure.
| When using to continuously monitor for all changes to a database, the method FindChangedItems(Boolean, Int32, Object, Object) is preferable as it eliminates the possibility of missing changes which occur simultaneously with the call. |
Examples
// This example demonstrates getting changes made by other users // and refreshing the objects. // Get the System and System Cookie PISystem myPISystem = new PISystems().DefaultPISystem; object sysCookie = myPISystem.GetFindChangedItemsCookie(searchSandbox: false); // Wait for changes to be made... //======================================================= // Find changes made by other users. List<AFChangeInfo> list = new List<AFChangeInfo>(); int resultsPerPage = 1000; while (true) { var results = myPISystem.FindChangedItems(false, true, resultsPerPage, sysCookie, out sysCookie); if ((results?.Count ?? 0) == 0) break; list.AddRange(results); } // Refresh objects that have been changed. AFChangeInfo.Refresh(myPISystem, list); // Find the objects that have been changed. foreach (AFChangeInfo info in list) { AFObject myObj = info.FindObject(myPISystem, false); Console.WriteLine("Found changed object: {0}", myObj); }
// This example demonstrates persisting and restoring the cookie // using the XmlSerializer. Other serializers could also be used. // Then the cookie is restored and used to get changes made while // the application was shut down. // Get the System and Database and their Cookie Values PISystem myPISystem = new PISystems().DefaultPISystem; AFDatabase myDB = myPISystem.Databases.DefaultDatabase; object sysCookie = myPISystem.GetFindChangedItemsCookie(searchSandbox: false); object dbCookie; myDB.FindChangedItems(false, int.MaxValue, null, out dbCookie); // Persist the cookie if you want to save to pick up changes // where you left off after restarting application. string tmpDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string sysCookieFile = Path.Combine(tmpDir, "AFSysCookie.xml"); string dbCookieFile = Path.Combine(tmpDir, "AFDbCookie.xml"); XmlSerializer serializer = new XmlSerializer(typeof(object[])); using (var stream = File.Create(sysCookieFile)) { serializer.Serialize(stream, sysCookie); } using (var stream = File.Create(dbCookieFile)) { serializer.Serialize(stream, dbCookie); } // Shut down application, and wait for changes to be made... //======================================================= // After application restarts, reload persisted cookies. using (var stream = File.OpenRead(sysCookieFile)) { sysCookie = serializer.Deserialize(stream); } using (var stream = File.OpenRead(dbCookieFile)) { dbCookie = serializer.Deserialize(stream); } // Find changes made while application not running. List<AFChangeInfo> list = new List<AFChangeInfo>(); int resultsPerPage = 1000; while (true) { var results = myPISystem.FindChangedItems(false, resultsPerPage, sysCookie, out sysCookie); if ((results?.Count ?? 0) == 0) break; list.AddRange(results); } while (true) { var results = myDB.FindChangedItems(false, resultsPerPage, dbCookie, out dbCookie); if ((results?.Count ?? 0) == 0) break; list.AddRange(results); } // Find the objects that have been changed. foreach (AFChangeInfo info in list) { AFObject myObj = info.FindObject(myPISystem, false); Console.WriteLine("Found changed object: {0}", myObj); }
Version Information
AFSDK
Obsolete (compiler warning) in 3.1.1Obsolete (compiler warning) in 3.1.0
Obsolete (compiler warning) in 3.0.2
Obsolete (compiler warning) in 3.0.1
Obsolete (compiler warning) in 3.0.0
Obsolete (compiler warning) in 2.10.11
Obsolete (compiler warning) in 2.10.5
Obsolete (compiler warning) in 2.10.0
Obsolete (compiler warning) in 2.10
Obsolete (compiler warning) in 2.9.5
Obsolete (compiler warning) in 2.9
Obsolete (compiler warning) in 2.8.5
Obsolete (compiler warning) in 2.8
Obsolete (compiler warning) in 2.7.5
Obsolete (compiler warning) in 2.7
Obsolete (compiler warning) in 2.6
Obsolete (compiler warning) in 2.5
Obsolete (compiler warning) in 2.4