【问题标题】:Programmatically "Insert Image" to TFS Work Item以编程方式将图像“插入”到 TFS 工作项
【发布时间】:2013-12-09 23:35:30
【问题描述】:

我一直在开发一个小型 winform c# 应用程序,它使我能够在 TFS 中创建一个工作项,而无需实际在 TFS 服务器上进行。我已经弄清楚如何添加标题、附件、描述等。但是我似乎无法弄清楚如何将本地图像插入到 TFS 工作项“复制步骤”字段中。到目前为止,这是我的代码。

Uri collectionUri = new Uri("Server Adress" + project);
TfsTeamProjectCollection server = new TfsTeamProjectCollection(collectionUri);
WorkItemStore store = (WorkItemStore)server.GetService(typeof(WorkItemStore));

WorkItem workItem = store.Projects[SubProject].WorkItemTypes["Bug"].NewWorkItem();
workItem.Title = "Title";
workItem.IterationPath = "Iteration";
workItem.AreaPath = "Area"; 

workItem.Fields["repro steps"].Value = "Text"; //Here is where I would like to add my image

workItem.Fields["Assigned To"].Value = "Assigned";
workItem.Attachments.Add(new Attachment(File, "comment"));
workItem.Save();

为了进一步澄清,这是我本质上想要做的事情:

【问题讨论】:

    标签: c# tfs tfs-sdk


    【解决方案1】:

    我相信Description字段被编码为各种HTML,并且图像首先作为单独的文件附加。 (历史上它是一个文本字段,所以我找不到任何其他说明)

    Here is an example of attaching a file

    【讨论】:

    • 所以我应该附加文件(就像我对其他附件所做的那样)然后在“workItem.Descpription”命令中以某种方式引用它?
    • @Jhogg:是的,我还会使用 API 来获取您手动修改的工作项的 Description,以确保您具有正确的语法。
    • 我是 c# 的新手(这实际上是我的第一个应用程序)你认为你可以告诉我假设 Description 是正确的语法,命令可能是什么样子吗?说我Attachments.Add("file","Description"); 会不会是Description.Add("File"); 之类的东西?
    • @Jhogg:我相信 description 是一个字符串属性,所以Description = "File"
    猜你喜欢
    • 1970-01-01
    • 2010-11-01
    • 2011-11-29
    • 2011-02-20
    • 2011-04-19
    • 1970-01-01
    • 2014-09-14
    • 2015-02-04
    • 1970-01-01
    相关资源
    最近更新 更多