Redmine.Net.Api.Types.TimeEntry 如何和issue关联并给出示例代码
时间: 2023-12-14 22:39:51 浏览: 166
redmine-net-api:用于Redmine错误任务管理系统的.Net API
可以使用Redmine.Net.Api.Types.TimeEntry的IssueId属性将TimeEntry与Issue关联起来。以下是一个示例代码片段,演示如何创建一个与Issue关联的TimeEntry:
```csharp
using Redmine.Net.Api;
using Redmine.Net.Api.Types;
using System;
namespace RedmineTimeEntryExample
{
class Program
{
static void Main(string[] args)
{
var redmineManager = new RedmineManager("https://your.redmine.url", "your-api-key");
// create a new time entry
var timeEntry = new TimeEntry
{
ActivityId = 9, // set the activity ID
SpentOn = DateTime.Now.Date, // set the date
Hours = 2.5F, // set the time spent
Comments = "Some comments here", // set the comments
IssueId = 123 // set the issue ID
};
// create the time entry and associate it with the issue
var createdTimeEntry = redmineManager.CreateObject<TimeEntry>(timeEntry);
Console.WriteLine("Time entry created successfully!");
}
}
}
```
在上面的代码中,我们设置了TimeEntry的IssueId属性,将其与Issue关联起来。在创建TimeEntry时,Redmine.Net.Api会自动将其与相应的Issue关联起来。
阅读全文