Exemple #1
0
        private void Run(string[] args)
        {
            RuntimeSettings runtimeSettings = new RuntimeSettings()
            {
                CustomLogFileName = "updater.txt"
            };

            LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
            logger = LogManager.GetCurrentClassLogger();

            logger.Info("Jackett Updater v" + GetCurrentVersion());
            logger.Info("Options \"" + string.Join("\" \"", args) + "\"");

            bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;

            if (isWindows)
            {
                //The updater starts before Jackett closes
                logger.Info("Pausing for 3 seconds to give Jackett & tray time to shutdown");
                System.Threading.Thread.Sleep(3000);
            }

            processService = new ProcessService(logger);
            windowsService = new WindowsServiceConfigService(processService, logger);

            var commandLineParser = new Parser(settings => settings.CaseSensitive = false);

            try
            {
                var optionsResult = commandLineParser.ParseArguments <UpdaterConsoleOptions>(args);
                optionsResult.WithParsed(options =>
                {
                    ProcessUpdate(options);
                }
                                         );
                optionsResult.WithNotParsed(errors =>
                {
                    logger.Error(HelpText.AutoBuild(optionsResult));
                    logger.Error("Failed to process update arguments!");
                    Console.ReadKey();
                });
            }
            catch (Exception e)
            {
                logger.Error(e, "Exception applying update!");
            }
        }
Exemple #2
0
        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>();

                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);
            }
            catch (Exception exception)
            {
                _logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!");

                return(false);
            }

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

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

                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);

                _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;
            }
            catch (Exception exception)
            {
                _logger.LogError("Failed to initialize job! {Exception}", exception);

                return(false);
            }

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

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

                var retrievedMaxManifestSize = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize);
                MaxManifestSize = retrievedMaxManifestSize == null
                    ? DefaultMaxAllowedManifestBytes
                    : Convert.ToInt64(retrievedMaxManifestSize);

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

                Enum.TryParse(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StorageType), out StorageType storageType);
                switch (storageType)
                {
                case StorageType.FileSystem:
                    FileStorage = new FileSystemStorage(jobArgsDictionary);
                    break;

                default:
                    FileStorage = new AzureStorage(jobArgsDictionary);
                    break;
                }

                MaxTryCount = DefaultMaxRetryCount;
            }
            catch (Exception exception)
            {
                Trace.TraceError($"Failed to initalize job! {exception}");
                return(false);
            }

            return(true);
        }
Exemple #5
0
        private static AutofacWebApiDependencyResolver GetDependencyResolver(HttpConfiguration config)
        {
            var configuration = GetConfiguration();

            var globalTelemetryDimensions        = new Dictionary <string, string>();
            var applicationInsightsConfiguration = InitializeApplicationInsights(configuration);

            var services = new ServiceCollection();

            services.AddSingleton(configuration.SecretReaderFactory);
            services.AddSingleton(applicationInsightsConfiguration.TelemetryConfiguration);
            services.AddSingleton <IConfiguration>(configuration.Root);
            services.Add(ServiceDescriptor.Scoped(typeof(IOptionsSnapshot <>), typeof(NonCachingOptionsSnapshot <>)));
            services.Configure <AzureSearchConfiguration>(configuration.Root.GetSection(ConfigurationSectionName));
            services.Configure <SearchServiceConfiguration>(configuration.Root.GetSection(ConfigurationSectionName));
            services.AddAzureSearch(globalTelemetryDimensions);
            services.AddSingleton(new TelemetryClient(applicationInsightsConfiguration.TelemetryConfiguration));
            services.AddTransient <ITelemetryClient, TelemetryClientWrapper>();

            var builder = new ContainerBuilder();

            builder.RegisterAssemblyModules(typeof(WebApiConfig).Assembly);
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterWebApiFilterProvider(config);
            builder.RegisterWebApiModelBinderProvider();
            builder.Populate(services);
            builder.AddAzureSearch();

            var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: false);
            var loggerFactory       = LoggingSetup.CreateLoggerFactory(
                loggerConfiguration,
                telemetryConfiguration: applicationInsightsConfiguration.TelemetryConfiguration);

            builder.RegisterInstance(loggerFactory).As <ILoggerFactory>();
            builder.RegisterGeneric(typeof(Logger <>)).As(typeof(ILogger <>));

            var container = builder.Build();

            return(new AutofacWebApiDependencyResolver(container));
        }
Exemple #6
0
        public static void Main()
        {
            AttachConsole(-1);
            new RuntimeCheckWpf().Check();
            SetupAssemblyLoader();
            new AssemblyHandler().Register();

            Common.Flags = new Common.StartupFlags(_args = Environment.GetCommandLineArgs().Skip(1).ToArray(),
                                                   Environment.Is64BitOperatingSystem);

            LoggingSetup.Setup(Consts.ProductTitle);
            SetupVersion();
            Init();
            //Cheat.Args = new ArgsO { Port =, WorkingDirectory = Directory.GetCurrentDirectory() } // todo;
            try {
                HandleSquirrel();
            } catch (Exception ex) {
                MainLog.Logger.FormattedErrorException(ex, "An error occurred during processing startup");
                throw;
            }
            StartApp();
        }
