Esempio n. 1
0
        public void FillInfoTree(int deviceId)
        {
            var list = Db.GetDeviceInfoMeta(deviceId);

            foreach (var deviceInfoMeta in list)
            {
                var node = new TreeNode
                {
                    Text = deviceInfoMeta.NodeName,
                    Tag  = new NodeProperty(deviceInfoMeta.NodeId, NodeTypeEnum.DeviceComplexParameter)
                };
                TreeNodesHelper.AddNode(node, treeViewDeviceInfo.Nodes,
                                        treeViewDeviceInfo.Nodes, deviceInfoMeta.ParentNodeId);
            }
            list.Clear();
            list = Db.GetDeviceInfo(deviceId);
            foreach (var deviceInfo in list)
            {
                var node = new TreeNode
                {
                    Text = deviceInfo.NodeName,
                    Tag  = new NodeProperty(deviceInfo.NodeId, NodeTypeEnum.DeviceSimpleParameter)
                };
                TreeNodesHelper.AddNode(node, treeViewDeviceInfo.Nodes,
                                        treeViewDeviceInfo.Nodes, deviceInfo.ParentNodeId);
            }
            treeViewDeviceInfo.ExpandAll();
        }
Esempio n. 2
0
        private void SearchFormSt1_Load(object sender, EventArgs e)
        {
            CancelSearch = true;
            //Загрузка департаментов в дерево
            treeViewDepartments.Nodes.Clear();
            Db     = new DevicesDatabase();
            SpgNew = new SearchParametersGroup();
            var list = Db.GetDepartments(SpgNew);

            foreach (var department in list)
            {
                var node = new TreeNode
                {
                    Text = department.NodeName,
                    Tag  = new NodeProperty(department.NodeId, NodeTypeEnum.DepartmentNode)
                };
                TreeNodesHelper.AddNode(node, treeViewDepartments.Nodes, treeViewDepartments.Nodes, department.ParentNodeId);
            }

            //Загрузка типов узлов в combobox
            var view = Db.GetDeviceTypes();

            comboBoxDevTypes.DisplayMember = "DeviceType";
            for (var i = 0; i < view.Table.Rows.Count; i++)
            {
                comboBoxDevTypes.Items.Add(new DeviceTypeComboboxItem(view.Table.Rows[i]["Type"].ToString(),
                                                                      Convert.ToInt32(view.Table.Rows[i]["ID Device Type"])));
            }
        }
Esempio n. 3
0
        private void LoadNodes()
        {
            var list  = Db.GetDepartments(Spg);
            var cache = new List <Node>();
            int cacheCount;

            do
            {
                cacheCount = cache.Count;
                cache.Clear();
                foreach (var department in list)
                {
                    var node = new TreeNode
                    {
                        Text = department.NodeName,
                        Tag  = new NodeProperty(department.NodeId, NodeTypeEnum.DepartmentNode)
                    };
                    var inserted = TreeNodesHelper.AddNode(node, treeViewComputers.Nodes, treeViewComputers.Nodes, department.ParentNodeId);
                    if (!inserted)
                    {
                        cache.Add(department);
                    }
                }
                list.Clear();
                list.AddRange(cache);
            }while (cache.Count != cacheCount);
            if (Np.NodeType != NodeTypeEnum.DeviceSimpleParameter)
            {
                treeViewComputers.Sort();
                if (treeViewComputers.Nodes.Count > 0)
                {
                    treeViewComputers.SelectedNode = treeViewComputers.Nodes[0];
                }
                return;
            }
            list = Db.GetDevices(Spg);
            foreach (var device in list)
            {
                var node = new TreeNode
                {
                    Text = device.NodeName,
                    Tag  = new NodeProperty(device.NodeId, NodeTypeEnum.DeviceNode)
                };
                TreeNodesHelper.AddNode(node, treeViewComputers.Nodes, treeViewComputers.Nodes, device.ParentNodeId);
            }
            treeViewComputers.Sort();
            if (treeViewComputers.Nodes.Count > 0)
            {
                treeViewComputers.SelectedNode = treeViewComputers.Nodes[0];
            }
        }
Esempio n. 4
0
        private void SearchFormSt2_Load(object sender, EventArgs e)
        {
            Db = new DevicesDatabase();
            var list = Db.GetDeviceInfoMetaByType(DeviceTypeId);

            foreach (var deviceInfoMeta in list)
            {
                var node = new TreeNode
                {
                    Text = deviceInfoMeta.NodeName,
                    Tag  = new NodeProperty(deviceInfoMeta.NodeId, NodeTypeEnum.DeviceComplexParameter)
                };
                TreeNodesHelper.AddNode(node, treeViewDeviceInfo.Nodes,
                                        treeViewDeviceInfo.Nodes, deviceInfoMeta.ParentNodeId);
            }
            treeViewDeviceInfo.ExpandAll();
            comboBoxDeviceParameters.DisplayMember = "ParameterName";
        }
