コード例 #1
0
        // Clean up any stale data since this is a snapshot of data ingestion
        private void Cleanup()
        {
            this.logger.LogInformation($"Deleting up stale data for {this.vssClient.OrganizationName}...");
            using VssDbContext dbContext            = new VssDbContext(logger, this.sqlServerConnectionString);
            using IDbContextTransaction transaction = dbContext.Database.BeginTransaction();
            int deletedBuildDefinitionResult     = dbContext.BulkDelete(dbContext.VssBuildDefinitionEntities.Where(v => v.Organization == this.vssClient.OrganizationName && v.RowUpdatedDate < Helper.UtcNow));
            int deletedBuildDefinitionStepResult = dbContext.BulkDelete(dbContext.VssBuildDefinitionStepEntities.Where(v => v.Organization == this.vssClient.OrganizationName && v.RowUpdatedDate < Helper.UtcNow).ToList());

            transaction.Commit();
            this.logger.LogInformation($"Done deleting {deletedBuildDefinitionResult} build definitions and {deletedBuildDefinitionStepResult} build definition steps");
        }
コード例 #2
0
        private void IngestData(List <TeamProjectReference> projects)
        {
            List <VssProjectEntity> entities = new List <VssProjectEntity>();

            foreach (TeamProjectReference project in projects)
            {
                VssProjectEntity entity = new VssProjectEntity
                {
                    Organization   = this.vssClient.OrganizationName,
                    ProjectId      = project.Id,
                    Name           = project.Name,
                    LastUpdateTime = project.LastUpdateTime,
                    Revision       = project.Revision,
                    State          = project.State.ToString(),
                    Visibility     = project.Visibility.ToString(),
                    Url            = project.Url,
                };
                entities.Add(entity);
            }

            this.logger.LogInformation("Start ingesting projects data...");
            using VssDbContext context = new VssDbContext(logger, this.sqlConnectionString);
            using IDbContextTransaction transaction = context.Database.BeginTransaction();
            context.BulkDelete(context.VssProjectEntities.Where(v => v.Organization == this.vssClient.OrganizationName));
            int insertedResult = context.BulkInsert(entities);

            transaction.Commit();
            this.logger.LogInformation($"Done ingesting {insertedResult} records");
        }