Пример #1
0
		private void ExpandNode(DataNode node)
		{
			if (node == null || node.Populated)
				return;

			node.Nodes.Clear();
			spaceTree.Update();

			switch (node.NodeType)
			{
				case USER:
					PopulateUser(node);
					break;
				case CUSTOMERS:
					PopulateCustomers(node);
					break;
				case SPACES:
					PopulateSpaces(node);
					break;
			}

			node.Populated = true;
			node.Expand();
		}
Пример #2
0
		private void PopulateUser(DataNode parentNode)
		{
			UserInfo info = parentNode.Tag as UserInfo;
			if ((UserRole)info.RoleId != UserRole.User)
			{
				AddTreeNode(parentNode, CUSTOMERS, 1, CUSTOMERS, info, true);
			}
			AddTreeNode(parentNode, SPACES, 2, SPACES, info, true); 
		}
Пример #3
0
		private DataNode AddTreeNode(DataNode parentNode, string text, int imageIndex, string nodeType, object data, bool hasChildren)
		{
			DataNode node = new DataNode();
			node.Text = text;
			node.SelectedImageIndex = imageIndex;
			node.ImageIndex = imageIndex;
			node.NodeType = nodeType;
			node.Tag = data;
			if (hasChildren)
			{
				node.Populated = false;
				DataNode tmpNode = new DataNode();
				tmpNode.Text = "Expanding...";
				tmpNode.SelectedImageIndex = 2;
				tmpNode.ImageIndex = 2;
				tmpNode.NodeType = TMP;
				node.Nodes.Add(tmpNode);
			}
			else
			{
				node.Populated = true;
			}
			if (parentNode != null)
				parentNode.Nodes.Add(node);
			else
				spaceTree.Nodes.Add(node);
			return node;
		}
Пример #4
0
		private void PopulateSpaces(DataNode parentNode)
		{
			UserInfo info = parentNode.Tag as UserInfo;
			DataSet ds = null;
			try
			{
				ds = PackageController.GetRawMyPackages(info.UserId);
			}
			catch(Exception ex)
			{
				ShowError("Unable to load spaces.", ex);
			}
			if (ds != null)
			{
				foreach (DataRow dr in ds.Tables[0].Rows)
				{
					PackageInfo data = new PackageInfo();
					data.PackageId = Utils.GetDbInt32(dr["PackageId"]);
					data.PackageName = Utils.GetDbString(dr["PackageName"]);
					data.UserId = Utils.GetDbInt32(dr["UserId"]);
					AddTreeNode(parentNode, data.PackageName, 3, SPACE, data, false);
				}
			}

		}
Пример #5
0
		private void PopulateCustomers(DataNode parentNode)
		{
			UserInfo info = parentNode.Tag as UserInfo;
			DataSet ds = null;
			try
			{
				ds = UserController.GetRawUsers(info.UserId, false);
			}
			catch(Exception ex)
			{
				ShowError("Unable to load users.", ex);
			}
			if (ds != null)
			{

				foreach (DataRow dr in ds.Tables[0].Rows)
				{

					UserInfo user = new UserInfo();
					user.UserId = Utils.GetDbInt32(dr["UserId"]);
					user.Username = Utils.GetDbString(dr["Username"]);
					user.RoleId = Utils.GetDbInt32(dr["RoleId"]);
					AddTreeNode(parentNode, user.Username, 0, USER, user, true);
				}
			}

		}
Пример #6
0
		private void ExpandNode(DataNode node)
		{
			if (node == null || node.Populated)
			   return;

			node.Nodes.Clear();
			ouTree.Update();
			try
			{
				DirectoryEntry parent = node.Tag as DirectoryEntry;

				foreach (DirectoryEntry child in parent.Children)
				{
					AddTreeNode(node, child);
				}
			}
			catch (Exception ex)
			{
				ShowError("Unable to load Active Directory data.", ex);
			}

			node.Populated = true;
			node.Expand();
		}
