public bool Run(out string ErrorMessage) { Issues = RESTApi.GET <List <IssueData> >(ApiUrl, String.Format("issues?includeresolved=true&maxresults={0}", MaxResults)); ErrorMessage = null; return(true); }
void FetchIssues(int NewMaxResults) { try { SortedDictionary <int, IssueData> NewSortedIssues = new SortedDictionary <int, IssueData>(); List <IssueData> OpenIssues = RESTApi.GET <List <IssueData> >(IssueMonitor.ApiUrl, "issues"); foreach (IssueData OpenIssue in OpenIssues) { NewSortedIssues[(int)OpenIssue.Id] = OpenIssue; } List <IssueData> ResolvedIssues = RESTApi.GET <List <IssueData> >(IssueMonitor.ApiUrl, String.Format("issues?includeresolved=true&maxresults={0}", NewMaxResults)); foreach (IssueData ResolvedIssue in ResolvedIssues) { NewSortedIssues[(int)ResolvedIssue.Id] = ResolvedIssue; } List <IssueData> NewIssues = NewSortedIssues.Values.Reverse().ToList(); MainThreadSynchronizationContext.Post((o) => { if (!bDisposed) { FetchIssuesSuccess(NewMaxResults, NewIssues); } }, null); } catch (Exception Ex) { MainThreadSynchronizationContext.Post((o) => { if (!bDisposed) { FetchIssuesFailure(Ex); } }, null); } }
bool ReadEventsFromBackend() { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine(); LogWriter.WriteLine("Polling for reviews at {0}...", DateTime.Now.ToString()); ////////////// /// Initial Ids ////////////// if (LatestIds.LastBuildId == 0 && LatestIds.LastCommentId == 0 && LatestIds.LastEventId == 0) { LatestData InitialIds = RESTApi.GET <LatestData>(ApiUrl, "latest", string.Format("project={0}", Project)); LatestIds.LastBuildId = InitialIds.LastBuildId; LatestIds.LastCommentId = InitialIds.LastCommentId; LatestIds.LastEventId = InitialIds.LastEventId; } ////////////// /// Reviews ////////////// List <EventData> Events = RESTApi.GET <List <EventData> >(ApiUrl, "event", string.Format("project={0}", Project), string.Format("lasteventid={0}", LatestIds.LastEventId)); foreach (EventData Review in Events) { IncomingEvents.Enqueue(Review); LatestIds.LastEventId = Math.Max(LatestIds.LastEventId, Review.Id); } ////////////// /// Comments ////////////// List <CommentData> Comments = RESTApi.GET <List <CommentData> >(ApiUrl, "comment", string.Format("project={0}", Project), string.Format("lastcommentid={0}", LatestIds.LastCommentId)); foreach (CommentData Comment in Comments) { IncomingComments.Enqueue(Comment); LatestIds.LastCommentId = Math.Max(LatestIds.LastCommentId, Comment.Id); } ////////////// /// Bulids ////////////// List <BuildData> Builds = RESTApi.GET <List <BuildData> >(ApiUrl, "build", string.Format("project={0}", Project), string.Format("lastbuildid={0}", LatestIds.LastBuildId)); foreach (BuildData Build in Builds) { IncomingBuilds.Enqueue(Build); LatestIds.LastBuildId = Math.Max(LatestIds.LastBuildId, Build.Id); } LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Last update failed: ({0})", Ex.ToString()); return(false); } }
private void ShowIssue(IssueData Issue) { try { Issue.Builds = RESTApi.GET <List <IssueBuildData> >(IssueMonitor.ApiUrl, String.Format("issues/{0}/builds", Issue.Id)); } catch (Exception Ex) { MessageBox.Show(Owner, Ex.ToString(), "Error querying builds", MessageBoxButtons.OK); return; } IssueDetailsWindow.Show(Owner, IssueMonitor, ServerAndPort, UserName, ServerTimeOffset, Issue, Log, CurrentStream); }
void FetchIssues(int NewMaxResults) { try { List <IssueData> NewIssues = RESTApi.GET <List <IssueData> >(IssueMonitor.ApiUrl, String.Format("issues?includeresolved=true&maxresults={0}", NewMaxResults)); MainThreadSynchronizationContext.Post((o) => { if (!bDisposed) { FetchIssuesSuccess(NewMaxResults, NewIssues); } }, null); } catch (Exception Ex) { MainThreadSynchronizationContext.Post((o) => { if (!bDisposed) { FetchIssuesFailure(Ex); } }, null); } }
bool ReadCurrentIssues() { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine(); LogWriter.WriteLine("Polling for notifications at {0}...", DateTime.Now.ToString()); // Get the initial number of issues. We won't post updates if this stays at zero. int InitialNumIssues = Issues.Count; // Fetch the new issues List <IssueData> NewIssues = RESTApi.GET <List <IssueData> >(ApiUrl, String.Format("issues?user={0}", UserName)); // Check if we're tracking a particular issue. If so, we want updates even when it's resolved. long[] LocalTrackingIssueIds; lock (LockObject) { LocalTrackingIssueIds = TrackingIssueIds.Distinct().ToArray(); } foreach (long LocalTrackingIssueId in LocalTrackingIssueIds) { if (!NewIssues.Any(x => x.Id == LocalTrackingIssueId)) { try { IssueData Issue = RESTApi.GET <IssueData>(ApiUrl, String.Format("issues/{0}", LocalTrackingIssueId)); if (Issue != null) { NewIssues.Add(Issue); } } catch (Exception Ex) { LogWriter.WriteException(Ex, "Exception while fetching tracked issue"); } } } // Update all the builds for each issue foreach (IssueData NewIssue in NewIssues) { NewIssue.Builds = RESTApi.GET <List <IssueBuildData> >(ApiUrl, String.Format("issues/{0}/builds", NewIssue.Id)); } // Apply any pending updates to this issue list, and update it lock (LockObject) { foreach (IssueUpdateData PendingUpdate in PendingUpdates) { ApplyPendingUpdate(NewIssues, PendingUpdate); } Issues = NewIssues; } // Update the main thread if (InitialNumIssues > 0 || Issues.Count > 0) { if (OnIssuesChanged != null) { OnIssuesChanged(); } } // Update the stats LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Last update failed: ({0})", Ex.ToString()); return(false); } }
bool ReadEventsFromBackend(bool bFireThrottledRequests) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine(); LogWriter.WriteLine("Polling for reviews at {0}...", DateTime.Now.ToString()); ////////////// /// Initial Ids ////////////// if (ApiVersion == 0) { LatestData InitialIds = RESTApi.GET <LatestData>(ApiUrl, "latest", string.Format("project={0}", Project)); ApiVersion = (InitialIds.Version == 0)? 1 : InitialIds.Version; LatestIds.LastBuildId = InitialIds.LastBuildId; LatestIds.LastCommentId = InitialIds.LastCommentId; LatestIds.LastEventId = InitialIds.LastEventId; } if (ApiVersion == 2) { int NewMinChangeCopy = NewMinChange; if (NewMinChangeCopy != 0) { // If the range of changes has decreased, update the MinChange value before we fetch anything MinChange = Math.Max(MinChange, NewMinChangeCopy); // Get the first part of the query string CommonArgs = String.Format("stream={0}", MetadataStream); if (MetadataProject != null) { CommonArgs += String.Format("&project={0}", MetadataProject); } // Fetch any updates in the current range of changes if (MinChange != 0) { GetMetadataListResponseV2 NewEventList = RESTApi.GET <GetMetadataListResponseV2>(ApiUrl, "metadata", String.Format("{0}&minchange={1}&sequence={2}", CommonArgs, MinChange, MetadataSequenceNumber)); foreach (GetMetadataResponseV2 NewEvent in NewEventList.Items) { IncomingMetadata.Enqueue(NewEvent); } MetadataSequenceNumber = Math.Max(NewEventList.SequenceNumber, MetadataSequenceNumber); } // Fetch any new changes if (NewMinChangeCopy < MinChange) { GetMetadataListResponseV2 NewEvents = RESTApi.GET <GetMetadataListResponseV2>(ApiUrl, "metadata", String.Format("{0}&minchange={1}&maxchange={2}", CommonArgs, NewMinChangeCopy, MinChange)); foreach (GetMetadataResponseV2 NewEvent in NewEvents.Items) { IncomingMetadata.Enqueue(NewEvent); } MinChange = NewMinChangeCopy; } } } else { ////////////// /// Bulids ////////////// List <BadgeData> Builds = RESTApi.GET <List <BadgeData> >(ApiUrl, "build", string.Format("project={0}", Project), string.Format("lastbuildid={0}", LatestIds.LastBuildId)); foreach (BadgeData Build in Builds) { IncomingBadges.Enqueue(Build); LatestIds.LastBuildId = Math.Max(LatestIds.LastBuildId, Build.Id); } ////////////////////////// /// Throttled Requests ////////////////////////// if (bFireThrottledRequests) { ////////////// /// Reviews ////////////// List <EventData> Events = RESTApi.GET <List <EventData> >(ApiUrl, "event", string.Format("project={0}", Project), string.Format("lasteventid={0}", LatestIds.LastEventId)); foreach (EventData Review in Events) { IncomingEvents.Enqueue(Review); LatestIds.LastEventId = Math.Max(LatestIds.LastEventId, Review.Id); } ////////////// /// Comments ////////////// List <CommentData> Comments = RESTApi.GET <List <CommentData> >(ApiUrl, "comment", string.Format("project={0}", Project), string.Format("lastcommentid={0}", LatestIds.LastCommentId)); foreach (CommentData Comment in Comments) { IncomingComments.Enqueue(Comment); LatestIds.LastCommentId = Math.Max(LatestIds.LastCommentId, Comment.Id); } } } LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Last update failed: ({0})", Ex.ToString()); return(false); } }
private void ShowIssue(IssueData Issue) { Issue.Builds = RESTApi.GET <List <IssueBuildData> >(IssueMonitor.ApiUrl, String.Format("issues/{0}/builds", Issue.Id)); IssueDetailsWindow.Show(Owner, IssueMonitor, ServerAndPort, UserName, ServerTimeOffset, Issue, Log, CurrentStream); }