79 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using Newtonsoft.Json;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Configuration;
 | |
| using System.Web.Http;
 | |
| 
 | |
| namespace WebAPI.Controllers
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 
 | |
|     /// </summary>
 | |
|     public class VideoController : ApiController
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         /// <returns></returns>
 | |
|         public Model.ResponeData getVideoInfor(string projectId)
 | |
|         {
 | |
|             Model.ResponeData responeData = new Model.ResponeData();
 | |
|             try
 | |
|             {
 | |
|                 string url =ConfigurationManager.AppSettings["Video_URL"];
 | |
|                 List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
 | |
|                 responeData.data = data;
 | |
|                 List<string> urls = new List<string>();
 | |
|                 string res = APIGetHttpService.Http(url + "api/v1/device/channeltree");
 | |
|                 var name = BLL.ProjectService.GetProjectNameByProjectId(projectId);
 | |
|                 List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
 | |
|                 foreach (Dictionary<string, string> nvr in jsonNvr)
 | |
|                 {
 | |
|                     if (nvr["customName"] == name)
 | |
|                     {
 | |
|                         string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?serial=" + nvr["serial"]);
 | |
|                         data.AddRange(JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras));
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 responeData.code = 0;
 | |
|                 responeData.message = ex.Message;
 | |
|                 ErrLogInfo.WriteLog(ex, "WX接口-监控视频", "VideoController.getVideoInfor");
 | |
|             }
 | |
| 
 | |
|             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 url =  ConfigurationManager.AppSettings["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;
 | |
|                 ErrLogInfo.WriteLog(ex, "WX接口-监控视频", "VideoController.getVideoUrl");
 | |
|             }
 | |
| 
 | |
|             return responeData;
 | |
|         }
 | |
|     }
 | |
| }
 |