Esempio n. 5
0
        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            if (((NodeProperty)treeViewComputers.SelectedNode.Tag).NodeType != NodeTypeEnum.DeviceNode && ((NodeProperty)treeViewComputers.SelectedNode.Tag).NodeType != NodeTypeEnum.DepartmentNode)
            {
                return;
            }
            if (treeViewComputers.SelectedNode.Parent == null)
            {
                return;
            }
            if (((NodeProperty)treeViewComputers.SelectedNode.Parent.Tag).NodeId <= 0)
            {
                return;
            }
            var node = (TreeNode)treeViewComputers.SelectedNode.Clone();
            var np   = ((NodeProperty)treeViewComputers.SelectedNode.Tag);

            if (_mcf == null)
            {
                _mcf = new MoveComputersForm(np);
            }
            else
            {
                _mcf.Np = np;
            }
            _mcf.Text  = @"Перемещение узла " + treeViewComputers.SelectedNode.Text;
            _mcf.Moved = false;
            _mcf.ShowDialog();
            if (_mcf.Moved)
            {
                if (toolStripButton6.Checked)
                {
                    Reload(true);
                }
                else
                {
                    //Удалить в старом департаменте узел и добавить в новый
                    treeViewComputers.SelectedNode.Remove();
                    //Добавить узел в новое место
                    TreeNodesHelper.AddNode(node, treeViewComputers.Nodes, treeViewComputers.Nodes, _mcf.NewId);
                    treeViewComputers.Sort();
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Заполнить дерево устройств
        /// </summary>
        public void FillInfoTree()
        {
            List <Node> list;

            if (SearchInArchive)
            {
                list = _db.GetDeviceInfoMetaInArchive(DeviceId);
                toolStrip1.Enabled = false;
                добавитьToolStripMenuItem.Enabled = false;
                изменитьToolStripMenuItem.Enabled = false;
                удалитьToolStripMenuItem.Enabled  = false;
            }
            else
            {
                list = _db.GetDeviceInfoMeta(DeviceId);
            }
            foreach (var deviceInfoMeta in list)
            {
                var node = new TreeNode
                {
                    Text = deviceInfoMeta.NodeName,
                    Tag  = new NodeProperty(deviceInfoMeta.NodeId, NodeTypeEnum.DeviceComplexParameter)
                };
                TreeNodesHelper.AddNode(node, treeViewDeviceInfo.Nodes,
                                        treeViewDeviceInfo.Nodes, deviceInfoMeta.ParentNodeId);
            }
            list.Clear();
            list = SearchInArchive ? _db.GetDeviceInfoFromArchive(DeviceId) : _db.GetDeviceInfo(DeviceId);
            foreach (var deviceInfo in list)
            {
                var node = new TreeNode
                {
                    Text = deviceInfo.NodeName,
                    Tag  = new NodeProperty(deviceInfo.NodeId, NodeTypeEnum.DeviceSimpleParameter)
                };
                TreeNodesHelper.AddNode(node, treeViewDeviceInfo.Nodes,
                                        treeViewDeviceInfo.Nodes, deviceInfo.ParentNodeId);
            }
            treeViewDeviceInfo.ExpandAll();
        }
Esempio n. 7
0
        private void Reload(bool autoOpenFirstFoundDevice = false)
        {
            treeViewComputers.Nodes.Clear();
            Db = new DevicesDatabase();
            var list     = Db.GetDepartments(Spg);
            var listFull = Db.GetDepartments(new SearchParametersGroup());
            var cache    = new List <Node>();
            int cacheCount;

            do
            {
                cacheCount = cache.Count;
                cache.Clear();
                foreach (var department in listFull)
                {
                    if (!HasChildDepartmentsFromActiveList(department, listFull, list))
                    {
                        continue;
                    }
                    var node = new TreeNode
                    {
                        Text = department.NodeName,
                        Tag  = new NodeProperty(department.NodeId, NodeTypeEnum.DepartmentNode)
                    };
                    var inserted = TreeNodesHelper.AddNode(node, treeViewComputers.Nodes, treeViewComputers.Nodes, department.ParentNodeId);
                    if (!inserted)
                    {
                        cache.Add(department);
                    }
                }
                listFull.Clear();
                listFull.AddRange(cache);
            }while (cache.Count != cacheCount);
            list = Db.GetDevices(Spg);
            TreeNode selectNode = null;

            foreach (var device in list)
            {
                var node = new TreeNode
                {
                    Text = device.NodeName,
                    Tag  = new NodeProperty(device.NodeId, NodeTypeEnum.DeviceNode)
                };
                TreeNodesHelper.AddNode(node, treeViewComputers.Nodes, treeViewComputers.Nodes, device.ParentNodeId);
                if (selectNode == null && autoOpenFirstFoundDevice)
                {
                    selectNode = node;
                }
            }
            treeViewComputers.Sort();
            if (treeViewComputers.Nodes.Count > 0)
            {
                treeViewComputers.SelectedNode = selectNode ?? treeViewComputers.Nodes[0];
            }
            toolStripStatusLabelDeviceCount.Text = string.Format("Сетевых узлов: {0}", list.Count);

            var monitoringWarnings = Db.GetMonitoringWarnings().ToList();

            if (!monitoringWarnings.Any())
            {
                toolStripStatusLabelWarning.Visible = false;
            }
            else
            {
                toolStripStatusLabelWarning.Visible     = true;
                toolStripStatusLabelWarning.ToolTipText = string.Join(Environment.NewLine, monitoringWarnings.ToArray());
            }
        }