public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { List <CameraList> cameraList; List <StreamMediaList> streamMediaList; List <StreamServerList> streamServerList; List <StationList> stationList; //获取数据库的所有设备信息,登录设备 CameraListRepository camera = new CameraListRepository(); cameraList = camera.GetList(); StreamMediaListRepository streamMedia = new StreamMediaListRepository(); streamMediaList = streamMedia.GetList(); StreamServerListRepository streamServer = new StreamServerListRepository(); streamServerList = streamServer.GetList(); StationListRepository station = new StationListRepository(); stationList = station.GetList(); //组装数据 DeviceData data = new DeviceData(); data.cameraList = cameraList; data.streamMediaList = streamMediaList; data.streamServerList = streamServerList; data.stationList = stationList; //转json string str = JsonConvert.SerializeObject(data); session.Send(str); }
public void DeleteTest() { CameraListRepository repo = new CameraListRepository(); List <CameraList> cameraList = repo.GetList(); //int result = repo.Delete(cameraList[0].DeviceID); //result = repo.DeleteList(new { VideoType = cameraList[1].VideoType }); int result = repo.DeleteList("where VideoType=2"); }
public void UpdateTest() { CameraListRepository repo = new CameraListRepository(); List <CameraList> cameraList = repo.GetList(); //cameraList[0].VideoName = DateTime.Now.ToString(); //cameraList[1].Stream_MainID = repo.GetGuid(); //int result = repo.Update(cameraList[0]); }
public void RecordCountTest() { CameraListRepository repo = new CameraListRepository(); int count = repo.RecordCount(); }
private void ReveiceData1() { while (true) { try { serverSocket1 = sSocket1.Accept(); string recStr = ""; byte[] recByte = new byte[4096]; int bytes = serverSocket1.Receive(recByte, recByte.Length, 0); recStr += Encoding.UTF8.GetString(recByte, 0, bytes); //显示 ReceiveDataPackageEvent(recStr); string[] str1 = recStr.Split('/'); if (str1.Length != 2) { return; } string[] str2 = str1[1].Split(','); //各种数据解析 int i_Action = -1; string message = ""; byte[] b; if (int.Parse(str2[0]) >= 1 && int.Parse(str2[0]) < 9) { switch (str2[0]) { //八方位、聚焦、视场 case "1": tmpGuid = new Guid(str2[1]); tmpSpeed = int.Parse(str2[4]); switch (str2[3]) { case "0": i_Action = (int)HDCommand.DirectionStop; break; //左上 case "1": //转发 i_Action = (int)HDCommand.LeftUp; break; //上 case "2": //转发 i_Action = (int)HDCommand.Up; break; //右上 case "3": //转发 i_Action = (int)HDCommand.RightDown; break; //左 case "4": //转发 i_Action = (int)HDCommand.Left; break; //初始位 case "5": //转发 i_Action = (int)HDCommand.InitialPoint; break; //右 case "6": //转发 i_Action = (int)HDCommand.Right; break; //左下 case "7": //转发 i_Action = (int)HDCommand.LeftUp; break; //下 case "8": //转发 i_Action = (int)HDCommand.Down; break; //右下 case "9": //转发 i_Action = (int)HDCommand.RightDown; break; //视场- case "10": i_Action = (int)CCDCommand.CCD_TurnShort; //转发 break; //视场- 停 case "11": i_Action = (int)CCDCommand.CCD_TurnShortStop; break; //视场+ case "12": //转发 i_Action = (int)CCDCommand.CCD_TurnLong; break; //视场+ 停 case "13": i_Action = (int)CCDCommand.CCD_TurnLongStop; break; //焦距- case "14": //转发 i_Action = (int)CCDCommand.CCD_FocusShort; break; //焦距- 停 case "15": i_Action = (int)CCDCommand.CCD_FocusShortStop; break; //焦距+ case "16": //转发 i_Action = (int)CCDCommand.CCD_FocusLong; break; //焦距+ 停 case "17": i_Action = (int)CCDCommand.CCD_FocusLongStop; break; } if (Convert.ToInt32(str2[2]) >= 0 && Convert.ToInt32(str2[2]) < 10) { InterfaceControl.HDControl(tmpGuid, i_Action, tmpSpeed, 0, null); } else if (Convert.ToInt32(str2[2]) > 10) { VideoType = int.Parse(str2[1]); if (VideoType == 1) { InterfaceControl.CCDControl(tmpGuid, i_Action, tmpSpeed, 0, null); } else { InterfaceControl.IRControl(tmpGuid, i_Action, 0, 0, null); } } Control_Command.GetStateData(tmpGuid); break; //扇扫开 case "4": tmpGuid = new Guid(str2[1]); int i_HorizontalSt = Convert.ToInt32(str2[2]); int i_HorizontalEnd = Convert.ToInt32(str2[3]); int i_Hspeed = Convert.ToInt32(str2[4]); int i_VerticalSt = Convert.ToInt32(str2[5]); int i_VerticalEnd = Convert.ToInt32(str2[6]); int i_Vspeed = Convert.ToInt32(str2[7]); //0,1, 2 3 4 5 6 7 //4,设ID,水平起点、水平终点、水平速度、俯仰起点、俯仰终点、俯仰速度 InterfaceControl.SectorScanOpen(tmpGuid, i_HorizontalSt, i_HorizontalEnd, i_Hspeed, i_VerticalSt, i_VerticalEnd, i_Vspeed); break; //扇扫关 case "5": tmpGuid = new Guid(str2[1]); InterfaceControl.SectorScanOff(tmpGuid); break; //预置位调用 case "6": TurntablePresetData tmpPresetData = new TurntablePresetData(); tmpPresetData.VideoGuid = new Guid(str2[1]); tmpPresetData.PresetName = str2[2]; //0 1 2 //6,设ID,预置位1 InterfaceControl.SetPreset(tmpPresetData); break; //预置位轮巡开 case "7": break; //预置位轮巡关 case "8": break; } } else if (int.Parse(str2[0]) >= 9 && int.Parse(str2[0]) < 12) { switch (str2[0]) { //设备授时 case "9": message = "TimeSet/" + str2[1] + "\r\n"; break; //报警设置 case "10": message = "Alertor/" + str2[1] + "\r\n"; break; //叠加字符 case "11": message = "StringSet/" + str2[1] + "\r\n"; break; } b = Encoding.UTF8.GetBytes(message); if (!tcp1.Connected) { tcp1 = new TcpClient(); string BCServer_IP = ConfigurationManager.AppSettings["BCServer_IP"]; int BCServer_Port1 = int.Parse(ConfigurationManager.AppSettings["BCServer_Port"]); try { tcp1.Connect(BCServer_IP, BCServer_Port1); stream1 = tcp1.GetStream(); } catch (Exception ex) { Console.WriteLine("外部数据中心连接业务协同服务失败。错误信息:" + ex.ToString()); } } stream1.Write(b, 0, b.Length); } else if (int.Parse(str2[0]) >= 12) { switch (str2[0]) { //流媒体列表 case "12": List <CameraList> cameraList; CameraListRepository camera = new CameraListRepository(); cameraList = camera.GetList(); string str = JsonConvert.SerializeObject(cameraList); serverSocket1.Send(Encoding.UTF8.GetBytes(str)); break; } } } catch (Exception ex) { Console.WriteLine("外部数据中心发送数据失败。错误信息:" + ex.ToString()); } } }