Exemple #7
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(ConsoleLogOnly);
                var loggerFactory       = LoggingSetup.CreateLoggerFactory(loggerConfiguration);
                Logger = loggerFactory.CreateLogger <Job>();

                var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryDatabase);
                GalleryDatabase = new SqlConnectionStringBuilder(databaseConnectionString);
            }
            catch (Exception exception)
            {
                Logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!");

                return(false);
            }

            return(true);
        }
        private static IServiceProvider InitializeAndGetServiceProvider()
        {
            ServicePointManager.DefaultConnectionLimit = 64;
            ServicePointManager.SecurityProtocol      &= ~SecurityProtocolType.Ssl3;
            ServicePointManager.SecurityProtocol      |= SecurityProtocolType.Tls12;

            var configurationRoot  = GetConfigurationRoot();
            var instrumentationKey = configurationRoot
                                     .GetSection(ConfigurationSectionName)
                                     .GetValue <string>(nameof(V3PerPackageConfiguration.InstrumentationKey));

            ApplicationInsights.Initialize(instrumentationKey);

            var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: true);
            var loggerFactory       = LoggingSetup.CreateLoggerFactory(loggerConfiguration, LogEventLevel.Information);

            var serviceCollection = new ServiceCollection();

            serviceCollection.Configure <V3PerPackageConfiguration>(configurationRoot.GetSection(ConfigurationSectionName));
            serviceCollection.AddOptions();
            serviceCollection.Add(ServiceDescriptor.Scoped(typeof(IOptionsSnapshot <>), typeof(NonCachingOptionsSnapshot <>)));

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(loggerFactory);

            serviceCollection.AddSingleton(new ControlledDisposeHttpClientHandler());
            serviceCollection.AddTransient <HttpMessageHandler>(x => x.GetRequiredService <ControlledDisposeHttpClientHandler>());
            serviceCollection.AddSingleton(x => new HttpClient(x.GetRequiredService <HttpMessageHandler>()));
            serviceCollection.AddTransient <Func <HttpMessageHandler> >(x => () => x.GetRequiredService <HttpMessageHandler>());
            serviceCollection.AddTransient <PerBatchProcessor>();
            serviceCollection.AddTransient <ITelemetryService, TelemetryService>();
            serviceCollection.AddTransient <PerWorkerProcessor>();
            serviceCollection.AddTransient <PerProcessProcessor>();
            serviceCollection.AddSingleton <StringLocker>();
            serviceCollection.AddTransient <EnqueueCollector>();
            serviceCollection.AddTransient <EnqueueCommand>();
            serviceCollection.AddTransient <CleanUpCommand>();

            serviceCollection.AddSingleton(x =>
            {
                var globalContext = x.GetRequiredService <GlobalContext>();

                var perProcessContext = new PerProcessContext(
                    globalContext,
                    UniqueName.New("process"),
                    WorkerCount,
                    MessageCount,
                    BatchSize);

                var blobClient       = BlobStorageUtilities.GetBlobClient(globalContext);
                var flatContainerUrl = $"{blobClient.BaseUri.AbsoluteUri}/{globalContext.FlatContainerContainerName}/{perProcessContext.Name}";
                RegistrationMakerCatalogItem.PackagePathProvider = new FlatContainerPackagePathProvider(flatContainerUrl);

                return(perProcessContext);
            });

            serviceCollection.AddTransient(x =>
            {
                var settings = x.GetRequiredService <IOptionsSnapshot <V3PerPackageConfiguration> >();
                return(new GlobalContext(
                           settings.Value.StorageBaseAddress,
                           settings.Value.StorageAccountName,
                           settings.Value.StorageKeyValue,
                           settings.Value.ContentBaseAddress,
                           settings.Value.GalleryBaseAddress));
            });

            serviceCollection.AddSingleton(new TelemetryClient());

            serviceCollection.AddTransient <IStorageQueue <PackageMessage> >(x =>
            {
                var globalContext      = x.GetRequiredService <GlobalContext>();
                var storageCredentials = new StorageCredentials(globalContext.StorageAccountName, globalContext.StorageKeyValue);
                var storageAccount     = new CloudStorageAccount(storageCredentials, useHttps: true);

                return(new StorageQueue <PackageMessage>(
                           new AzureStorageQueue(storageAccount, "v3perpackage"),
                           new JsonMessageSerializer <PackageMessage>(JsonSerializerUtility.SerializerSettings),
                           PackageMessage.Version));
            });

            return(serviceCollection.BuildServiceProvider());
        }
Exemple #9
0
        private QueryBoostingContext Load(string configFileName, InMemoryLoader loader)
        {
            var logger = LoggingSetup.CreateLoggerFactory().CreateLogger(nameof(QueryBoostingContext));

            return(QueryBoostingContext.Load(configFileName, loader, logger));
        }
