コード例 #1
0
        /// <summary>
        /// Run the report.
        /// </summary>
        /// <param name="reportRunner">
        /// A <see cref="IReportRunner{TReportResult}"/> to run the report. This cannot be null.
        /// </param>
        /// <param name="reportResultFormatter">
        /// A <see cref="IReportResultFormatter{TReportResult}"/> to format the report results. This cannot be null.
        /// </param>
        /// <param name="credentialRepository">
        /// Used to load previously saved credentials. Cannot be null.
        /// </param>
        /// <param name="options">
        /// The command line options. Cannot be null.
        /// </param>
        /// <returns>
        /// The process return value.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="reportRunner"/>, <paramref name="reportResultFormatter"/>, <paramref name="credentialRepository"/>
        /// and <paramref name="options"/> cannot be null.
        /// </exception>
        private static int RunReport <TReportResult>(IReportRunner <TReportResult> reportRunner, IReportResultFormatter <TReportResult> reportResultFormatter,
                                                     ICredentialRepository credentialRepository, CheckmarxReportOptions options)
        {
            if (reportRunner == null)
            {
                throw new ArgumentNullException(nameof(reportRunner));
            }
            if (reportResultFormatter == null)
            {
                throw new ArgumentNullException(nameof(reportResultFormatter));
            }
            if (credentialRepository == null)
            {
                throw new ArgumentNullException(nameof(credentialRepository));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            string userName;
            string password;

            GetCredentials(credentialRepository, options.Server, options.UserName, options.Password, out userName, out password);

            using (Stream stream = string.IsNullOrWhiteSpace(options.OutputPath)
                ? Console.OpenStandardOutput() : new FileStream(options.OutputPath, FileMode.Create))
                using (StreamWriter output = new StreamWriter(stream, Encoding.UTF8))
                    using (CheckmarxApiSession checkmarxApiSession = new CheckmarxApiSession(options.Server, userName, password))
                    {
                        reportResultFormatter.Format(reportRunner.Run(checkmarxApiSession, options), output, options, userName);
                    }

            return(ExitSuccess);
        }
コード例 #2
0
 public ReportsController(ULODBEntities db, IComponentContext componentContext, ICacher cacher, Serilog.ILogger logger, IReportRunner reportRunner, IRecurringJobManager rjm, IBackgroundJobClient backgroundJobClient)
     : base(db, componentContext, cacher, logger)
 {
     this.ReportRunner        = reportRunner;
     this.RJM                 = rjm;
     this.BackgroundJobClient = backgroundJobClient;
 }
コード例 #3
0
 public BackgroundTasks(IEmailServer emailServer, ULODBEntities db, IWorkflowManager workflowManager, ILogger log, IReportRunner reportRunner)
 {
     EmailServer     = emailServer;
     DB              = db;
     WorkflowManager = workflowManager;
     ReportRunner    = reportRunner;
     Log             = log.ForContext(GetType());
 }
コード例 #4
0
 public ReportsController(IReportRunner reportRunner, IOptions <Config> configOptions, UloDbContext db, ICacher cacher, PortalHelpers portalHelpers, UserHelpers userHelpers, ILogger <ReportsController> logger, IRecurringJobManager rjm, IBackgroundJobClient backgroundJobClient)
     : base(db, cacher, portalHelpers, userHelpers, logger)
 {
     ReportRunner        = reportRunner;
     ConfigOptions       = configOptions;
     RJM                 = rjm;
     BackgroundJobClient = backgroundJobClient;
 }
コード例 #5
0
 public BackgroundTasks(IConnectionStringProvider connectionStringProvider, SpecialFolderProvider specialFolderProvider, RazorTemplateProcessor razorTemplateProcessor, IReportRunner reportRunner, IOptions <Config> configOptions, UserHelpers userHelpers, IEmailServer emailServer, UloDbContext db, IWorkflowManager workflowManager, ILogger <BackgroundTasks> logger, PortalHelpers portalHelpers)
     : base(logger)
 {
     ConnectionStringProvider = connectionStringProvider;
     SpecialFolderProvider    = specialFolderProvider;
     RazorTemplateProcessor   = razorTemplateProcessor;
     ReportRunner             = reportRunner;
     ConfigOptions            = configOptions;
     UserHelpers     = userHelpers;
     EmailServer     = emailServer;
     DB              = db;
     WorkflowManager = workflowManager;
     PortalHelpers   = portalHelpers;
 }