<< 目次を表示 >> ページ位置: API・アドイン・スクリプト > API > サンプルコード > 要素に対するさまざまな操作 |
シナリオや制約など、要素に関する情報の追加と削除の例です。
class ElementExtrasOperationSample
{
public void ElementExtras(EA.Repository repository)
{
// 対象の要素を取得します
// IDの値(10)には適切な値を設定してください。
EA.Element element = repository.GetElementByID(10);
// 要素の制約を追加し削除します
EA.Constraint newConstraint = (EA.Constraint)element.Constraints.AddNew("Appended","事前条件");
newConstraint.Update();
element.Constraints.Refresh();
for (short i = 0; i < element.Constraints.Count; i++)
{
EA.Constraint constraint = element.Constraints.GetAt(i);
Console.WriteLine(constraint.Name);
if (constraint.Name == "Appended")
{
element.Constraints.DeleteAt(i, true);
break;
}
}
// 作業
EA.Effort newEffort = (EA.Effort)element.Efforts.AddNew("Appended", "Type");
newEffort.Update();
element.Efforts.Refresh();
for (short i = 0; i < element.Efforts.Count; i++)
{
EA.Effort effort = element.Efforts.GetAt(i);
Console.WriteLine(effort.Name);
if (effort.Name == "Appended")
{
element.Efforts.DeleteAt(i, true);
break;
}
}
// リスク
EA.Risk newRisk = (EA.Risk)element.Risks.AddNew("Appended", "Type");
newRisk.Update();
element.Risks.Refresh();
for (short i = 0; i < element.Risks.Count; i++)
{
EA.Risk risk = element.Risks.GetAt(i);
Console.WriteLine(risk.Name);
if (risk.Name == "Appended")
{
element.Risks.DeleteAt(i, true);
break;
}
}
// 測定
EA.Metric newMetric = (EA.Metric)element.Metrics.AddNew("Appended", "Change");
newMetric.Update();
element.Metrics.Refresh();
for (short i = 0; i < element.Metrics.Count; i++)
{
EA.Metric metric = element.Metrics.GetAt(i);
Console.WriteLine(metric.Name);
if (metric.Name == "Appended")
{
element.Metrics.DeleteAt(i, true);
break;
}
}
// タグ付き値
EA.TaggedValue newTaggedValue = (EA.TaggedValue)element.TaggedValues.AddNew("Appended", "Change");
newTaggedValue.Update();
element.TaggedValues.Refresh();
for (short i = 0; i < element.TaggedValues.Count; i++)
{
EA.TaggedValue taggedValue = element.TaggedValues.GetAt(i);
Console.WriteLine(taggedValue.Name);
{
if (taggedValue.Name == "Appended")
{
element.TaggedValues.DeleteAt(i, true);
break;
}
}
}
// シナリオ
EA.Scenario newScenario = (EA.Scenario)element.Scenarios.AddNew("Appended", "Change");
newScenario.Update();
element.Scenarios.Refresh();
for (short i = 0; i < element.Scenarios.Count; i++)
{
EA.Scenario scenario = element.Scenarios.GetAt(i);
Console.WriteLine(scenario.Name);
if (scenario.Name == "Appended")
{
element.Scenarios.DeleteAt(i, true);
break;
}
}
// ファイル
EA.File newFile = (EA.File)element.Files.AddNew("MyFile", "doc");
newFile.Update();
element.Files.Refresh();
for (short i = 0; i < element.Files.Count; i++)
{
EA.File file = element.Files.GetAt(i);
Console.WriteLine(file.Name);
if (file.Name == "MyFile")
{
element.Files.DeleteAt(i, true);
break;
}
}
// テスト項目
EA.Test newTest = (EA.Test)element.Tests.AddNew("TestPlan", "負荷");
newTest.Update();
element.Tests.Refresh();
for (short i = 0; i < element.Tests.Count; i++)
{
EA.Test test = element.Tests.GetAt(i);
Console.WriteLine(test.Name);
if (test.Name == "TestPlan")
{
element.Tests.DeleteAt(i, true);
break;
}
}
// 要素のバグ項目
EA.Issue newIssueDefect = (EA.Issue)element.Issues.AddNew("Broken", "Defect");
newIssueDefect.Update();
element.Issues.Refresh();
for (short i = 0; i < element.Issues.Count; i++)
{
EA.Issue issueDefect = element.Issues.GetAt(i);
Console.WriteLine(issueDefect.Name);
if (issueDefect.Name == "Broken")
{
element.Issues.DeleteAt(i, true);
break;
}
}
// 要素の変更点
EA.Issue newIssueChange = (EA.Issue)element.Issues.AddNew("Change", "Change");
newIssueChange.Update();
element.Issues.Refresh();
for (short i = 0; i < element.Issues.Count; i++)
{
EA.Issue issueChange = element.Issues.GetAt(i);
Console.WriteLine(issueChange.Name);
if (issueChange.Name == "Change")
{
element.Issues.DeleteAt(i, true);
break;
}
}
}
}