5 Replies Latest reply on Mar 7, 2017 3:22 PM by Hans_Drost

    Getting previous value of AF Attribute at AFDataPipeEvent OnNext

    Hans_Drost

      Hi all,

       

      Currently I am working on a service that has to trigger on the change of an attribute value. To be able to do this I use the IObserver(AFDataPipeEvent).

      Everything works fine, except that whenever it triggers, I retrieve the values from AF (I need all other child attributes at the same level, so I get its parent attribute) and the triggered attribute is back to its old value.

      Is there any way to get the new value? Below is my code, where GBpObject is an object with an attribute and some other variables in it and the OSISoftDataManager is the part of the code that "handels" the data and writes stuff back.

       

      public class AFPipeReceiver : IObserver<AFDataPipeEvent>
              {
                  List<GBpObject> _GBpObjectList;
                  PIServer _PIServer;
                  public AFPipeReceiver(List<GBpObject> GBpObjectList, PIServer PIServer)
                  {
                      _GBpObjectList = GBpObjectList;
                      _PIServer = PIServer;
                 }
                  public void OnCompleted()
                  {
                  }
                  public void OnError(Exception error)
                  {
                  }
                  public void OnNext(AFDataPipeEvent value)
                  {
                      if (value.Action == AFDataPipeAction.Add || value.Action == AFDataPipeAction.Update)
                      {
                          OSISoftDataManager.UpdateGBpPoints(_GBpObjectList.First(x => x.Attribute.Equals(value.Value.Attribute.Parent)), _PIServer);
                      }
                  }
              }
      
      
      
      
      

       

      Kind regards,

       

      Hans Drost