140 lines
5.1 KiB
C#
140 lines
5.1 KiB
C#
using BLL;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.Video
|
|
{
|
|
public partial class Video : PageBase
|
|
{
|
|
|
|
public string playIds
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["playIds"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["playIds"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (this.CurrUser != null)
|
|
{
|
|
this.playIds = "";
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode
|
|
{
|
|
Text = "项目-设备",
|
|
NodeID = "0",
|
|
Expanded = true
|
|
};
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
try
|
|
{
|
|
string url = ConfigurationManager.AppSettings["Video_URL"];
|
|
List<string> urls = new List<string>();
|
|
string res = APIGetHttpService.Http(url + "api/v1/device/channeltree");
|
|
|
|
List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
|
|
foreach (Dictionary<string, string> nvr in jsonNvr)
|
|
{
|
|
TreeNode newNode = new TreeNode
|
|
{
|
|
NodeID = nvr["id"],
|
|
Text = nvr["customName"],
|
|
ToolTip = "项目",
|
|
Expanded = false
|
|
};
|
|
rootNode.Nodes.Add(newNode);
|
|
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
|
|
var data = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras);
|
|
foreach (var video in data)
|
|
{
|
|
TreeNode tempNode = new TreeNode
|
|
{
|
|
NodeID = video["id"],
|
|
Text = video["name"],
|
|
ToolTip = "设备",
|
|
EnableClickEvent = true
|
|
};
|
|
|
|
newNode.Nodes.Add(tempNode);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog(ex, "视频监控", "Video.Video.aspx");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 树展开事件
|
|
/// <summary>
|
|
/// 树展开事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
|
|
{ }
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
var id = this.tvControlItem.SelectedNodeID;
|
|
if (id.Contains(":"))
|
|
{
|
|
try
|
|
{
|
|
string url = ConfigurationManager.AppSettings["Video_URL"];
|
|
var stmp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds() + "";
|
|
string jsonCamera = APIGetHttpService.Http(url + "api/v1/stream/start?serial=" + id.Split(':')[0] + "&code=" + id.Split(':')[1] + "&_=" + stmp);
|
|
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonCamera);
|
|
for (int i = 1; i <= 9; i++)
|
|
{
|
|
if (this.playIds.Contains("player0" + i))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
this.playIds += "player0" + i;
|
|
PageContext.RegisterStartupScript("play(\"" + "player0" + i + "\",\"" + data["HLS"] + "\")");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog(ex, "视频监控", "Video.Video.aspx");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
var id = Request.Form["__EVENTARGUMENT"];
|
|
this.playIds = this.playIds.Replace(id, "");
|
|
PageContext.RegisterStartupScript("play(\"" + id + "\",\"\")");
|
|
}
|
|
}
|
|
} |