private void LoadIcon(BuildStatusEnum statusValue, bool isInProgress, bool isStuck)
        {
            BuildStatus status = new BuildStatus(statusValue, isInProgress, isStuck);
            if (iconsByKey.ContainsKey(status.Key))
                return;

            try
            {
                string resourceName = string.Format("JenkinsTray.Resources.TrayIcons.{0}.ico", status.Key);
                Icon icon = ResourceImageHelper.CreateIconFromResources(resourceName, GetType().Assembly);
                iconsByKey.Add(status.Key, icon);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(JenkinsTrayResources.FailedLoadingIcons_Text,
                    JenkinsTrayResources.FailedLoadingIcons_Caption,
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                LoggingHelper.LogError(logger, ex);
                throw new Exception("Failed loading icon: " + statusValue, ex);
            }
        }
        private void UpdateIcon(BuildStatus buildStatus)
        {
            Icon icon = iconsByKey[buildStatus.Key];
            notifyIcon.Icon = icon;

            // update the main window's icon
            if (ConfigurationService.GeneralSettings.UpdateMainWindowIcon)
                MainForm.Instance.UpdateIcon(icon);
        }
 public void AcknowledgeStatus(Project project, BuildStatus currentStatus)
 {
     lock (acknowledgedStatusByProject)
     {
         acknowledgedStatusByProject[project] = currentStatus;
     }
     UpdateNotifier();
 }
        private void DoUpdateNotifier()
        {
            BuildStatusEnum? worstBuildStatus = null;
            bool buildInProgress = false;
            bool buildIsStuck = false;
            var errorProjects = new HashedSet<Project>();
            var regressingProjects = new HashedSet<Project>();
            var progressingAndErrorProjects = new HashedSet<Project>();
            var interestingProjects = new HashedSet<Project>();

            foreach (Server server in ConfigurationService.Servers)
            {
                foreach (Project project in server.Projects)
                {
                    BuildStatus status = GetProjectStatus(project);
                    if (worstBuildStatus == null || status.Value > worstBuildStatus)
                        worstBuildStatus = status.Value;
                    if (status.Value >= BuildStatusEnum.Failed)
                        errorProjects.Add(project);
                    if (status.Value > BuildStatusEnum.Successful)
                        progressingAndErrorProjects.Add(project);
                    if (status.IsInProgress)
                    {
                        buildInProgress = true;
                        progressingAndErrorProjects.Add(project);
                    }
                    if (status.IsStuck)
                        buildIsStuck = true;
                    if (IsRegressing(project))
                        regressingProjects.Add(project);
                    lastProjectsBuildDetails[project] = project.AllBuildDetails;

                    if (project.Activity.HasBuildActivity)
                    {
                        interestingProjects.Add(project);
                    }
                }
            }

            if (worstBuildStatus == null)
                worstBuildStatus = BuildStatusEnum.Unknown;

            #if false // tests
            lastBuildStatus++;
            if (lastBuildStatus > BuildStatus.Failed_BuildInProgress)
                lastBuildStatus = 0;
            worstBuildStatus = lastBuildStatus;
            Console.WriteLine("tray:"+lastBuildStatus);
            #endif

            BuildStatus buildStatus = new BuildStatus(worstBuildStatus.Value, buildInProgress, buildIsStuck);

            UpdateIcon(buildStatus);
            UpdateBalloonTip(errorProjects, regressingProjects);
            UpdateTrayTooltip(progressingAndErrorProjects);
            ShowBallowTip(interestingProjects);

            lastBuildStatus = buildStatus;
        }
 private bool TreatAsFailure(BuildStatus status)
 {
     return status.Value == BuildStatusEnum.Failed
         || status.Value == BuildStatusEnum.Unstable;
 }
Beispiel #6
0
 public static bool IsWorse(BuildStatus status, BuildStatus thanStatus)
 {
     bool res = status.Value > thanStatus.Value;
     return res;
 }
Beispiel #7
0
 public static bool IsErrorBuild(BuildStatus status)
 {
     return IsErrorBuild(status.Value);
 }
Beispiel #8
0
 public static BuildStatus DegradeStatus(BuildStatus status)
 {
     return new BuildStatus(status.Value, false, status.IsStuck);
 }
Beispiel #9
0
        private void LoadIcon(BuildStatusEnum statusValue, bool isInProgress, bool isStuck)
        {
            BuildStatus status = new BuildStatus(statusValue, isInProgress, isStuck);
            if (iconsByKey.ContainsKey(status.Key))
                return;

            try
            {
                string resourceName = string.Format("JenkinsTray.Resources.StatusIcons.{0}.gif", status.Key);
                Image img = ResourceImageHelper.CreateImageFromResources(resourceName, GetType().Assembly);
                byte[] imgBytes = DevExpress.XtraEditors.Controls.ByteImageConverter.ToByteArray(img, ImageFormat.Gif);
                iconsByKey.Add(status.Key, imgBytes);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(JenkinsTrayResources.FailedLoadingIcons_Text,
                    JenkinsTrayResources.FailedLoadingIcons_Caption,
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                LoggingHelper.LogError(logger, ex);
                throw new Exception("Failed loading icon: " + status, ex);
            }
        }