Пример #7
0
		private DataNode AddTreeNode(DataNode parentNode, DirectoryEntry entry)
		{
			bool hasChildren = true;
			DataNode node = new DataNode();
			node.Text = (string)entry.Properties["name"].Value;
			
			node.NodeType = entry.SchemaClassName;
			int imageIndex = 2;
			switch (entry.SchemaClassName)
			{
				case OU:
					imageIndex = 1;
					break;
				case CONTAINER:
					imageIndex = 2;
					break;
				case COMPUTER:
					imageIndex = 3;
					break;
				case USER:
					imageIndex = 4;
					hasChildren = false;
					break;
				case CONTACT:
					imageIndex = 8;
					hasChildren = false;
					break;
				case GROUP:
					imageIndex = 5;
					hasChildren = false;
					break;
				default:
					imageIndex = 6;
					break;
			}
			
			node.SelectedImageIndex = imageIndex;
			node.ImageIndex = imageIndex;
			node.Tag = entry;
			if (hasChildren)
			{
				node.Populated = false;
				DataNode tmpNode = new DataNode();
				tmpNode.Text = "Expanding...";
				tmpNode.SelectedImageIndex = 2;
				tmpNode.ImageIndex = 2;
				tmpNode.NodeType = TMP;
				node.Nodes.Add(tmpNode);
			}
			else
			{
				node.Populated = true;
			}
			if (parentNode != null)
				parentNode.Nodes.Add(node);
			else
				ouTree.Nodes.Add(node);
			return node;
		}
Пример #8
0
        private void OnBeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            DataNode node = e.Node as DataNode;

            ExpandNode(node);
        }
Пример #9
0
        private DataNode AddTreeNode(DataNode parentNode, DirectoryEntry entry)
        {
            bool     hasChildren = true;
            DataNode node        = new DataNode();

            node.Text = (string)entry.Properties["name"].Value;

            node.NodeType = entry.SchemaClassName;
            int imageIndex = 2;

            switch (entry.SchemaClassName)
            {
            case OU:
                imageIndex = 1;
                break;

            case CONTAINER:
                imageIndex = 2;
                break;

            case COMPUTER:
                imageIndex = 3;
                break;

            case USER:
                imageIndex  = 4;
                hasChildren = false;
                break;

            case CONTACT:
                imageIndex  = 8;
                hasChildren = false;
                break;

            case GROUP:
                imageIndex  = 5;
                hasChildren = false;
                break;

            default:
                imageIndex = 6;
                break;
            }

            node.SelectedImageIndex = imageIndex;
            node.ImageIndex         = imageIndex;
            node.Tag = entry;
            if (hasChildren)
            {
                node.Populated = false;
                DataNode tmpNode = new DataNode();
                tmpNode.Text = "Expanding...";
                tmpNode.SelectedImageIndex = 2;
                tmpNode.ImageIndex         = 2;
                tmpNode.NodeType           = TMP;
                node.Nodes.Add(tmpNode);
            }
            else
            {
                node.Populated = true;
            }
            if (parentNode != null)
            {
                parentNode.Nodes.Add(node);
            }
            else
            {
                ouTree.Nodes.Add(node);
            }
            return(node);
        }
Пример #10
0
        private void OnSelectClick(object sender, EventArgs e)
        {
            DataNode node = spaceTree.SelectedNode as DataNode;

            if (node == null || node.NodeType != SPACE)
            {
                ShowWarning("Please select hosting space.");
                return;
            }
            PackageInfo data = node.Tag as PackageInfo;

            if (data == null || data.PackageId == 0 || data.PackageId == 1)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }

            PackageContext cntx = null;

            try
            {
                cntx = PackageController.GetPackageContext(data.PackageId);
            }
            catch (Exception ex)
            {
                ShowError("Unable to load space data", ex);
                return;
            }

            if (cntx == null)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }

            bool exchangeEnabled = false;
            bool orgEnabled      = false;

            foreach (HostingPlanGroupInfo group in cntx.GroupsArray)
            {
                if (!group.Enabled)
                {
                    continue;
                }
                if (group.GroupName == ResourceGroups.Exchange)
                {
                    exchangeEnabled = true;
                    continue;
                }
                else if (group.GroupName == ResourceGroups.HostedOrganizations)
                {
                    orgEnabled = true;
                    continue;
                }
            }
            if (!exchangeEnabled || !orgEnabled)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }
            this.selectedSpace = data;
            this.DialogResult  = DialogResult.OK;
            this.Close();
        }