示例#1
0
        private void LoadRegion(TreeNode parentNode, SubRegion parentRegion)
        {
            TreeNode node;
            TreeNode adminNode;
            TreeNode managersNode;
            TreeNode managerNode;
            TreeNode sitesNode;
            TreeNode siteNode;
            TreeNode settingsNode;
            TreeNode channelSettingsNode;
            TreeNode linkSettingsNode;
            TreeNode equipmentSettingsNode;
            UsersModel usersModel;
            TreeNode channelSettingNode;
            TreeNode linkConfigurationNode;
            TreeNode equipmentParameterNode;
            if (parentRegion.Sub == null)
                return;
            foreach (SubRegion region in parentRegion.Sub)
            {
                node = parentNode.Nodes.Add(region.Name);
                node.Tag = region;
                node.ImageIndex = node.SelectedImageIndex = ICON_REGION;

                if (node.Parent != mGlobalNode)
                    adminNode = node.Nodes.Add("Administrator - " + region.Owner);
                else
                    adminNode = node.Nodes.Add("Administrator - [SYSTEM ADMIN]");
                adminNode.SelectedImageIndex = adminNode.ImageIndex = ICON_ADMIN;

                if (region.Manager.IndexOf(HTTPAgent.Username) >= 0
                    || region.Manager.Count == 0 && region.Owner != null && region.Owner.Equals(HTTPAgent.Username))
                {
                    managersNode = node.Nodes.Add("Managers");
                    usersModel = new UsersModel();
                    managersNode.Tag = usersModel;
                    managersNode.SelectedImageIndex = managersNode.ImageIndex = ICON_USERS;
                    if (region.Manager != null)
                    {
                        foreach (string manager in region.Manager)
                        {
                            managerNode = managersNode.Nodes.Add(manager);
                            managerNode.SelectedImageIndex = managerNode.ImageIndex = ICON_MANAGER;
                            usersModel.Add(manager);
                        }
                    }

                    sitesNode = node.Nodes.Add("Sites");
                    sitesNode.SelectedImageIndex = sitesNode.ImageIndex = ICON_SITES;
                    sitesNode.Tag = new SitesModel();
                    Site site;
                    if (region.Site != null)
                    {
                        foreach (string siteID in region.Site)
                        {
                            if (DataCenter.Instance().Sites.ContainsKey(siteID))
                                site = DataCenter.Instance().Sites[siteID];
                            else
                                site = new Site(siteID);
                            siteNode = sitesNode.Nodes.Add(site.ToString());
                            siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                            siteNode.Tag = new SiteModel(site);
                        }
                    }
                    SiteNodeListSorter.SortByName(sitesNode);

                    settingsNode = node.Nodes.Add("Settings");
                    settingsNode.SelectedImageIndex = settingsNode.ImageIndex = ICON_SETTINGS;

                    channelSettingsNode = settingsNode.Nodes.Add("Channel Settings");
                    channelSettingsNode.SelectedImageIndex = channelSettingsNode.ImageIndex = ICON_CHANNELSETTINGS;

                    linkSettingsNode = settingsNode.Nodes.Add("Link Configuration Settings");
                    linkSettingsNode.SelectedImageIndex = linkSettingsNode.ImageIndex = ICON_LINKSETTINGS;

                    equipmentSettingsNode = settingsNode.Nodes.Add("Equipment Parameter Settings");
                    equipmentSettingsNode.SelectedImageIndex = equipmentSettingsNode.ImageIndex = ICON_EQUIPMENTSETTINGS;

                    /*
                    channelSettingNode = settingsNode.Nodes.Add("");
                    if (region.ChannelSettingID == -1)
                        channelSettingNode.Text = "Channel setting - <Not set>";
                    else
                        channelSettingNode.Text = "Channel setting - " + DataCenter.Instance().ChannelSettingDescriptions[region.ChannelSettingID].FileName;
                    channelSettingNode.SelectedImageIndex = channelSettingNode.ImageIndex = ICON_CHANNELSETTING;
                    channelSettingNode.Tag = new ChannelModel(region.ChannelSettingID);

                    linkConfigurationNode = settingsNode.Nodes.Add("");
                    if (region.LinkConfigurationID == -1)
                        linkConfigurationNode.Text = "Link configuration - <Not set>";
                    else
                        linkConfigurationNode.Text = DataCenter.Instance().LinkConfigurationDescriptions[region.LinkConfigurationID].FileName;
                    linkConfigurationNode.SelectedImageIndex = linkConfigurationNode.ImageIndex = ICON_LINKCONFIGURATION;
                    linkConfigurationNode.Tag = new LinkModel(region.LinkConfigurationID);

                    equipmentParameterNode = settingsNode.Nodes.Add("");
                    if (region.EquipmentParameterID == -1)
                        equipmentParameterNode.Text = "Equipment parameter - <Not set>";
                    else
                        equipmentParameterNode.Text = DataCenter.Instance().EquipmentParameterDescriptions[region.EquipmentParameterID].FileName;
                    equipmentParameterNode.SelectedImageIndex = equipmentParameterNode.ImageIndex = ICON_EQUIPMENTPARAMETER;
                    equipmentParameterNode.Tag = new EquipmentModel(region.EquipmentParameterID);
                    */

                    if (region.Task != null)
                    {
                        foreach (long taskID in region.Task)
                        {
                            LoadTask(node, taskID);
                        }
                    }

                }
                else
                {
                    node.ImageIndex = node.SelectedImageIndex = ICON_REGIONUNAUTHORIZED;
                }

                LoadRegion(node, region);
            }
        }
