Ejemplo n.º 1
0
        /// <summary>
        /// Method to add items to a ALM customList
        /// </summary>
        /// <param name="oriCustomListNode">Original CustomListNode where will be add new items</param>
        /// <param name="currentCustomListNode">CustomListNode where the items are taken to save them to the original customList</param>
        /// <returns>Returns the message of the performed operations</returns>
        private string AddItemsToList(CustomizationListNode oriCustomListNode, CustomizationListNode currentCustomListNode)
        {
            string message = "";
            for (int i = 0; i < oriCustomListNode.ChildrenCount; i++)
            {
                CustomizationListNode customGrandChild = null;
                List oriChildList = new List();
                List currentChildList = new List();
                oriChildList = oriCustomListNode.Children;
                currentChildList = currentCustomListNode.Children;

                //Get the original ChildListNode
                CustomizationListNode oriChildListNode = (CustomizationListNode)oriChildList[i + 1];

                if (oriChildListNode.ChildrenCount > 0) //If the child has grandchildren
                {
                    if (!ExistsCustomListNode(oriChildListNode.Name, currentCustomListNode)) //If the item doesn't exist
                    {
                        currentCustomListNode.AddChild(oriChildListNode.Name);
                        customGrandChild = (CustomizationListNode)currentCustomListNode.get_Child(oriChildListNode.Name);

                        AddItemsToList(oriChildListNode, customGrandChild);
                        message += "\t \t \t \t \t Item '" + oriChildListNode.Name + "' added to List '" + oriCustomListNode.Name + "'" + Environment.NewLine;
                    }
                }
                else // If child has no more children
                {
                    if (!ExistsCustomListNode(oriChildListNode.Name, currentCustomListNode)) //If the item doesn't exist
                    {
                        currentCustomListNode.AddChild(oriChildListNode.Name);
                        message += "\t \t \t \t \t Item '" + oriChildListNode.Name + "' added to List '" + oriCustomListNode.Name + "'" + Environment.NewLine;
                    }
                }
            }

            return message;
        }