Exemple #10
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            var            commandLineParser = new Parser(settings => settings.CaseSensitive = false);
            var            optionsResult     = commandLineParser.ParseArguments <ConsoleOptions>(args);
            var            runtimeDictionary = new Dictionary <string, string>();
            ConsoleOptions consoleOptions    = new ConsoleOptions();

            optionsResult.WithNotParsed(errors =>
            {
                var text       = HelpText.AutoBuild(optionsResult);
                text.Copyright = " ";
                text.Heading   = "Jackett v" + EnvironmentUtil.JackettVersion;
                Console.WriteLine(text);
                Environment.Exit(1);
                return;
            });

            optionsResult.WithParsed(options =>
            {
                if (string.IsNullOrEmpty(options.Client))
                {
                    bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("Core", StringComparison.OrdinalIgnoreCase) >= 0;

                    if (runningOnDotNetCore)
                    {
                        options.Client = "httpclientnetcore";
                    }
                    else
                    {
                        options.Client = "httpclient";
                    }
                }

                Settings          = options.ToRunTimeSettings();
                consoleOptions    = options;
                runtimeDictionary = GetValues(Settings);
            });

            LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(Settings);
            Logger logger = LogManager.GetCurrentClassLogger();

            logger.Info("Starting Jackett v" + EnvironmentUtil.JackettVersion);

            // create PID file early
            if (!string.IsNullOrWhiteSpace(Settings.PIDFile))
            {
                try
                {
                    var proc = Process.GetCurrentProcess();
                    File.WriteAllText(Settings.PIDFile, proc.Id.ToString());
                }
                catch (Exception e)
                {
                    logger.Error(e, "Error while creating the PID file");
                }
            }

            Initialisation.CheckEnvironmentalVariables(logger);
            Initialisation.ProcessSettings(Settings, logger);

            ISerializeService     serializeService     = new SerializeService();
            IProcessService       processService       = new ProcessService(logger);
            IConfigurationService configurationService = new ConfigurationService(serializeService, processService, logger, Settings);

            if (consoleOptions.Install || consoleOptions.Uninstall || consoleOptions.StartService || consoleOptions.StopService || consoleOptions.ReserveUrls)
            {
                bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;

                if (isWindows)
                {
                    ServerConfig serverConfig = configurationService.BuildServerConfig(Settings);
                    Initialisation.ProcessWindowsSpecificArgs(consoleOptions, processService, serverConfig, logger);
                }
                else
                {
                    logger.Error($"ReserveUrls and service arguments only apply to Windows, please remove them from your start arguments");
                    Environment.Exit(1);
                }
            }

            var builder = new ConfigurationBuilder();

            builder.AddInMemoryCollection(runtimeDictionary);
            builder.AddJsonFile(Path.Combine(configurationService.GetAppDataFolder(), "appsettings.json"), optional: true);

            Configuration = builder.Build();

            do
            {
                if (!isWebHostRestart)
                {
                    if (consoleOptions.Port != 0 || consoleOptions.ListenPublic || consoleOptions.ListenPrivate)
                    {
                        ServerConfig serverConfiguration = configurationService.BuildServerConfig(Settings);
                        Initialisation.ProcessConsoleOverrides(consoleOptions, processService, serverConfiguration, configurationService, logger);
                    }
                }

                ServerConfig serverConfig = configurationService.BuildServerConfig(Settings);
                Int32.TryParse(serverConfig.Port.ToString(), out Int32 configPort);
                string[] url = serverConfig.GetListenAddresses(serverConfig.AllowExternal);

                isWebHostRestart = false;

                try
                {
                    logger.Debug("Creating web host...");
                    string applicationFolder = Path.Combine(configurationService.ApplicationFolder(), "Content");
                    logger.Debug($"Content root path is: {applicationFolder}");

                    CreateWebHostBuilder(args, url, applicationFolder).Build().Run();
                }
                catch (Exception ex)
                {
                    if (ex.InnerException is Microsoft.AspNetCore.Connections.AddressInUseException)
                    {
                        logger.Error("Address already in use: Most likely Jackett is already running. " + ex.Message);
                        Environment.Exit(1);
                    }
                    logger.Error(ex);
                    throw;
                }
            } while (isWebHostRestart);
        }
