public IssueCollection FetchAllIssues() { var collection = new IssueCollection(); int batchSize = 100; int start = 0; List <string> fields = new List <string>() { "id", "updated" }; DateTime lastUpdated = DateTime.MinValue; var cache = QueryCache.LoadFromTemp(this.Filter.ToString()); if (false && cache != null) { if (cache.Filter.ToUpperInvariant() == this.Filter.ToString().ToUpperInvariant()) { foreach (LightIssue issue in cache.Issues) { collection.Add(new Issue() { id = issue.id, updated = issue.updated }); } this.UpdatedAfter = cache.LastUpdated; cache.LastUpdated = DateTime.Now.Date; } } var received = FetchIssues(batchSize, start); collection.AddRange(received); while (received.Count == batchSize) { start += received.Count; received = FetchIssues(batchSize, start); collection.AddRange(received); } var issues_with_history = new IssueCollection(); Parallel.ForEach(collection, (issue) => { var cached_issue = Issue.LoadFromTemp(issue.id); if (false && cached_issue != null && (cached_issue.updated <= issue.updated || issue.updated == DateTime.MinValue)) { // Console.WriteLine("{0} loaded from cache", issue.id); issues_with_history.Add(cached_issue); return; } issues_with_history.Add(Issue.GetHistory(issue)); System.Diagnostics.Trace.WriteLine(string.Format("Loading history for issue {0}", issue.id)); }); cache.Issues.Clear(); cache.AddIssues(issues_with_history); cache.SaveToTemp(); return(issues_with_history); }
public IssueCollection IssueHistory(string IssueId) { var collection = new IssueCollection(); collection.AllowDuplicates = true; var client = new WebClient(); var connection = new Connection("mcneel.myjetbrains.com", 80, false, "youtrack"); Authenticate(connection); var path = string.Format("issue/{0}/history", IssueId); var request = connection.CreateHttpRequest(); var command = connection._uriConstructor.ConstructBaseUri(path); var response = request.Get(command); var dyn = Newtonsoft.Json.Linq.JArray.Parse(response.RawText); foreach (var i in dyn) { collection.Add(Issue.FromJObject(i)); } return(collection); }
public IssueCollection AsOf(DateTime Timestamp) { IssueCollection result = new IssueCollection(); foreach (Issue issue in this) { if (issue == null) { continue; } var issueAsOf = issue.AsOf(Timestamp); if (issueAsOf != null) { result.Add(issueAsOf); } } return(result); }
public IssueCollection FetchIssues(int max = 10, int start = 0, IEnumerable <string> returnFields = null) { var collection = new IssueCollection(); var connection = new Connection("mcneel.myjetbrains.com", 80, false, "youtrack"); Authenticate(connection); var uri = new Uri("http://mcneel.myjetbrains.com/issue"); uri = uri.AddQuery("filter", this.ToString()); uri = uri.AddQuery("max", max.ToString()); uri = uri.AddQuery("after", start.ToString()); if (returnFields != null) { foreach (var field in returnFields) { uri = uri.AddQuery("with", field); } } var request = connection.CreateHttpRequest(); var command = connection._uriConstructor.ConstructBaseUri(uri.PathAndQuery.TrimStart("/".ToCharArray())); var response = request.Get(command); var dyn = Newtonsoft.Json.Linq.JObject.Parse(response.RawText); foreach (var d in dyn) { foreach (var i in d.Value) { collection.Add(Issue.FromJObject(i)); } } return(collection); }