4 Replies Latest reply on Oct 20, 2017 1:09 AM by Eugene Lee

    PIWebApi Get Event Frames by Element Heirarchy Root Element

    I.Berry

      Is there a recommeded PIWebAPI pattern to query all the event frames based on a root AF Element?

       

      I see there are two possible approaches

       

      1) Get all the elements for a given root element, then use a batch query to get all the event frames for each element.

       

      2) Get all the events, then filter the returned set based on RefElementWebIds

       

      I am currently using option (2) in a web based application, but considering a move to (1), since getting all the open events is slower as the system grows. Both of these methods seem like a lot of work, is there another way to do this? I believe in the AFSDK we would need to do something like (1) as well, so perhaps there is not.

       

      Thanks!

       

      .

        • Re: PIWebApi Get Event Frames by Element Heirarchy Root Element
          Dan Fishman

          I probably would go with option 1.  It seems with option 2, you don't know how many Event Frames you might be getting back so it could be a lot of extra overhead.  The batch queries are really efficient and I think they are done in paralleled by the Web API.  Unfortunately, it does seems like a lot of work.

          1 of 1 people found this helpful
          • Re: PIWebApi Get Event Frames by Element Heirarchy Root Element
            Eugene Lee

            Option 1 example:

             

            {          "2": {
                        "Method": "Get",
                        "RequestTemplate": {
                        "Resource": "$.1.Content.Items[*].Links.EventFrames"},
                        "ParentIds": [
                          "1"
                        ]
                      },
                      "1": {
                        "Method": "GET",
                        "Resource": "https://webserver/piwebapi/elements/{0}/elements?searchFullHierarchy=true&selectedFields=Items.Links.EventFrames",
                         "ParentIds": [
                          "0"
                        ],
                        "Parameters": ["$.0.Content.WebId"]
                      },
                      
                      "0": {
                        "Method": "GET",
                        "Resource": "https://webserver/piwebapi/elements?path=\\\\eugene\\test\\root&selectedFields=WebId"
                      }
            }