Exemple #11
0
        public static async Task MainAsync(string[] args)
        {
            if (args.Length > 0 && string.Equals("dbg", args[0], StringComparison.OrdinalIgnoreCase))
            {
                args = args.Skip(1).ToArray();
                Debugger.Launch();
            }

            NgJob job = null;

            try
            {
                // Get arguments
                var arguments = CommandHelpers.GetArguments(args, 1);

                // Ensure that SSLv3 is disabled and that Tls v1.2 is enabled.
                ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
                ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

                // Determine the job name
                if (args.Length == 0)
                {
                    throw new ArgumentException("Missing job name argument.");
                }

                var jobName = args[0];
                TelemetryConfiguration.Active.TelemetryInitializers.Add(new JobNameTelemetryInitializer(jobName));

                // Configure ApplicationInsights
                ApplicationInsights.Initialize(arguments.GetOrDefault <string>(Arguments.InstrumentationKey));

                // Create an ILoggerFactory
                var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: true);
                loggerConfiguration.WriteTo.File("Log.txt", retainedFileCountLimit: 3, fileSizeLimitBytes: 1000000, rollOnFileSizeLimit: true);

                var loggerFactory = LoggingSetup.CreateLoggerFactory(loggerConfiguration, LogEventLevel.Debug);

                // Create a logger that is scoped to this class (only)
                _logger = loggerFactory.CreateLogger <Program>();

                var cancellationTokenSource = new CancellationTokenSource();

                // Create an ITelemetryService
                var telemetryService = new TelemetryService(new TelemetryClient());

                // Allow jobs to set global custom dimensions
                TelemetryConfiguration.Active.TelemetryInitializers.Add(new JobPropertiesTelemetryInitializer(telemetryService));

                job = NgJobFactory.GetJob(jobName, telemetryService, loggerFactory);
                await job.RunAsync(arguments, cancellationTokenSource.Token);
            }
            catch (ArgumentException ae)
            {
                _logger?.LogError("A required argument was not found or was malformed/invalid: {Exception}", ae);

                Console.WriteLine(job != null ? job.GetUsage() : NgJob.GetUsageBase());
            }
            catch (Exception e)
            {
                _logger?.LogCritical("A critical exception occured in ng.exe! {Exception}", e);
            }

            Trace.Close();
            TelemetryConfiguration.Active.TelemetryChannel.Flush();
        }
        protected override void Load(ContainerBuilder builder)
        {
            var services = new ServiceCollection();

            var configuration       = new ConfigurationService();
            var secretReaderFactory = new SecretReaderFactory(configuration);
            var secretReader        = secretReaderFactory.CreateSecretReader();
            var secretInjector      = secretReaderFactory.CreateSecretInjector(secretReader);

            builder.RegisterInstance(secretInjector)
            .AsSelf()
            .As <ISecretInjector>()
            .SingleInstance();

            configuration.SecretInjector = secretInjector;

            // Register the ILoggerFactory and configure it to use AppInsights if an instrumentation key is provided.
            var instrumentationKey = configuration.Current.AppInsightsInstrumentationKey;

            if (!string.IsNullOrEmpty(instrumentationKey))
            {
                TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey;
            }

            var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: false);
            var loggerFactory       = LoggingSetup.CreateLoggerFactory(loggerConfiguration);

            var telemetryClient = TelemetryClientWrapper.Instance;

            builder.RegisterInstance(telemetryClient)
            .AsSelf()
            .As <ITelemetryClient>()
            .SingleInstance();

            var diagnosticsService = new DiagnosticsService(telemetryClient);

            builder.RegisterInstance(diagnosticsService)
            .AsSelf()
            .As <IDiagnosticsService>()
            .SingleInstance();

            services.AddSingleton(loggerFactory);
            services.AddSingleton(typeof(ILogger <>), typeof(Logger <>));

            UrlHelperExtensions.SetConfigurationService(configuration);

            builder.RegisterInstance(configuration)
            .AsSelf()
            .As <IGalleryConfigurationService>();

            builder.Register(c => configuration.Current)
            .AsSelf()
            .AsImplementedInterfaces();

            // Force the read of this configuration, so it will be initialized on startup
            builder.Register(c => configuration.Features)
            .AsSelf()
            .As <FeatureConfiguration>();

            builder.Register(c => configuration.PackageDelete)
            .As <IPackageDeleteConfiguration>();

            var telemetryService = new TelemetryService(diagnosticsService, telemetryClient);

            builder.RegisterInstance(telemetryService)
            .AsSelf()
            .As <ITelemetryService>()
            .As <IFeatureFlagTelemetryService>()
            .SingleInstance();

            builder.RegisterType <CredentialBuilder>().As <ICredentialBuilder>().SingleInstance();
            builder.RegisterType <CredentialValidator>().As <ICredentialValidator>().SingleInstance();

            builder.RegisterInstance(LuceneCommon.GetDirectory(configuration.Current.LuceneIndexLocation))
            .As <Lucene.Net.Store.Directory>()
            .SingleInstance();

            ConfigureResilientSearch(loggerFactory, configuration, telemetryService, services);
            ConfigureSearch(builder, configuration);

            builder.RegisterType <DateTimeProvider>().AsSelf().As <IDateTimeProvider>().SingleInstance();

            builder.RegisterType <HttpContextCacheService>()
            .AsSelf()
            .As <ICacheService>()
            .InstancePerLifetimeScope();

            var galleryDbConnectionFactory = CreateDbConnectionFactory(
                diagnosticsService,
                nameof(EntitiesContext),
                configuration.Current.SqlConnectionString,
                secretInjector);

            builder.RegisterInstance(galleryDbConnectionFactory)
            .AsSelf()
            .As <ISqlConnectionFactory>()
            .SingleInstance();

            builder.Register(c => new EntitiesContext(CreateDbConnection(galleryDbConnectionFactory), configuration.Current.ReadOnlyMode))
            .AsSelf()
            .As <IEntitiesContext>()
            .As <DbContext>()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <User> >()
            .AsSelf()
            .As <IEntityRepository <User> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <ReservedNamespace> >()
            .AsSelf()
            .As <IEntityRepository <ReservedNamespace> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <PackageRegistration> >()
            .AsSelf()
            .As <IEntityRepository <PackageRegistration> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Package> >()
            .AsSelf()
            .As <IEntityRepository <Package> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <PackageDependency> >()
            .AsSelf()
            .As <IEntityRepository <PackageDependency> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <PackageDelete> >()
            .AsSelf()
            .As <IEntityRepository <PackageDelete> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Certificate> >()
            .AsSelf()
            .As <IEntityRepository <Certificate> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <AccountDelete> >()
            .AsSelf()
            .As <IEntityRepository <AccountDelete> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Credential> >()
            .AsSelf()
            .As <IEntityRepository <Credential> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Scope> >()
            .AsSelf()
            .As <IEntityRepository <Scope> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <PackageOwnerRequest> >()
            .AsSelf()
            .As <IEntityRepository <PackageOwnerRequest> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Organization> >()
            .AsSelf()
            .As <IEntityRepository <Organization> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <SymbolPackage> >()
            .AsSelf()
            .As <IEntityRepository <SymbolPackage> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <PackageDeprecation> >()
            .AsSelf()
            .As <IEntityRepository <PackageDeprecation> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Cve> >()
            .AsSelf()
            .As <IEntityRepository <Cve> >()
            .InstancePerLifetimeScope();

            builder.RegisterType <EntityRepository <Cwe> >()
            .AsSelf()
            .As <IEntityRepository <Cwe> >()
            .InstancePerLifetimeScope();

            var supportDbConnectionFactory = CreateDbConnectionFactory(
                diagnosticsService,
                nameof(SupportRequestDbContext),
                configuration.Current.SqlConnectionStringSupportRequest,
                secretInjector);

            builder.Register(c => new SupportRequestDbContext(CreateDbConnection(supportDbConnectionFactory)))
            .AsSelf()
            .As <ISupportRequestDbContext>()
            .InstancePerLifetimeScope();

            builder.RegisterType <SupportRequestService>()
            .AsSelf()
            .As <ISupportRequestService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <UserService>()
            .AsSelf()
            .As <IUserService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageService>()
            .AsSelf()
            .As <IPackageService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageDeleteService>()
            .AsSelf()
            .As <IPackageDeleteService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <DeleteAccountService>()
            .AsSelf()
            .As <IDeleteAccountService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageOwnerRequestService>()
            .AsSelf()
            .As <IPackageOwnerRequestService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <FormsAuthenticationService>()
            .As <IFormsAuthenticationService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <CookieTempDataProvider>()
            .As <ITempDataProvider>()
            .InstancePerLifetimeScope();

            builder.RegisterType <StatusService>()
            .AsSelf()
            .As <IStatusService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <SecurityPolicyService>()
            .AsSelf()
            .As <ISecurityPolicyService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ReservedNamespaceService>()
            .AsSelf()
            .As <IReservedNamespaceService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <SymbolPackageService>()
            .AsSelf()
            .As <ISymbolPackageService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageUploadService>()
            .AsSelf()
            .As <IPackageUploadService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <SymbolPackageUploadService>()
            .AsSelf()
            .As <ISymbolPackageUploadService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageOwnershipManagementService>()
            .AsSelf()
            .As <IPackageOwnershipManagementService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ValidationService>()
            .AsSelf()
            .As <IValidationService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ReadMeService>()
            .AsSelf()
            .As <IReadMeService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ApiScopeEvaluator>()
            .AsSelf()
            .As <IApiScopeEvaluator>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ContentObjectService>()
            .AsSelf()
            .As <IContentObjectService>()
            .SingleInstance();

            builder.RegisterType <CertificateValidator>()
            .AsSelf()
            .As <ICertificateValidator>()
            .SingleInstance();

            builder.RegisterType <CertificateService>()
            .AsSelf()
            .As <ICertificateService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <TyposquattingService>()
            .AsSelf()
            .As <ITyposquattingService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <TyposquattingCheckListCacheService>()
            .AsSelf()
            .As <ITyposquattingCheckListCacheService>()
            .SingleInstance();

            builder.Register <ServiceDiscoveryClient>(c =>
                                                      new ServiceDiscoveryClient(c.Resolve <IAppConfiguration>().ServiceDiscoveryUri))
            .As <IServiceDiscoveryClient>();

            builder.RegisterType <LicenseExpressionSplitter>()
            .As <ILicenseExpressionSplitter>()
            .InstancePerLifetimeScope();

            builder.RegisterType <LicenseExpressionParser>()
            .As <ILicenseExpressionParser>()
            .InstancePerLifetimeScope();

            builder.RegisterType <LicenseExpressionSegmentator>()
            .As <ILicenseExpressionSegmentator>()
            .InstancePerLifetimeScope();

            builder.RegisterType <PackageDeprecationService>()
            .As <IPackageDeprecationService>()
            .InstancePerLifetimeScope();

            RegisterFeatureFlagsService(builder, configuration);
            RegisterMessagingService(builder, configuration);

            builder.Register(c => HttpContext.Current.User)
            .AsSelf()
            .As <IPrincipal>()
            .InstancePerLifetimeScope();

            IAuditingService defaultAuditingService = null;

            switch (configuration.Current.StorageType)
            {
            case StorageType.FileSystem:
            case StorageType.NotSpecified:
                ConfigureForLocalFileSystem(builder, configuration);
                defaultAuditingService = GetAuditingServiceForLocalFileSystem(configuration);
                break;

            case StorageType.AzureStorage:
                ConfigureForAzureStorage(builder, configuration, telemetryClient);
                defaultAuditingService = GetAuditingServiceForAzureStorage(builder, configuration);
                break;
            }

            RegisterAsynchronousValidation(builder, diagnosticsService, configuration, secretInjector);

            RegisterAuditingServices(builder, defaultAuditingService);

            RegisterCookieComplianceService(builder, configuration, diagnosticsService);

            builder.RegisterType <MicrosoftTeamSubscription>()
            .AsSelf()
            .InstancePerLifetimeScope();

            if (configuration.Current.Environment == GalleryConstants.DevelopmentEnvironment)
            {
                builder.RegisterType <AllowLocalHttpRedirectPolicy>()
                .As <ISourceDestinationRedirectPolicy>()
                .InstancePerLifetimeScope();
            }
            else
            {
                builder.RegisterType <NoLessSecureDestinationRedirectPolicy>()
                .As <ISourceDestinationRedirectPolicy>()
                .InstancePerLifetimeScope();
            }

            ConfigureAutocomplete(builder, configuration);
            builder.Populate(services);
        }
