示例#1
0
        public MarkClean(
            IDictionary <string, string> jobArgsDictionary,
            ILogger <MarkClean> logger,
            CloudStorageAccount cloudStorageAccount,
            string containerName,
            NuGetV2Feed feed,
            PackageValidationAuditor packageValidationAuditor,
            string galleryBaseAddress)
        {
            _logger = logger;
            _cloudStorageAccount = cloudStorageAccount;
            _containerName       = containerName;

            PackageId      = JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.PackageId);
            PackageId      = HttpUtility.UrlDecode(PackageId);
            PackageVersion = JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.PackageVersion);
            PackageVersion = HttpUtility.UrlDecode(PackageVersion);
            var validationIdStr = JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.ValidationId);

            _validationId             = Guid.Parse(validationIdStr);
            _comment                  = JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.Comment);
            _alias                    = JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.Alias);
            _feed                     = feed;
            _packageValidationAuditor = packageValidationAuditor;
            _galleryBaseAddress       = galleryBaseAddress;
        }
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            string maxManifestSizeString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize);

            if (string.IsNullOrEmpty(maxManifestSizeString))
            {
                MaxManifestSize = DefaultMaxAllowedManifestBytes;
            }
            else
            {
                MaxManifestSize = Convert.ToInt64(maxManifestSizeString);
            }

            PackageDatabase = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                    JobArgumentNames.PackageDatabase,
                                                    EnvironmentVariableKeys.SqlGallery));

            Source = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                    JobArgumentNames.SourceStorage, EnvironmentVariableKeys.StorageGallery));
            Backups = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                    JobArgumentNames.BackupStorage, EnvironmentVariableKeys.StorageGallery));

            SourceContainerName  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultSourceContainerName;
            BackupsContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.BackupContainerName) ?? DefaultBackupContainerName;

            SourceContainer  = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
            BackupsContainer = Backups.CreateCloudBlobClient().GetContainerReference(BackupsContainerName);
            return(true);
        }
示例#3
0
文件: Job.cs 项目: edyoung/NuGet.Jobs
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var packageDatabaseConnString = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)).ToString();

            var statisticsDatabaseConnString = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase)).ToString();

            var statisticsStorageAccount = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount));

            var statisticsReportsContainerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName);

            var destination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

            var destinationContainerName =
                JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName)
                ?? DefaultContainerName;

            _destContainer       = destination.CreateCloudBlobClient().GetContainerReference(destinationContainerName);
            _statisticsContainer = statisticsStorageAccount.CreateCloudBlobClient().GetContainerReference(statisticsReportsContainerName);

            _exportersToRun = new List <Exporter> {
                new VerifiedPackagesExporter(LoggerFactory.CreateLogger <VerifiedPackagesExporter>(), packageDatabaseConnString, _destContainer, ScriptVerifiedPackages, OutputNameVerifiedPackages),
                new NestedJArrayExporter(LoggerFactory.CreateLogger <NestedJArrayExporter>(), packageDatabaseConnString, _destContainer, ScriptCuratedFeed, OutputNameCuratedFeed, Col0CuratedFeed, Col1CuratedFeed),
                new NestedJArrayExporter(LoggerFactory.CreateLogger <NestedJArrayExporter>(), packageDatabaseConnString, _destContainer, ScriptOwners, OutputNameOwners, Col0Owners, Col1Owners),
                new RankingsExporter(LoggerFactory.CreateLogger <RankingsExporter>(), statisticsDatabaseConnString, _destContainer, ScriptRankingsTotal, OutputNameRankings),
                new BlobStorageExporter(LoggerFactory.CreateLogger <BlobStorageExporter>(), _statisticsContainer, StatisticsReportName, _destContainer, StatisticsReportName)
            };
        }
