This commit is contained in:
parent
2323e1ca78
commit
b1628fdf4a
|
@ -21,21 +21,26 @@ namespace WebAPI.Controllers
|
||||||
{
|
{
|
||||||
Model.ResponeData responeData = new Model.ResponeData();
|
Model.ResponeData responeData = new Model.ResponeData();
|
||||||
try
|
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<string, string> dicres = JsonConvert.DeserializeObject<Dictionary<string, string>>(restoken);
|
||||||
|
URLToken = dicres["URLToken"];
|
||||||
List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
|
List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
|
||||||
responeData.data = data;
|
responeData.data = data;
|
||||||
List<string> urls = new List<string>();
|
List<string> urls = new List<string>();
|
||||||
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);
|
var name = BLL.ProjectService.GetProjectNameByProjectId(projectId);
|
||||||
List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
|
List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
|
||||||
foreach (Dictionary<string, string> nvr in jsonNvr)
|
foreach (Dictionary<string, string> nvr in jsonNvr)
|
||||||
{
|
{
|
||||||
if (nvr["customName"] == name)
|
|
||||||
{
|
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]+ "&token="+URLToken);
|
||||||
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
|
|
||||||
data.AddRange(JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras));
|
data.AddRange(JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -60,9 +65,17 @@ namespace WebAPI.Controllers
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
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<string, string> dicres = JsonConvert.DeserializeObject<Dictionary<string, string>>(restoken);
|
||||||
|
URLToken = dicres["URLToken"];
|
||||||
|
|
||||||
|
|
||||||
var stmp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds() + "";
|
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<Dictionary<string, string>>(jsonCamera);
|
responeData.data = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonCamera);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Reference in New Issue