我試圖編寫一些C#代碼來利用VersionOne SDK來創建缺陷資產。我詢問我們的系統,並已經確定了所需的屬性:如何:使用VersionOne SDK創建資產
Defect derives from PrimaryWorkitem
- Description : LongText
- Name : Text
- Parent : Relation to Theme — reciprocal of Children
- Priority : Relation to WorkitemPriority — reciprocal of PrimaryWorkitems
- Scope : Relation to Scope — reciprocal of Workitems
- Source : Relation to StorySource — reciprocal of PrimaryWorkitems
- Status : Relation to StoryStatus — reciprocal of PrimaryWorkitems
- Team : Relation to Team — reciprocal of Workitems
一些值是顯而易見的,而另一些有點抽象。例如,我不確定要爲「父」屬性或「範圍」指定什麼。使用SDK創建資產的文檔相當稀少。我似乎無法找到使用SDK的任何代碼示例。此刻,我的代碼返回一個例外:
The remote server returned an error: (400) Bad Request Violation'Required'AttributeDefinition'Parent'Defect
而且,這裏是我使用的時刻代碼:
static void AddV1Record(List<V1WerRecord> records)
{
V1Connector connector = V1Connector
.WithInstanceUrl(VersionOneURL)
.WithUserAgentHeader("VersionOneUpdate", "1.0")
.WithUsernameAndPassword(VersionOneId, VersionOnePwd)
.Build();
IServices services = new Services(connector);
Oid projectId = services.GetOid("Scope:0");
IAssetType storyType = services.Meta.GetAssetType("Defect");
Asset newDefect = services.New(storyType, projectId);
IAttributeDefinition descAttribute = storyType.GetAttributeDefinition("Description");
newDefect.SetAttributeValue(descAttribute, "My New Defect");
IAttributeDefinition nameAttribute = storyType.GetAttributeDefinition("Name");
newDefect.SetAttributeValue(nameAttribute, "My Name");
services.Save(newDefect);
我理解錯誤是由不指定所有所致所需的屬性。我不知道爲什麼要指定一些屬性:父,範圍等
有誰知道更好的文檔解釋使用SDK來創建資產?是否有任何好的SDK示例/示例代碼可用?
感謝您的幫助。這對於如何使用SDK構建代碼確實闡明瞭很多。你提供的查詢語法是我需要的中斷。 – rrirower