示例#4
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                // Init member variables
                Source =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.SourceDatabase,
                                                            EnvironmentVariableKeys.SqlGallery));
                Destination =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.DestinationDatabase,
                                                            EnvironmentVariableKeys.SqlWarehouse));

                MinTimestamp         = JobConfigurationManager.TryGetDateTimeArgument(jobArgsDictionary, "MinTimestamp");
                MaxTimestamp         = JobConfigurationManager.TryGetDateTimeArgument(jobArgsDictionary, "MaxTimestamp");
                ClearExistingRecords = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, "Clear");

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
示例#5
0
文件: Job.cs 项目: Yustos/NuGet.Jobs
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                _loggerFactory = LoggingSetup.CreateLoggerFactory();
                _logger        = _loggerFactory.CreateLogger <Job>();

                var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
                _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

                _minAgeInDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, "MinAgeInDays") ?? DefaultMinAgeInDays;
                Trace.TraceInformation("Min age in days: " + _minAgeInDays);

                return(true);
            }
            catch (Exception exception)
            {
                _logger.LogCritical("Job failed to initialize. {Exception}", exception);
            }

            return(false);
        }
示例#6
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                PackageDatabase = new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase));

                Source = CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source));

                PrimaryDestination = CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

                var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination);
                SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr);

                SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName;

                DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName;

                SourceContainer               = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
                PrimaryDestinationContainer   = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
                SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

                CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName;

                // Initialized successfully
                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
示例#7
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            PackageDatabase = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase));

            Source = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source));

            PrimaryDestination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

            var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination);

            SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr);

            SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName;

            DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName;

            SourceContainer               = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
            PrimaryDestinationContainer   = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
            SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

            CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName;
        }
示例#8
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
            var statisticsDatabaseConnectionString  = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
            var galleryDatabaseConnectionString     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceDatabase);
            var dataStorageAccountConnectionString  = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);

            _sqlCommandTimeoutSeconds            = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.CommandTimeOut) ?? DefaultSqlCommandTimeoutSeconds;
            _perPackageReportDegreeOfParallelism = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.PerPackageReportDegreeOfParallelism) ?? DefaultPerPackageReportDegreeOfParallelism;

            _cloudStorageAccount     = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString, JobArgumentNames.AzureCdnCloudStorageAccount);
            _statisticsContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName), JobArgumentNames.AzureCdnCloudStorageContainerName);
            _dataStorageAccount      = ValidateAzureCloudStorageAccount(dataStorageAccountConnectionString, JobArgumentNames.DataStorageAccount);
            _reportName         = ValidateReportName(JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.WarehouseReportName));
            _statisticsDatabase = new SqlConnectionStringBuilder(statisticsDatabaseConnectionString);
            _galleryDatabase    = new SqlConnectionStringBuilder(galleryDatabaseConnectionString);

            var containerNames = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataContainerName)
                                 .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var containerName in containerNames)
            {
                ValidateAzureContainerName(containerName, JobArgumentNames.DataContainerName);
            }

            _dataContainerNames = containerNames;
        }
示例#9
0
文件: Job.cs 项目: edyoung/NuGet.Jobs
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            _whatIf = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.WhatIf);

            var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryDatabase);

            _galleryDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

            _galleryBrand      = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryBrand);
            _galleryAccountUrl = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryAccountUrl);

            _mailFrom = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.MailFrom);

            var smtpConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SmtpUri);
            var smtpUri = new SmtpUri(new Uri(smtpConnectionString));

            _smtpClient = CreateSmtpClient(smtpUri);

            _warnDaysBeforeExpiration = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.WarnDaysBeforeExpiration)
                                        ?? _warnDaysBeforeExpiration;

            _allowEmailResendAfterDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.AllowEmailResendAfterDays)
                                         ?? _allowEmailResendAfterDays;

            var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
            var storageContainerName    = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);

            var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            var storageFactory = new AzureStorageFactory(storageAccount, storageContainerName, LoggerFactory);

            _storage = storageFactory.Create();
        }
