Example #1
0
        private void SetItemSource()
        {
            ShowProgressBar();
            Task.Factory.StartNew(() =>
            {
                Task.Delay(5000);
                projs = VSTSService.GetVSTSProjects();
            }).ContinueWith(async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    source = new List <ItemDetails>();

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

                    ((CollectionViewSource)Resources["ProjectGroups"]).Source = itemSource;

                    manuallyselected = true;
                    HideProgressBar();
                });
            });
        }
        private void rejectBtn_Click(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            string comments = getApprovalComments();
            string status   = "rejected";

            ShowProgressBar();
            Approval responseApproval;

            Task.Factory.StartNew(() =>
            {
                responseApproval = VSTSService.PatchApproval(approval, status, comments);

                if (responseApproval != null)
                {
                    approval = responseApproval;
                }
            }).ContinueWith(async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    approvalCardSP.DataContext = approval;
                    HideProgressBar();
                });
            });
        }
 private void ShowApprovals()
 {
     if (approvalsList == null || approvalsList.Count < 1 || ifRefresh)
     {
         ShowProgressBar();
         Task.Factory.StartNew(() =>
         {
             //if(releasesList.Count == 0)
             //{
             //    approvalsList = VSTSService.GetApprovals();
             //}
             //else
             //{
             //    approvalsList = VSTSService.GetApprovals(releasesList);
             //}
             approvalsList = VSTSService.GetApprovals();
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 approvalsLV.ItemsSource = approvalsList;
                 HideProgressBar();
             });
         });
     }
     else
     {
         approvalsLV.ItemsSource = approvalsList;
         HideProgressBar();
     }
 }
 private void ShowLogsData()
 {
     ShowProgressBar();
     if (ifRefresh || release == null)
     {
         Task.Factory.StartNew(() =>
         {
             release = VSTSService.GetARelease(releaseId);
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 envPickerCB.ItemsSource   = release.Environments;
                 envPickerCB.SelectedIndex = 0;
                 HideProgressBar();
             });
         });
     }
     else
     {
         ShowProgressBar();
         envPickerCB.ItemsSource = release.Environments;
         HideProgressBar();
     }
 }
 private void ShowReleases()
 {
     if (releasesList == null || releasesList.Count < 1 || ifRefresh)
     {
         ShowProgressBar();
         Task.Factory.StartNew(() =>
         {
             if (releaseDefinition != null && releaseDefinition.Artifacts != null)
             {
                 releaseDefinition = VSTSService.GetAReleaseDefinition(releaseDefinition.Id);
             }
             releasesList = VSTSService.GetReleases(releaseDefinition);
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 releasesLV.ItemsSource = releasesList;
                 HideProgressBar();
             });
         });
     }
     else
     {
         releasesLV.ItemsSource = releasesList;
         HideProgressBar();
     }
 }
 private void ShowSummaryData()
 {
     if (release == null || ifRefresh)
     {
         ReleaseP.Visibility = Visibility.Collapsed;
         ShowProgressBar();
         Task.Factory.StartNew(() =>
         {
             release = VSTSService.GetARelease(releaseId);
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 summarySP.DataContext   = release;
                 artifactsLV.ItemsSource = release.Artifacts;
                 headerTB.Text           = release.Name;
                 HideProgressBar();
                 ReleaseP.Visibility = Visibility.Visible;
             });
         });
     }
     else
     {
         summarySP.DataContext = release;
         HideProgressBar();
         ReleaseP.Visibility = Visibility.Visible;
     }
 }
