//private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public static AFEventFrameCriteria queryToCriteria(OSIsoft.AF.Search.AFEventFrameSearch query) { AFEventFrameCriteria criteria = new AFEventFrameCriteria(); IList <OSIsoft.AF.Search.AFSearchToken> starttimes; query.TryFindSearchTokens(OSIsoft.AF.Search.AFSearchFilter.Start, out starttimes); if (starttimes.Count == 2) { criteria.SearchMode = AFSearchMode.StartInclusive; AFTime start = new AFTime(starttimes[0].Value); AFTime end = new AFTime(starttimes[1].Value); if (start < end) { criteria.StartTime = starttimes[0].Value; criteria.EndTime = starttimes[1].Value; } else { criteria.StartTime = starttimes[1].Value; criteria.EndTime = starttimes[0].Value; } } else if (starttimes.Count == 1) { criteria.StartTime = starttimes[0].Value; } OSIsoft.AF.Search.AFSearchToken endtime = new OSIsoft.AF.Search.AFSearchToken(); query.TryFindSearchToken(OSIsoft.AF.Search.AFSearchFilter.End, out endtime); if (endtime.Value != null) { criteria.EndTime = endtime.Value; } query.Tokens.Remove(endtime); OSIsoft.AF.Search.AFSearchToken inprogress = new OSIsoft.AF.Search.AFSearchToken(); query.TryFindSearchToken(OSIsoft.AF.Search.AFSearchFilter.InProgress, out inprogress); if (inprogress.Value != null) { criteria.InProgress = inprogress.Value == "True" ? true : false; } query.Tokens.Remove(inprogress); /* * // * // Summary: * // This is the value of an uninitialized search mode. * None = 0, * // * // Summary: * // Includes all objects whose start time is within the specified range. Also known * // as "Starting Between". * StartInclusive = 1, * // * // Summary: * // Includes all objects whose end time is within the specified range. Also known * // as "Ending Between". * EndInclusive = 2, * // * // Summary: * // Includes all objects whose start and end time are within the specified range. * // Also know as "Entirely Between". * Inclusive = 3, * // * // Summary: * // Includes all objects whose time range overlaps with the specified range at any * // point in time. Also known as "Active Between". * Overlapped = 4, * // * // Summary: * // Includes all objects whose start time is within the specified range and end time * // is OSIsoft.AF.Time.AFTime.MaxValue. Also known as "Starting Between and In Progress". * InProgress = 5 */ criteria.LastFullSearchString = query.ToString(); return(criteria); }