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); } }
public bool Run(out string ErrorMessage) { Issues = RESTApi.GET <List <IssueData> >(ApiUrl, String.Format("issues?includeresolved=true&maxresults={0}", MaxResults)); ErrorMessage = null; return(true); }
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); } }
void SendMetadataUpdateUpdateV2(int Change, string Project, string UserName, EventType?Event, string Comment) { UpdateMetadataRequestV2 Update = new UpdateMetadataRequestV2(); Update.Stream = MetadataStream; Update.Project = MetadataProject; Update.Change = Change; Update.UserName = UserName; if (Event != null) { switch (Event) { case EventType.Syncing: Update.Synced = true; break; case EventType.Compiles: Update.Vote = nameof(UgsUserVote.CompileSuccess); break; case EventType.DoesNotCompile: Update.Vote = nameof(UgsUserVote.CompileFailure); break; case EventType.Good: Update.Vote = nameof(UgsUserVote.Good); break; case EventType.Bad: Update.Vote = nameof(UgsUserVote.Bad); break; case EventType.Unknown: Update.Vote = nameof(UgsUserVote.None); break; case EventType.Starred: Update.Starred = true; break; case EventType.Unstarred: Update.Starred = false; break; case EventType.Investigating: Update.Investigating = true; break; case EventType.Resolved: Update.Investigating = false; break; } } Update.Comment = Comment; RESTApi.POST(ApiUrl, "metadata", new JavaScriptSerializer().Serialize(Update)); }
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); }
bool SendUpdate(IssueUpdateData Update) { try { RESTApi.PUT <IssueUpdateData>(ApiUrl, String.Format("issues/{0}", Update.Id), Update); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Failed to send update: ({0})", Ex.ToString()); return(false); } }
bool SendEventToBackend(EventData Event) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting event... ({0}, {1}, {2})", Event.Change, Event.UserName, Event.Type); RESTApi.POST(ApiUrl, "event", new JavaScriptSerializer().Serialize(Event)); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendErrorData(TelemetryErrorData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting error data... ({0}, {1})", Data.Type, Data.Timestamp); RESTApi.POST(ApiUrl, "error", new JavaScriptSerializer().Serialize(Data), string.Format("Version={0}", Version), string.Format("IpAddress={0}", IpAddress)); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendTimingData(TelemetryTimingData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting timing data... ({0}, {1}, {2}, {3}, {4}, {5})", Data.Action, Data.Result, Data.UserName, Data.Project, Data.Timestamp, Data.Duration); RESTApi.POST(ApiUrl, "telemetry", new JavaScriptSerializer().Serialize(Data), string.Format("Version={0}", Version), string.Format("IpAddress={0}", IpAddress)); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendCommentToBackend(CommentData Comment) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting comment... ({0}, {1}, {2}, {3})", Comment.ChangeNumber, Comment.UserName, Comment.Text, Comment.Project); RESTApi.POST(ApiUrl, "comment", new JavaScriptSerializer().Serialize(Comment)); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
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); }