Example #7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Utility.SetStatusBarColor("#212121", "#ffffff", 1);

            log        = e.Parameter as StringKeyValuePair;
            logTB.Text = log.key;
            string logStr = "";

            ShowProgressBar();
            logSV.Visibility = Visibility.Collapsed;
            Task.Factory.StartNew(() =>
            {
                string logsUrl = log.value;
                if (logsUrl.ToLowerInvariant().Contains("/release/releases"))
                {
                    logStr = VSTSService.GetReleaseLogs(logsUrl);
                }
                else
                {
                    logStr = VSTSService.GetBuildTimelineRecordLogs(logsUrl);
                }
            }).ContinueWith(async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    logTextTB.Text = logStr;
                    HideProgressBar();

                    logSV.Visibility = Visibility.Visible;
                });
            });
        }
        private void GetArtifactsVersions()
        {
            string postBodyForGettingArtifactVersions = getPostBodyForGettingArtifactVersions();

            releaseArtifactsWithVersionsList = VSTSService.GetReleaseArtifactsVersions(releaseDefinition.Artifacts, postBodyForGettingArtifactVersions);
            artifactsLV.ItemsSource          = releaseArtifactsWithVersionsList;
        }
 private void ShowApprovalsData()
 {
     if (ifRefresh || release == null || approvalsList == null || approvalsList.Count < 1)
     {
         ShowProgressBar();
         Task.Factory.StartNew(() =>
         {
             if (release == null)
             {
                 release = VSTSService.GetARelease(releaseId);
             }
             approvalsList = getApprovalListFromRelease(release);
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 approvalsLV.ItemsSource = approvalsList;
                 HideProgressBar();
             });
         });
     }
     else
     {
         ShowProgressBar();
         approvalsLV.ItemsSource = approvalsList;
         HideProgressBar();
     }
 }
 public TicketViewModel(TicketService ticketService, UserManager <ApplicationUser> userManager, IMailManager mailManager, VSTSService vstsService, UserService userService, ExactOnlineService exactOnlineService, UserInCompanyService userInCompanyService, ApplicationDbContext context)
 {
     m_ticketService        = ticketService;
     m_userManager          = userManager;
     m_mailmanager          = mailManager;
     m_VSTSService          = vstsService;
     m_userService          = userService;
     m_exactOnlineService   = exactOnlineService;
     m_userInCompanyService = userInCompanyService;
     m_context = context;
 }
Example #11
0
        private QueuedBuild queueBuild()
        {
            bool        success = false;
            string      branch  = build.SourceBranch;
            QueuedBuild queuedB = new QueuedBuild();

            if (String.IsNullOrWhiteSpace(branch))
            {
                branch = build.SourceBranch == null ? "" : build.SourceBranch;
            }

            success = VSTSService.QueueBuild(build.Definition.Id, branch, "", out queuedB);

            return(queuedB);
        }
        private QueuedBuild queueBuild(Build b, string branch)
        {
            bool        success = false;
            QueuedBuild queuedB = new QueuedBuild();

            if (String.IsNullOrWhiteSpace(branch))
            {
                branch = b.SourceBranch;
            }
            if (b.Definition != null)
            {
                success = VSTSService.QueueBuild(b.Definition.Id, branch, "", out queuedB);
            }
            return(queuedB);
        }
 private void ShowApprovals()
 {
     ShowProgressBar();
     Task.Factory.StartNew(() =>
     {
         approvalsList = VSTSService.GetApprovals();
     }).ContinueWith(async(Task t) =>
     {
         await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             //approvalsLV.ItemsSource = approvalsList;
             HideProgressBar();
         });
     });
 }
        private void GetRDDetailsAndSetUI(string releaseDefinitionId)
        {
            ShowProgressBar();

            Task.Factory.StartNew(() =>
            {
                releaseDefinition = VSTSService.GetAReleaseDefinition(releaseDefinitionId);
            }).ContinueWith((async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    definitionTB.Text = releaseDefinition.Name;
                    GetArtifactsVersions();
                    HideProgressBar();
                });
            }));
        }
Example #15
0
        private QueuedBuild queueBuild(BuildDefinition b, string branch, string description)
        {
            bool        success = false;
            QueuedBuild queuedB = new QueuedBuild();

            if (String.IsNullOrWhiteSpace(branch))
            {
                if (b.Repository != null)
                {
                    branch = b.Repository.DefaultBranch == null ? "" : b.Repository.DefaultBranch;
                }
            }

            success = VSTSService.QueueBuild(b.Id, branch, description, out queuedB);

            return(queuedB);
        }
        public void GetAndSetWorkItemCategories()
        {
            string api = String.Format(Constants.API_GET_WI_CATEGORIES, lc.VSTSAccountUrl, Project);

            string responseBody = VSTSService.GetResponseFromGetRESTUri(api);

            if (responseBody != null)
            {
                try
                {
                    dynamic json = JsonConvert.DeserializeObject(responseBody);


                    foreach (var v in json.value)
                    {
                        string s = v.referenceName;
                        if (s != null && !s.Equals(String.Empty))
                        {
                            switch (s)
                            {
                            case WI_FEATURE_CATEGORY:
                                FeatureTypeName = v.defaultWorkItemType.name;
                                break;

                            case WI_REQUIREMENT_CATEGORY:
                                RequirementTypeName = v.defaultWorkItemType.name;
                                break;

                            case WI_TASK_CATEGORY:
                                TaskTypeName = v.defaultWorkItemType.name;
                                break;

                            case WI_BUG_CATEGORY:
                                BugTypeName = v.defaultWorkItemType.name;
                                break;
                            }
                        }
                    }
                }
                catch
                {
                    //
                }
            }
        }
        private void newreleaseABB_Click(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            string descriptionStr = descriptionTB.Text;

            if (!LoginContext.GetLoginContext().Pro)
            {
                descriptionStr += noProDescriptionTB.Text;
            }

            if (!haveAllArtifactsRequired())
            {
                return;
            }

            Release r = null;

            ShowProgressBar();
            Task.Factory.StartNew(() =>
            {
                r = VSTSService.CreateARelease(releaseDefinition.Id, descriptionStr, releaseArtifactsWithVersionsList);
            }).ContinueWith(async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    HideProgressBar();
                    if (r != null && !String.IsNullOrWhiteSpace(r.Id))
                    {
                        Utility.ShowToastMessage("Release created successfully!", r.Name);
                        if (Frame.CanGoBack)
                        {
                            Frame.GoBack();
                        }
                    }
                    else
                    {
                        Utility.ShowToastMessage("Failed to create release.", "Please retry later...");
                    }
                });
            });
        }