示例#2
0
        private void LoadTask(TreeNode regionNode, long taskID)
        {
            if (!DataCenter.Instance().Tasks.ContainsKey(taskID))
            {
                MessageBox.Show("Task " + taskID + " does not exist !");
                return;
            }

            BindingTask task = DataCenter.Instance().Tasks[taskID];
            TreeNode taskNode = regionNode.Nodes.Add(task.Name);
            taskNode.Tag = new TaskModel(task);
            taskNode.SelectedImageIndex = taskNode.ImageIndex = ICON_TASK;

            TreeNode sitesNode = taskNode.Nodes.Add("Sites");
            sitesNode.SelectedImageIndex = sitesNode.ImageIndex = ICON_SITES;
            sitesNode.Tag = new SitesModel();

            Site site;
            TreeNode siteNode, analyzersNode, analyzerNode;
            foreach (string siteID in task.Site)
            {
                if (DataCenter.Instance().Sites.ContainsKey(siteID))
                    site = DataCenter.Instance().Sites[siteID];
                else
                    site = new Site(siteID);
                siteNode = sitesNode.Nodes.Add(site.ToString());
                siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                siteNode.Tag = new SiteModel(site);
            }

            foreach (string siteID in task.UnassignedSite)
            {
                if (DataCenter.Instance().Sites.ContainsKey(siteID))
                    site = DataCenter.Instance().Sites[siteID];
                else
                    site = new Site(siteID);
                siteNode = sitesNode.Nodes.Add(site.ToString());
                siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_UNASSIGNEDSITE;
                siteNode.Tag = new SiteModel(site);
            }

            analyzersNode = taskNode.Nodes.Add("Analyzers");
            UsersModel usersModel = new UsersModel();
            analyzersNode.Tag = usersModel;
            analyzersNode.SelectedImageIndex = analyzersNode.ImageIndex = ICON_USERS;
            if (task.Analyzer != null)
            {
                foreach (string analyzer in task.Analyzer)
                {
                    analyzerNode = analyzersNode.Nodes.Add(analyzer);
                    analyzerNode.SelectedImageIndex = analyzerNode.ImageIndex = ICON_ANALYZER;
                    usersModel.Add(analyzer);
                }
            }
        }
示例#3
0
        private void AdminForm_Load(object sender, EventArgs e)
        {
            HTTPAgent.instance().onUpdateRegionSuccessfully += new HTTPAgent.updateRegionSuccessfully(AdminForm_onUpdateRegionSuccessfully);
            HTTPAgent.instance().onUpdateRegionFailed += new HTTPAgent.updateRegionFailed(AdminForm_onUpdateRegionFailed);

            HTTPAgent.instance().onAddUserSuccessfully +=new HTTPAgent.addUserSuccessfully(AdminForm_onAddUserSuccessfully);
            HTTPAgent.instance().onAddUserFailed+=new HTTPAgent.addUserFailed(AdminForm_onAddUserFailed);

            HTTPAgent.instance().onRemoveUserSuccessfully+=new HTTPAgent.removeUserSuccessfully(AdminForm_onRemoveUserSuccessfully);
            HTTPAgent.instance().onRemoveUserFailed += new HTTPAgent.removeUserFailed(AdminForm_onRemoveUserFailed);

            HTTPAgent.instance().onUpdateUserSuccessfully += new HTTPAgent.updateUserSuccessfully(AdminForm_onUpdateUserSuccessfully);
            HTTPAgent.instance().onUpdateUserFailed += new HTTPAgent.updateUserFailed(AdminForm_onUpdateUserFailed);

            /************************************************************************/
            /* Load Region                                                          */
            /************************************************************************/
            RegionTreeView.ImageList = ImageList;
            mGlobalNode = RegionTreeView.Nodes.Add("Global");
            mGlobalNode.SelectedImageIndex = mGlobalNode.ImageIndex = PIC_GLOBAL;
            mGlobalNode.Tag = DataCenter.Instance().GlobalRegion.Root;

            if (DataCenter.Instance().GlobalRegion.Root.Sub != null)
            {
                TreeNode regionNode;
                TreeNode managersNode;
                TreeNode managerNode;
                foreach (SubRegion region in DataCenter.Instance().GlobalRegion.Root.Sub)
                {
                    regionNode = mGlobalNode.Nodes.Add(region.Name);
                    regionNode.SelectedImageIndex = regionNode.ImageIndex = PIC_REGION;
                    regionNode.Tag = region;

                    managersNode = regionNode.Nodes.Add("Managers");
                    UsersModel usersModel = new UsersModel();
                    managersNode.Tag = usersModel;
                    managersNode.SelectedImageIndex = managersNode.ImageIndex = PIC_MANAGERS;

                    if (region.Manager == null)
                        continue;

                    Debug.WriteLine("Region=" + region.Name);
                    foreach (string manager in region.Manager)
                    {
                        Debug.WriteLine("Manager=" + manager);
                        managerNode = managersNode.Nodes.Add(manager);
                        managerNode.SelectedImageIndex = managerNode.ImageIndex = PIC_MANAGER;
                        usersModel.Add(manager);
                    }
                }
            }

            /************************************************************************/
            /* Load Users                                                           */
            /************************************************************************/
            foreach (KeyValuePair<string, User> pair in DataCenter.Instance().Users)
            {
                if (!pair.Value.locked)
                {
                    ActiveUsersListBox.Items.Add(pair.Key);
                }
                else
                {
                    LockedUsersListBox.Items.Add(pair.Key);
                }
            }
        }