1.0.0-beta.414.3

Former-commit-id: d73fe4a1c3e6b29bbd0d4968e974b46a6083c859
TangShanKaiPing
wanggang 5 years ago
parent 8c2c01e71f
commit cb28a8225f

@ -10,7 +10,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CS-Script.Core" Version="1.3.1" /> <PackageReference Include="CS-Script.Core" Version="1.3.1" />
<PackageReference Include="Hangfire.Core" Version="1.7.10" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.1.3" />
@ -45,8 +44,6 @@
<PackageReference Include="System.Management" Version="4.7.0" /> <PackageReference Include="System.Management" Version="4.7.0" />
<PackageReference Include="ValueInjecter" Version="3.2.0" /> <PackageReference Include="ValueInjecter" Version="3.2.0" />
<PackageReference Include="Flurl" Version="2.8.2" /> <PackageReference Include="Flurl" Version="2.8.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.10" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
<PackageReference Include="Cronos" Version="0.7.0" /> <PackageReference Include="Cronos" Version="0.7.0" />
<PackageReference Include="Polly" Version="7.2.0" /> <PackageReference Include="Polly" Version="7.2.0" />
</ItemGroup> </ItemGroup>

@ -1,5 +1,3 @@
using Hangfire;
using Hangfire.MemoryStorage;
using Infrastructure.Application.Services.Settings; using Infrastructure.Application.Services.Settings;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Events; using Infrastructure.Events;
@ -212,7 +210,6 @@ namespace Infrastructure.Web
//}; //};
}); });
} }
this.UseScheduler(services);
services.AddMemoryCache(); services.AddMemoryCache();
services.AddHttpContextAccessor(); services.AddHttpContextAccessor();
@ -237,11 +234,6 @@ namespace Infrastructure.Web
} }
} }
public virtual void UseScheduler(IServiceCollection services)
{
services.AddHangfire(x => x.UseMemoryStorage());
}
public virtual void ConfigureOptions(IServiceCollection services) public virtual void ConfigureOptions(IServiceCollection services)
{ {
services.ConfigureOptions(new FileConfigureOptions(this.Env)); services.ConfigureOptions(new FileConfigureOptions(this.Env));
@ -363,7 +355,6 @@ namespace Infrastructure.Web
app.UseSession(); app.UseSession();
this.UseAuthentication(app); this.UseAuthentication(app);
this.UseSwagger(app); this.UseSwagger(app);
this.UseScheduler(app);
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
this.UseSignalR(endpoints); this.UseSignalR(endpoints);
@ -420,12 +411,6 @@ namespace Infrastructure.Web
}); });
} }
public virtual void UseScheduler(IApplicationBuilder app)
{
app.UseHangfireDashboard(pathMatch: "/job");
app.UseHangfireServer();
}
public virtual void UseSignalR(IEndpointRouteBuilder endpoints) public virtual void UseSignalR(IEndpointRouteBuilder endpoints)
{ {
this.UseSignalR<BasePageHub>(endpoints); this.UseSignalR<BasePageHub>(endpoints);

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0-beta.414.1</Version> <Version>1.0.0-beta.414.2</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />

@ -0,0 +1,39 @@
using Application.Domain.Entities;
using Infrastructure.Events;
using Microsoft.Extensions.Caching.Distributed;
namespace IoTCenter.Services
{
public class CacheEventHandler :
IEventHander<EntityInsertedEvent<SceneTigger>>,
IEventHander<EntityUpdatedEvent<SceneTigger>>,
IEventHander<EntityDeletedEvent<SceneTigger>>
{
private readonly IDistributedCache _cache;
public CacheEventHandler(IDistributedCache cache)
{
this._cache = cache;
}
public void Handle(EntityInsertedEvent<SceneTigger> message)
{
this.Remove();
}
public void Handle(EntityUpdatedEvent<SceneTigger> message)
{
this.Remove();
}
public void Handle(EntityDeletedEvent<SceneTigger> message)
{
this.Remove();
}
private void Remove()
{
this._cache.Remove(CacheKey.SceneTiggerKey);
}
}
}

@ -0,0 +1,7 @@
namespace IoTCenter.Services
{
public class CacheKey
{
public static string SceneTiggerKey => nameof(SceneTiggerKey);
}
}

@ -0,0 +1,30 @@
using Application.Domain.Entities;
using Infrastructure.Extensions;
using Microsoft.Extensions.Caching.Distributed;
using System.Collections.Generic;
namespace IoTCenter.Services
{
public class CachedSceneTiggerService : ISceneTiggerService
{
private readonly IDistributedCache _cache;
private readonly SceneTiggerService _sceneTiggerService;
public CachedSceneTiggerService(IDistributedCache cache, SceneTiggerService sceneTiggerService)
{
this._cache = cache;
this._sceneTiggerService = sceneTiggerService;
}
public IList<SceneTigger> GetSceneTiggers()
{
var sceneTiggers = this._cache.Get<IList<SceneTigger>>(CacheKey.SceneTiggerKey);
if (sceneTiggers == null)
{
sceneTiggers = this._sceneTiggerService.GetSceneTiggers();
_cache.Set(CacheKey.SceneTiggerKey, sceneTiggers);
}
return sceneTiggers;
}
}
}

@ -0,0 +1,10 @@
using Application.Domain.Entities;
using System.Collections.Generic;
namespace IoTCenter.Services
{
public interface ISceneTiggerService
{
IList<SceneTigger> GetSceneTiggers();
}
}

@ -25,9 +25,6 @@ namespace IoTCenter.Services
IEventHander<EntityInsertedEvent<SceneTimer>>, IEventHander<EntityInsertedEvent<SceneTimer>>,
IEventHander<EntityUpdatedEvent<SceneTimer>>, IEventHander<EntityUpdatedEvent<SceneTimer>>,
IEventHander<EntityDeletedEvent<SceneTimer>>, IEventHander<EntityDeletedEvent<SceneTimer>>,
IEventHander<EntityInsertedEvent<SceneTigger>>,
IEventHander<EntityUpdatedEvent<SceneTigger>>,
IEventHander<EntityDeletedEvent<SceneTigger>>,
IEventHander<EntityInsertedEvent<Node>>, IEventHander<EntityInsertedEvent<Node>>,
IEventHander<EntityUpdatedEvent<Node>>, IEventHander<EntityUpdatedEvent<Node>>,
IEventHander<EntityDeletedEvent<Node>>, IEventHander<EntityDeletedEvent<Node>>,
@ -47,12 +44,12 @@ namespace IoTCenter.Services
IEventHander<EntityUpdatedEvent<Scene>>, IEventHander<EntityUpdatedEvent<Scene>>,
IEventHander<EntityDeletedEvent<Scene>> IEventHander<EntityDeletedEvent<Scene>>
{ {
public static ConcurrentDictionary<Guid, SceneTigger> Tiggers = new ConcurrentDictionary<Guid, SceneTigger>();
private readonly IConfiguration _cfg; private readonly IConfiguration _cfg;
private readonly ILogger<IoTCenterEventHandler> _logger; private readonly ILogger<IoTCenterEventHandler> _logger;
private readonly IRepository<Scene> _sceneRepo; private readonly IRepository<Scene> _sceneRepo;
private readonly IRepository<Device> _deviceRepo; private readonly IRepository<Device> _deviceRepo;
private readonly IRepository<SceneTigger> _sceneTiggerRepo; private readonly IRepository<SceneTigger> _sceneTiggerRepo;
private readonly ISceneTiggerService _sceneTiggerService;
private readonly IHubContext<IoTCenterHub> _hub; private readonly IHubContext<IoTCenterHub> _hub;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
@ -61,6 +58,7 @@ namespace IoTCenter.Services
IRepository<Scene> sceneRepo, IRepository<Scene> sceneRepo,
IRepository<Device> deviceRepo, IRepository<Device> deviceRepo,
IRepository<SceneTigger> sceneTiggerRepo, IRepository<SceneTigger> sceneTiggerRepo,
ISceneTiggerService sceneTiggerService,
IHubContext<IoTCenterHub> hub, IHubContext<IoTCenterHub> hub,
IHttpClientFactory httpClientFactory) IHttpClientFactory httpClientFactory)
{ {
@ -69,6 +67,7 @@ namespace IoTCenter.Services
this._sceneRepo = sceneRepo; this._sceneRepo = sceneRepo;
this._deviceRepo = deviceRepo; this._deviceRepo = deviceRepo;
this._sceneTiggerRepo = sceneTiggerRepo; this._sceneTiggerRepo = sceneTiggerRepo;
this._sceneTiggerService = sceneTiggerService;
this._hub = hub; this._hub = hub;
this._httpClientFactory = httpClientFactory; this._httpClientFactory = httpClientFactory;
} }
@ -119,39 +118,6 @@ namespace IoTCenter.Services
#endregion timer #endregion timer
#region tigger
public void Handle(EntityInsertedEvent<SceneTigger> message)
{
var tigger = message.Data;
if (_sceneRepo.ReadOnlyTable().Any(o => o.Id == tigger.SceneId && o.NodeId == null))
{
Tiggers.TryRemove(message.Data.Id, out _);
Tiggers.TryAdd(tigger.Id, tigger);
}
}
public void Handle(EntityUpdatedEvent<SceneTigger> message)
{
var tigger = message.Data;
if (_sceneRepo.ReadOnlyTable().Any(o => o.Id == tigger.SceneId && o.NodeId == null))
{
Tiggers.TryRemove(message.Data.Id, out _);
Tiggers.TryAdd(tigger.Id, tigger);
}
}
public void Handle(EntityDeletedEvent<SceneTigger> message)
{
var tigger = message.Data;
if (_sceneRepo.ReadOnlyTable().Any(o => o.Id == tigger.SceneId && o.NodeId == null))
{
Tiggers.TryRemove(tigger.Id, out _);
}
}
#endregion tigger
#region Product #region Product
public void Handle(EntityInsertedEvent<Product> message) public void Handle(EntityInsertedEvent<Product> message)
@ -292,10 +258,9 @@ namespace IoTCenter.Services
{ {
try try
{ {
foreach (var item in Tiggers) foreach (var tigger in this._sceneTiggerService.GetSceneTiggers())
{ {
var data = message.Data; var data = message.Data;
var tigger = item.Value;
if (tigger.DataId == data.Id) if (tigger.DataId == data.Id)
{ {
var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}"; var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}";

@ -0,0 +1,22 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using System.Collections.Generic;
using System.Linq;
namespace IoTCenter.Services
{
public class SceneTiggerService : ISceneTiggerService
{
private readonly IRepository<SceneTigger> _sceneTiggerRepo;
public SceneTiggerService(IRepository<SceneTigger> sceneTiggerRepo)
{
this._sceneTiggerRepo = sceneTiggerRepo;
}
public IList<SceneTigger> GetSceneTiggers()
{
return this._sceneTiggerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId == null && !o.Disabled).ToList();
}
}
}

@ -1,20 +1,15 @@
using Application.Domain.Entities; using Infrastructure.Data;
using Infrastructure.Data;
using Infrastructure.Email; using Infrastructure.Email;
using Infrastructure.Sms; using Infrastructure.Sms;
using Infrastructure.UI; using Infrastructure.UI;
using Infrastructure.Web; using Infrastructure.Web;
using IoT.Shared.Services; using IoT.Shared.Services;
using IoTCenter.Services; using IoTCenter.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace IoTCenter namespace IoTCenter
{ {
@ -26,6 +21,8 @@ namespace IoTCenter
public override void ConfigureServices(IServiceCollection services) public override void ConfigureServices(IServiceCollection services)
{ {
services.AddTransient<SceneTiggerService>();
services.AddTransient<ISceneTiggerService, CachedSceneTiggerService>();
services.AddTransient<IDbConfig, DbConfig>(); services.AddTransient<IDbConfig, DbConfig>();
services.AddTransient<IRoleService, RoleService>(); services.AddTransient<IRoleService, RoleService>();
services.AddTransient<IEmailSender, EmptyEmailSender>(); services.AddTransient<IEmailSender, EmptyEmailSender>();
@ -34,22 +31,6 @@ namespace IoTCenter
base.ConfigureServices(services); base.ConfigureServices(services);
} }
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
base.Configure(app, env, loggerFactory);
//
Task.Run(() =>
{
using var scope = app.ApplicationServices.CreateScope();
var tiggerRepo = scope.ServiceProvider.GetService<IRepository<SceneTigger>>();
var tiggers = tiggerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId == null).ToList();
foreach (var tigger in tiggers)
{
IoTCenterEventHandler.Tiggers.TryAdd(tigger.Id, tigger);
}
});
}
public override void ConfigureOptions(IServiceCollection services) public override void ConfigureOptions(IServiceCollection services)
{ {
services.ConfigureOptions(new FileConfigureOptions(Env, new List<string> { "IoT.Shared" })); services.ConfigureOptions(new FileConfigureOptions(Env, new List<string> { "IoT.Shared" }));

@ -2,9 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0-beta.414</Version> <Version>1.0.0-beta.414.3</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.7.10" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.10" />
<PackageReference Include="Hangfire.LiteDB" Version="0.3.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,39 @@
using Application.Domain.Entities;
using Infrastructure.Events;
using Microsoft.Extensions.Caching.Distributed;
namespace IoTNode.Services
{
public class CacheEventHandler :
IEventHander<EntityInsertedEvent<SceneTigger>>,
IEventHander<EntityUpdatedEvent<SceneTigger>>,
IEventHander<EntityDeletedEvent<SceneTigger>>
{
private readonly IDistributedCache _cache;
public CacheEventHandler(IDistributedCache cache)
{
this._cache = cache;
}
public void Handle(EntityInsertedEvent<SceneTigger> message)
{
this.Remove();
}
public void Handle(EntityUpdatedEvent<SceneTigger> message)
{
this.Remove();
}
public void Handle(EntityDeletedEvent<SceneTigger> message)
{
this.Remove();
}
private void Remove()
{
this._cache.Remove(CacheKey.SceneTiggerKey);
}
}
}

@ -0,0 +1,7 @@
namespace IoTNode.Services
{
public class CacheKey
{
public static string SceneTiggerKey => nameof(SceneTiggerKey);
}
}

@ -0,0 +1,30 @@
using Application.Domain.Entities;
using Infrastructure.Extensions;
using Microsoft.Extensions.Caching.Distributed;
using System.Collections.Generic;
namespace IoTNode.Services
{
public class CachedSceneTiggerService : ISceneTiggerService
{
private readonly IDistributedCache _cache;
private readonly SceneTiggerService _sceneTiggerService;
public CachedSceneTiggerService(IDistributedCache cache, SceneTiggerService sceneTiggerService)
{
this._cache = cache;
this._sceneTiggerService = sceneTiggerService;
}
public IList<SceneTigger> GetSceneTiggers()
{
var sceneTiggers = this._cache.Get<IList<SceneTigger>>(CacheKey.SceneTiggerKey);
if (sceneTiggers == null)
{
sceneTiggers = this._sceneTiggerService.GetSceneTiggers();
_cache.Set(CacheKey.SceneTiggerKey, sceneTiggers);
}
return sceneTiggers;
}
}
}

@ -0,0 +1,10 @@
using Application.Domain.Entities;
using System.Collections.Generic;
namespace IoTNode.Services
{
public interface ISceneTiggerService
{
IList<SceneTigger> GetSceneTiggers();
}
}

@ -12,16 +12,14 @@ namespace IoTNode.Services
IEventHander<EntityInsertedEvent<SceneTimer>>, IEventHander<EntityInsertedEvent<SceneTimer>>,
IEventHander<EntityUpdatedEvent<SceneTimer>>, IEventHander<EntityUpdatedEvent<SceneTimer>>,
IEventHander<EntityDeletedEvent<SceneTimer>>, IEventHander<EntityDeletedEvent<SceneTimer>>,
IEventHander<EntityInsertedEvent<SceneTigger>>,
IEventHander<EntityUpdatedEvent<SceneTigger>>,
IEventHander<EntityDeletedEvent<SceneTigger>>,
IEventHander<EntityUpdatedEvent<Data>> IEventHander<EntityUpdatedEvent<Data>>
{ {
public static ConcurrentDictionary<Guid, SceneTigger> Tiggers = new ConcurrentDictionary<Guid, SceneTigger>(); private readonly ISceneTiggerService _sceneTiggerService;
private readonly IoTNodeJob _job; private readonly IoTNodeJob _job;
public IoTNodeEventHandler(IoTNodeJob job) public IoTNodeEventHandler(ISceneTiggerService sceneTiggerService, IoTNodeJob job)
{ {
this._sceneTiggerService = sceneTiggerService;
this._job = job; this._job = job;
} }
@ -40,28 +38,11 @@ namespace IoTNode.Services
RecurringJob.RemoveIfExists(message.Data.Id.ToString()); RecurringJob.RemoveIfExists(message.Data.Id.ToString());
} }
public void Handle(EntityInsertedEvent<SceneTigger> message)
{
Tiggers.TryAdd(message.Data.Id, message.Data);
}
public void Handle(EntityUpdatedEvent<SceneTigger> message)
{
Tiggers.TryRemove(message.Data.Id, out _);
Tiggers.TryAdd(message.Data.Id, message.Data);
}
public void Handle(EntityDeletedEvent<SceneTigger> message)
{
Tiggers.TryRemove(message.Data.Id, out _);
}
public void Handle(EntityUpdatedEvent<Data> message) public void Handle(EntityUpdatedEvent<Data> message)
{ {
var data = message.Data; var data = message.Data;
foreach (var item in Tiggers) foreach (var tigger in this._sceneTiggerService.GetSceneTiggers())
{ {
var tigger = item.Value;
if (tigger.DataId == data.Id) if (tigger.DataId == data.Id)
{ {
var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}"; var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}";

@ -4,7 +4,6 @@ using IoT.Shared.Services;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
namespace IoTNode.Services namespace IoTNode.Services

@ -0,0 +1,22 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using System.Collections.Generic;
using System.Linq;
namespace IoTNode.Services
{
public class SceneTiggerService : ISceneTiggerService
{
private readonly IRepository<SceneTigger> _sceneTiggerRepo;
public SceneTiggerService(IRepository<SceneTigger> sceneTiggerRepo)
{
this._sceneTiggerRepo = sceneTiggerRepo;
}
public IList<SceneTigger> GetSceneTiggers()
{
return this._sceneTiggerRepo.ReadOnlyTable().Where(o => !o.Disabled).ToList();
}
}
}

@ -1,5 +1,5 @@
using Application.Domain.Entities; using Hangfire;
using Hangfire; using Hangfire.LiteDB;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Email; using Infrastructure.Email;
using Infrastructure.Web; using Infrastructure.Web;
@ -13,9 +13,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IoTNode namespace IoTNode
{ {
@ -27,6 +24,9 @@ namespace IoTNode
public override void ConfigureServices(IServiceCollection services) public override void ConfigureServices(IServiceCollection services)
{ {
services.AddHangfire(o => o.UseLiteDbStorage("job.db"));
services.AddTransient<SceneTiggerService>();
services.AddTransient<ISceneTiggerService, CachedSceneTiggerService>();
services.AddTransient<IDbConfig, DbConfig>(); services.AddTransient<IDbConfig, DbConfig>();
services.AddTransient<IRoleService, RoleService>(); services.AddTransient<IRoleService, RoleService>();
services.AddTransient<DataService>(); services.AddTransient<DataService>();
@ -47,22 +47,20 @@ namespace IoTNode
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{ {
base.Configure(app, env, loggerFactory); base.Configure(app, env, loggerFactory);
Task.Run(() => app.UseHangfireDashboard(pathMatch: "/job");
{
using var scope = app.ApplicationServices.CreateScope(); app.UseHangfireServer();
var timerRepo = scope.ServiceProvider.GetService<IRepository<SceneTimer>>();
var timers = timerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId != null).ToList(); //Task.Run(() =>
foreach (var timer in timers) //{
{ // using var scope = app.ApplicationServices.CreateScope();
RecurringJob.AddOrUpdate<IoTNodeJob>(timer.Id.ToString(), o => o.TimerHanle(timer.Id), timer.Cron, TimeZoneInfo.Local); // var timerRepo = scope.ServiceProvider.GetService<IRepository<SceneTimer>>();
} // var timers = timerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId != null).ToList();
var tiggerRepo = scope.ServiceProvider.GetService<IRepository<SceneTigger>>(); // foreach (var timer in timers)
var tiggers = tiggerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId != null).ToList(); // {
foreach (var tigger in tiggers) // RecurringJob.AddOrUpdate<IoTNodeJob>(timer.Id.ToString(), o => o.TimerHanle(timer.Id), timer.Cron, TimeZoneInfo.Local);
{ // }
IoTNodeEventHandler.Tiggers.TryAdd(tigger.Id, tigger); //});
}
});
} }
} }
} }
Loading…
Cancel
Save