コード例 #1
0
        /// <summary>
        /// Writes child item XML to the provided writer.
        /// </summary>
        /// <param name="folderItem">Parent item.</param>
        /// <param name="xmlWriter">XmlTextWriter to output to.</param>
        private void WriteChildItems(QSetFolderItem folderItem, XmlTextWriter xmlWriter)
        {
            //write all folders
            foreach (QSetItemBase childItem in folderItem.ChildItems)
            {
                if (childItem.GetType() == typeof(QSetFolderItem))
                {
                    QSetFolderItem childFolderItem = (QSetFolderItem)childItem;
                    xmlWriter.WriteStartElement(QSetFolderItem.TypeName);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childFolderItem.Name);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childFolderItem.ID.ToString());
                    WriteChildItems(childFolderItem, xmlWriter);
                    xmlWriter.WriteEndElement();
                }
            }

            //write all machines
            foreach (QSetItemBase childItem in folderItem.ChildItems)
            {
                if (childItem.GetType() == typeof(QSetMachineItem))
                {
                    QSetMachineItem childMachineItem = (QSetMachineItem)childItem;
                    xmlWriter.WriteStartElement(QSetMachineItem.TypeName);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childMachineItem.Name);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childMachineItem.ID.ToString());
                    WriteChildItems(childMachineItem, xmlWriter);
                    xmlWriter.WriteEndElement();
                }
            }

            //write all queues
            foreach (QSetItemBase childItem in folderItem.ChildItems)
            {
                QSetQueueItem childQueueItem = childItem as QSetQueueItem;
                if (childQueueItem != null)
                {
                    xmlWriter.WriteStartElement(QSetQueueItem.TypeName);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childQueueItem.Name);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childQueueItem.ID.ToString());
                    if (childQueueItem.MessageViewerXslt != null && childQueueItem.MessageViewerXslt.Trim().Length > 0)
                    {
                        xmlWriter.WriteAttributeString(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, childQueueItem.MessageViewerXslt.Trim());
                    }
                    xmlWriter.WriteEndElement();
                }
            }

            //write all web services
            foreach (QSetItemBase childItem in folderItem.ChildItems)
            {
                QSetWebServiceItem childWebServiceItem = childItem as QSetWebServiceItem;
                if (childWebServiceItem != null)
                {
                    xmlWriter.WriteStartElement(QSetWebServiceItem.TypeName);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childWebServiceItem.Name);
                    xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childWebServiceItem.ID.ToString());
                    xmlWriter.WriteEndElement();
                }
            }
        }
コード例 #2
0
ファイル: QSetItems.cs プロジェクト: modulexcite/QSet
		/// <summary>
		/// Writes child item XML to the provided writer.
		/// </summary>
		/// <param name="folderItem">Parent item.</param>
		/// <param name="xmlWriter">XmlTextWriter to output to.</param>
		private void WriteChildItems(QSetFolderItem folderItem, XmlTextWriter xmlWriter)
		{
			//write all folders
			foreach(QSetItemBase childItem in folderItem.ChildItems)
			{				
				if (childItem.GetType() == typeof(QSetFolderItem))
				{
					QSetFolderItem childFolderItem = (QSetFolderItem)childItem;
					xmlWriter.WriteStartElement(QSetFolderItem.TypeName);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childFolderItem.Name);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childFolderItem.ID.ToString());
					WriteChildItems(childFolderItem, xmlWriter);
					xmlWriter.WriteEndElement();
				}
			}

			//write all machines
			foreach(QSetItemBase childItem in folderItem.ChildItems)
			{				
				if (childItem.GetType() == typeof(QSetMachineItem))
				{
					QSetMachineItem childMachineItem = (QSetMachineItem)childItem;
					xmlWriter.WriteStartElement(QSetMachineItem.TypeName);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childMachineItem.Name);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childMachineItem.ID.ToString());
					WriteChildItems(childMachineItem, xmlWriter);
					xmlWriter.WriteEndElement();
				}
			}

			//write all queues			
			foreach(QSetItemBase childItem in folderItem.ChildItems)
			{
				QSetQueueItem childQueueItem = childItem as QSetQueueItem;
				if (childQueueItem != null)
				{
					xmlWriter.WriteStartElement(QSetQueueItem.TypeName);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childQueueItem.Name);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childQueueItem.ID.ToString());					
					if (childQueueItem.MessageViewerXslt != null && childQueueItem.MessageViewerXslt.Trim().Length > 0)
						xmlWriter.WriteAttributeString(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, childQueueItem.MessageViewerXslt.Trim());
					xmlWriter.WriteEndElement();
				}
			}

			//write all web services
			foreach(QSetItemBase childItem in folderItem.ChildItems)
			{
				QSetWebServiceItem childWebServiceItem = childItem as QSetWebServiceItem;
				if (childWebServiceItem != null)
				{
					xmlWriter.WriteStartElement(QSetWebServiceItem.TypeName);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Name, childWebServiceItem.Name);
					xmlWriter.WriteAttributeString(QSetXmlFileFormat.ItemAttributes.Guid, childWebServiceItem.ID.ToString());
					xmlWriter.WriteEndElement();
				}
			}
		}
