public void InitializeAndShutdown()
        {
            var configuration = new VolatileLogConfiguration();
            var stage         = ProcessingPipelineStage.Create <ElasticsearchPipelineStage>("Elasticsearch", configuration);

            // let the configuration provide the appropriate Elasticsearch endpoints
            var stageSettings = configuration.ProcessingPipeline.Stages.First(x => x.Name == "Elasticsearch");

            stageSettings.SetSetting("Server.ApiBaseUrls", Setting_Server_ApiBaseUrls, UriArrayToString, StringToUriArray);
            stageSettings.SetSetting("Server.Authentication.Schemes", Setting_Server_Authentication_Schemes);
            stageSettings.SetSetting("Server.Authentication.Username", Setting_Server_Authentication_Username);
            stageSettings.SetSetting("Server.Authentication.Password", Setting_Server_Authentication_Password);
            stageSettings.SetSetting("Server.Authentication.Domain", Setting_Server_Authentication_Domain);
            stageSettings.SetSetting("Server.BulkRequest.MaxConcurrencyLevel", Setting_Server_BulkRequest_MaxConcurrencyLevel);
            stageSettings.SetSetting("Server.BulkRequest.MaxMessageCount", Setting_Server_BulkRequest_MaxMessageCount);
            stageSettings.SetSetting("Server.BulkRequest.MaxSize", Setting_Server_BulkRequest_MaxSize);
            stageSettings.SetSetting("Server.IndexName", Setting_Server_IndexName);
            stageSettings.SetSetting("Data.Organization.Id", Setting_Data_Organization_Id);
            stageSettings.SetSetting("Data.Organization.Name", Setting_Data_Organization_Name);
            stageSettings.SetSetting("Stage.SendQueueSize", Setting_Stage_SendQueueSize);

            // initialize the stage
            stage.Initialize();
            Assert.True(stage.IsInitialized);
            Assert.False(stage.IsOperational);
            Assert.Equal(Setting_Server_ApiBaseUrls, stage.ApiBaseUrls);
            Assert.Equal(Setting_Server_Authentication_Schemes, stage.AuthenticationSchemes);
            Assert.Equal(Setting_Server_Authentication_Username, stage.Username);
            Assert.Equal(Setting_Server_Authentication_Password, stage.Password);
            Assert.Equal(Setting_Server_Authentication_Domain, stage.Domain);
            Assert.Equal(Setting_Server_BulkRequest_MaxConcurrencyLevel, stage.BulkRequestMaxConcurrencyLevel);
            Assert.Equal(Setting_Server_BulkRequest_MaxMessageCount, stage.BulkRequestMaxMessageCount);
            Assert.Equal(Setting_Server_BulkRequest_MaxSize, stage.BulkRequestMaxSize);
            Assert.Equal(Setting_Server_IndexName, stage.IndexName);
            Assert.Equal(Setting_Data_Organization_Id, stage.OrganizationId);
            Assert.Equal(Setting_Data_Organization_Name, stage.OrganizationName);
            Assert.Equal(Setting_Stage_SendQueueSize, stage.SendQueueSize);

            // wait for some time before shutting down
            Thread.Sleep(1000);

            // shut the stage down
            stage.Shutdown();
            Assert.False(stage.IsInitialized);
        }
Exemple #2
0
        /// <summary>
        /// Is called, if specified command line arguments have successfully been validated.
        /// </summary>
        /// <param name="options">Command line options.</param>
        /// <returns>Exit code the application should return.</returns>
        private static ExitCode RunOptionsAndReturnExitCode(Options options)
        {
            // configure the log verbosity
            var configuration = new VolatileLogConfiguration();

            configuration.AddLogWriterDefault(x => x.WithBaseLevel(options.Verbose ? LogLevel.All: LogLevel.Note));
            Log.Configuration = configuration;

            sLog.Write(LogLevel.Developer, "LicenseCollector v{0}", Assembly.GetExecutingAssembly().GetName().Version);
            sLog.Write(LogLevel.Developer, "--------------------------------------------------------------------------------");
            sLog.Write(LogLevel.Developer, "Verbose:            '{0}'", options.Verbose);
            sLog.Write(LogLevel.Developer, "SolutionFile:       '{0}'", options.SolutionFilePath);
            sLog.Write(LogLevel.Developer, "Configuration:      '{0}'", options.Configuration);
            sLog.Write(LogLevel.Developer, "Platform:           '{0}'", options.Platform);
            sLog.Write(LogLevel.Developer, "SearchPattern:      '{0}'", options.SearchPattern);
            sLog.Write(LogLevel.Developer, "LicenseTemplatePath '{0}'", options.LicenseTemplatePath);
            sLog.Write(LogLevel.Developer, "OutputPath:         '{0}'", options.OutputLicensePath);
            sLog.Write(LogLevel.Developer, "--------------------------------------------------------------------------------");

            // the given path for the solution does not exist
            if (!File.Exists(options.SolutionFilePath))
            {
                sLog.Write(LogLevel.Error, "The path to the solution file under '{0}' does not exist.", options.SolutionFilePath);
                return(ExitCode.FileNotFound);
            }
            // the given path is not a solution file
            if (!Path.GetExtension(options.SolutionFilePath).Equals(".sln"))
            {
                sLog.Write(LogLevel.Error, "The path '{0}' is not a solution file.", options.SolutionFilePath);
                return(ExitCode.ArgumentError);
            }
            // convert given relative paths to absolute paths if necessary
            if (!Path.IsPathRooted(options.SolutionFilePath))
            {
                options.SolutionFilePath = Path.GetFullPath(options.SolutionFilePath);
            }
            if (!Path.IsPathRooted(options.OutputLicensePath))
            {
                options.OutputLicensePath = Path.GetFullPath(options.OutputLicensePath);
            }
            if (!string.IsNullOrEmpty(options.LicenseTemplatePath) && !Path.IsPathRooted(options.LicenseTemplatePath))
            {
                options.LicenseTemplatePath = Path.GetFullPath(options.LicenseTemplatePath);
            }

            var app = new AppCore(options.SolutionFilePath, options.Configuration, options.Platform,
                                  options.OutputLicensePath, options.SearchPattern, options.LicenseTemplatePath);

            try
            {
                app.CollectProjects();

                app.GetNuGetPackages();

                app.GetNuGetLicenseInfo();

                app.GetStaticLicenseInfo();

                app.GenerateOutputFileAsync().Wait();
            }
            catch (Exception ex)
            {
                sLog.Write(LogLevel.Error, "Caught exception during processing. Exception: {0}", ex);
                return(ExitCode.GeneralError);
            }

            return(ExitCode.Success);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VolatileProcessingPipelineConfiguration"/> class.
 /// </summary>
 /// <param name="configuration">The log configuration the processing pipeline configuration belongs to.</param>
 internal VolatileProcessingPipelineConfiguration(VolatileLogConfiguration configuration)
 {
     Stages = new VolatileProcessingPipelineStageConfigurations(configuration);
 }