/// <summary> /// Check if exists one amplied zone that has the PDM passed and our group associated. /// </summary> /// <param name="pdm">PDM to search for amplied zone</param> /// <returns>ID of the amplied zone or -1 if no amplied zone is found.</returns> protected int CheckForAmpliedZone(int pdm) { CmpStatus cmps = new CmpStatus(); UnorderedTree tree = null; // Build the logical tree of the pdm ArrayList ar = cmps.GetUnitTree(pdm, true, false, out tree); // Now search for ar, searching for our group. If we found and is a amplied zone that means that exists // an amplied zone containing both: our group, and the pdm. foreach (object o in ar) { CmpStatus.StatusTreeItem titem = ((CmpStatus.StatusTreeItem)((UnorderedTree.TreeItem)o).Data); if (titem.IsGroup && titem.Id == _grpid && titem.IdType == _ampliedZoneTypeId) { return(titem.Id); } } return(-1); }
/// <summary> /// Constructs a new CmpConstraints /// </summary> /// <param name="constraintId">ID of the constraint to check</param> /// <param name="groups">ArrayList of all groups (sorted by PHY_ORDER)</param> /// <param name="treeGroups">Tree of all groups. The parameter group MUST be obtained by calling ToArrayList() method /// of that parameter.</param> public CmpConstraints(int constraintId, ArrayList groups, UnorderedTree treeGroups) { _conid = constraintId; _lstGroups = groups; // ArrayList of UnorderedTree::TreeItem with CmpStatus::StatusTreeItem objects in Data property _treeGroups = treeGroups; // Tree from which _lstGroups was obtained. }
/// <summary> /// Get the list of all parent (and parent types) of the group or unit specified by groupid /// </summary> /// <param name="groupId">ID of the group</param> /// <param name="isUnit">true if groupId is a ID of a UNIT instead a ID of a GROUP</param> /// <param name="searchPhyGroups">If true, only physical groups (DGRP_PHYORDER NOT NULL) will be searched</param> /// <param name="tree">Out parameter containing the tree of GROUP with groupId and ALL HIS parents</param> /// <returns>An ArrayList of OTS.Framework.Collection.UnorderedTree::TreeItem objects. /// Each item of ArrayList contains a CmpStatus::StatusTreeItem object in its Data property</returns> public ArrayList GetUnitTree(int groupId, bool isUnit, bool searchPhyGroups, out UnorderedTree tree) { tree = null; // Find the group type and physical order for the passed groupId int groupDefId = -1; int groupDefPhyorder = -1; CmpGroupsDefDB gddb = new CmpGroupsDefDB(); DataTable dtgd = gddb.GetGroupDefByGroup(groupId); if (dtgd.Rows.Count > 0) { groupDefId = Convert.ToInt32(dtgd.Rows[0]["DGRP_ID"]); groupDefPhyorder = Convert.ToInt32(dtgd.Rows[0]["DGRP_PHYORDER"]); } StatusTreeItem item = new StatusTreeItem(groupId, groupDefId, groupDefPhyorder, false, isUnit); GetUnitTree(item, null, ref tree, searchPhyGroups); ArrayList list = tree.ToArrayList(new UnorderedTree.OrderItemDelegate(CompareStatusTreeItems)); // At that point we have the list the groupId and ALL his parents. Now we have to put the GROUPS_DEF // items in the list (such as <sectores> or <zonas>,... (the list must have at least two elements: groupId and // his parent) StatusTreeItem itemAnt = null; StatusTreeItem itemAct = null; if (list.Count > 1) { itemAnt = (StatusTreeItem)((UnorderedTree.TreeItem)list[0]).Data; for (int i = 1; i < list.Count; i++) { itemAct = (StatusTreeItem)((UnorderedTree.TreeItem)list[i]).Data; if (itemAnt.IdType != itemAct.IdType && !itemAnt.IsUnit) { // We must insert a new item AFTER itemAnt // (for example list[i-1] is a Zona and list[i] is a Sector, so we have to add // a <Zona> element in middle of both StatusTreeItem toInsert = new StatusTreeItem(-1, itemAnt.IdType, itemAnt.PhyOrder, true, false); // In order for consistency insert the StatusTreeItem in the tree. The item is inserted // as an Orphan item, because there is not really a parent-child relation... UnorderedTree.TreeItem titem = tree.Add(toInsert); // For consistency again: Insert a UnorderedTree::TreeItem in the list // instead of a StatusTreeItem. Of course tha UnorderedTree::TreeItem inserted // will have only a StatusTreeItem object (in its data property) list.Insert(i, titem); i++; // just skip the new element } itemAnt = (StatusTreeItem)((UnorderedTree.TreeItem)list[i]).Data; } } // Add the final GROUPS_DEF item (the GROUPS_DEF item corresponding to the last element) item = (StatusTreeItem)((UnorderedTree.TreeItem)list[list.Count - 1]).Data; if (item.IsGroup) // item must be a group, nor a type or unit { StatusTreeItem toInsert = new StatusTreeItem(-1, item.IdType, item.PhyOrder, true, false); // Insert the last item in the tree AND in the list UnorderedTree.TreeItem titem = tree.Add(toInsert); list.Add(titem); } return(list); }
/// <summary> /// Get the list of all parent (and parent types) of the group or unit specified by groupid. /// NOTE: Only physical groups are searched! /// </summary> /// <param name="groupId">ID of the group</param> /// <param name="isUnit">true if groupId is a ID of a UNIT instead a ID of a GROUP</param> /// <param name="tree">Out parameter containing the tree of GROUP with groupId and ALL HIS parents</param> /// <returns>An ArrayList of OTS.Framework.Collection.UnorderedTree::TreeItem objects. /// Each item of ArrayList contains a CmpStatus::StatusTreeItem object in its Data property</returns> public ArrayList GetUnitTree(int groupId, bool isUnit, out UnorderedTree tree) { return(GetUnitTree(groupId, isUnit, true, out tree)); }