2

我正在从redmine timeentry.

问题是我只得到最后 25 条记录。我的过滤器不工作

任何想法,为什么过滤器不起作用或我在做什么类型的错误?

我已经安装了redminefromNuget

这是代码:

string host = "redmine.xyz.net";
string apiKey = "e69e2243f4b357f34533322408d6339b7f5b2579e36";

var manager = new RedmineManager(host, apiKey);
List<EEmployeeTimeSheet> liEmpTimeSheet = new List<EEmployeeTimeSheet>();
var parameters = new NameValueCollection();
parameters.Add("per_page", "100");
parameters.Add("created_on", DateTime.Now.Date.ToString("yyyy-MM-dd"));
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.CloseOutput = false;
XmlWriter xmlWriter = XmlWriter.Create(Path.Combine(HostingEnvironment.MapPath("~/test.xml")), settings);
var timeentry=manager.GetObjectList<TimeEntry>(parameters).Take(100);
foreach (var issue in timeentry)
{
     issue.WriteXml(xmlWriter);
     EEmployeeTimeSheet emp = new EEmployeeTimeSheet();
     emp.strActivity = issue.Activity.ToString();
     emp.strComments = issue.Comments;
     emp.nHours = issue.Hours;
     emp.dtCreatedOn = issue.CreatedOn;
     emp.strProject = issue.Project.Name;
     emp.strEmployeeName = issue.User.Name;
     liEmpTimeSheet.Add(emp);
}
xmlWriter.Flush();
xmlWriter.Close();
4

1 回答 1

0

默认情况下,API 仅返回 25 个项目。您可以使用 GetObjects() 方法的重载:

const int limit = 1000;
var parameters = new string[0];
IList<Project> redmineProjects = 
   manager.GetObjects<Project>(limit: limit, offset: 0, include: parameters);
于 2018-04-02T14:08:42.730 回答