/// <summary> /// Delete undefined Reference (former ExternalReference).The element subtype is "1001". It searches for /// </summary> /// <returns></returns> /// Search for External references /// Select ea_guid As CLASSGUID, object_type As CLASSTYPE,ea_GUID As el_guid, name As el_name, * from t_object o where NType=1001 private static void DeleteUndefinedReference(EA.Repository repository, EA.Element el, Boolean dialog = true, Boolean completePackage = false) { //if (el.Type.Equals("Boundary")) if (el.Subtype == 1001 && completePackage == false) { EA.Package pkg = repository.GetPackageByID(el.PackageID); // Not version controlled, checked out to this user int versionControlState = pkg.VersionControlGetStatus(); if (versionControlState == 0 || versionControlState == 2) { // delete External Reference for (short idx = (short)(pkg.Elements.Count - 1); idx >= 0; idx--) { if ((el.ElementID == ((EA.Element)pkg.Elements.GetAt(idx)).ElementID) || (completePackage && el.Subtype == 1001)) { // with or without dialog try { if (dialog) { DialogResult res = MessageBox.Show("Delete element '" + el.Name + "'", "Delete element", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { pkg.Elements.DeleteAt(idx, false); if (completePackage == false) { break; } } } else { pkg.Elements.DeleteAt(idx, false); if (completePackage == false) { break; } } } catch { } } } pkg.Update(); } else { string s = String.Format("Delete element '{0}' Version control state={1} not possible!", el.Name, versionControlState); MessageBox.Show(s, "Package can't be changed, checked in?, break;"); } } return; }
public static string GetVCstate(EA.Package pkg, Boolean isLong) { long state = 0; string[] checkedOutStatusLong = { "Uncontrolled", "Checked in", "Checked out to this user", "Read only version", "Checked out to another user", "Offline checked in", "Offline checked out by user", "Offline checked out by other user", "Deleted" }; string[] checkedOutStatusShort = { "Uncontrolled", "Checked in", "Checked out", "Read only", "Checked out", "Offline checked in", "Offline checked out", "Offline checked out", "Deleted" }; try { state = pkg.VersionControlGetStatus(); } catch (Exception e) { if (isLong) { return("VC State Error: " + e.Message); } else { return("State Error"); } } if (isLong) { return(checkedOutStatusLong[state]); } else { return(checkedOutStatusShort[state]); } }