Former-commit-id: 999889b790069af9dfb0ff308fc188e934599fd0
TangShanKaiPing
wanggang 6 years ago
parent 6a2bd07b0e
commit 774c6cdf6c

@ -0,0 +1,11 @@
using Infrastructure.Domain;
namespace Application.Domain.Entities
{
public class LiveRecord : BaseEntity
{
public string DeviceNumber { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
}

@ -92,6 +92,7 @@ namespace IoT.UI.Shard
modelBuilder.Entity<Device>().HasOne(o => o.Node).WithMany(o => o.Devices).HasForeignKey(o => o.NodeId).OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Data>().HasOne(o => o.Device).WithMany(o => o.Data).HasForeignKey(o => o.DeviceId);
modelBuilder.Entity<Parameter>().HasOne(o => o.Api).WithMany(o => o.Parameters).HasForeignKey(o => o.ApiId);
modelBuilder.Entity<LiveRecord>().Property(o => o.DeviceNumber).IsRequired();
modelBuilder.Entity<Scene>().HasOne(o => o.Node).WithMany(o => o.Scenes).HasForeignKey(o => o.NodeId);
modelBuilder.Entity<Command>().HasOne(o => o.Scene).WithMany(o => o.Commands).HasForeignKey(o => o.SceneId);
modelBuilder.Entity<Command>().HasOne(o => o.Api).WithMany(o => o.Commands).HasForeignKey(o => o.ApiId);

@ -26,18 +26,21 @@ namespace IoTCenter.Controllers
private readonly IJwtHelper _jwtHelper;
private readonly IRepository<Node> _nodeRepo;
private readonly IRepository<Device> _deviceRepo;
private readonly IRepository<LiveRecord> _liveRecordRepo;
private readonly IHubContext<PageHub> _pageHubContext;
public AppController(IConfiguration configuration,
IJwtHelper jwtHelper,
IRepository<Node> nodeRepo,
IRepository<Device> deviceRepo,
IRepository<LiveRecord> liveRecordRepo,
IHubContext<PageHub> pageHubContext)
{
this._configuration = configuration;
this._jwtHelper = jwtHelper;
this._nodeRepo = nodeRepo;
this._deviceRepo = deviceRepo;
this._liveRecordRepo = liveRecordRepo;
this._pageHubContext = pageHubContext;
}
@ -171,9 +174,20 @@ namespace IoTCenter.Controllers
{
using (var reader = new StreamReader(Request.Body))
{
var body = reader.ReadToEnd();
// Do something
var json = reader.ReadToEnd();
var result = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (result["action"] == "on_dvr")
{
var streamId = result["stream"];
var deviceNumber = streamId.StartsWith("main") ? streamId.Substring(4) : streamId.Substring(3);
this._liveRecordRepo.Add(new LiveRecord
{
DeviceNumber = deviceNumber,
Name = "回放",
Value = $"live{result["file"].Substring(result["file"].LastIndexOf('/'))}"
});
this._liveRecordRepo.SaveChanges();
}
}
return Content(string.Empty);
}

Loading…
Cancel
Save