|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|