示例#10
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            var packageDatabaseConnString = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)).ToString();

            var statisticsDatabaseConnString = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase)).ToString();

            var destination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

            var destinationContainerName =
                JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName)
                ?? DefaultContainerName;

            _destContainer = destination.CreateCloudBlobClient().GetContainerReference(destinationContainerName);

            _sqlExportScriptsToRun = new List <GenerateAuxiliaryData.SqlExporter> {
                new NestedJArrayExporter(packageDatabaseConnString, _destContainer, ScriptCuratedFeed, OutputNameCuratedFeed, Col0CuratedFeed, Col1CuratedFeed),
                new NestedJArrayExporter(packageDatabaseConnString, _destContainer, ScriptOwners, OutputNameOwners, Col0Owners, Col1Owners),
                new RankingsExporter(statisticsDatabaseConnString, _destContainer, ScriptRankingsTotal, ScriptRankingsProjectTypes, ScriptRankingsDistinctProjectTypes, OutputNameRankings)
            };

            return(true);
        }
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                // Init member variables
                Source =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.SourceDatabase,
                                                            EnvironmentVariableKeys.SqlGallery));
                Destination =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.DestinationDatabase,
                                                            EnvironmentVariableKeys.SqlWarehouse));

                // By default, keep 7 days of statistics
                DaysToKeep = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, "DaysToKeep") ?? 7;

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
示例#12
0
文件: Job.cs 项目: edyoung/NuGet.Jobs
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
            var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
            var databaseConnectionString            = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);

            _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString);

            _targetDatabase            = new SqlConnectionStringBuilder(databaseConnectionString);
            _azureCdnAccountNumber     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
            _azureCdnPlatform          = ValidateAzureCdnPlatform(azureCdnPlatform);
            _cloudStorageContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName));

            _aggregatesOnly = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.AggregatesOnly);

            // construct a cloud blob client for the configured storage account
            _cloudBlobClient = _cloudStorageAccount.CreateCloudBlobClient();
            _cloudBlobClient.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(10), 5);

            // Get the source blob container (containing compressed log files)
            // and construct a log source (fetching raw logs from the source blob container)
            var sourceBlobContainer = _cloudBlobClient.GetContainerReference(_cloudStorageContainerName);

            _blobLeaseManager = new LogFileProvider(sourceBlobContainer, LoggerFactory);
        }
示例#13
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
                var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
                var databaseConnectionString            = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
                _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString);

                _targetDatabase            = new SqlConnectionStringBuilder(databaseConnectionString);
                _azureCdnAccountNumber     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
                _azureCdnPlatform          = ValidateAzureCdnPlatform(azureCdnPlatform);
                _cloudStorageContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName));

                return(true);
            }
            catch (Exception exception)
            {
                ApplicationInsights.TrackException(exception);
                Trace.TraceError(exception.ToString());
            }
            return(false);
        }
示例#14
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            PackageDatabase =
                new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.PackageDatabase,
                                                        EnvironmentVariableKeys.SqlGallery));

            DataStorageAccount =
                CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.DataStorageAccount,
                                                        EnvironmentVariableKeys.StoragePrimary));

            DataContainerName =
                JobConfigurationManager.TryGetArgument(jobArgsDictionary,
                                                       JobArgumentNames.DataContainerName);

            if (string.IsNullOrEmpty(DataContainerName))
            {
                DataContainerName = DefaultDataContainerName;
            }

            ContainerName =
                JobConfigurationManager.TryGetArgument(jobArgsDictionary,
                                                       JobArgumentNames.ContainerName);

            // Initialized successfully, return true
            return(true);
        }
示例#15
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            WarehouseConnection =
                new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.DestinationDatabase,
                                                        EnvironmentVariableKeys.SqlWarehouse));
            Destination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                    JobArgumentNames.PrimaryDestination, EnvironmentVariableKeys.StoragePrimary));

            DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName;


            DestinationContainer = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

            string rankingCountString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.RankingCount);

            if (string.IsNullOrEmpty(rankingCountString))
            {
                RankingCount = DefaultRankingCount;
            }
            else
            {
                RankingCount = Convert.ToInt32(rankingCountString);
            }

            return(true);
        }
示例#16
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                PackageDatabase =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.PackageDatabase,
                                                            EnvironmentVariableKeys.SqlGallery));

                var storageGalleryCstr = Environment.GetEnvironmentVariable(EnvironmentVariableKeys.StorageGallery);
                if (string.IsNullOrEmpty(storageGalleryCstr))
                {
                    throw new ArgumentException("Environment variable for storage gallery is not defined");
                }

                ContentAccount = CloudStorageAccount.Parse(storageGalleryCstr);
                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
