Ejemplo n.º 1
0
        public async Task UpdateProviderSourceDatasetHistory(IEnumerable <ProviderSourceDatasetHistory> providerSourceDatasets)
        {
            Guard.ArgumentNotNull(providerSourceDatasets, nameof(providerSourceDatasets));

            List <Task>   allTasks  = new List <Task>();
            SemaphoreSlim throttler = new SemaphoreSlim(initialCount: 15);

            foreach (ProviderSourceDatasetHistory dataset in providerSourceDatasets)
            {
                await throttler.WaitAsync();

                allTasks.Add(
                    Task.Run(async() =>
                {
                    try
                    {
                        await _cosmosRepository.CreateAsync(new KeyValuePair <string, ProviderSourceDatasetHistory>(dataset.ProviderId, dataset));
                    }
                    finally
                    {
                        throttler.Release();
                    }
                }));
            }
            await Task.WhenAll(allTasks);
        }
        public async Task SaveVersion(T newVersion, T currentVersion = null)
        {
            if (currentVersion == null)
            {
                newVersion.Version = 1;

                newVersion.PublishStatus = PublishStatus.Draft;
            }
            else
            {
                newVersion.Version = await GetNextVersionNumber(newVersion);

                switch (currentVersion.PublishStatus)
                {
                case PublishStatus.Draft:
                    newVersion.PublishStatus = PublishStatus.Draft;
                    break;

                case PublishStatus.Approved:
                    if (newVersion.PublishStatus == PublishStatus.Draft)
                    {
                        break;
                    }
                    else
                    {
                        newVersion.PublishStatus = PublishStatus.Updated;
                    }
                    break;

                default:
                    newVersion.PublishStatus = PublishStatus.Updated;
                    break;
                }
            }

            newVersion.Date = DateTimeOffset.Now.ToLocalTime();

            await _cosmosRepository.CreateAsync <T>(newVersion);
        }
Ejemplo n.º 3
0
 public Task <HttpStatusCode> SaveDefinitionSpecificationRelationship(DefinitionSpecificationRelationship relationship)
 {
     return(_cosmosRepository.CreateAsync(relationship));
 }
 public async Task CreateDatasetAggregations(DatasetAggregations datasetAggregations)
 {
     await _cosmosRepository.CreateAsync <DatasetAggregations>(datasetAggregations);
 }
Ejemplo n.º 5
0
 public async Task <HttpStatusCode> SaveJobDefinition(JobDefinition definition)
 {
     return(await _cosmosRepository.CreateAsync(definition));
 }
Ejemplo n.º 6
0
 public async Task <HttpStatusCode> CreateDraftCalculation(Calculation calculation)
 {
     return(await _cosmosRepository.CreateAsync(calculation));
 }
Ejemplo n.º 7
0
 public Task <HttpStatusCode> CreateBuildProject(BuildProject buildProject)
 {
     return(_cosmosRepository.CreateAsync(buildProject));
 }