Esempio n. 1
0
        public async Task RunAsync(TimeSpan waitPeriodAfterEachUpdate, CancellationToken ct)
        {
            var buildManagement   = new BuildManagement(devOpsAccessSetting);
            var releaseManagement = new ReleaseManagement(devOpsAccessSetting);
            var bugWiqlManagement = new BugWiqlManagement(devOpsAccessSetting);
            var bugManagement     = new BugManagement(devOpsAccessSetting);

            while (!ct.IsCancellationRequested)
            {
                await ImportVstsBugDataAsync(bugWiqlManagement, bugQueries);

                foreach (string branch in this.branches)
                {
                    foreach (BuildDefinitionId buildDefinitionId in BuildExtension.BuildDefinitions)
                    {
                        IList <VstsBuild> builds = await GetBuildsAndTrackLastUpdatedAsync(buildManagement, buildDefinitionId, branch);

                        Console.WriteLine($"Received {builds.Count} builds");
                        ImportVstsBuildsDataForSpecificDefinitionAsync(builds, buildDefinitionId);
                        await OpenBugsForFailingBuilds(bugManagement, builds, branch, buildDefinitionId);
                    }
                }

                foreach (string branch in this.branches)
                {
                    await ImportVstsReleasesDataAsync(releaseManagement, branch, ReleaseDefinitionId.E2ETest);
                }

                Console.WriteLine($"Import Vsts data finished at {DateTime.UtcNow}; wait {waitPeriodAfterEachUpdate} for next update.");
                await Task.Delay((int)waitPeriodAfterEachUpdate.TotalMilliseconds);
            }
        }
Esempio n. 2
0
        async Task ImportVstsBugDataAsync(BugWiqlManagement bugWiqlManagement, HashSet <BugWiqlQuery> bugQueries)
        {
            Console.WriteLine($"Import VSTS bugs started at {DateTime.UtcNow}.");
            SqlConnection sqlConnection = null;

            try
            {
                sqlConnection = new SqlConnection(this.dbConnectionString);
                sqlConnection.Open();
                foreach (BugWiqlQuery bugQuery in bugQueries)
                {
                    int bugCount = await bugWiqlManagement.GetBugsCountAsync(bugQuery);

                    Console.WriteLine($"Query VSTS bugs for area [{bugQuery.Area}] and priority [{bugQuery.BugPriorityGrouping.Priority}] and inProgress [{bugQuery.InProgress}]: last update={DateTime.UtcNow} => result count={bugCount}");
                    UpsertVstsBugCountToDb(sqlConnection, bugQuery, bugCount);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                sqlConnection?.Close();
            }
        }