Пример #1
0
        internal static string stripTokens(OSIsoft.AF.Search.AFEventFrameSearch query)
        {
            List <AFSearchToken> tokens = query.Tokens.ToList();

            tokens.RemoveAll(t => t.Filter == AFSearchFilter.InProgress || t.Filter == AFSearchFilter.Start || t.Filter == AFSearchFilter.End || t.Filter == AFSearchFilter.Value);
            OSIsoft.AF.Search.AFEventFrameSearch timeless = new OSIsoft.AF.Search.AFEventFrameSearch(query.Database, "TimeLess", tokens);
            return(timeless.ToString());
        }
 private void eventFrameSearchPage_SearchCompleted(object sender, EventArgs e)
 {
     //AFEventFrameCriteria criteria = eventFrameSearchPage.EventFrameCriteria;
     //OSIsoft.AF.Search.AFEventFrameSearch createdQUery = LimitCalculatorSDK.EFutilities.criteriaToQuery(criteria);
     // Convert the criteria to a AFSDK criteria here
     if (eventFrameSearchPage.EventFrameCriteria.LastFullSearchString.Contains("Root:"))
     {
     }
     OSIsoft.AF.Search.AFEventFrameSearch criteria = searchToCriteria(eventFrameSearchPage);
     main.Controls["queryTextBox"].Text = criteria.ToString();
 }
