web API example calling Transposed Tag data by AF Template
Often we query by a template name to get a transposed list of attribute values between a nominated date range. The hacked OLEDB SQL code is below.
Ideally, I'd like to be able to run this as a WEB API Call. Can you provide a WEB API Example of calling transposed data by Template between a nominated date range and then filtering the records that do not meet criteria? In this example, they're not null.
SELECT eh.Path + eh.Name as Element, ta.[time] as dt, ta.[Tag 1 Name] as Tag1, [Tag 2 Name]as Tag2
FROM '@AFDatabase'.[Asset].[ElementTemplate] et
INNER JOIN '@AFDatabase'.[Asset].[Element] e
ON et.ID = e.ElementTemplateID
INNER JOIN '@AFDatabase'.[Asset].[ElementHierarchy] eh
ON e.ID = eh.ElementID
CROSS APPLY '@AFDatabase'.DataT.[TransposeArchive_Bay]
( eh.ElementID,
DATE(N'@StartTime'), /StartTime/
DATE(N'') /EndTime*/
) ta
WHERE et.Name = N'@TemplateName'
AND eh.Path + eh.Name = '@ElementName'
AND ta.[Tag 1 Name] IS NOT NULL
AND [Tag 2 Name] IS NOT NULL
OPTION (FORCE ORDER, IGNORE ERRORS, EMBED ERRORS)
