コード例 #1
0
        public void LaunchUrl()
        {
            IssueBuildData LastBuild = Issue.Builds.OrderByDescending(x => x.Change).FirstOrDefault();

            if (LastBuild != null)
            {
                System.Diagnostics.Process.Start(LastBuild.ErrorUrl);
            }
        }
コード例 #2
0
        public void LaunchUrl()
        {
            IssueBuildData LastBuild = Issue.Builds.OrderByDescending(x => x.Change).FirstOrDefault();

            if (LastBuild != null)
            {
                if (String.IsNullOrEmpty(LastBuild.ErrorUrl))
                {
                    MessageBox.Show("No additional information is available");
                }
                else
                {
                    try
                    {
                        System.Diagnostics.Process.Start(LastBuild.ErrorUrl);
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(String.Format("Unable to launch '{0}' (Error: {1})", LastBuild.ErrorUrl, Ex.Message));
                    }
                }
            }
        }
コード例 #3
0
        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)
                {
                    if (NewIssue.Version == 0)
                    {
                        List <IssueBuildData> Builds = RESTApi.GET <List <IssueBuildData> >(ApiUrl, String.Format("issues/{0}/builds", NewIssue.Id));
                        if (Builds != null && Builds.Count > 0)
                        {
                            NewIssue.bIsWarning = !Builds.Any(x => x.Outcome != IssueBuildOutcome.Warning);

                            IssueBuildData LastBuild = Builds.OrderByDescending(x => x.Change).FirstOrDefault();
                            if (LastBuild != null && !String.IsNullOrEmpty(LastBuild.ErrorUrl))
                            {
                                NewIssue.BuildUrl = LastBuild.ErrorUrl;
                            }
                        }
                    }
                }

                // 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);
            }
        }