private void LoadDataAndSetPIItems()
        {
            Pivot p = BuildP;

            if (p != null)
            {
                PivotItem pi = p.SelectedItem as PivotItem;
                if (pi != null)
                {
                    if (pi.Name.Equals("definitionsPI"))
                    {
                        if (buildDefList == null || buildDefList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                buildDefList = VSTSService.GetBuildDefinitions();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    source = new List <ItemDetails>();

                                    foreach (var bd in buildDefList)
                                    {
                                        source.Add(new ItemDetails(bd.Name));
                                    }
                                    itemSource = AlphaKeyGroup <ItemDetails> .CreateGroups(source,
                                                                                           CultureInfo.CurrentUICulture, s => s.Name, true);

                                    ((CollectionViewSource)Resources["DefinitionGroups"]).Source = itemSource;
                                    manuallyselected = true;
                                    HideProgressBar();
                                }
                                                               );
                            });
                        }
                        else
                        {
                            ((CollectionViewSource)Resources["DefinitionGroups"]).Source = itemSource;
                            manuallyselected = true;
                        }
                    }
                    else if (pi.Name.Equals("completedBuildsPI"))
                    {
                        if (completedBuildsList == null || completedBuildsList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                completedBuildsList = VSTSService.GetBuilds();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    completedBuildsLV.ItemsSource = completedBuildsList;
                                    HideProgressBar();
                                });
                            });
                        }
                        else
                        {
                            completedBuildsLV.ItemsSource = completedBuildsList;
                        }
                    }
                    else if (pi.Name.Equals("queuedBuildsPI"))
                    {
                        if (queuedBuildsList == null || queuedBuildsList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                queuedBuildsList = VSTSService.GetQueuedBuilds();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    queuedBuildsLV.ItemsSource = queuedBuildsList;
                                    HideProgressBar();
                                });
                            });
                        }
                        else
                        {
                            queuedBuildsLV.ItemsSource = queuedBuildsList;
                        }
                    }
                    //else if(pi.Name.Equals(""))
                    //{
                    //    showCB();
                    //}
                    ifRefresh = false;
                }
            }
        }
Ejemplo n.º 2
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 (bd == null || ifRefresh || !bd.Id.Equals(bdReceived.Id))
                    {
                        summarySP.Visibility = Visibility.Collapsed;
                        ShowProgressBar();
                        Task.Factory.StartNew(() =>
                        {
                            bd = VSTSService.GetABuildDefinition(bdReceived);
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                summaryPI.DataContext = bd;
                                HideProgressBar();

                                summarySP.Visibility = Visibility.Visible;
                            });
                        });
                    }
                    else
                    {
                        summaryPI.DataContext = bd;
                        summarySP.Visibility  = Visibility.Visible;
                    }
                }
                else if (pi.Name.Equals("completedBuildsPI"))
                {
                    if (completedBuildsList == null || completedBuildsList.Count < 1 || ifRefresh || !bd.Id.Equals(completedBuildsBDId))
                    {
                        ShowProgressBar();
                        Task.Factory.StartNew(() =>
                        {
                            completedBuildsList = VSTSService.GetBuilds(bd);
                            completedBuildsBDId = bd.Id;
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                completedBuildsLV.ItemsSource = completedBuildsList;
                                HideProgressBar();
                            });
                        });
                    }
                    else
                    {
                        completedBuildsLV.ItemsSource = completedBuildsList;
                        HideProgressBar();
                    }
                }
                else if (pi.Name.Equals("queuedBuildsPI"))
                {
                    if (queuedBuildsList == null || queuedBuildsList.Count < 1 || ifRefresh || !bd.Id.Equals(queuedBuildsBDId))
                    {
                        ShowProgressBar();
                        Task.Factory.StartNew(() =>
                        {
                            queuedBuildsList = VSTSService.GetQueuedBuilds(bd);
                            queuedBuildsBDId = bd.Id;
                        }).ContinueWith(async(Task t) =>
                        {
                            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                queuedBuildsLV.ItemsSource = queuedBuildsList;
                                HideProgressBar();
                            });
                        });
                    }
                    else
                    {
                        queuedBuildsLV.ItemsSource = queuedBuildsList;
                        HideProgressBar();
                    }
                }

                ifRefresh = false;
            }
        }