Example #18
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Login);

            spConfig = GetSharedPreferences("config", FileCreationMode.Private);
            activity = this;

            webView = (WebView)FindViewById(Resource.Id.webView);
            webView.Settings.JavaScriptEnabled       = true;
            webView.Settings.DefaultTextEncodingName = "utf-8";
            webView.Settings.UseWideViewPort         = true;

            //判断是否已经登录
            var refreshToken = spConfig.GetString("refresh_token", string.Empty);

            if (!string.IsNullOrEmpty(refreshToken))
            {
                webView.LoadUrl("file:///android_asset/loading.html");
                //获取新的token,存储并跳转
                var service     = new TokenService(this);
                var accessToken = await service.RefreshToken(refreshToken);

                //获取项目及workitem信息并保存
                var VSTSService = new VSTSService(accessToken);
                var projects    = await VSTSService.GetMyProjectAsync();

                var workitems = await VSTSService.GetWorkItemsAsync();

                var spData = GetSharedPreferences("data", FileCreationMode.Private);
                var editor = spData.Edit();
                editor.PutString("projects", JsonConvert.SerializeObject(projects));
                editor.PutString("workitems", JsonConvert.SerializeObject(workitems));
                editor.Commit();

                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                webView.SetWebViewClient(new MyWebViewClient());
                webView.LoadUrl("https://workitem.msdev.cc/");
            }
        }
        private string getReleaseUrlFor(Release release)
        {
            string releaseUrl = "INVALID_URL_REQUEST";

            if (release != null)
            {
                if (!String.IsNullOrWhiteSpace(release.Url))
                {
                    releaseUrl = release.Url;
                }
                else
                {
                    releaseUrl = VSTSService.getReleaseServiceUrl() + "/DefaultCollection/" + ProjectContext.GetProjectContext().Project + "/_apis/release/releases/" + release.Id;
                }
            }

            return(releaseUrl);
        }
 private void ShowRDDetails()
 {
     ShowProgressBar();
     detailsSP.Visibility = Visibility.Collapsed;
     Task.Factory.StartNew(() =>
     {
         if (releaseDefinition == null || releaseDefinition.Artifacts == null)
         {
             releaseDefinition = VSTSService.GetAReleaseDefinition(releaseDefinition.Id);
         }
     }).ContinueWith(async(Task t) =>
     {
         await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             detailsPI.DataContext = releaseDefinition;
             HideProgressBar();
             detailsSP.Visibility = Visibility.Visible;
         });
     });
 }
 private void ShowEnvironmentsData()
 {
     if (ifRefresh || release == null)
     {
         Task.Factory.StartNew(() =>
         {
             release = VSTSService.GetARelease(releaseId);
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 environmentsLV.ItemsSource = release.Environments;
                 ifRefresh = false;
             });
         });
     }
     else
     {
         environmentsLV.ItemsSource = release.Environments;
     }
 }
        private void ShowDefintionDetails()
        {
            if (releaseDefList == null || releaseDefList.Count < 1 || ifRefresh)
            {
                ShowProgressBar();
                Task.Factory.StartNew(() =>
                {
                    releaseDefList = VSTSService.GetReleaseDefinitions();
                }).ContinueWith(async(Task t) =>
                {
                    await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        if (releaseDefList != null)
                        {
                            source = new List <ItemDetails>();

                            foreach (var bd in releaseDefList)
                            {
                                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
                        {
                            Utility.ShowMsg("Unable to get release definitions list. Check internet connection and try again later.");
                        }
                    });
                });
            }
            else
            {
                ((CollectionViewSource)Resources["DefinitionGroups"]).Source = itemSource;
                manuallyselected = true;
            }
        }
        public void GetAndSetProjectDetails()
        {
            LoginContext lc     = LoginContext.GetLoginContext();
            string       apiUrl = String.Format(Constants.GET_API_TEAM_PROJECT_WITH_CAPABILITIES, lc.VSTSAccountUrl, Project);

            string responseBody = VSTSService.GetResponseFromGetRESTUri(apiUrl);

            if (responseBody != null)
            {
                try
                {
                    dynamic json = JsonConvert.DeserializeObject(responseBody);
                    RepositoryType  = json.capabilities.versioncontrol.sourceControlType;
                    ProjectTemplate = json.capabilities.processTemplate.templateName;

                    localSettings.Values[str_project]         = _project;
                    localSettings.Values[str_repositoryType]  = _repositoryType;
                    localSettings.Values[str_projectTemplate] = _projectTemplate;
                }
                catch { }
            }
        }
