/// <summary> /// Gets the current dependencies of the package. /// </summary> /// <param name="package">The package.</param> /// <returns>a list of the current package dependencies</returns> private static DependingPackageList CurrentDependencies(Package package) { ProgressInfo.Info = Resources.stateListConnectors; DependingPackageList dpList = new DependingPackageList(); List <Connector> connectors = Manipulation.GetAllPackageConnectors(package); ProgressInfo.Reset(Resources.stateSearchCurDep, 0, connectors.Count); foreach (Connector connector in connectors) { ProgressInfo.Next(); if (connector.Stereotype.Equals(appSettings.Stereotype)) { Element clientPackage = pRepository.GetElementByID(connector.ClientID); Element supplierPackage = pRepository.GetElementByID(connector.SupplierID); //string client = connector.ClientID.ToString(); //string supplier = connector.SupplierID.ToString(); if ((supplierPackage != null) && (clientPackage != null)) { if (clientPackage.ElementID != supplierPackage.ElementID) { if (!dpList.IsInList(supplierPackage.ElementID, clientPackage.ElementID)) { dpList.AddNew(supplierPackage, clientPackage, connector.Direction, connector); } } } } } ProgressInfo.Reset(); return(dpList); }
/// <summary> /// Deletes all Package Dependencies from the Repository /// </summary> /// <param name="repository"></param> /// <param name="package"></param> /// <exception cref="NotImplementedException"></exception> public static void DeleteDependenciesFromModel(Repository repository, Package package) { List <Package> allPackages = Manipulation.GetAllPackages(repository); List <Connector> allPackageConnectors = new List <Connector>(); foreach (var thePackage in allPackages) { allPackageConnectors.AddRange(Manipulation.GetAllPackageConnectors(thePackage)); } IEnumerable <Connector> affectedConnectors = allPackageConnectors.Where(con => con.Stereotype.Equals(appSettings.Stereotype)); foreach (Connector packageConnector in affectedConnectors) { repository.Execute("DELETE FROM t_connector WHERE Connector_ID =" + packageConnector.ConnectorID + ";"); repository.Execute("DELETE FROM t_diagramlinks WHERE ConnectorID =" + packageConnector.ConnectorID + ";"); } List <Diagram> allDiagrams = Manipulation.GetAllDiagrams(package); foreach (Diagram theDiagram in allDiagrams) { if (theDiagram.Stereotype == "generated") { theDiagram.Update(); foreach (DiagramObject diagramObj in theDiagram.DiagramObjects) { diagramObj.Update(); } theDiagram.Update(); //If diagram open than close and open if (repository.IsTabOpen(theDiagram.Name) != 0) { repository.CloseDiagram(theDiagram.DiagramID); repository.OpenDiagram(theDiagram.DiagramID); } } } }