Пример #3
0
        private void displaySearch_Click(object sender, EventArgs e)
        {
            h      = new EventFrameSearch(this, db);
            search = (OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage)h.Controls["eventFrameSearchPage"];
            //search.EventFrameCriteria.RestoreCriteria(calculationName.Text);
            //search.EventFrameCriteria.LastFullSearchString = queryTextBox.Text;*/
            search.CriteriaInitiallyOpened = true;
            OSIsoft.AF.Search.AFEventFrameSearch query = new OSIsoft.AF.Search.AFEventFrameSearch(db, "search", queryTextBox.Text);
            //OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage search = (OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage)h.Controls["eventFrameSearchPage"];
            AFEventFrameCriteria criteria = queryToCriteria(query);

            search.EventFrameCriteria = criteria;
            //refreshSearchWindow();
            // TODO, try and find the control that shows or doesn't show a certain value filter
            h.Show();
        }
        private static OSIsoft.AF.Search.AFEventFrameSearch searchToCriteria(OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage page)
        {
            //page.EventFrameCriteria.SearchMode;

            AFDatabase db            = page.Database;
            string     start         = page.EventFrameCriteria.StartTime;
            string     end           = page.EventFrameCriteria.EndTime;
            string     AFstart       = page.EventFrameCriteria.AFStartTimeString;
            bool       inProgress    = page.EventFrameCriteria.InProgress;
            string     LastFullSeach = page.EventFrameCriteria.LastFullSearchString;

            LastFullSeach = LastFullSeach.Replace(@"\", "").Replace("\'", "'");
            OSIsoft.AF.Search.AFEventFrameSearch timelessTerms = new OSIsoft.AF.Search.AFEventFrameSearch(db, "notime", LastFullSeach);
            List <AFSearchToken> tokens = timelessTerms.Tokens.ToList();

            switch (page.EventFrameCriteria.SearchType)
            {
            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.ActiveBetween:
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.LessThanOrEqual, end));
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.GreaterThanOrEqual, start));
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingAfter:
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.GreaterThanOrEqual, AFstart));
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingBefore:
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.LessThanOrEqual, AFstart));
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingBetween:
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.GreaterThanOrEqual, start));
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.LessThanOrEqual, end));
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EntirelyBetween:
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.GreaterThanOrEqual, start));
                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.LessThanOrEqual, end));
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingAfter:
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.GreaterThanOrEqual, AFstart));
                if (inProgress)
                {
                    tokens.Add(new AFSearchToken(AFSearchFilter.InProgress, AFSearchOperator.Equal, "true"));
                }
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingBefore:
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.LessThanOrEqual, AFstart));
                if (inProgress)
                {
                    tokens.Add(new AFSearchToken(AFSearchFilter.InProgress, AFSearchOperator.Equal, "true"));
                }
                break;

            case OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingBetween:
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.GreaterThanOrEqual, start));
                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.LessThanOrEqual, end));
                if (inProgress)
                {
                    tokens.Add(new AFSearchToken(AFSearchFilter.InProgress, AFSearchOperator.Equal, "true"));
                }
                break;
            }

            OSIsoft.AF.Search.AFEventFrameSearch criteria = new OSIsoft.AF.Search.AFEventFrameSearch(db, "search", tokens);

            AFNamedCollection <AFEventFrame> UIFrames = page.EventFrames;

            IEnumerable <AFEventFrame> AFSDKframes = criteria.FindEventFrames();

            try
            {
                int count = AFSDKframes.Count() > 1000 ? 1000 : AFSDKframes.Count();
                if (UIFrames.Count != count)
                {
                    MessageBox.Show("They UI and AFKSDK frames report different variables", "Count error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.FormatException e)
            {
                // Bad event frame search formatting for AFSDK UI.
                MessageBox.Show(e.Message);
            }
            return(criteria);
        }
        public static void compareEventFrame(OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage uisearch, OSIsoft.AF.Search.AFEventFrameSearch afsdksearch)
        {
            string path = @"C:\Users\jlefebvre\Desktop\differences\";
            //AFNamedCollectionList<AFEventFrame> uiEF_raw = uisearch.EventFrames;
            List <AFEventFrame> asfkEF        = afsdksearch.FindEventFrames().ToList <AFEventFrame>();
            List <AFEventFrame> uiEF          = uisearch.EventFrames.ToList <AFEventFrame>();//new List<AFEventFrame>();
            List <AFEventFrame> uiExceptafsdk = uiEF.Except(asfkEF).ToList();
            List <AFEventFrame> afsdkExceptui = asfkEF.Except(uiEF).ToList();

            if (uiExceptafsdk.Count != 0)
            {
                List <string> ef_names = uiExceptafsdk.Select(ef => "U " + ef.Name).ToList();
                File.WriteAllLines(path + "InUInotAFSDK.txt", ef_names);
            }
            if (afsdkExceptui.Count != 0)
            {
                List <string> ef_names = afsdkExceptui.Select(ef => "A " + ef.Name).ToList();
                File.WriteAllLines(path + "InASDKnotUI.txt", ef_names);
            }
        }
Пример #6
0
        static AFEventFrameCriteria queryToCriteria(OSIsoft.AF.Search.AFEventFrameSearch query)
        {
            AFEventFrameCriteria criteria = new AFEventFrameCriteria();

            criteria.Database = query.Database;
            IList <AFSearchToken> starts;

            query.TryFindSearchTokens(OSIsoft.AF.Search.AFSearchFilter.Start, out starts);
            IList <AFSearchToken> ends;

            query.TryFindSearchTokens(OSIsoft.AF.Search.AFSearchFilter.End, out ends);
            AFSearchToken templatename;

            query.TryFindSearchToken(OSIsoft.AF.Search.AFSearchFilter.Template, out templatename);
            IList <AFSearchToken> values;

            query.TryFindSearchTokens(OSIsoft.AF.Search.AFSearchFilter.Value, out values);

            if (values.Count != 0)
            {
                AFAttributeValueQuery[] queries = new AFAttributeValueQuery[values.Count];
                criteria.AttributeValueQueries = new AFAttributeValueQuery[values.Count];
                criteria.TemplateName          = templatename.Value;
                for (int i = 0; i < values.Count; i++)
                {
                    AFSearchToken       value             = values[i];
                    string              attributeName     = value.Path.TrimStart(new char[] { '|' });
                    AFElementTemplate   template          = query.Database.ElementTemplates[templatename.Value];
                    AFAttributeTemplate templateAttribute = template.AttributeTemplates[attributeName];
                    queries[i] = new AFAttributeValueQuery(templateAttribute, value.Operator, value.Value, templateAttribute.DefaultUOM);
                    criteria.AttributeValueQueries[i] = new AFAttributeValueQuery(templateAttribute, value.Operator, value.Value, templateAttribute.DefaultUOM);
                }

                //criteria.AttributeValueQueries = queries;
                //criteria.ValueQueryString = value.ToString();
                //criteria.
            }
            if (ends.Count == 2)
            {
                criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingBetween;
                criteria.StartTime  = ends[0].Value;
                criteria.EndTime    = ends[1].Value;
            }
            else if (starts.Count == 2)
            {
                criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingBetween;
                criteria.StartTime  = starts[0].Value;
                criteria.EndTime    = starts[1].Value;
            }
            else if (starts.Count == 1 && ends.Count == 1)
            {
                AFSearchToken start = starts[0];
                AFSearchToken end   = ends[0];
                if (start.Operator == AFSearchOperator.LessThanOrEqual && end.Operator == AFSearchOperator.GreaterThanOrEqual)
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.ActiveBetween;
                    criteria.StartTime  = end.Value;
                    criteria.EndTime    = start.Value;
                }
                else if (start.Operator == AFSearchOperator.GreaterThanOrEqual && end.Operator == AFSearchOperator.LessThanOrEqual)
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EntirelyBetween;
                    criteria.StartTime  = start.Value;
                    criteria.EndTime    = end.Value;
                }
            }
            else if (starts.Count == 1)
            {
                AFSearchToken start = starts[0];
                if (start.Operator == AFSearchOperator.GreaterThanOrEqual)
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingAfter;
                }
                else
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.StartingBefore;
                }
                criteria.AFStartTimeString = start.Value;
            }
            else if (ends.Count == 1)
            {
                AFSearchToken end = ends[0];
                if (end.Operator == AFSearchOperator.GreaterThanOrEqual)
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingAfter;
                }
                else
                {
                    criteria.SearchType = OSIsoft.AF.UI.Search.AFBaseEventFrameCriteria.EventFrameSearchType.EndingBefore;
                }
                criteria.AFStartTimeString = end.Value;
            }

            criteria.LastFullSearchString = stripTokens(query);
            return(criteria);
        }