Ejemplo n.º 1
0
        private void GetAndSetPItems()
        {
            Pivot p = BuildP;

            if (p != null)
            {
                PivotItem pi = p.SelectedItem as PivotItem;
                if (pi == null)
                {
                    return;
                }

                if (pi.Name.Equals("summaryPI"))
                {
                    if (build == null)
                    {
                        summarySP.Visibility = Visibility.Collapsed;
                        ShowProgressBar();
                        Task.Factory.StartNew(() =>
                        {
                            build = VSTSService.GetABuild(buildReceived.Url);
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                summaryPI.DataContext = build;
                                if (build.FinishTime != null && build.StartTime != null)
                                {
                                    durationTB.Text = build.FinishTime.Subtract(build.StartTime).TotalMinutes + " mins";
                                }
                                HideProgressBar();
                                summarySP.Visibility = Visibility.Visible;
                            });
                        });
                    }
                    else
                    {
                        summaryPI.DataContext = build;
                        summarySP.Visibility  = Visibility.Visible;
                    }
                }
                else if (pi.Name.Equals("timelinePI"))
                {
                    ShowProgressBar();
                    if (timelineRecords != null)
                    {
                        HideProgressBar();
                        timelineLV.ItemsSource = timelineRecords;
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            timelineRecords = VSTSService.GetBuildTimeLineRecords(build.Url + "/timeline");
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                timelineLV.ItemsSource = timelineRecords;
                                HideProgressBar();
                            });
                        });
                    }
                }
                else if (pi.Name.Equals("artifactsPI"))
                {
                    ShowProgressBar();
                    if (artifactsList != null)
                    {
                        HideProgressBar();
                        artifactsLV.ItemsSource = artifactsList;
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            artifactsList = VSTSService.GetBuildArtifactss(build.Url + "/artifacts");
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                artifactsLV.ItemsSource = artifactsList;
                                HideProgressBar();
                            });
                        });
                    }
                }
                //if (BuildP != null)
                //{
                //    pivotIndex = BuildP.SelectedIndex;
                //}
            }
        }