本文整理汇总了C#中EA.GetPackageByID方法的典型用法代码示例。如果您正苦于以下问题:C# EA.GetPackageByID方法的具体用法?C# EA.GetPackageByID怎么用?C# EA.GetPackageByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EA
的用法示例。
在下文中一共展示了EA.GetPackageByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBranch
/// <summary>
/// Get list of package ids as comma separated list
/// </summary>
/// <param name="rep"></param>
/// <param name="branch"></param>
/// <param name="id"></param>
/// <returns></returns>
public static string GetBranch (EA.Repository rep, string branch, int id)
{
if (id > 0)
{
// add current package id
if (branch == "") branch = id.ToString();
else branch = branch + ", " + id;
EA.Package pkg = rep.GetPackageByID(id);
foreach (EA.Package p in pkg.Packages)
{
int pkgId = p.PackageID;
string s = pkgId.ToString();
branch = GetBranch(rep, branch, pkgId);
}
}
return branch;
}
示例2: CreateActivityForOperation
//--------------------------------------------------------------------------------
// createActivityForOperation
//--------------------------------------------------------------------------------
// Create an Activity Diagram for the operation
public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos=100)
{
// get class
EA.Element elClass = rep.GetElementByID(m.ParentID);
EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID);
// create a package with the name of the operation
var pkgTrg = (EA.Package)pkgSrc.Packages.AddNew(m.Name, "");
pkgTrg.TreePos = treePos;
pkgTrg.Update();
pkgSrc.Packages.Refresh();
EA.Element frame = null; // frame beneath package
if (ActivityIsSimple == false)
{
// create Class Activity Diagram in target package
var pkgActDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Activity");
pkgActDia.Update();
pkgTrg.Diagrams.Refresh();
// add frame in Activity diagram
var frmObj = (EA.DiagramObject)pkgActDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
frame = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
frame.Update();
frmObj.ElementID = frame.ElementID;
//frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
frmObj.Update();
pkgTrg.Elements.Refresh();
pkgActDia.DiagramObjects.Refresh();
}
// create activity with the name of the operation
var act = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Activity");
if (ActivityIsSimple == false)
{
act.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
}
act.StereotypeEx = m.StereotypeEx;
act.Update();
pkgTrg.Elements.Refresh();
// create activity diagram beneath Activity
var actDia = (EA.Diagram)act.Diagrams.AddNew(m.Name, "Activity");
// update diagram properties
actDia.ShowDetails = 0; // hide details
// scale page to din A4
actDia.StyleEx = actDia.StyleEx.Length > 0 ? actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1") : "HideQuals=1;";
// Hide Qualifier
actDia.ExtendedStyle = actDia.ExtendedStyle.Length > 0 ? actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1") : "ScalePI=1;";
actDia.Update();
act.Diagrams.Refresh();
// put the activity on the diagram
Util.AddSequenceNumber(rep, actDia);
var actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", "");
actObj.ElementID = act.ElementID;
actObj.Sequence = 1;
actObj.Update();
Util.SetSequenceNumber(rep, actDia, actObj, "1");
actDia.DiagramObjects.Refresh();
// add default nodes (init/final)
CreateDefaultElementsForActivity(rep, actDia, act);
if (ActivityIsSimple == false)
{
// Add Heading to diagram
Util.AddSequenceNumber(rep, actDia);
var noteObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=40;r=700;t=25;b=50", "");
var note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");
note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
note.Update();
noteObj.ElementID = note.ElementID;
noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
noteObj.Sequence = 1;
noteObj.Update();
Util.SetSequenceNumber(rep, actDia, noteObj, "1");
}
pkgTrg.Elements.Refresh();
actDia.DiagramObjects.Refresh();
// Link Operation to activity
Util.SetBehaviorForOperation(rep, m, act);
// Set show behavior
Util.SetShowBehaviorInDiagram(rep, m);
// add parameters to activity
UpdateParameterFromOperation(rep, act, m);
int pos = 0;
foreach (EA.Element actPar in act.EmbeddedElements)
//.........这里部分代码省略.........
示例3: EA_OnPostNewPackage
public Boolean EA_OnPostNewPackage(EA.Repository repository, EA.EventProperties info)
{
EA.Package package = repository.GetPackageByID(IDcollect(repository, info));
MessageBox.Show("NEW PACKAGE CREATED");
return true;
}
示例4: DoRule12
private void DoRule12(EA.Repository Repository, EA.Attribute Attribute)
{
if (Attribute.Stereotype == "XisEntityAttribute")
{
if (string.IsNullOrEmpty(Attribute.Type))
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12));
isValid = false;
}
else
{
bool primitive = false;
switch (Attribute.Type.ToLower())
{
case "int":
case "integer":
case "double":
case "float":
case "long":
case "short":
case "char":
case "string":
case "bool":
case "boolean":
case "byte":
case "date":
case "time":
case "image":
case "url":
primitive = true;
break;
default:
break;
}
if (!primitive)
{
EA.Package package = Repository.GetPackageByID(Repository.GetElementByID(Attribute.ParentID).PackageID);
EA.Element el = null;
bool exists = false;
for (short i = 0; i < package.Elements.Count; i++)
{
el = package.Elements.GetAt(i);
if (el.Name == Attribute.Type && (el.Stereotype == "XisEntity" || el.Stereotype == "XisEnumeration"))
{
exists = true;
break;
}
}
if (!exists)
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12));
isValid = false;
}
}
}
}
}
示例5: DoRule87
private void DoRule87(EA.Repository Repository, EA.Method method)
{
if (method.Stereotype == "XisAction")
{
string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value;
if (type == "Navigate")
{
string navigation = M2MTransformer.GetMethodTag(method.TaggedValues, "navigation").Value;
if (!string.IsNullOrEmpty(navigation))
{
EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID);
EA.Package interaction = null;
if (model.StereotypeEx == "InteractionSpace View")
{
interaction = model;
}
if (interaction != null)
{
EA.Element el = null;
bool exists = false;
for (short i = 0; i < interaction.Elements.Count; i++)
{
el = interaction.Elements.GetAt(i);
if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace" && el.Name == navigation)
{
exists = true;
break;
}
}
if (!exists)
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
}
}
示例6: insertCDE
public static void insertCDE(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.dataelement de, EAUtil.INSERT_XSD_TYPE xsdType)
{
try
{
string id = de.names.id;
string name = de.names.preferred;
string definition = QueryServiceControl.QueryServiceControl.getDefinition(de.definition);
EA.Package package = m_Repository.GetPackageByID(m_Repository.GetCurrentDiagram().PackageID);
EA.Element o = (EA.Element)package.Elements.AddNew(name.Replace(" ", "_"), "Class");
o.Notes = definition + " (ID: " + id + ")";
EAUtil.addTaggedValue("CDERef", id, o);
EAUtil.addTaggedValue("preferred name", name, o);
if (package.StereotypeEx == "XSDschema")
{
if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ELEMENT)
{
o.Stereotype = "XSDtopLevelElement";
}
else if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ATTRIBUTE)
{
o.Stereotype = "XSDtopLevelAttribute";
}
}
if (de.values != null && de.values.Item is QueryServiceControl.QueryServiceManager.nonenumerated)
{
string dataType = (de.values.Item as QueryServiceControl.QueryServiceManager.nonenumerated).datatype;
if (dataType.StartsWith("xs:"))// || dataType.StartsWith("xsd:"))
{
//o.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";";
string simpleTypeClassName = name.Replace(" ", "_") + "_Type";
EA.Element simpleTypeClass = (EA.Element)package.Elements.AddNew(simpleTypeClassName, "Class");
simpleTypeClass.Stereotype = "XSDsimpleType";
simpleTypeClass.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";";
simpleTypeClass.Update();
simpleTypeClass.Refresh();
EA.DiagramObject simpleTypeDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", ""));
simpleTypeDiag.ElementID = simpleTypeClass.ElementID;
simpleTypeDiag.Update();
EA.Connector simpleTypeConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization");
simpleTypeConnector.SupplierID = simpleTypeDiag.ElementID;
simpleTypeConnector.Update();
o.Connectors.Refresh();
}
else
{
o.Genlinks = "Parent=" + dataType + ";";
}
}
else if (de.values != null && de.values.Item is QueryServiceControl.QueryServiceManager.enumerated)
{
string enumClassName = "Enum_" + name.Replace(" ", "_");
EA.Element enumClass = (EA.Element)package.Elements.AddNew(enumClassName, "Class");
enumClass.Stereotype = "enumeration";
enumClass.Genlinks = "Parent=string;";
QueryServiceControl.QueryServiceManager.enumerated en =
de.values.Item as QueryServiceControl.QueryServiceManager.enumerated;
foreach (QueryServiceControl.QueryServiceManager.validvalue vv in en.validvalue)
{
EA.Attribute at = (EA.Attribute)enumClass.Attributes.AddNew("", "");
at.Stereotype = "enum";
at.Name = vv.code;
at.Notes = QueryServiceControl.QueryServiceControl.getMeaning(vv.meaning);
at.Update();
}
enumClass.Attributes.Refresh();
EA.DiagramObject enumDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", ""));
enumDiag.ElementID = enumClass.ElementID;
enumDiag.Update();
EA.Connector enumConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization");
enumConnector.SupplierID = enumDiag.ElementID;
enumConnector.Update();
o.Connectors.Refresh();
enumClass.Update();
enumClass.Refresh();
}
//attr.Update();
//o.Attributes.Refresh();
o.Update();
o.Refresh();
EA.DiagramObject diagram = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", ""));
diagram.ElementID = o.ElementID;
diagram.Update();
m_Repository.ReloadDiagram(diagram.DiagramID);
//this.Close();
//.........这里部分代码省略.........
示例7: sendDataAboutModel
/// <summary>
/// method sends all data about model
/// </summary>
/// <param name="sendingDataWindow">window for data sending</param>
/// <param name="repository">EA repository</param>
public void sendDataAboutModel(SendingDataWindow sendingDataWindow, EA.Repository repository)
{
try
{
using (WebClient webClient = new WebClient())
{
using (var stream = webClient.OpenRead(Utils.serviceAddress))
{
stream.Close();
this.sendingDataWindow = sendingDataWindow;
ChangeService.newEvent.Set();
changeModelGUID(repository);
modelTraverse.sendDataAboutModel(repository);
ScenarioChange propertyChange = new ScenarioChange();
propertyChange.modelGUID = repository.GetPackageByID(1).PackageGUID;
propertyChange.elementType = 777;
modelTraverse.saveCreate(propertyChange, repository);
user = getLoggedUser();
modelInformation = new ModelInformation();
modelInformation.modelGUID = repository.GetPackageByID(1).PackageGUID;
modelInformation.token = user.token;
timer = new System.Timers.Timer();
timer.Elapsed += new System.Timers.ElapsedEventHandler(checkLastCreate);
timer.Interval = 5000;
timer.Start();
}
}
}
catch (Exception e)
{
MessageBox.Show("Server is unavailable. Check your internet connection.");
}
}
示例8: newversion
public void newversion(EA.Repository Repository)
{
Form3 form = new Form3();
form.ShowDialog();
if (form.confirm == 1)
{
this.encours = false;
int packageid = 0;
int packversionid = 0;
EA.Package pack0 = Repository.Models.GetAt(0);
foreach (EA.Package package in pack0.Packages)
{
foreach (EA.Package pack in package.Packages)
{
packageid = pack.PackageID;
}
}
pack0 = Repository.GetPackageByID(packageid);
foreach (EA.Package packversion in pack0.Packages)
{
if (packversion.Name == "Version")
packversionid = packversion.PackageID;
}
if (packversionid == 0)
{
EA.Collection collec = pack0.Packages;
EA.Package packversion = collec.AddNew("Version", "Package");
packversion.Update();
collec.Refresh();
pack0.Update();
packversionid = packversion.PackageID;
}
EA.Collection newversion = Repository.GetPackageByID(packversionid).Elements;
EA.Element version = newversion.AddNew("Version" + form.number.Text, "Class");
EA.Collection newversionattributes = version.Attributes;
EA.Attribute att = newversionattributes.AddNew("number", "char");
att.Default = form.number.Text;
att.Pos = 1;
att.Update();
att = newversionattributes.AddNew("date", "char");
att.Default = form.Date.Text;
att.Pos = 2;
att.Update();
att = newversionattributes.AddNew("author", "char");
att.Default = form.author.Text;
att.Pos = 3;
att.Update();
att = newversionattributes.AddNew("changes", "char");
att.Default = form.Changes.Text;
att.Pos = 4;
att.Update();
att = newversionattributes.AddNew("status", "char");
att.Default = form.Status.Text;
att.Pos = 5;
att.Update();
newversionattributes.Refresh();
version.Update();
newversion.Refresh();
Repository.RefreshModelView(packversionid);
}
this.encours = true;
}
示例9: newterm
public void newterm(EA.Repository Repository)
{
Form4 form = new Form4();
form.ShowDialog();
if (form.confirm == 1)
{
this.encours = false;
int packageid = 0;
int packtermid = 0;
EA.Package pack0 = Repository.Models.GetAt(0);
foreach (EA.Package package in pack0.Packages)
{
foreach (EA.Package pack in package.Packages)
{
packageid = pack.PackageID;
}
}
pack0 = Repository.GetPackageByID(packageid);
foreach (EA.Package packterm in pack0.Packages)
{
if (packterm.Name == "Terms")
packtermid = packterm.PackageID;
}
if (packtermid == 0)
{
EA.Collection collec = pack0.Packages;
EA.Package packterm = collec.AddNew("Terms", "Package");
packterm.Update();
collec.Refresh();
pack0.Update();
packtermid = packterm.PackageID;
}
EA.Collection newterm = Repository.GetPackageByID(packtermid).Elements;
EA.Element term = newterm.AddNew(form.Term.Text, "Class");
EA.Collection newtermattributes = term.Attributes;
EA.Attribute att = newtermattributes.AddNew("term", "char");
att.Default = form.Term.Text;
att.Pos = 1;
att.Update();
att = newtermattributes.AddNew("definition", "char");
att.Default = form.Definition.Text;
att.Pos = 2;
att.Update();
newtermattributes.Refresh();
term.Update();
newterm.Refresh();
Repository.RefreshModelView(packtermid);
}
this.encours = true;
}
示例10: ping
public void ping(string GUID, EA.Repository repository)
{
if (!active.ContainsKey(GUID))
{
return;
}
foreach (RuleEntry ruleEntry in active[GUID]) {
ruleEntry.actions++;
DefectReport defectReport = new DefectReport();
defectReport.modelGUID = repository.GetPackageByID(1).PackageGUID;
defectReport.ruleGUID = ruleEntry.GUID;
defectReport.ruleName = ruleEntry.name;
defectReport.actionsBeforeCorrection = ruleEntry.actions;
defectReportService.saveReport(defectReport);
}
}
示例11: newscenario
public void newscenario(EA.Repository Repository)
{
Form10 form = new Form10();
form.ShowDialog();
if (form.confirm == 1)
{
this.encours = false;
int packageid = 0;
int packscenarioid = 0;
EA.Package pack0 = Repository.Models.GetAt(0);
foreach (EA.Package package in pack0.Packages)
{
foreach (EA.Package pack in package.Packages)
{
packageid = pack.PackageID;
}
}
pack0 = Repository.GetPackageByID(packageid);
foreach (EA.Package packscenario in pack0.Packages)
{
if (packscenario.Name == "Scenarios")
packscenarioid = packscenario.PackageID;
}
EA.Collection newscenario = Repository.GetPackageByID(packscenarioid).Elements;
EA.Element scenario = newscenario.AddNew(form.Name.Text, "Use Case");
scenario.Stereotype = "Scenario";
scenario.Update();
EA.Collection newscenarios = scenario.Scenarios;
EA.Scenario sc = newscenarios.AddNew(form.Name.Text, "Basic Path");
sc.Update();
newscenarios.Refresh();
newscenario.Refresh();
Repository.OpenElementPropertyDlg(scenario.ElementID);
}
this.encours = true;
}
示例12: deletePackage
/// <summary>
/// method deletes package
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="packageGUID">GUID of package that should be deleted</param>
public void deletePackage(EA.Repository Repository, string packageGUID)
{
EA.Package packageToDelete = (EA.Package)Repository.GetPackageByGuid(packageGUID);
string name = packageToDelete.Name;
EA.Package parentPackage = (EA.Package)Repository.GetPackageByID(packageToDelete.ParentID);
for (short i = 0; i < parentPackage.Packages.Count; i++)
{
EA.Package actualPackage = (EA.Package)parentPackage.Packages.GetAt(i);
if (actualPackage.PackageGUID == packageGUID)
{
parentPackage.Packages.DeleteAt(i, false);
break;
}
}
parentPackage.Packages.Refresh();
BPAddIn.synchronizationWindow.addToList("Deletion of package '" + name + "' from package '" + parentPackage.Name + "'");
}
示例13: deleteElement
/// <summary>
/// method deletes element
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="elementGUID">GUID of element that should be deleted</param>
/// <param name="elementType">type of element that should be deleted</param>
public void deleteElement(EA.Repository Repository, string elementGUID, int elementType)
{
EA.Element elementToDelete = (EA.Element)Repository.GetElementByGuid(elementGUID);
string name = elementToDelete.Name;
int packageID = elementToDelete.PackageID;
int parentID = elementToDelete.ParentID;
EA.Collection elements;
if (elementToDelete.ParentID == 0)
{
elements = (EA.Collection)Repository.GetPackageByID(elementToDelete.PackageID).Elements;
}
else
{
elements = (EA.Collection)Repository.GetElementByID(elementToDelete.ParentID).Elements;
}
for (short i = 0; i < elements.Count; i++)
{
EA.Element actualElement = (EA.Element)elements.GetAt(i);
if (actualElement.ElementGUID == elementGUID)
{
elements.DeleteAt(i, false);
break;
}
}
elements.Refresh();
BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '"
+ name + "' (Previous location of element: " +
itemTypes.getLocationOfItem(Repository, packageID, parentID));
}
示例14: deleteDiagram
/// <summary>
/// method deletes diagram
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="diagramGUID">GUID of diagram that should be deleted</param>
/// <param name="elementType">type of diagram that should be deleted</param>
public void deleteDiagram(EA.Repository Repository, string diagramGUID, int elementType)
{
EA.Diagram diagramToDelete = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);
string name = diagramToDelete.Name;
int packageID = diagramToDelete.PackageID;
int parentID = diagramToDelete.ParentID;
EA.Collection diagrams;
if (diagramToDelete.ParentID == 0)
{
diagrams = (EA.Collection)Repository.GetPackageByID(diagramToDelete.PackageID).Diagrams;
}
else
{
diagrams = (EA.Collection)Repository.GetElementByID(diagramToDelete.ParentID).Diagrams;
}
for (short i = 0; i < diagrams.Count; i++)
{
EA.Diagram actualDiagram = (EA.Diagram)diagrams.GetAt(i);
if (actualDiagram.DiagramGUID == diagramGUID)
{
diagrams.DeleteAt(i, false);
break;
}
}
diagrams.Refresh();
BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '" +
name + "' (Previous location of diagram: " +
itemTypes.getLocationOfItem(Repository, packageID, parentID));
}
示例15: getLocationOfItem
public string getLocationOfItem(EA.Repository repository, int packageID, int parentID)
{
EA.Package parentPackage = (EA.Package)repository.GetPackageByID(packageID);
if (parentID == 0)
{
return " package '" + parentPackage.Name + "')";
}
else
{
EA.Element parentElement = (EA.Element)repository.GetElementByID(parentID);
return " element '" + parentElement.Name + "' in package '" + parentPackage.Name + "')";
}
}