public void Update() { using (var dbContext = new HelloHomeDbContext()) { var nodes = dbContext.Nodes .Include(_ => _.Ports) .Include(_ => _.LatestValues) .Where(_ => _.Configuration.EmonCmsNodeId.HasValue); foreach (var node in nodes) { var values = new List <float> { node.LatestValues.VIn ?? 0, node.LatestValues.Temperature ?? 0, node.LatestValues.Humidity ?? 0, node.LastSeen.HasValue ? (float)(DateTime.Now - node.LastSeen.Value).TotalDays : 0 }; foreach (var port in node.Ports.OfType <PulseSensor>().OrderBy(_ => _.Number)) { values.Add(port.PulseCount); } values.Add(node.LatestValues.Rssi); _emonCmsAgent.Send(node.Configuration.EmonCmsNodeId.Value, values); } } }
public NodeStartupScenario(ITestOutputHelper output, TestableGateway testableGateway) { _testableGateway = testableGateway; _dbCtx = testableGateway.DbCtx; _msgChannel = new Mock <INodeMessageChannel>(); _gtw = testableGateway.CreateGateway(_msgChannel.Object); Logger.Debug("Gateway created with channel {0}", _msgChannel.GetHashCode()); }
public TestableGateway() { //Database.SetInitializer (new MySqlInitializer ()); Database.SetInitializer <HelloHomeDbContext>(null); _ioCcontainer = new WindsorContainer(); _ioCcontainer.Install(new DefaultInstaller( Component.For <IEMonCmsUpdater>().Instance(new Mock <IEMonCmsUpdater>().Object), Component.For <IHelloHomeDbContext>().ImplementedBy <HelloHomeDbContext>().LifestyleSingleton() )); DbCtx = (HelloHomeDbContext)_ioCcontainer.Resolve <IHelloHomeDbContext>(); DbCtx.Database.Delete(); DbCtx.Database.Create(); }
protected EntityTest() { DbCtx = new HelloHomeDbContext(); _transact = DbCtx.Database.BeginTransaction(); }
public void ReleaseDbContext(HelloHomeDbContext ctx) { _ioCcontainer.Release(ctx); }
public IEnumerable <Node> Get() { using (var dbContext = new HelloHomeDbContext()) { return(dbContext.Nodes.ToList()); } }