This commit is contained in:
李超 2023-12-19 09:07:45 +08:00
parent 46a2904880
commit 242ce72163
1 changed files with 33 additions and 8 deletions

View File

@ -9,6 +9,8 @@ using System.Text;
using BLL;
using Microsoft.SqlServer.Server;
using System.Configuration;
using System.Linq;
using Model;
namespace WebAPI.Controllers
{
@ -27,15 +29,38 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
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)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string jsonCameras = APIGetHttpService.Http(url+"api/v1/device/channeltree?serial=" + nvr["serial"]);
responeData.data = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras);
Base_Project project = null;
if (!string.IsNullOrEmpty(projectId))
{
project = db.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
}
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>> resDic = new List<Dictionary<string, string>>();
List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
foreach (Dictionary<string, string> nvr in jsonNvr)
{
if (project != null && nvr["customName"].ToString() == project.ProjectName)
{
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
responeData.data = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras);
return responeData;
}
else if (project == null)
{
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
resDic.AddRange(JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras));
}
else
{
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
resDic.AddRange(JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras));
}
}
responeData.data = resDic;
}
}