Exemple #13
0
        static void Main(string[] args)
        {
            #region Start Up

            void StartLogging()
            {
                var nlogger           = LogManager.GetCurrentClassLogger();
                var mapGrpToNameSpace = new Dictionary <LogGroup, string>
                {
                    [LogGroup.App]        = "OmniId.TagLab",
                    [LogGroup.Gateways]   = "OmniId.Hdk.Gateway",
                    [LogGroup.RFIDRdrs]   = "OmniId.Hdk.RfidReader",
                    [LogGroup.ImageFns]   = "OmniId.Hdk.Image",
                    [LogGroup.Printers]   = "OmniId.Hdk.Printer",
                    [LogGroup.UtilityFns] = "OmniId.Hdk.Common"
                };

                LoggingSetup.FileTargetFileName = "ScanTestLogFile_${date:format=yyyyMMdd}.txt";

                // Set in initial settings into the logging facility
                LoggingSetup.FileTargetDir = "${specialfolder:folder=MyDocuments}/DeviceSampleAppLogs/";


                // Create targets and set their priority
                LoggingSetup.AddFileTarget();
                LoggingSetup.SetTargetEnable(LoggingSetup.FileTargetName,
                                             true);

                //OmniIdHdkLogger.AddConsoleTarget();
                //OmniIdHdkLogger.SetTargetEnable(OmniIdHdkLogger.ConsoleTargetName,
                //    true);

                // Set in priorities for each of the categories
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.App],
                                              OmniId.Hdk.Common.LogLevel.Trace);
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.Gateways],
                                              OmniId.Hdk.Common.LogLevel.Trace);
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.RFIDRdrs],
                                              OmniId.Hdk.Common.LogLevel.Trace);
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.ImageFns],
                                              OmniId.Hdk.Common.LogLevel.Trace);
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.Printers],
                                              OmniId.Hdk.Common.LogLevel.Trace);
                LoggingSetup.SetPriorityLevel(mapGrpToNameSpace[LogGroup.UtilityFns],
                                              OmniId.Hdk.Common.LogLevel.Trace);

                nlogger.Info("Starting DeviceSampleApp!");
            }

            StartLogging();


            RfidRdrMgr.Singleton.RfidRdrListChanged += OnRfidRdrListChanged;

            CmdDispatchMgr.Singleton.CmdStatusChanged += OnGtwyCmdStatusChanged;
            CmdDispatchMgr.Singleton.GrpStatusChanged += OnGrpStatusChanged;
            CmdDispatchMgr.Singleton.QueryResponse    += OnQueryResponse;

            GtwyMgr.Singleton.AnnounceRcvd     += OnAnnounceReceived;
            GtwyMgr.Singleton.CmdSent          += CmdSend;
            GtwyMgr.Singleton.ConnectionStatus += CommectionStatus;

            RfidCmdDispatchMgr.Singleton.TagRead             += OnTagRead;
            RfidCmdDispatchMgr.Singleton.CmdStatusChanged    += OnRfidCmdStatusChanged;
            RfidCmdDispatchMgr.Singleton.ConnectionStatus    += OnConnectionStatus;
            RfidCmdDispatchMgr.Singleton.AntennaStatus       += OnAntennaStatus;
            RfidCmdDispatchMgr.Singleton.BarcodeRead         += OnBarcodeRead;
            RfidCmdDispatchMgr.Singleton.ReadParamCompleted  += OnReadParamCompleted;
            RfidCmdDispatchMgr.Singleton.RfidReaderException += OnRfidReaderException;
            RfidCmdDispatchMgr.Singleton.TimerTick           += OnTimerTick;

            RTLSMgr.Singleton.TagLocationChanged += OnTagLocationChanged;
            RTLSMgr.Singleton.TagGtwyChanged     += OnTagGtwyChanged;

            GtwyNwSvcEndPnt.Singleton.Configuration.HostSvcEndPntPort = 30005;

            bool ok = GtwyNwSvcEndPnt.Singleton.OpenHostSvcEndpt();

            if (!ok)
            {
                throw new Exception($"Unable to open host service endpoint to receive calls from the gateways:{GtwyNwSvcEndPnt.Singleton.LastErrorMessage}");
            }

            var result = RfidRdrMgr.Singleton.CreateRfidRdr(
                "10.0.0.231",
                RfidRdrType.CreateFromType(typeof(SpeedwayReader)),
                true).Result;

            if (result.ConfigurationStatus == RfidConfigurationStatusCode.Fail)
            {
                throw new Exception("what does this mean?!");
            }

            var reader = result.GetReader();

            var gateway = GtwyMgr.Singleton.CreateGtwy(
                typeof(NetworkGtwy),
                true,
                out var errMsg,
                "10.0.0.230",
                "80");

            if (!string.IsNullOrEmpty(errMsg))
            {
                throw new Exception($"error connecting to {gateway}: {errMsg}");
            }

            #endregion

            #region Scan

            var scanCommand = new ScanRfidCmd(null);


            scanCommand.Bind(null, reader);

            var success = RfidCmdDispatchMgr.Singleton.SendQueuedCmd(scanCommand);
            if (!string.IsNullOrEmpty(success))
            {
                throw new Exception(success);
            }

            #endregion

            #region Trigger Images

            errMsg = TagUtils.TagUID_StrToInt64(Epc, out var tagUid);

            if (!string.IsNullOrEmpty(errMsg))
            {
                throw new Exception($"{Epc} cannot be convert to a tagType");
            }


            while (true)
            {
                Task.Delay(10000).Wait();

                var setPage = new DataPacketCurPageNum(2);
                var tagCmd  = new TagCmd(setPage, tagUid, null, reader);
                CmdDispatchMgr.Singleton.SendTriggeredCmdAsync(tagCmd);
            }

            #endregion
        }
