示例#1
0
        private async Task <PublishedProvider> CreateVersion(PublishedProvider publishedProvider, Reference author)
        {
            IEnumerable <PublishedProviderCreateVersionRequest> publishedProviderCreateVersionRequests =
                _publishedProviderVersioningService.AssemblePublishedProviderCreateVersionRequests(new[] { publishedProvider }, author, PublishedProviderStatus.Updated);

            PublishedProviderCreateVersionRequest publishedProviderCreateVersionRequest = publishedProviderCreateVersionRequests.FirstOrDefault();

            if (publishedProviderCreateVersionRequest == null)
            {
                _logger.Warning($"Assign profile pattern key to published provider with ID: {publishedProvider.Id} failed on create new version step.");

                return(null);
            }

            return(await _publishedProviderVersioningService.CreateVersion(publishedProviderCreateVersionRequest));
        }
        public async Task <int> UpdatePublishedProviderStatus(IEnumerable <PublishedProvider> publishedProviders, Reference author,
                                                              PublishedProviderStatus publishedProviderStatus, string jobId = null, string correlationId = null, bool force = false)
        {
            Guard.ArgumentNotNull(publishedProviders, nameof(publishedProviders));
            Guard.ArgumentNotNull(author, nameof(author));

            IEnumerable <PublishedProviderCreateVersionRequest> publishedProviderCreateVersionRequests = _publishedProviderVersioningService.AssemblePublishedProviderCreateVersionRequests(
                publishedProviders.ToList(),
                author, publishedProviderStatus, jobId, correlationId, force);


            if (!publishedProviderCreateVersionRequests.IsNullOrEmpty())
            {
                bool shouldNotifyProgress = !jobId.IsNullOrWhitespace();

                if (shouldNotifyProgress)
                {
                    await CreatePublishedProviderVersionsInBatches(publishedProviderStatus,
                                                                   publishedProviderCreateVersionRequests.ToList(), jobId);
                }
                else
                {
                    await CreateLatestPublishedProviderVersions(publishedProviderStatus,
                                                                publishedProviderCreateVersionRequests);
                }

                return(publishedProviderCreateVersionRequests.Count());
            }
            else
            {
                return(0);
            }
        }