void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { // 選択された属性に対する更新処理 if (selectedAttribute != null) { EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid); if (attr != null) { repo.ShowInProjectView(attr); } else { // 属性がGUIDで空振りしたら要素GUIDで再検索 EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem != null) { repo.ShowInProjectView(elem); } } } // 選択された操作に対する更新処理 if (selectedMethod != null) { EA.Method mth = (EA.Method)repo.GetMethodByGuid(selectedMethod.guid); if (mth != null) { repo.ShowInProjectView(mth); } else { // 操作がGUIDで空振りしたら要素GUIDで再検索 EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem != null) { repo.ShowInProjectView(elem); } } } } else { MessageBox.Show("EAにアタッチしていないため、選択できません"); } }
public bool EA_OnContextItemDoubleClicked(EAAPI.Repository repository, string guid, EAAPI.ObjectType objectType) { bool result = false; if (objectType == EAAPI.ObjectType.otElement) { EAAPI.Element element = repository.GetElementByGuid(guid); ViewModelBase viewModel = null; viewModel = GetEditorViewModel(repository, element); if (viewModel != null) { FMCElementPropertyWindow newAgentWindow = new FMCElementPropertyWindow(); newAgentWindow.DataContext = viewModel; newAgentWindow.ShowDialog(); repository.AdviseElementChange(element.ElementID); result = true; } } else if (objectType == EAAPI.ObjectType.otConnector) { EAAPI.Connector connector = repository.GetConnectorByGuid(guid) as EAAPI.Connector; if (connector != null && connector.Stereotype == "access type" && _mainViewModel != null) { _mainViewModel.ShowConnectorDirectionDialogCommand.Execute(connector); repository.AdviseConnectorChange(connector.ConnectorID); result = true; } } return(result); }
private void RemoveInvalidIds() { for (int i = L.Count - 1; i >= 0; i--) { try { switch (L[i].EaTyp) { case ObjectType.otDiagram: EA.Diagram dia = (EA.Diagram)_rep.GetDiagramByGuid(L[i].Guid); if (dia == null) { L.RemoveAt(i); continue; } UpdateDiagram(i, dia); break; case ObjectType.otPackage: EA.Package pkg = _rep.GetPackageByGuid(L[i].Guid); if (pkg == null) { L.RemoveAt(i); continue; } UpdatePackage(i, pkg); break; case ObjectType.otElement: EA.Element el = _rep.GetElementByGuid(L[i].Guid); if (el == null) { L.RemoveAt(i); continue; } UpdateElement(i, el); break; } } catch //(Exception e) { L.RemoveAt(i); } } LPosition = L.Count - 1; }
public EA.Element GetElementByGUID(String elementGUID) { EA.Element eaElement; eaElement = eaRepository.GetElementByGuid(elementGUID); return(eaElement); }
/// <summary> /// Update import package with: /// </summary> protected virtual void UpdatePackage() { EA.Element el = _rep.GetElementByGuid(_pkg.PackageGUID); TaggedValue.SetUpdate(el, "Imported", $"{DateTime.Now:G}"); TaggedValue.SetUpdate(el, "ImportedBy", $"{Environment.UserName}"); TaggedValue.SetUpdate(el, "ImportedFile", $"{_importModuleFile}"); TaggedValue.SetUpdate(el, "ImportedCount", $"{_dtRequirements.Rows.Count}"); TaggedValue.SetUpdate(el, "ImportedNew", $"{_countNew}"); TaggedValue.SetUpdate(el, "ImportedChanged", $"{_countChanged}"); }
/// <summary> /// EAのTaggedValueを上書きもしくは追加する /// </summary> internal static void updateEaTaggedValueObject(ElementVO myElement, TaggedValueVO selectedTag) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Element elem = null; // この属性を持っているはずの要素をGUIDより検索 elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem == null) { return; } TaggedValue tvObj = null; if (elem.TaggedValues != null && elem.TaggedValues.Count > 0) { for (int i = 0; i < elem.TaggedValues.Count; i++) { tvObj = elem.TaggedValues.GetAt((short)i); if (selectedTag.guid == tvObj.PropertyGUID) { break; } } } // 結果的に TaggedValue のオブジェクトが取得できなかったら、この要素の配下にタグ付き値を追加する if (tvObj == null) { tvObj = elem.TaggedValues.AddNew(selectedTag.name, ""); } // 更新前後で更新ログ出力 writeUpdateLogTaggedValue(tvObj, false); tvObj.Name = selectedTag.name; tvObj.Notes = selectedTag.notes; // tvObj.ObjectType = selectedTag.name; tvObj.PropertyGUID = selectedTag.guid; tvObj.Value = selectedTag.tagValue; // トランザクションのコミット tvObj.Update(); // 更新前後で更新ログ出力 writeUpdateLogTaggedValue(tvObj, true); }
/// <summary> /// Create/Update an Activity Diagram for the operation /// </summary> /// <param name="rep"></param> /// <param name="m"></param> /// <param name="treePos">If a new package is created the new tree position to show the package in the correct order</param> /// <returns></returns> 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); // Check if update behavior, behavior exists string behaviorGuid = m.Behavior; // Check if update Activity or Create a new one if (behaviorGuid.StartsWith("{") && behaviorGuid.EndsWith("}")) { //behaviorGuid = behaviorGuid.Substring(1, behaviorGuid.Length-2); EA.Element actForUpdate = rep.GetElementByGuid(behaviorGuid); if (actForUpdate == null) { var res = MessageBox.Show($@"Can't update Activity for Operation, invalid link to Activity found Behavior GUID =GUID of expected Activity: {behaviorGuid} Unable to find Activity for this GUID", @"Invalid link to Activity found, Create a new one?", MessageBoxButtons.OKCancel); if (res != DialogResult.OK) { return(false); } CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass); } else { UpdateParameterFromOperation(rep, actForUpdate, m); // update parameters from Operation for Activity } return(true); } CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass); return(true); }
public bool EA_OnContextItemDoubleClicked(EAAPI.Repository repopsitory, string guid, EAAPI.ObjectType objectType) { bool result = false; if (objectType == EAAPI.ObjectType.otElement && _mainViewModel != null) { EAAPI.Element element = repopsitory.GetElementByGuid(guid); if (element.Type == "Requirement") { string identifier = element.GetTaggedValueString("Identifier"); if (!string.IsNullOrEmpty(identifier)) { _mainViewModel.OpenJiraViewCommand.Execute(identifier); result = true; } } } return(result); }
/// <summary> /// EAのMethod(t_operator)を上書きもしくは追加する /// </summary> internal static void updateEaMethodObject(ElementVO myElement, MethodVO selectedMethod) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Element elem = null; // EA.Repository の GetMethodByGuid を呼んでEA上の該当メソッドオブジェクトを取得する EA.Method mthObj = getMethodByGuid(selectedMethod.guid); if (mthObj == null) { elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem == null) { return; } mthObj = (EA.Method)elem.Methods.AddNew(selectedMethod.name, selectedMethod.returnType); } writeUpdateLogMethod(mthObj, false); mthObj.Name = selectedMethod.name; mthObj.MethodGUID = selectedMethod.guid; mthObj.Alias = selectedMethod.alias; mthObj.StereotypeEx = selectedMethod.stereoType; mthObj.Notes = selectedMethod.notes; mthObj.Behavior = selectedMethod.behavior; mthObj.Abstract = selectedMethod.isAbstract; mthObj.ClassifierID = selectedMethod.classifierID; mthObj.Code = selectedMethod.code; mthObj.Concurrency = selectedMethod.concurrency; mthObj.IsConst = selectedMethod.isConst; mthObj.IsLeaf = selectedMethod.isLeaf; mthObj.IsPure = selectedMethod.isPure; mthObj.IsQuery = selectedMethod.isQuery; mthObj.IsRoot = selectedMethod.isRoot; mthObj.IsStatic = selectedMethod.isStatic; // mth.IsSynchronized = selectedMethod; mthObj.Pos = selectedMethod.pos; mthObj.ReturnIsArray = selectedMethod.returnIsArray; mthObj.ReturnType = selectedMethod.returnType; mthObj.StateFlags = selectedMethod.stateFlags; mthObj.StyleEx = selectedMethod.styleEx; mthObj.Throws = selectedMethod.throws; mthObj.Visibility = selectedMethod.visibility; mthObj.Update(); // 既にパラメータが設定されている場合は一旦削除 for (short i = 0; i < mthObj.Parameters.Count; i++) { mthObj.Parameters.Delete(i); } // XMLから読み込まれたパラメータの値を設定する foreach (ParameterVO prm in selectedMethod.parameters) { EA.Parameter paramObj = (EA.Parameter)mthObj.Parameters.AddNew(prm.name, prm.eaType); paramObj.Alias = prm.alias; paramObj.ClassifierID = prm.classifierID; paramObj.Default = prm.defaultValue; paramObj.IsConst = prm.isConst; paramObj.Kind = prm.kind; paramObj.Name = prm.name; paramObj.Notes = prm.notes; paramObj.ParameterGUID = prm.guid; paramObj.Position = prm.pos; paramObj.StereotypeEx = prm.stereoType; // paramObj.Style = prm.Style ; // paramObj.StyleEx = prm.StyleEx ; paramObj.Type = prm.eaType; paramObj.Update(); } mthObj.Update(); writeUpdateLogMethod(mthObj, true); }
/// <summary> /// EAのAttributeを上書きもしくは追加する /// </summary> internal static void updateEaAttributeObject(ElementVO myElement, AttributeVO selectedAttribute) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Element elem = null; int tmp = -1; // EAのAPIを使って属性をGUIDより検索 EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid); // 取得できなかったら(該当するGUIDの属性が存在しなかったら) if (attrObj == null) { // この属性を持っているはずの要素をGUIDより検索 elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem == null) { return; } attrObj = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, selectedAttribute.eaType); } // 更新前後で更新ログ出力 writeUpdateLogAttribute(attrObj, false); attrObj.Name = selectedAttribute.name; attrObj.AttributeGUID = selectedAttribute.guid; attrObj.Alias = selectedAttribute.alias; attrObj.StereotypeEx = selectedAttribute.stereoType; attrObj.Notes = selectedAttribute.notes; attrObj.AllowDuplicates = selectedAttribute.allowDuplicates; if ("".Equals(selectedAttribute.classifierID) || !Int32.TryParse(selectedAttribute.classifierID, out tmp)) { selectedAttribute.classifierID = "0"; } else { attrObj.ClassifierID = tmp; } attrObj.Container = selectedAttribute.container; attrObj.Containment = selectedAttribute.containment; attrObj.Default = selectedAttribute.defaultValue; attrObj.IsCollection = selectedAttribute.isCollection; attrObj.IsConst = selectedAttribute.isConst; attrObj.IsDerived = selectedAttribute.isDerived; // attr.IsID = selectedAttribute.; attrObj.IsOrdered = selectedAttribute.isOrdered; attrObj.IsStatic = selectedAttribute.isStatic; attrObj.Length = selectedAttribute.length.ToString(); attrObj.LowerBound = selectedAttribute.lowerBound.ToString(); attrObj.Precision = selectedAttribute.precision.ToString(); attrObj.Pos = selectedAttribute.pos; // attr.RedefinedProperty = selectedAttribute.; attrObj.Scale = selectedAttribute.scale.ToString(); attrObj.Stereotype = selectedAttribute.stereoType; // attr.Style = selectedAttribute.; // attr.SubsettedProperty = selectedAttribute.; attrObj.StyleEx = selectedAttribute.styleEx; attrObj.Type = selectedAttribute.eaType; attrObj.UpperBound = selectedAttribute.upperBound.ToString(); attrObj.Visibility = selectedAttribute.visibility; attrObj.Update(); // elem.Update(); // 更新前後で更新ログ出力 writeUpdateLogAttribute(attrObj, true); }
void ReflectToEAToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Element elem = null; int tmp = -1; if (repo != null) { // 選択された属性に対する更新処理 if (selectedAttribute != null) { //メッセージボックスを表示する DialogResult result = MessageBox.Show("EAのリポジトリの属性を上書き、もしくは追加します。よろしいですか?", "質問", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //何が選択されたか調べる if (result == DialogResult.Yes) { EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid); if (attr == null) { elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem == null) { return; } attr = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, "String"); } attr.Name = selectedAttribute.name; attr.AttributeGUID = selectedAttribute.guid; attr.Alias = selectedAttribute.alias; attr.StereotypeEx = selectedAttribute.stereoType; attr.Notes = selectedAttribute.notes; attr.AllowDuplicates = selectedAttribute.allowDuplicates; if ("".Equals(selectedAttribute.classifierID) || !Int32.TryParse(selectedAttribute.classifierID, out tmp)) { selectedAttribute.classifierID = "0"; } else { attr.ClassifierID = tmp; } // attr.ClassifierID = Int32.Parse( selectedAttribute.classifierID ); attr.Container = selectedAttribute.container; attr.Containment = selectedAttribute.containment; attr.Default = selectedAttribute.defaultValue; attr.IsCollection = selectedAttribute.isCollection; attr.IsConst = selectedAttribute.isConst; attr.IsDerived = selectedAttribute.isDerived; // attr.IsID = selectedAttribute.; attr.IsOrdered = selectedAttribute.isOrdered; attr.IsStatic = selectedAttribute.isStatic; attr.Length = selectedAttribute.length.ToString(); attr.LowerBound = selectedAttribute.lowerBound.ToString(); attr.Precision = selectedAttribute.precision.ToString(); // attr.RedefinedProperty = selectedAttribute.; attr.Scale = selectedAttribute.scale.ToString(); // attr.Stereotype = ; // attr.Style = selectedAttribute.; // attr.SubsettedProperty = selectedAttribute.; // attr.StyleEx = selectedAttribute.; attr.Type = selectedAttribute.eaType; attr.UpperBound = selectedAttribute.upperBound.ToString(); attr.Visibility = selectedAttribute.visibility; attr.Update(); // elem.Update(); } else { return; } } // 選択された操作に対する更新処理 if (selectedMethod != null) { //メッセージボックスを表示する DialogResult result = MessageBox.Show("EAのリポジトリの操作を上書き、もしくは追加します。よろしいですか?", "質問", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //何が選択されたか調べる if (result == DialogResult.Yes) { EA.Method mth = getMethodByGuid(selectedMethod.guid); if (mth == null) { elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem == null) { return; } mth = (EA.Method)elem.Methods.AddNew(selectedMethod.name, selectedMethod.returnType); } mth.Name = selectedMethod.name; mth.MethodGUID = selectedMethod.guid; mth.Alias = selectedMethod.alias; mth.StereotypeEx = selectedMethod.stereoType; mth.Notes = selectedMethod.notes; mth.Behavior = selectedMethod.behavior; mth.Abstract = selectedMethod.isAbstract; mth.ClassifierID = selectedMethod.classifierID; mth.Code = selectedMethod.code; mth.Concurrency = selectedMethod.concurrency; mth.IsConst = selectedMethod.isConst; mth.IsLeaf = selectedMethod.isLeaf; mth.IsPure = selectedMethod.isPure; mth.IsQuery = selectedMethod.isQuery; mth.IsRoot = selectedMethod.isRoot; mth.IsStatic = selectedMethod.isStatic; // mth.IsSynchronized = selectedMethod.s isSynchronized; mth.Pos = selectedMethod.pos; mth.ReturnIsArray = selectedMethod.returnIsArray; mth.ReturnType = selectedMethod.returnType; mth.StateFlags = selectedMethod.stateFlags; // mth.StyleEx = selectedMethod.StyleEx; mth.Throws = selectedMethod.throws; mth.Visibility = selectedMethod.visibility; mth.Update(); // 既にパラメータが設定されている場合は一旦削除 for (short i = 0; i < mth.Parameters.Count; i++) { mth.Parameters.Delete(i); } // XMLから読み込まれたパラメータの値を設定する foreach (ParameterVO prm in selectedMethod.parameters) { EA.Parameter paramObj = (EA.Parameter)mth.Parameters.AddNew(prm.name, prm.eaType); paramObj.Alias = prm.alias; paramObj.ClassifierID = prm.classifierID; paramObj.Default = prm.defaultValue; paramObj.IsConst = prm.isConst; paramObj.Kind = prm.kind; paramObj.Name = prm.name; paramObj.Notes = prm.notes; paramObj.ParameterGUID = prm.guid; paramObj.Position = prm.pos; paramObj.StereotypeEx = prm.stereoType; // paramObj.Style = prm.Style ; // paramObj.StyleEx = prm.StyleEx ; paramObj.Type = prm.eaType; paramObj.Update(); } // elem.Update(); } else { return; } } } else { MessageBox.Show("EAにアタッチしていないため、反映できません"); } }
public int dzialajDlaProjektuLinkedDoc(string pr, string sql) { log("Projekt " + pr, "Info"); int ile = 0; using (MySql.Data.MySqlClient.MySqlConnection conn2 = new MySql.Data.MySqlClient.MySqlConnection()) using (MySqlCommand cmd2 = new MySqlCommand()) using (MySqlCommand cmd = new MySqlCommand()) { try { cmd.Connection = conn; cmd.CommandText = sql; string sciezkaDef = sciezkaDomyslna + pr + @"\LinkedDoc\"; string sciezkaDb; using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { if (EA_Connect(pr) == 0) { conn2.ConnectionString = "server=10.22.23.82;uid=eakzg;database=eakzg_schema;Pwd=a;port=3306"; conn2.Open(); cmd2.Connection = conn2; while (reader.Read()) { string objectID = reader["object_ID"].ToString(); string datWyrzyg = reader["dataWyrzygu"].ToString(); string sciezka = reader["sciezka"].ToString(); string plik = reader["plik"].ToString(); string objectGuid = reader["ea_guid"].ToString(); if (sciezka == String.Empty) { sciezka = sciezkaDef; } try { System.IO.Directory.CreateDirectory(sciezka); sciezkaDb = sciezka.Replace(@"\", @"\\"); //projektInterfejs.PutDiagramImageToFile(objectGuid, sciezka + objectID + ".png", 1); /* sql = " SELECT o.object_id,d.BinContent, o.Note FROM " + * "`" + schema + "`.t_object o " + * ", `" + schema + "`.t_document d " + * " WHERE o.Style LIKE '%MDoc=1%' and o.object_type='Object' and d.elementid=o.ea_guid and o.name='Skrot';"; */ EA.Element e = eaRepository.GetElementByGuid(objectGuid); string rtf = e.GetLinkedDocument(); string html = ConvertRtfToHtml(rtf); System.IO.StreamWriter file = new System.IO.StreamWriter(sciezka + objectID + ".html"); file.Write(html); file.Close(); System.IO.StreamWriter filertf = new System.IO.StreamWriter(sciezka + objectID + ".rtf"); filertf.Write(rtf); filertf.Close(); string updt = " INSERT INTO eakzg_schema.eakzg_wyrzyg_log (id,projekt,objectID,objectGUID,dataWyrzygu,sciezka,plik) " + "values (null,'" + pr + "','" + objectID + "','" + objectGuid + "', " + @"now(), '" + sciezkaDb + "','" + objectID + ".html') on duplicate key update " + @" dataWyrzygu=now(),sciezka='" + sciezkaDb + "',plik='" + objectID + ".html'"; cmd2.CommandText = updt; int numRowsUpdated = cmd2.ExecuteNonQuery(); ile++; } catch (Exception ex) { log("Blad IO msg: " + ex.Message, "Exc - dzialajDlaProjektu " + " TargetSite: " + ex.TargetSite.ToString()); } } } } } } catch (MySqlException ex) { log("Blad " + ex.Number + " msg: " + ex.Message, "Exc - dzialajDlaProjektu " + " TargetSite: " + ex.TargetSite.ToString()); } log("Projekt " + pr + "### Wygenerowano: " + ile + " diagramów", "Info"); } return(ile); }