Exemple #14
0
        public void Configuration(IAppBuilder app, IConfigurationFactory configFactory, Directory directory,
                                  ILoader loader)
        {
            _configFactory = configFactory;
            var config = _configFactory.Get <BasicSearchConfiguration>().Result;

            // Configure
            if (!string.IsNullOrEmpty(config.ApplicationInsightsInstrumentationKey))
            {
                TelemetryConfiguration.Active.InstrumentationKey = config.ApplicationInsightsInstrumentationKey;
            }

            // Add telemetry initializers
            TelemetryConfiguration.Active.TelemetryInitializers.Add(new MachineNameTelemetryInitializer());
            TelemetryConfiguration.Active.TelemetryInitializers.Add(new DeploymentIdTelemetryInitializer());

            // Create telemetry sink
            _searchTelemetryClient = new SearchTelemetryClient();

            // Add telemetry processors
            var processorChain = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;

            processorChain.Use(next =>
            {
                var processor = new RequestTelemetryProcessor(next);

                processor.SuccessfulResponseCodes.Add(400);
                processor.SuccessfulResponseCodes.Add(404);

                return(processor);
            });

            processorChain.Use(next => new ExceptionTelemetryProcessor(next, _searchTelemetryClient.TelemetryClient));

            processorChain.Build();

            // Create an ILoggerFactory
            var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: false)
                                      .Enrich.With <HttpRequestIdEnricher>()
                                      .Enrich.With <HttpRequestTraceIdEnricher>()
                                      .Enrich.With <HttpRequestTypeEnricher>()
                                      .Enrich.With <HttpRequestUrlReferrerEnricher>()
                                      .Enrich.With <HttpRequestUserAgentEnricher>()
                                      .Enrich.With <HttpRequestRawUrlEnricher>();

            var loggerFactory = LoggingSetup.CreateLoggerFactory(loggerConfiguration);

            // Create a logger that is scoped to this class (only)
            _logger = loggerFactory.CreateLogger <Startup>();

            _logger.LogInformation(LogMessages.AppStartup);

            // Overwrite the index's Azure Directory cache path if configured ot use an Azure Local Storage resource.
            if (!string.IsNullOrEmpty(config.AzureDirectoryCacheLocalResourceName))
            {
                if (SafeRoleEnvironment.TryGetLocalResourceRootPath(config.AzureDirectoryCacheLocalResourceName, out var path))
                {
                    config.AzureDirectoryCachePath = path;

                    _logger.LogInformation(
                        "Set Azure Directory cache path to Azure Local Resource = {LocalResourceName}, Path = {LocalResourcePath}",
                        config.AzureDirectoryCacheLocalResourceName,
                        config.AzureDirectoryCachePath);
                }
                else
                {
                    _logger.LogWarning(
                        "Cannot use Azure Local Resource {LocalResourceName} for caching when the RoleEnvironment is not available",
                        config.AzureDirectoryCacheLocalResourceName);
                }
            }

            // redirect all HTTP requests to HTTPS
            if (config.RequireSsl)
            {
                if (string.IsNullOrWhiteSpace(config.ForceSslExclusion))
                {
                    app.UseForceSsl(config.SslPort);
                }
                else
                {
                    app.UseForceSsl(config.SslPort, new[] { config.ForceSslExclusion });
                }
            }

            // Correlate requests
            app.Use(typeof(CorrelationIdMiddleware));

            // Add Application Insights
            app.Use(typeof(RequestTrackingMiddleware));

            // Set up exception logging
            app.Use(typeof(ExceptionTrackingMiddleware));

            // Enable HSTS
            app.Use(async(context, next) =>
            {
                context.Response.Headers.Add("Strict-Transport-Security", new string[] { "max-age=31536000; includeSubDomains" });
                await next.Invoke();
            });

            // Disable content type sniffing
            app.Use(async(context, next) =>
            {
                context.Response.Headers.Add("X-Content-Type-Options", new[] { "nosniff" });
                await next.Invoke();
            });

            // Enable CORS
            var corsPolicy = new CorsPolicy
            {
                Methods         = { "GET", "HEAD", "OPTIONS" },
                Headers         = { "Content-Type", "If-Match", "If-Modified-Since", "If-None-Match", "If-Unmodified-Since", "Accept-Encoding" },
                ExposedHeaders  = { "Content-Type", "Content-Length", "Last-Modified", "Transfer-Encoding", "ETag", "Date", "Vary", "Server", "X-Hit", "X-CorrelationId" },
                AllowAnyOrigin  = true,
                PreflightMaxAge = 3600
            };

            app.UseCors(new CorsOptions
            {
                PolicyProvider = new CorsPolicyProvider
                {
                    PolicyResolver = context => Task.FromResult(corsPolicy)
                }
            });

            // Search test console
            app.Use(typeof(SearchConsoleMiddleware));
            app.UseStaticFiles(new StaticFileOptions(new SharedOptions
            {
                RequestPath = new PathString("/console"),
                FileSystem  = new EmbeddedResourceFileSystem(typeof(Startup).Assembly, "NuGet.Services.BasicSearch.Console")
            }));

            // Start the service running - the Lucene index needs to be reopened regularly on a background thread
            var intervalSec = config.IndexRefreshSec;

            _logger.LogInformation(LogMessages.SearchIndexRefreshConfiguration, intervalSec);

            if (InitializeSearcherManager(config, directory, loader, loggerFactory))
            {
                var intervalMs = intervalSec * 1000;

                _gate             = 0;
                _indexReloadTimer = new Timer(ReopenCallback, 0, intervalMs, intervalMs);
            }

            _responseWriter = new ResponseWriter();

            app.Run(InvokeAsync);
        }
