Beispiel #1
0
        // Return Rule IDs present in the underlying BSOA Rules Table (all reachable rules, in *sorted* order)
        // Used to verify Collect() has removed and kept all reachable rows.
        private string TableRules(Run run)
        {
            RunDatabase        db         = (RunDatabase)run.DB;
            IEnumerable <Rule> tableRules = db.Rule;

            return(string.Join(", ", tableRules.Select((r) => r.Id).OrderBy((id) => id)));
        }
Beispiel #2
0
        /// <summary>
        /// Retrieves the most recent 100 Runs from Database, Time Filtered
        /// </summary>
        /// <returns>Top 100 most recent Runs</returns>
        public async Task <List <Run> > GetTop100RunsAsync()
        {
            var result  = RunDatabase.Where <Run>(run => run.SubmissionTime < DateTime.UtcNow);
            var ordered = result.OrderByDescending(r => r.SubmissionTime);
            var top100  = ordered.Take <Run>(100);

            return(await top100.ToListAsync <Run>());
        }
Beispiel #3
0
        /// <summary>
        /// Adds a run to the Database
        /// </summary>
        /// <param name="newRun">New Run</param>
        /// <returns>True if created, false else</returns>
        public async Task <bool> AddNewRun(Run newRun)
        {
            try
            {
                await RunDatabase.AddAsync(newRun);
                await SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets a Run based on RunID
        /// </summary>
        /// <param name="runId">Id of Run</param>
        /// <returns>Run</returns>
        public async Task <Run> GetRunById(int runId)
        {
            // Because EF Core does not support Thread-Reentry, we want to handle any possible failure
            // cases within the method itself.
            try
            {
                var run = await RunDatabase.Where <Run>(r => r.RunId == runId).FirstOrDefaultAsync <Run>();

                return(run);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #5
0
 private static void Main(string[] args)
 {
     RunDatabase.Run();
     Console.ReadKey();
 }