diff --git a/SGGL/WebAPI/Controllers/VideoController.cs b/SGGL/WebAPI/Controllers/VideoController.cs index 5d5608c8..2038c568 100644 --- a/SGGL/WebAPI/Controllers/VideoController.cs +++ b/SGGL/WebAPI/Controllers/VideoController.cs @@ -21,21 +21,26 @@ namespace WebAPI.Controllers { Model.ResponeData responeData = new Model.ResponeData(); try - { + { string url =ConfigurationManager.AppSettings["Video_URL"]; + var project = BLL.ProjectService.GetProjectByProjectId(projectId); + + string URLToken = ""; + String restoken = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/login?username=" + project.ProjectCode + "&password=" + Funs.EncryptionPassword(project.MonitorPW)); + Dictionary dicres = JsonConvert.DeserializeObject>(restoken); + URLToken = dicres["URLToken"]; List> data = new List>(); responeData.data = data; List urls = new List(); - string res = APIGetHttpService.Http(url + "api/v1/device/channeltree"); + string res = APIGetHttpService.Http(url + "api/v1/device/channeltree?token=" + URLToken); var name = BLL.ProjectService.GetProjectNameByProjectId(projectId); List> jsonNvr = JsonConvert.DeserializeObject>>(res); foreach (Dictionary nvr in jsonNvr) { - if (nvr["customName"] == name) - { - string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]); + + string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]+ "&token="+URLToken); data.AddRange(JsonConvert.DeserializeObject>>(jsonCameras)); - } + } } catch (Exception ex) @@ -60,9 +65,17 @@ namespace WebAPI.Controllers var responeData = new Model.ResponeData(); try { - string url = ConfigurationManager.AppSettings["Video_URL"]; + string url = ConfigurationManager.AppSettings["Video_URL"]; + var project = BLL.ProjectService.GetProjectByProjectId(projectId); + + string URLToken = ""; + String restoken = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/login?username=" + project.ProjectCode + "&password=" + Funs.EncryptionPassword(project.MonitorPW)); + Dictionary dicres = JsonConvert.DeserializeObject>(restoken); + URLToken = dicres["URLToken"]; + + var stmp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds() + ""; - string jsonCamera = APIGetHttpService.Http(url +"api/v1/stream/start?serial=" + serial + "&code=" + code + "&_=" + stmp); + string jsonCamera = APIGetHttpService.Http(url + "api/v1/stream/start?token="+URLToken+"&serial=" + serial + "&code=" + code + "&_=" + stmp); responeData.data = JsonConvert.DeserializeObject>(jsonCamera); } catch (Exception ex)