Exemple #15
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                if (!ApplicationInsights.Initialized)
                {
                    string instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                    if (!string.IsNullOrWhiteSpace(instrumentationKey))
                    {
                        ApplicationInsights.Initialize(instrumentationKey);
                    }
                }

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

                // Configure job
                _galleryBaseAddress = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryBaseAddress);

                var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
                _cloudStorageAccount = CreateCloudStorageAccount(JobArgumentNames.DataStorageAccount, storageConnectionString);

                _containerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);

                _runValidationTasks     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.RunValidationTasks).Split(';');
                _requestValidationTasks = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.RequestValidationTasks).Split(';');

                // Add validators
                if (_runValidationTasks.Contains(UnzipValidator.ValidatorName))
                {
                    _validators.Add(new UnzipValidator(_loggerFactory));
                }
                if (_runValidationTasks.Contains(VcsValidator.ValidatorName))
                {
                    // if contact alias set, use it, if not, use submitter alias.
                    string submitterAlias = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorSubmitterAlias);
                    string contactAlias   = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.VcsContactAlias)
                                            ?? submitterAlias;

                    _validators.Add(new VcsValidator(
                                        JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorServiceUrl),
                                        JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorCallbackUrl),
                                        contactAlias,
                                        submitterAlias,
                                        JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsPackageUrlTemplate),
                                        _loggerFactory));
                }

                return(true);
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.LogError(TraceEvent.CommandLineProcessingFailed, ex, "Exception occurred while processing command line arguments");
                }
                else
                {
                    Trace.TraceError("Exception occurred while processing command line arguments: {0}", ex);
                }
            }

            return(false);
        }