使用 VersionOne SDK 向故事添加 Link
Adding a Link to a Story Using the VersionOne SDK
我正在编写代码在 VersionOne 中创建故事,但我不知道如何向故事中添加 link。
我目前用来创建故事的代码是:
part = snapHash.Split(":")
snapHash = part(0) & ":<" & part(1) & ">" & part(2) & " / " & part(3) & " \ " & errorMessage
connector = V1Connector _
.WithInstanceUrl(ConfigurationManager.AppSettings("InstanceUrl")) _
.WithUserAgentHeader("VersionOne", "1.0") _
.WithAccessToken(ConfigurationManager.AppSettings("AccessToken")) _
.UseOAuthEndpoints() _
.Build
services = New Services(connector)
projectId = services.GetOid("Scope:" & ConfigurationManager.AppSettings("Scope"))
storyType = services.Meta.GetAssetType("Story")
newStory = services.New(storyType, projectId)
newAttribute = storyType.GetAttributeDefinition("Name")
newStory.SetAttributeValue(newAttribute, snapHash)
newAttribute = storyType.GetAttributeDefinition("Source")
newStory.SetAttributeValue(newAttribute, "StorySource:" & ConfigurationManager.AppSettings("StorySource"))
newAttribute = storyType.GetAttributeDefinition("Description")
newStory.SetAttributeValue(newAttribute, href)
newAttribute = storyType.GetAttributeDefinition("Team")
newStory.SetAttributeValue(newAttribute, "Team:" & ConfigurationManager.AppSettings("Team"))
services.Save(newStory)
VersionOne 的 href 存储在描述中。我不想将 href 存储在描述中,我想将其添加为 link.
经过反复试验,我弄明白了。保存新 Story 后,调用 Story 对象上的 AcceptChanges()。这提供了下一步所需的 Oid,即创建 LInk 资产并将故事的 Oid 传递给它。
connector = V1Connector _
.WithInstanceUrl(ConfigurationManager.AppSettings("InstanceUrl")) _
.WithUserAgentHeader("VersionOne", "1.0") _
.WithAccessToken(ConfigurationManager.AppSettings("AccessToken")) _
.UseOAuthEndpoints() _
.Build
services = New Services(connector)
scopeOid = services.GetOid("Scope:" & ConfigurationManager.AppSettings("Scope"))
storyType = services.Meta.GetAssetType("Story")
storyAsset = services.New(storyType, scopeOid)
newAttribute = storyType.GetAttributeDefinition("Name")
storyAsset.SetAttributeValue(newAttribute, snapHash)
newAttribute = storyType.GetAttributeDefinition("Source")
storyAsset.SetAttributeValue(newAttribute, "StorySource:" & ConfigurationManager.AppSettings("StorySource"))
newAttribute = storyType.GetAttributeDefinition("Description")
storyAsset.SetAttributeValue(newAttribute, errorMessage)
newAttribute = storyType.GetAttributeDefinition("Team")
storyAsset.SetAttributeValue(newAttribute, "Team:" & ConfigurationManager.AppSettings("Team"))
services.Save(storyAsset)
storyAsset.AcceptChanges()
linkType = services.Meta.GetAssetType("Link")
linkAsset = services.New(linkType, scopeOid)
newAttribute = linkType.GetAttributeDefinition("Asset")
linkAsset.SetAttributeValue(newAttribute, storyAsset.Oid)
newAttribute = linkType.GetAttributeDefinition("Name")
linkAsset.SetAttributeValue(newAttribute, "SnapDumps Link")
newAttribute = linkType.GetAttributeDefinition("OnMenu")
linkAsset.SetAttributeValue(newAttribute, True)
newAttribute = linkType.GetAttributeDefinition("URL")
linkAsset.SetAttributeValue(newAttribute, href)
services.Save(linkAsset)
我正在编写代码在 VersionOne 中创建故事,但我不知道如何向故事中添加 link。
我目前用来创建故事的代码是:
part = snapHash.Split(":")
snapHash = part(0) & ":<" & part(1) & ">" & part(2) & " / " & part(3) & " \ " & errorMessage
connector = V1Connector _
.WithInstanceUrl(ConfigurationManager.AppSettings("InstanceUrl")) _
.WithUserAgentHeader("VersionOne", "1.0") _
.WithAccessToken(ConfigurationManager.AppSettings("AccessToken")) _
.UseOAuthEndpoints() _
.Build
services = New Services(connector)
projectId = services.GetOid("Scope:" & ConfigurationManager.AppSettings("Scope"))
storyType = services.Meta.GetAssetType("Story")
newStory = services.New(storyType, projectId)
newAttribute = storyType.GetAttributeDefinition("Name")
newStory.SetAttributeValue(newAttribute, snapHash)
newAttribute = storyType.GetAttributeDefinition("Source")
newStory.SetAttributeValue(newAttribute, "StorySource:" & ConfigurationManager.AppSettings("StorySource"))
newAttribute = storyType.GetAttributeDefinition("Description")
newStory.SetAttributeValue(newAttribute, href)
newAttribute = storyType.GetAttributeDefinition("Team")
newStory.SetAttributeValue(newAttribute, "Team:" & ConfigurationManager.AppSettings("Team"))
services.Save(newStory)
VersionOne 的 href 存储在描述中。我不想将 href 存储在描述中,我想将其添加为 link.
经过反复试验,我弄明白了。保存新 Story 后,调用 Story 对象上的 AcceptChanges()。这提供了下一步所需的 Oid,即创建 LInk 资产并将故事的 Oid 传递给它。
connector = V1Connector _
.WithInstanceUrl(ConfigurationManager.AppSettings("InstanceUrl")) _
.WithUserAgentHeader("VersionOne", "1.0") _
.WithAccessToken(ConfigurationManager.AppSettings("AccessToken")) _
.UseOAuthEndpoints() _
.Build
services = New Services(connector)
scopeOid = services.GetOid("Scope:" & ConfigurationManager.AppSettings("Scope"))
storyType = services.Meta.GetAssetType("Story")
storyAsset = services.New(storyType, scopeOid)
newAttribute = storyType.GetAttributeDefinition("Name")
storyAsset.SetAttributeValue(newAttribute, snapHash)
newAttribute = storyType.GetAttributeDefinition("Source")
storyAsset.SetAttributeValue(newAttribute, "StorySource:" & ConfigurationManager.AppSettings("StorySource"))
newAttribute = storyType.GetAttributeDefinition("Description")
storyAsset.SetAttributeValue(newAttribute, errorMessage)
newAttribute = storyType.GetAttributeDefinition("Team")
storyAsset.SetAttributeValue(newAttribute, "Team:" & ConfigurationManager.AppSettings("Team"))
services.Save(storyAsset)
storyAsset.AcceptChanges()
linkType = services.Meta.GetAssetType("Link")
linkAsset = services.New(linkType, scopeOid)
newAttribute = linkType.GetAttributeDefinition("Asset")
linkAsset.SetAttributeValue(newAttribute, storyAsset.Oid)
newAttribute = linkType.GetAttributeDefinition("Name")
linkAsset.SetAttributeValue(newAttribute, "SnapDumps Link")
newAttribute = linkType.GetAttributeDefinition("OnMenu")
linkAsset.SetAttributeValue(newAttribute, True)
newAttribute = linkType.GetAttributeDefinition("URL")
linkAsset.SetAttributeValue(newAttribute, href)
services.Save(linkAsset)