1 Reply Latest reply on May 31, 2010 2:50 PM by hanyong

    Remove Archived events using C#

    Aantje

      Hi there,

       

      This is my first post on the vCampus, and mayby it is a silly question...

       

      Is there anybody who has experience with removing archived events using the RemoveValues class?

       

      I'm a a little stuck, so some example code (C#) would be very usefull to me.

       

       

       

      Greetz, Arie

        • Re: Remove Archived events using C#
          hanyong

          Hi Arie,

           

          Here's a code snippets in C#. The RemoveValues method basically removes archive values in the specified time range, for the last 2 hours below.

           

          I think the only thing that you might want to take note of the the Data removal behaviour, there are 2 types of behaviour, "Remove All" and "Remove First only". "Remove All" deletes all value, whereas "Remove First only" remove the first value at the same time (when there is duplicate value).

          PIPoint CDT158 = _Server.PIPoints["CDT158"];
          PITime start = new PITime();
          PITime end = new PITime();
          end.SetToCurrent();
          start.LocalDate = end.LocalDate.AddHours(-2);

          CDT158.Data.RemoveValues(start, end, DataRemovalConstants.drRemoveAll, null);