public int SendPtz(PtzOperationType operation, int param1, int param2, string code) { string strCameracode = code; if (string.IsNullOrEmpty(strCameracode)) { strCameracode = string.Empty; LogService.Info("Search request info:==>>CameraCode is null."); return(-1); } LogService.Info("Search request info:==>>CameraCode:" + strCameracode + ",PtzOperationType:" + operation.ToString() + ",Param1:" + param1.ToString() + ",Param2:" + param2.ToString()); var resultValue = OcxHelper.OCX.IVS_OCX_PtzControl(strCameracode, (int)operation, param1.ToString(), param2.ToString()); OcxResult result = XmlHelper.ProcessOcxResponseMsg(resultValue); var lockStatus = string.Empty; if (result.BodyXmlNode.SelectSingleNode("LockStatus") != null) { lockStatus = result.BodyXmlNode.SelectSingleNode("LockStatus").InnerText; } if (result.ResultCode != "0") { throw new Exception(result.ResultCode + "," + lockStatus); } LogService.Info("IVS_OCX_PtzControl response info:==>>" + resultValue); return(int.Parse(lockStatus.ToString())); }
private void AddPresetProcess() { try { if (string.IsNullOrEmpty(liveVideoPtzUserControls.PresetName.Text.ToString())) { return; } VideoEntity camera = liveVideoPtzUserControls.CameraList.SelectedItem as VideoEntity; string resultValue = OcxHelper.OCX.IVS_OCX_AddPTZPreset(camera.CameraCode, liveVideoPtzUserControls.PresetName.Text.ToString()); liveVideoPtzUserControls.eSDKCodeTextBlock.Text = @"int resultCode = OcxHelper.IVS_OCX_AddPTZPreset(camera.CameraCode, liveVideoPtzUserControls.PresetName.Text.ToString());"; OcxResult result = XmlHelper.ProcessOcxResponseMsg(resultValue); if (result.ResultCode != "0") { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource(result.ResultCode); } else { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource("AddPreset") + StringHelper.FindLanguageResource("Success"); } } catch (Exception ex) { LogService.Error(ex.ToString()); OcxHelper.MainWin.OperationInfo.Content = ex.ToString(); return; } }
static public OcxResult ProcessOcxResponseMsg(string responseMsg) { var ocxResult = new OcxResult() { ResultCode = "0" }; var doc = new XmlDocument(); try { doc.LoadXml(responseMsg); } catch (Exception) { ocxResult.ResultCode = "ServerResponseFailed"; } XmlNode content = doc.SelectSingleNode("Content"); if (content != null) { XmlNode resultCode = content.SelectSingleNode("ResultCode"); if (resultCode != null) { ocxResult.ResultCode = resultCode.InnerText; content.RemoveChild(resultCode); } else { //响应消息体不存在RESULT_CODE节点 ocxResult.ResultCode = "ServerResponseFailed"; } } else { //响应消息体不存在CV_CONTENT节点 ocxResult.ResultCode = "ServerResponseFailed"; } ocxResult.BodyXmlNode = content; return(ocxResult); }
public List <VideoEntity> LoadDeviceInfoByUser() { List <VideoEntity> deviceList = new List <VideoEntity>(); try { string resultXml = OcxHelper.OCX.IVS_OCX_GetDeviceList((uint)IVSDeviceType.DEVICE_TYPE_CAMERA, (uint)1, (uint)PageSize); OcxResult ocxResult = XmlHelper.ProcessOcxResponseMsg(resultXml); if (ocxResult.ResultCode != "0") { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource("GetCameraList") + StringHelper.FindLanguageResource(ocxResult.ResultCode); } else { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource("GetCameraList") + StringHelper.FindLanguageResource("Success"); XmlNode node = ocxResult.BodyXmlNode; XmlNodeList nodeList = node.SelectNodes("VideoInChanList/VideoInChanInfo"); foreach (XmlNode xmlNode in nodeList) { VideoEntity video = new VideoEntity(); video.CameraCode = xmlNode.SelectSingleNode("CameraCode").InnerXml.ToString(); video.AliasName = xmlNode.SelectSingleNode("CameraName").InnerXml.ToString(); string cameraType = xmlNode.SelectSingleNode("CameraType").InnerXml.ToString(); video.CameraType = cameraType.Equals("FIX") ? CameraType.FIX : cameraType.Equals("PTZ") ? CameraType.PTZ : cameraType.Equals("DOME") ? CameraType.DOME : cameraType.Equals("HALFDOME") ? CameraType.HALFDOME : cameraType.Equals("DOME") ? CameraType.DOME : CameraType.None; video.IsOnline = xmlNode.SelectSingleNode("IsOnline").InnerXml.Equals("ON") ? true : false; deviceList.Add(video); } } } catch (Exception ex) { LogService.Error(ex.ToString()); OcxHelper.MainWin.OperationInfo.Content = ex.ToString(); return(null); } return(deviceList); }
private void QueryPresetProcess() { try { VideoEntity camera = liveVideoPtzUserControls.CameraList.SelectedItem as VideoEntity; var resultValue = OcxHelper.OCX.IVS_OCX_GetPTZPresetList(camera.CameraCode); liveVideoPtzUserControls.eSDKCodeTextBlock.Text = @"int resultCode = OcxHelper.IVS_OCX_GetPTZPresetList(CameraCode);"; OcxResult result = XmlHelper.ProcessOcxResponseMsg(resultValue); if (result.ResultCode != "0") { throw new Exception(result.ResultCode); } var returnCameraCode = result.BodyXmlNode.SelectSingleNode("CameraCode").InnerText; List <PTZPresetEntity> preSetLocationEntityList = XmlHelper.DeserializeToList <PTZPresetEntity>(result.BodyXmlNode.SelectSingleNode("PresetPTZList")); foreach (PTZPresetEntity Preset in preSetLocationEntityList) { Preset.CameraCode = camera.CameraCode; } liveVideoPtzUserControls.PresetList.ItemsSource = preSetLocationEntityList; if (result.ResultCode != "0") { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource(result.ResultCode); } else { OcxHelper.MainWin.OperationInfo.Content = StringHelper.FindLanguageResource("QueryPreset") + StringHelper.FindLanguageResource("Success"); } } catch (Exception ex) { LogService.Error(ex.ToString()); OcxHelper.MainWin.OperationInfo.Content = ex.ToString(); return; } }