Exemple #1
0
        /// <summary>
        ///  Expands the TreeView along the element path. Iterative process that stops when node is found.
        /// </summary>
        /// <param name="node"> The starting node or node being evaluated. </param>
        /// <param name="element"> The element that is being searched for. </param>
        private bool findTreeNode(TreeNode node, AFElement element)
        {
            string path = element.GetPath();

            if (path.Contains(node.Text) || node.Text == "Elements")
            {
                node.Expand();
                string[] split = Regex.Split(path, node.Text);     //evaluate path string
                if (split.Length > 1 && split[1] == string.Empty)
                {
                    afTreeViewElements.AFSelect(element, element.Parent, path);
                    node.EnsureVisible();
                    node.ToolTipText = path;     // If not set here is null, because of dummy node.
                    AFTreeViewNode_Selected(this, null);
                    return(true);
                }
                else
                {
                    foreach (TreeNode child in node.Nodes)
                    {
                        if (findTreeNode(child, element))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        public AttributesForm(AFElement element)
        {
            Element = element;
            InitializeComponent();

            if (element != null)
            {
                lblElement.Text = element.GetPath(element.Database);
                afViewControl1.AFSetObject(element, null, null, null);
                // This should jump view to "Attributes" tab.
                afViewControl1.AFSelection = element.Attributes;
            }
        }
        private void btnReplace_Click(object sender, EventArgs e)
        {
            btnConnect_Click(null, null);

            bool res = AFOperations.BrowseElement(this, m_Database, null, ref m_FoundElement);

            if (!res)
            {
                return;
            }
            if (m_FoundElement == null)
            {
                MessageBox.Show("Element not selected", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string afelemName = "AF2." + m_FoundElement.GetPath();

            Display disp         = m_App.ActiveDisplay;
            var     selectedSyms = disp.SelectedSymbols;

            int replaceCount = 0;

            for (int i = 1; i <= selectedSyms.Count; i++)
            {
                try {
                    Symbol sym = selectedSyms.Item(i);
                    replaceCount += ProcessReplaceElement(sym, afelemName);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }

            MessageBox.Show(string.Format("Replace {0} item(s)", replaceCount));
            disp.Refresh();
        }
Exemple #4
0
        public GraphQlAfElement(AFElement aAfElement, Field afElementsField, Field afAttributesField)
        {
            name          = aAfElement.Name;
            template      = aAfElement.Template?.Name;
            path          = aAfElement.GetPath();
            ThisAfElement = aAfElement;

            if (afElementsField != null)
            {
                var afElementsNameFilterStrings           = GraphQlHelpers.GetArgumentStrings(afElementsField, "nameFilter");
                var afElementsAttributeValueFilterStrings = GraphQlHelpers.GetArgumentStrings(afElementsField, "attributeValueFilter");
                var afElementsChildField   = GraphQlHelpers.GetFieldFromSelectionSet(afElementsField, "afElements");
                var afAttributesChildField = GraphQlHelpers.GetFieldFromSelectionSet(afElementsField, "afAttributes");

                var returnElementsObject = new ConcurrentBag <GraphQlAfElement>();
                var afElementList        = aAfElement.Elements;
                Parallel.ForEach(afElementList, aAfChildElement =>
                {
                    if (GraphQlHelpers.JudgeElementOnFilters(aAfChildElement, afElementsNameFilterStrings, afElementsAttributeValueFilterStrings))
                    {
                        returnElementsObject.Add(new GraphQlAfElement(aAfChildElement, afElementsChildField, afAttributesChildField));
                    }
                });
                afElements = returnElementsObject.OrderBy(x => x.name).ToList();
            }

            if (afAttributesField != null)
            {
                var afAttributesNameFilterStrings = GraphQlHelpers.GetArgumentStrings(afAttributesField, "nameFilter");
                var afAttributesChildField        = GraphQlHelpers.GetFieldFromSelectionSet(afAttributesField, "afAttributes");
                var tsValuesField = GraphQlHelpers.GetFieldFromSelectionSet(afAttributesField, "tsPlotValues");

                var returnAttributesObject = new ConcurrentBag <GraphQlAfAttribute>();
                var afAttributeList        = aAfElement.Attributes.ToList <AFAttribute>();
                Parallel.ForEach(afAttributeList, aAfAttribute =>
                {
                    if (afAttributesNameFilterStrings.Count == 0 || afAttributesNameFilterStrings.Contains(aAfAttribute.Name))
                    {
                        returnAttributesObject.Add(new GraphQlAfAttribute(aAfAttribute, afAttributesChildField, tsValuesField));
                    }
                });
                afAttributes = returnAttributesObject.OrderBy(x => x.name).ToList();
            }
        }
Exemple #5
0
        private void lbNotificationRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Selected notification rule
            AFNotificationRule SelectedNotificationRule = lbNotificationRules.SelectedItem as AFNotificationRule;

            // Clear the notificaiton list
            lbNotificationInstances.Items.Clear();

            // Check empty Selected
            if (SelectedNotificationRule == null)
            {
                return;
            }

            // Get information from Notification Rule Selected;
            AFTime     startTime     = new AFTime(tbStart.Text);
            AFTime     endTime       = new AFTime(tbEnd.Text);
            AFElement  targetElement = SelectedNotificationRule.Target;
            AFDatabase database      = SelectedNotificationRule.Database;


            // Consulting the dataBase
            string             query  = string.Format("Element: '{0}' {1}", targetElement.GetPath(database), SelectedNotificationRule.Criteria);
            AFEventFrameSearch search = new AFEventFrameSearch(database, "", AFSearchMode.Overlapped, startTime, endTime, query);

            search.CacheTimeout = TimeSpan.FromMinutes(5);

            IEnumerable <AFEventFrame> instances = search.FindEventFrames(fullLoad: false);

            // Populate the eventframe listbox

            foreach (AFEventFrame instance in instances)
            {
                string s = string.Format("Element: {0}, \t{1}, \t{2}"
                                         , targetElement.Name
                                         , instance.StartTime.LocalTime
                                         , instance.EndTime == AFTime.MaxValue ? "Event is ongoing": instance.EndTime.LocalTime.ToString());
                lbNotificationInstances.Items.Add(s);
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            PISystems myPISystems = new PISystems();
            PISystem  myPISystem  = myPISystems.DefaultPISystem;

            if (myPISystem == null)
            {
                throw new InvalidOperationException("Default PISystem was not found.");
            }
            AFDatabase myDB = myPISystem.Databases["PE"];

            if (myDB == null)
            {
                throw new InvalidOperationException("Database was not found.");
            }
            AFElement element = myDB.Elements["El"];
            int       count;

            using (var search = new AFAnalysisSearch(myDB, "MyAnalysisSearch", string.Format(@"Target:'{0}'", element.GetPath())))
            {
                search.CacheTimeout = TimeSpan.FromMinutes(10);
                count = search.GetTotalCount();
                Console.WriteLine("Found {0} Analyses", count);
                foreach (var item in search.FindObjects(fullLoad: true))
                {
                    Console.Write("Analysis Name = {0},", item.Name);
                    Console.Write("Analysis Description = {0},", item.Description);
                    Console.Write("Analysis Target = {0}", item.Target);
                    Console.WriteLine();
                }
            }
        }
 /// <summary>
 ///  Expands the TreeView along the element path. Iterative process that stops when node is found.
 /// </summary>
 /// <param name="node"> The starting node or node being evaluated. </param>
 /// <param name="element"> The element that is being searched for. </param>
 private bool findTreeNode(TreeNode node, AFElement element)
 {
     string path = element.GetPath();
         if (path.Contains(node.Text) || node.Text == "Elements")
         {
             node.Expand();
             string[] split = Regex.Split(path, node.Text); //evaluate path string
             if (split.Length > 1 && split[1] == string.Empty)
             {
                 afTreeViewElements.AFSelect(element, element.Parent, path);
                 node.EnsureVisible();
                 node.ToolTipText = path; // If not set here is null, because of dummy node.
                 AFTreeViewNode_Selected(this, null);
                 return true;
             }
             else
             {
                 foreach (TreeNode child in node.Nodes)
                 {
                     if (findTreeNode(child, element))
                         return true;
                 }
             }
         }
         return false;
 }