コード例 #3
0
ファイル: QSetItems.cs プロジェクト: modulexcite/QSet
		/// <summary>
		/// Recursively creates all of the child items of a Q Set item.
		/// </summary>
		/// <param name="parentItem">Parent item.</param>
		/// <param name="parentNodeIterator">XPathNodeIterator positioned at the parent item. </param>
		private static void CreateChildItems(QSetFolderItem parentItem, XPathNodeIterator parentNodeIterator)
		{			
			//iterate through all child items
			XPathNodeIterator childNodeIterator = parentNodeIterator.Current.Select("*");
			while (childNodeIterator.MoveNext())
			{
				//get the item details	
				string itemName = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, "");	
				Guid itemGuid = Guid.Empty;
				if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "") != string.Empty)
					itemGuid = new Guid(childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, ""));
				
				//create a new item of the required type, specifying the guid if available				
				QSetItemBase newItem = null;
				if (childNodeIterator.Current.Name == QSetFolderItem.TypeName)
				{
					//create folder
					if (itemGuid == Guid.Empty)
						newItem = new QSetFolderItem(itemName);
					else
						newItem = new QSetFolderItem(itemGuid, itemName);						
				}
				else if (childNodeIterator.Current.Name == QSetMachineItem.TypeName)
				{
					//create machine
					if (itemGuid == Guid.Empty)
						newItem = new QSetMachineItem(itemName);
					else
						newItem = new QSetMachineItem(itemGuid, itemName);
				}
				else if (childNodeIterator.Current.Name == QSetQueueItem.TypeName)
				{
					//create queue
					if (itemGuid == Guid.Empty)
						newItem = new QSetQueueItem(itemName);
					else
						newItem = new QSetQueueItem(itemGuid, itemName);
					if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "") != string.Empty)
						((QSetQueueItem)newItem).MessageViewerXslt = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "");
				}
				else if (childNodeIterator.Current.Name == QSetWebServiceItem.TypeName)
				{
					//web service item
					if (itemGuid == Guid.Empty)
						newItem = new QSetWebServiceItem(itemName);
					else
						newItem = new QSetWebServiceItem(itemGuid, itemName);
				}
			
				//apply finaly settings and actions to new item
				if (newItem != null)
				{
					//finish type specific setup
					if (newItem is QSetFolderItem)
					{
						//create child items
						CreateChildItems((QSetFolderItem)newItem, childNodeIterator);
					}

					//final setup common to all item types
					parentItem.ChildItems.Add(newItem);
					newItem.IsDirty = false;			
				}		
			}
		}
コード例 #4
0
ファイル: QSetMonitor.cs プロジェクト: modulexcite/QSet
			/// <summary>
			/// Recurses the Q Set, getting queue information
			/// </summary>
			/// <param name="parentItem"></param>
			/// <param name="subscribeToEvents"></param>
			private void RecurseQSet(QSetFolderItem parentItem, bool subscribeToEvents)
			{
				//subscribe to folders events if necessary
				if (subscribeToEvents)
				{
					parentItem.ChildItems.AfterItemAdded += new AfterItemAddedEvent(ChildItems_AfterItemAdded);
					parentItem.ChildItems.BeforeItemRemoved += new BeforeItemRemovedEvent(ChildItems_BeforeItemRemoved);
				}

				//query all children of the parent
				foreach (QSetItemBase item in parentItem.ChildItems)
				{
					if (_isStopRequested)
						break;

					//monitor the queue, or query the folders children
					if (item is QSetQueueItem)
						CountQueueMessages(((QSetQueueItem)item));
					else if (item is QSetFolderItem)
						RecurseQSet((QSetFolderItem)item, subscribeToEvents);					
				}
			}