示例#17
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            var action = ParseEnum <Action>(JobConfigurationManager.GetArgument(jobArgsDictionary, CommandLineArguments.Action));

            var azureStorageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
            var containerName       = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);
            var cloudStorageAccount = CloudStorageAccount.Parse(azureStorageConnectionString);
            var galleryBaseAddress  = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryBaseAddress);

            switch (action)
            {
            case Action.Rescan:
                _command = new Rescan(
                    jobArgsDictionary,
                    LoggerFactory.CreateLogger <Rescan>(),
                    cloudStorageAccount,
                    containerName,
                    new NuGetV2Feed(new HttpClient(), LoggerFactory.CreateLogger <NuGetV2Feed>()),
                    new PackageValidationService(cloudStorageAccount, containerName, LoggerFactory),
                    galleryBaseAddress);
                break;

            case Action.MarkClean:
                _command = new MarkClean(
                    jobArgsDictionary,
                    LoggerFactory.CreateLogger <MarkClean>(),
                    cloudStorageAccount,
                    containerName,
                    new NuGetV2Feed(new HttpClient(), LoggerFactory.CreateLogger <NuGetV2Feed>()),
                    new PackageValidationAuditor(cloudStorageAccount, containerName, LoggerFactory),
                    galleryBaseAddress);
                break;
            }
        }
示例#18
0
文件: Job.cs 项目: Yustos/NuGet.Jobs
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                _loggerFactory = LoggingSetup.CreateLoggerFactory();
                _logger        = _loggerFactory.CreateLogger <Job>();

                var statisticsDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
                _statisticsDatabase = new SqlConnectionStringBuilder(statisticsDatabaseConnectionString);

                var destinationDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DestinationDatabase);
                _destinationDatabase = new SqlConnectionStringBuilder(destinationDatabaseConnectionString);
            }
            catch (Exception exception)
            {
                _logger.LogCritical("Failed to initialize job! {Exception}", exception);

                return(false);
            }

            return(true);
        }
示例#19
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var retrievedMaxManifestSize = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize);

            MaxManifestSize = retrievedMaxManifestSize == null
                ? DefaultMaxAllowedManifestBytes
                : Convert.ToInt64(retrievedMaxManifestSize);

            PackageDatabase = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase));

            Source = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceStorage));
            Backups = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.BackupStorage));
            SourceContainerName  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultSourceContainerName;
            BackupsContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.BackupContainerName) ?? DefaultBackupContainerName;
            ReadMeContainerName  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.ReadMeContainerName) ?? DefaultReadMeContainerName;

            SourceContainer  = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
            BackupsContainer = Backups.CreateCloudBlobClient().GetContainerReference(BackupsContainerName);
            ReadMeContainer  = Source.CreateCloudBlobClient().GetContainerReference(ReadMeContainerName);

            MaxTryCount = DefaultMaxRetryCount;
        }
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            Source =
                new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.SourceDatabase,
                                                        EnvironmentVariableKeys.SqlGallery));

            WarehouseConnection =
                new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.DestinationDatabase,
                                                        EnvironmentVariableKeys.SqlWarehouse));

            Destination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                    JobArgumentNames.WarehouseStorageAccount, EnvironmentVariableKeys.WarehouseStorage));

            DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.WarehouseContainerName) ?? DefaultPackageStatsContainerName;

            DestinationContainer  = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
            _globalReportBuilders = new Dictionary <string, Func <Task> >(StringComparer.OrdinalIgnoreCase)
            {
                { NuGetClientVersion, () => CreateReport(NuGetClientVersion, "Scripts.DownloadReport_NuGetClientVersion.sql") },
                { Last6Months, () => CreateReport(Last6Months, "Scripts.DownloadReport_Last6Months.sql") },
                { RecentPopularity, () => CreateReport(RecentPopularity, "Scripts.DownloadReport_RecentPopularity.sql") },
                { RecentPopularityDetail, () => CreateReport(RecentPopularityDetail, "Scripts.DownloadReport_RecentPopularityDetail.sql") },
            };

            return(true);
        }
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            Source =
                new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.SourceDatabase,
                                                        EnvironmentVariableKeys.SqlGallery));

            OutputDirectory = JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                                  JobArgumentNames.OutputDirectory);

            if (string.IsNullOrEmpty(OutputDirectory))
            {
                Destination = CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                        JobArgumentNames.PrimaryDestination, EnvironmentVariableKeys.StoragePrimary));

                DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName;


                DestinationContainer = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
            }

            return(true);
        }