Example #24
0
 private void ShowMyApprovals()
 {
     if (myApprovalsList == null || myApprovalsList.Count < 1 || ifRefresh)
     {
         ShowProgressBar();
         Task.Factory.StartNew(() =>
         {
             myApprovalsList = VSTSService.GetMyApprovals();
         }).ContinueWith(async(Task t) =>
         {
             await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 myApprovalsLV.ItemsSource = myApprovalsList;
                 HideProgressBar();
             });
         });
     }
     else
     {
         myApprovalsLV.ItemsSource = myApprovalsList;
         HideProgressBar();
     }
 }
        private void approveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            string comments = getApprovalComments();
            string status   = "approved";


            ShowProgressBar();
            Approval responseApproval;

            Task.Factory.StartNew(() =>
            {
                responseApproval = VSTSService.PatchApproval(approval, status, comments);

                if (responseApproval != null)
                {
                    approval = responseApproval;
                }
            }).ContinueWith(async(Task t) =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    approvalCardSP.DataContext = approval;

                    if (!approval.Status.ToLowerInvariant().Equals("pending"))
                    {
                        noProCommentsTB.Visibility = Visibility.Collapsed;
                    }
                    HideProgressBar();
                });
            });
        }
Example #26
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;
                //}
            }
        }
Example #27
0
        public static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();
            string vstsUrl          = Configuration["VSTS:URL"];
            string vstsToken        = Configuration["VSTS:Token"];
            string vstsProject      = Configuration["VSTS:Project"];
            string vstsQuery        = Configuration["VSTS:Query"];
            string vstsJiraKeyField = Configuration["VSTS:JIRAKeyField"];
            string jiraUrl          = Configuration["JIRA:URL"];
            string jiraProject      = Configuration["JIRA:Project"];
            string jiraUsername     = Configuration["JIRA:Username"];
            string jiraPassword     = Configuration["JIRA:Password"];

            Dictionary <string, int> keys = new Dictionary <string, int>();

            VSTSService vstsService = new VSTSService();

            string  result    = vstsService.GetWorkItemsByQuery(vstsUrl, vstsToken, vstsProject, vstsQuery);
            dynamic workItems = JObject.Parse(result);

            foreach (var workItem in workItems.value)
            {
                keys.Add(workItem.fields[vstsJiraKeyField].ToString(),
                         Convert.ToInt32(workItem.fields["System.Id"].ToString()));
            }

            JIRAService jiraService = new JIRAService();
            string      response    = jiraService.GetUnresolvedIssuesByProject(jiraUrl,
                                                                               jiraProject, jiraUsername, jiraPassword);

            dynamic responseJson = JObject.Parse(response);

            foreach (var issue in responseJson.issues)
            {
                try
                {
                    string key   = issue.key.ToString();
                    string title = issue.fields.summary.ToString();
                    // include the JIRA key in the workitem title if it's not already there
                    title = title.Contains(key) ? title : key + " " + title;

                    string description = issue.fields.description.ToString();
                    string issueType   = issue.fields.issuetype.name.ToString();
                    string assignedTo  = issue.fields.assignee.displayName.ToString();
                    string status      = issue.fields.status.statusCategory.name.ToString();
                    int    id          = 0;

                    if (keys.ContainsKey(key))
                    {
                        id = keys.GetValueOrDefault(key);
                    }

                    Console.WriteLine("Creating/updating VSTS work item " + issueType + " for JIRA issue " + key);
                    VSTSService service = new VSTSService();
                    service.CreateUpdateWorkItem(id, vstsUrl, "ICT Solutions Delivery", vstsToken, issueType,
                                                 title, description, key, assignedTo, status);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred: " + ex.Message + " - " + ex.StackTrace);
                }
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
Example #28
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;
            }
        }
        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;
                }
            }
        }
 public CreateBugModel(TicketService ticketService, VSTSService vstsService, UserManager <ApplicationUser> userManager)
 {
     m_ticketService = ticketService;
     m_VSTSService   = vstsService;
     m_userManager   = userManager;
 }