コード例 #5
0
ファイル: QSetExplorer.cs プロジェクト: modulexcite/QSet
		/// <summary>
		/// Recursively adds child nodes to a node.
		/// </summary>
		/// <param name="parentItem">Parent folder item.</param>
		/// <param name="parentNode">Parent node.</param>
		public void CreateChildNodes(QSetFolderItem parentFolderItem, TreeNode parentNode)
		{
			foreach (QSetItemBase item in parentFolderItem.ChildItems)
			{
				QSetItemTreeNode itemNode = new QSetItemTreeNode(item);
				parentNode.Nodes.Add((TreeNode)itemNode);

				if (item is QSetFolderItem)
					CreateChildNodes((QSetFolderItem)item, itemNode);
			}
		}
コード例 #6
0
ファイル: TaskManager.cs プロジェクト: modulexcite/QSet
		/// <summary>
		/// Adds a new folder to the Q Set.
		/// </summary>
		public void AddNewFolderToQSet()
		{
			if (_primaryControls.QSetExplorer.ActiveItem != null)
			{
				QSetFolderItem folderItem = _primaryControls.QSetExplorer.ActiveItem as QSetFolderItem;
				if (folderItem != null)
				{
					QSetFolderItem newFolderItem = new QSetFolderItem(GetNextAvailableNewItemName("New Folder", folderItem.ChildItems));
					folderItem.ChildItems.Add(newFolderItem);							
					_primaryControls.QSetExplorer.BeginEditActiveItem();
				}
			}
		}
コード例 #7
0
        /// <summary>
        /// Recursively creates all of the child items of a Q Set item.
        /// </summary>
        /// <param name="parentItem">Parent item.</param>
        /// <param name="parentNodeIterator">XPathNodeIterator positioned at the parent item. </param>
        private static void CreateChildItems(QSetFolderItem parentItem, XPathNodeIterator parentNodeIterator)
        {
            //iterate through all child items
            XPathNodeIterator childNodeIterator = parentNodeIterator.Current.Select("*");

            while (childNodeIterator.MoveNext())
            {
                //get the item details
                string itemName = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, "");
                Guid   itemGuid = Guid.Empty;
                if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "") != string.Empty)
                {
                    itemGuid = new Guid(childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, ""));
                }

                //create a new item of the required type, specifying the guid if available
                QSetItemBase newItem = null;
                if (childNodeIterator.Current.Name == QSetFolderItem.TypeName)
                {
                    //create folder
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetFolderItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetFolderItem(itemGuid, itemName);
                    }
                }
                else if (childNodeIterator.Current.Name == QSetMachineItem.TypeName)
                {
                    //create machine
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetMachineItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetMachineItem(itemGuid, itemName);
                    }
                }
                else if (childNodeIterator.Current.Name == QSetQueueItem.TypeName)
                {
                    //create queue
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetQueueItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetQueueItem(itemGuid, itemName);
                    }
                    if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "") != string.Empty)
                    {
                        ((QSetQueueItem)newItem).MessageViewerXslt = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "");
                    }
                }
                else if (childNodeIterator.Current.Name == QSetWebServiceItem.TypeName)
                {
                    //web service item
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetWebServiceItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetWebServiceItem(itemGuid, itemName);
                    }
                }

                //apply finaly settings and actions to new item
                if (newItem != null)
                {
                    //finish type specific setup
                    if (newItem is QSetFolderItem)
                    {
                        //create child items
                        CreateChildItems((QSetFolderItem)newItem, childNodeIterator);
                    }

                    //final setup common to all item types
                    parentItem.ChildItems.Add(newItem);
                    newItem.IsDirty = false;
                }
            }
        }
コード例 #8
0
ファイル: QSetItemCollection.cs プロジェクト: wushian/QSet
 /// <summary>
 /// Constructs an empty QSetItemCollection, specifying an owner item.
 /// </summary>
 /// <param name="ownerItem">The item which owns the collection.</param>
 public QSetItemCollection(QSetFolderItem ownerItem)
 {
     OwnerItem = ownerItem;
 }
コード例 #9
0
		/// <summary>
		/// Constructs an empty QSetItemCollection, specifying an owner item.
		/// </summary>
		/// <param name="ownerItem">The item which owns the collection.</param>
		public QSetItemCollection(QSetFolderItem ownerItem) 
		{
			OwnerItem = ownerItem;
		}