Inheritance: DbContext, IQueryContext
Example #1
0
 public IEnumerable<Query> GetQueries()
 {
     using (var db = new QueryContext())
     {
         return (from query in db.Queries
                select query).ToList();
     }
 }
Example #2
0
 public void Add(Query query)
 {
     using(var db = new QueryContext())
     {
         db.Queries.Add(query);
         db.SaveChanges();
     }
 }
Example #3
0
 public Query GetByName(string name)
 {
     using (var db = new QueryContext())
     {
         return (from query in db.Queries
                where query.Name == name
                select query).FirstOrDefault();
     }
 }
Example #4
0
 public void Add(QueryResult queryResult, string name)
 {
     using (var db = new QueryContext())
     {
         queryResult.Query = db.Queries.FirstOrDefault(x => x.Name == name);
         db.QueryResults.Add(queryResult);
         db.SaveChanges();
     }
 }
Example #5
0
        public Query GetById(int id)
        {
            using(var db = new QueryContext())
            {
                var q =db.Queries.Find(id);
                foreach(var r in q.Results )
                {

                }
                return q;
            }
        }
Example #6
0
        public void UpdateRunDates(string name, DateTime lastRun, DateTime? nextRun)
        {
            using (var db = new QueryContext())
            {
                var query = db.Queries.FirstOrDefault(x => x.Name == name);
                if (query == null)
                    return;

                if( query.LastRun == null || lastRun > query.LastRun )
                query.LastRun = lastRun;

                query.NextRun = nextRun;
                db.SaveChanges();
            }
        }
Example #7
0
        public void UpdateQuery(Query query)
        {
            using (var db = new QueryContext())
            {
                var q = db.Queries.Find(query.QueryId);
                q.Name = query.Name;
                q.DatabaseName = query.DatabaseName;
                q.AlertEmailTo = query.AlertEmailTo;
                q.AlertIfAboveThreshold = query.AlertIfAboveThreshold;
                q.CronExpression = query.CronExpression;
                q.QueryText = query.QueryText;
                q.ThresholdMilliseconds = query.ThresholdMilliseconds;

                db.SaveChanges();
            }
        }
Example #8
0
 public QueryController(IBus bus, QueryContext queryContext)
 {
     this.bus = bus;
     this.queryContext = queryContext;
     databases = ConfigurationManager.AppSettings["DatabaseNames"].Split(',');
 }