示例#22
0
文件: Job.cs 项目: Yustos/NuGet.Jobs
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(ConsoleLogOnly);
                _loggerFactory = LoggingSetup.CreateLoggerFactory(loggerConfiguration);
                _logger        = _loggerFactory.CreateLogger <Job>();

                if (!jobArgsDictionary.ContainsKey(JobArgumentNames.ScheduledTask))
                {
                    throw new NotSupportedException("The required argument -Task is missing.");
                }

                _jobArgsDictionary = jobArgsDictionary;
            }
            catch (Exception exception)
            {
                _logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!");

                return(false);
            }

            return(true);
        }
示例#23
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                _loggerFactory = LoggingSetup.CreateLoggerFactory();
                _logger        = _loggerFactory.CreateLogger <Job>();

                var ftpLogFolder        = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourceUri);
                var azureCdnPlatform    = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
                var cloudStorageAccount = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
                _cloudStorageContainerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName);
                _azureCdnAccountNumber     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
                _ftpUsername = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourceUsername);
                _ftpPassword = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourcePassword);

                _ftpServerUri        = ValidateFtpUri(ftpLogFolder);
                _azureCdnPlatform    = ValidateAzureCdnPlatform(azureCdnPlatform);
                _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccount);
            }
            catch (Exception ex)
            {
                _logger.LogCritical("Job failed to initialize! {Exception}", ex);

                return(false);
            }

            return(true);
        }
示例#24
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            ServicePointManager.DefaultConnectionLimit = MaximumConnectionsPerServer;
            _validateOnly          = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, ValidateArgument, defaultValue: false);
            ConfigurationValidated = false;

            base.Init(serviceContainer, jobArgsDictionary);
        }
示例#25
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            base.Init(serviceContainer, jobArgsDictionary);

            _preinstalledSetPath  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, RebuildPreinstalledSetArgumentName);
            _initialize           = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, InitializeArgumentName);
            _verifyInitialization = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, VerifyInitializationArgumentName);
        }
示例#26
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var configurationFilename = JobConfigurationManager.GetArgument(jobArgsDictionary, ConfigurationArgument);

            _validateOnly          = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, ValidateArgument, defaultValue: false);
            _serviceProvider       = GetServiceProvider(GetConfigurationRoot(configurationFilename, _validateOnly));
            ConfigurationValidated = false;
        }
示例#27
0
文件: Job.cs 项目: devlead/NuGet.Jobs
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var configurationFilename = JobConfigurationManager.GetArgument(jobArgsDictionary, ConfigurationArgument);

            _serviceProvider = GetServiceProvider(GetConfigurationRoot(configurationFilename));

            ServicePointManager.DefaultConnectionLimit = MaximumConnectionsPerServer;
        }
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);

            _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

            _targetClientName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "TargetClientName");
            _userAgentFilter  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "UserAgentFilter");
        }
示例#29
0
文件: Job.cs 项目: edyoung/NuGet.Jobs
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);

            _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

            _minAgeInDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MinAgeInDays) ?? DefaultMinAgeInDays;
            Logger.LogInformation("Min age in days: {MinAgeInDays}", _minAgeInDays);
        }
示例#30
0
 public FileSystemStorage(IDictionary <string, string> jobArgsDictionary)
 {
     _packageFolder = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceStorage);
     if (!string.IsNullOrEmpty(JobArgumentNames.BackupStorage))
     {
         _backupFolder = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.BackupStorage);
     }
     _snapshotService = new FileSystemSnapshotService();
 }