Ejemplo n.º 1
0
        private static async Task AddUserAsync(PcReport PcReport)
        {
            ConsoleWriter.WriteLine(_stopwatch, $"Adding primary user of {PcReport.ComputerName}.", ConsoleColor.Cyan);
            await Task.Delay(TimeSpan.FromMilliseconds(_getUserMsec));

            PcReport.PrimaryUser = new User {
                Username = $"{PcReport.ComputerName} User"
            };
            ConsoleWriter.WriteLine(_stopwatch, $"The primary user is {PcReport.PrimaryUser.Username}.", ConsoleColor.Cyan);
        }
Ejemplo n.º 2
0
        private static async Task AddDatabaseLogsAsync(PcReport PcReport)
        {
            ConsoleWriter.WriteLine(_stopwatch, $"Adding database logs for {PcReport.ComputerName}.", ConsoleColor.Yellow);
            await Task.Delay(TimeSpan.FromMilliseconds(_getDatabaseLogsMsecPerDay *PcReport.Days));

            if (PcReport.PrimaryUser != null)
            {
                PcReport.DatabaseLogs = new List <string> {
                    "Database Log 1", "Database Log 2", "Database Log 3"
                }
            }
            ;
            ConsoleWriter.WriteLine(_stopwatch, $"Database logs = {string.Join(", ", PcReport.DatabaseLogs ?? new List<string>())}.", ConsoleColor.Yellow);
        }
Ejemplo n.º 3
0
        private static async Task <PcReport> CreateReportSequentiallyAsync(string ComputerName, int Days)
        {
            var pcReport = new PcReport
            {
                ComputerName = ComputerName,
                Days         = Days
            };

            await AddUserAsync(pcReport);
            await AddFileLogsAsync(pcReport);
            await AddEventLogsAsync(pcReport);
            await AddDatabaseLogsAsync(pcReport);

            return(pcReport);
        }
Ejemplo n.º 4
0
        private static async Task <PcReport> CreateReportConcurrentlyRaceConditionAsync(string ComputerName, int Days)
        {
            var pcReport = new PcReport
            {
                ComputerName = ComputerName,
                Days         = Days
            };
            var addUser         = AddUserAsync(pcReport);
            var addFileLogs     = AddFileLogsAsync(pcReport);
            var addEventLogs    = AddEventLogsAsync(pcReport);
            var addDatabaseLogs = AddDatabaseLogsAsync(pcReport);
            var tasks           = new List <Task> {
                addUser, addFileLogs, addEventLogs, addDatabaseLogs
            };
            await Task.WhenAll(tasks);

            return(pcReport);
        }
Ejemplo n.º 5
0
 private static async Task RunAsync(IReadOnlyList <string> Arguments)
 {
     (string computerName, int days, Func <string, int, Task <PcReport> > createReportAsync) = ParseCommandLine(Arguments);
     // ReSharper disable once UnusedVariable
     PcReport pcReport = await createReportAsync(computerName, days);
 }