Exemple #1
0
        private DoWorkResults DoWork(TraySettings traySettings)
        {
            var           mainViewModels = new List <MainViewModel>();
            List <Server> servers        = traySettings.Servers.Where(server => server.BuildPlans.Count > 0).ToList();

            foreach (var server in servers)
            {
                try
                {
                    var bambooService = new BambooService(new Uri(server.Address), server.Username, server.PlaintextPassword);
                    foreach (var buildPlan in server.BuildPlans)
                    {
                        var planDetail = bambooService.GetPlanDetail(buildPlan.Key);
                        planDetail.Results = bambooService.GetPlanResults(buildPlan.Key);

                        var resultDetail = planDetail.Results.FirstOrDefault();
                        if (resultDetail != null)
                        {
                            resultDetail.Detail = bambooService.GetResultDetail(resultDetail.Key);
                        }

                        mainViewModels.Add(MainViewModelBuilder.Build(planDetail, server));
                    }
                }
                catch (BambooRequestException e)
                {
                    return(new DoWorkResults(e));
                }
            }

            return(new DoWorkResults(mainViewModels));
        }
Exemple #2
0
        private void RefreshServerBuild(Server server, List <MainViewModel> plans)
        {
            // todo: should be able to populate per server, but I believe this will only handle 1 server
            try
            {
                var bambooService = new BambooService(new Uri(server.Address), server.Username, server.PlaintextPassword);

                foreach (var buildPlan in server.BuildPlans)
                {
                    var planDetail = bambooService.GetPlanDetail(buildPlan.Key);
                    planDetail.Results = bambooService.GetPlanResults(buildPlan.Key);
                    var resultDetail = planDetail.Results.FirstOrDefault();
                    if (resultDetail != null)
                    {
                        var firstOrDefault = planDetail.Results.FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Detail = bambooService.GetResultDetail(resultDetail.Key);
                        }
                    }

                    plans.Add(MainViewModelBuilder.Build(planDetail, server));
                }

                GetPlansListViewData(plans);
                DoNotifications(plans);
                UpdateTrayIcon(plans);
                _lastBuildData = plans;
            }
            catch (BambooRequestException)
            {
                notifyIcon.Icon = _statusIcons[IconEnum.Grey];
                foreach (ListViewItem item in buildsListView.Items)
                {
                    item.ImageKey = "Offline";
                }
            }
        }