Exemplo n.º 1
0
        private async void InitializeIssueAutoUpdate(string url, JiraConfig jiraConfig,
                                                     JiraQuery jiraQuery, JiraIssueViewModelBase viewModel, JiraApiService jiraApiService,
                                                     JiraStatusCategory jiraStatusCategory)
        {
            const string apiBase = "/search";

            var issueResult = await _apiRequestService.MakeRequestWithBasicAuthAsync <APIIssueRequestRoot>(new Uri($"{url}{apiBase}"),
                                                                                                           jiraConfig.Username, Encoding.UTF8.GetString(Convert.FromBase64String(jiraConfig.Password)), jiraQuery.ToString());

            if (issueResult.StatusCode == 200)
            {
                viewModel.IssuesTotal = issueResult.Data.total;
                viewModel.AddOrUpdateNewIssues(jiraApiService.ParseIssues(issueResult));
                viewModel.Refresh();
            }

            var lastPage = IsLastPage(50, issueResult.Data.startAt, issueResult.Data.total);

            var startAt = 0;

            if (!lastPage)
            {
                startAt += issueResult.Data.issues.Length;
            }

            await SetupJiraWindow(url, apiBase, lastPage, startAt, jiraConfig, jiraQuery,
                                  viewModel, jiraApiService, issueResult.Data.total, jiraStatusCategory);
        }
Exemplo n.º 2
0
        private async Task MakeAsyncRequest(string url, string apiBase, JiraConfig jiraConfig,
                                            JiraQuery jiraQuery, JiraIssueViewModelBase viewModel, JiraApiService jiraApiService, int startAt)
        {
            async void Callback()
            {
                var issueResult = await _apiRequestService.MakeRequestWithBasicAuthAsync <APIIssueRequestRoot>(
                    new Uri($"{url}{apiBase}"), jiraConfig.Username, Encoding.UTF8.GetString(Convert.FromBase64String(jiraConfig.Password)), $"{jiraQuery}&startAt={startAt}");

                if (issueResult.StatusCode == 200)
                {
                    viewModel.AddOrUpdateNewIssues(jiraApiService.ParseIssues(issueResult));
                    viewModel.Refresh();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            await Task.Run(() => Dispatcher.Invoke(Callback));
        }