private int ReviewStatus_AFEventFrameSearch_GetTotalCount(object value, string elementName = null) { var templateName = "EFTCMBaseEvent"; var attributeName = "ReviewStatus"; AFStopwatch stopwatch = new AFStopwatch(); string elementNameFilter = elementName != null ? "ElementName:" + elementName + " " : string.Empty; var afEventFrameSearch = new AFEventFrameSearch(_afDatabase, "MyQuery" + value, elementNameFilter + "Template:" + templateName + " |" + attributeName + ":=" + value /* + " SortField:ID"*/); var count = afEventFrameSearch.GetTotalCount(); //Console.WriteLine("Done : " + count + ", " + stopwatch.ElapsedMilliseconds + "ms"); return(stopwatch.ElapsedMilliseconds); //_log.Info($"time:{stopwatch.Elapsed.TotalSeconds}, Template:{templateName}, {attributeName}: {value}, Element:{elementName}, count:{count}"); }
public void EventFrameSearchTest() { AFDatabase db = Fixture.AFDatabase; string baseEFNameText = $"OSIsoftTests_AF_EFSrchTst - {DateTime.UtcNow.ToString(AFFixture.DateTimeFormat, CultureInfo.InvariantCulture)}_"; string ef1Name = $"{baseEFNameText}EF1"; string ef2Name = $"{baseEFNameText}EF2"; string ef3Name = $"{baseEFNameText}LastEF"; string eventFrameSearchTxt = $"'{baseEFNameText}EF*'"; try { Output.WriteLine($"Create Event Frames for search."); _ = new AFEventFrame(db, ef1Name); _ = new AFEventFrame(db, ef2Name); _ = new AFEventFrame(db, ef3Name); db.CheckIn(); Output.WriteLine($"Execute search for Event Frames using search string [{eventFrameSearchTxt}]."); db = Fixture.ReconnectToDB(); // This operation clears AFSDK cache and assures retrieval from AF server using (var searchResults = new AFEventFrameSearch(db, string.Empty, eventFrameSearchTxt)) { int actualEventsFramesFound = searchResults.GetTotalCount(); const int ExpectedEventFrames = 2; Assert.True(actualEventsFramesFound == ExpectedEventFrames, $"Search string [{eventFrameSearchTxt}] found " + $"{actualEventsFramesFound} Event Frames, expected {ExpectedEventFrames}."); int actualEventFramesFoundWithSearch = 0; foreach (AFEventFrame at in searchResults.FindObjects()) { actualEventFramesFoundWithSearch++; } Assert.True(actualEventFramesFoundWithSearch == ExpectedEventFrames, $"Only able to find {actualEventFramesFoundWithSearch} Elements returned using Search string " + $"[{eventFrameSearchTxt}], expected {ExpectedEventFrames}."); } } finally { Fixture.RemoveEventFrameIfExists(ef1Name, Output); Fixture.RemoveEventFrameIfExists(ef2Name, Output); Fixture.RemoveEventFrameIfExists(ef3Name, Output); } }