Exemplo n.º 1
0
        public QueryRoot HandleQuery(string db, string query, IDbManagement dbm)
        {
            var root = new QueryRoot();
            var result = new QueryResult();
            var serie = new QuerySerie();

            if (query.ToLower() == "show measurements")
            {
                serie.name = "measurements";
                serie.columns.Add("name");

                var myDb = dbm.GetDb(db);
                serie.values.AddRange(myDb.GetMeasurementNames().Select(i => new List<object> {i}));

                result.series.Add(serie);

                root.results.Add(result);
                return root;
            }
            var dbInstance = dbm.GetDb(db);
            var scriptingEngine = new ScriptingEngine(dbInstance, query);
            var res = scriptingEngine.Execute();

            foreach (var s in res.Result.Series.OrderByDescending(i => i.FullName))
            {
                QuerySerie querySerie = new QuerySerie();
                CreateSingleResult(querySerie, s, result);
            }

            root.results.Add(result);
            return root;
        }
Exemplo n.º 2
0
 public void DynamicTableInScript()
 {
     var db = new DbManagement().GetDb("f*x");
     var result =
         new ScriptingEngine(db,
             @"db.GetTable<float>(""Aussen.Wetterstation.(?<k>[TF]).*?$"", ""time > now() - 1M"")
     .Transform(i => i.GroupByHours(1, o => o.Mean()))
     .ZipAndAdd(""Sum"", t => t.T + t.F)").Execute();
 }