Inheritance: DbContext, IQueryContext
Beispiel #1
0
 public IEnumerable<Query> GetQueries()
 {
     using (var db = new QueryContext())
     {
         return (from query in db.Queries
                select query).ToList();
     }
 }
Beispiel #2
0
 public void Add(Query query)
 {
     using(var db = new QueryContext())
     {
         db.Queries.Add(query);
         db.SaveChanges();
     }
 }
Beispiel #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();
     }
 }
Beispiel #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();
     }
 }
Beispiel #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;
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #8
0
 public QueryController(IBus bus, QueryContext queryContext)
 {
     this.bus = bus;
     this.queryContext = queryContext;
     databases = ConfigurationManager.AppSettings["DatabaseNames"].Split(',');
 }