94 lines
2.9 KiB
C#
94 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Web.Http;
|
|
using Newtonsoft.Json;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.Text;
|
|
using BLL;
|
|
using Microsoft.SqlServer.Server;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
|
|
namespace WebAPI.Controllers
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class VideoController : ApiController
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData getVideoInfor(string projectId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
{
|
|
string video_Url = string.Empty;
|
|
var sysSet16 = (from x in db.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault();
|
|
if (sysSet16 != null)
|
|
{
|
|
video_Url = sysSet16.SetValue;
|
|
}
|
|
string url = 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)
|
|
{
|
|
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
|
|
responeData.data = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras);
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="serial"></param>
|
|
/// <param name="code"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData getVideoUrl(string projectId, string serial, string code)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
string video_Url = string.Empty;
|
|
var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault();
|
|
if (sysSet16 != null)
|
|
{
|
|
video_Url = sysSet16.SetValue;
|
|
}
|
|
string url = video_Url;
|
|
var stmp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds() + "";
|
|
string jsonCamera = APIGetHttpService.Http(url +"api/v1/stream/start?serial=" + serial + "&code=" + code + "&_=" + stmp);
|
|
responeData.data = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonCamera);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
}
|
|
}
|