如何在RTC 7.0.2中查询正式项目,以获得每天的工作量(时间跟踪(或每天用于任务的时间?
自2015年以来,情况可能发生了变化,但本线程提到了
时间跟踪不是字段/属性。使用引用/链接将时间跟踪条目添加到工作项中。我知道其他人过去也这样做过。
涉及这个主题的文章是"工作项目时间跟踪API";来自Ralph
下面的代码更新或创建时间跟踪条目,但在此过程中,首先访问和读取现有的时间跟踪,这在这里很有趣。
public void updateOrCreateTimeSheetEntry(WorkItemWorkingCopy workingCopy,
ITimeCode timeCode, Timestamp startDateTimeStamp,
Duration workDuration, Identifier workType,
IProgressMonitor monitor) throws TeamRepositoryException {
// set the active work item from the working copy
setWorkItem(workingCopy.getWorkItem());
// Find a matching time sheet if it exists.
ITimeSheetEntry timeSheet = findTimeSheetEntry(timeCode,
startDateTimeStamp, monitor);
if (timeSheet == null) {
// There is no time sheet for this entry
// Create a new one and create the link
timeSheet = createTimeSheet();
workingCopy.getReferences()
.add(WorkItemEndPoints.WORK_TIME,
IReferenceFactory.INSTANCE
.createReferenceToItem(timeSheet));
// Add the entry to the map to hold the data
addEntry(timeSheet, monitor);
} else {
// There is a time sheet, we need to update it
// Get the workingCopy of the time sheet
timeSheet = (ITimeSheetEntry) timeSheet.getWorkingCopy();
// remove the time spent from current time
setTotalDuration(new Duration(getTotalDuration().longValue()
- timeSheet.getTimeSpent().longValue()));
}
// Set the new data
timeSheet.setStartDate(startDateTimeStamp);
timeSheet.setTimeCodeId(timeCode.getTimeCodeId());
// TODO: If I leave this out it fails....
timeSheet.setTimeCode(timeCode.getTimeCodeLabel());
timeSheet.setTimeSpent(workDuration);
timeSheet.setWorkType(workType);
// add the new time back
setTotalDuration(getTotalDuration().add(workDuration));
// Update the value
// Note: it is important to set the duration value, of the work item
// otherwise the work item is not marked as dirty and in need to update
// in the repository and the save process will not save the time sheet
getWorkItem().setDuration(getTotalDuration().longValue());
workingCopy.getDependentItems().add(timeSheet);
}
您可以创建一个查询来获取给定日期的工作项,使用存储的查询,并以这种方式列出您的工作项。