|
JAVA代码
/**
* 事件搜索
* @param req
* @return
*/
public EventRecordSearchResp eventSearchApi(EventRecordSearchReq req) {
HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT();
struXMLInput.read();
struXMLInput.dwSize = struXMLInput.size();
String strURL = "POST /ISAPI/ContentMgmt/eventRecordSearch?format=json";
int iURLlen = strURL.length();
HCNetSDK.BYTE_ARRAY ptrUrl = new HCNetSDK.BYTE_ARRAY(iURLlen+1);
System.arraycopy(strURL.getBytes(), 0, ptrUrl.byValue, 0, strURL.length());
ptrUrl.write();
struXMLInput.lpRequestUrl = ptrUrl.getPointer();
struXMLInput.dwRequestUrlLen = iURLlen;
String strInbuffer = JSONUtil.toJsonStr(req);
int iInBufLen = strInbuffer.length();
if(iInBufLen==0)
{
struXMLInput.lpInBuffer=null;
struXMLInput.dwInBufferSize=0;
struXMLInput.write();
}
else
{
HCNetSDK.BYTE_ARRAY ptrInBuffer = new HCNetSDK.BYTE_ARRAY(iInBufLen+1);
ptrInBuffer.read();
ptrInBuffer.byValue = strInbuffer.getBytes();
ptrInBuffer.write();
struXMLInput.lpInBuffer = ptrInBuffer.getPointer();
struXMLInput.dwInBufferSize = iInBufLen;
struXMLInput.write();
}
HCNetSDK.BYTE_ARRAY ptrStatusByte = new HCNetSDK.BYTE_ARRAY(ISAPI_STATUS_LEN);
ptrStatusByte.read();
HCNetSDK.BYTE_ARRAY ptrOutByte = new HCNetSDK.BYTE_ARRAY(ISAPI_DATA_LEN);
ptrOutByte.read();
HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
struXMLOutput.read();
struXMLOutput.dwSize = struXMLOutput.size();
struXMLOutput.lpOutBuffer = ptrOutByte.getPointer();
struXMLOutput.dwOutBufferSize = ptrOutByte.size();
struXMLOutput.lpStatusBuffer = ptrStatusByte.getPointer();
struXMLOutput.dwStatusSize = ptrStatusByte.size();
struXMLOutput.write();
if(!hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput))
{
int iErr = hCNetSDK.NET_DVR_GetLastError();
log.error( "NET_DVR_STDXMLConfig失败,错误号:" + iErr);
return null;
}
else
{
struXMLOutput.read();
ptrOutByte.read();
ptrStatusByte.read();
// 输出结果
String strOutXML = new String(ptrOutByte.byValue).trim();
// 输出状态
String strStatus = new String(ptrStatusByte.byValue).trim();
return JSONUtil.toBean(strOutXML, EventRecordSearchResp.class);
}
}
c#代码
private void btnXML_Click(object sender, EventArgs e)
{
CHCNetSDK.NET_DVR_XML_CONFIG_INPUT pInputXml = new CHCNetSDK.NET_DVR_XML_CONFIG_INPUT();
Int32 nInSize = Marshal.SizeOf(pInputXml);
pInputXml.dwSize = (uint)nInSize;
string strRequestUrl = textBoxRequest.Text;
uint dwRequestUrlLen = (uint)strRequestUrl.Length;
pInputXml.lpRequestUrl = Marshal.StringToHGlobalAnsi(strRequestUrl);
pInputXml.dwRequestUrlLen = dwRequestUrlLen;
string strInputParam = textBoxInXML.Text;
pInputXml.lpInBuffer = Marshal.StringToHGlobalAnsi(strInputParam);
pInputXml.dwInBufferSize = (uint)strInputParam.Length;
CHCNetSDK.NET_DVR_XML_CONFIG_OUTPUT pOutputXml = new CHCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
pOutputXml.dwSize = (uint)Marshal.SizeOf(pInputXml);
pOutputXml.lpOutBuffer = Marshal.AllocHGlobal(3 * 1024 * 1024);
pOutputXml.dwOutBufferSize = 3 * 1024 * 1024;
pOutputXml.lpStatusBuffer = Marshal.AllocHGlobal(4096 * 4);
pOutputXml.dwStatusSize = 4096 * 4;
if (!CHCNetSDK.NET_DVR_STDXMLConfig(m_lUserID, ref pInputXml, ref pOutputXml))
{
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
strErr = "NET_DVR_STDXMLConfig failed, error code= " + iLastErr;
//XML透传失败,输出错误号 Failed to send XML data and output the error code
MessageBox.Show(strErr);
}
uint iXMSize = pOutputXml.dwReturnedXMLSize;
byte[] managedArray = new byte[iXMSize];
Marshal.Copy(pOutputXml.lpOutBuffer, managedArray, 0, (int)iXMSize);
textBoxOutXML.Text = Encoding.UTF8.GetString(managedArray);
textBoxStatus.Text = Marshal.PtrToStringAnsi(pOutputXml.lpStatusBuffer);
Marshal.FreeHGlobal(pInputXml.lpRequestUrl);
Marshal.FreeHGlobal(pOutputXml.lpOutBuffer);
Marshal.FreeHGlobal(pOutputXml.lpStatusBuffer);
}
这一段可以翻译易语言实现功能的有没有可以帮忙!
补充内容 (2024-8-20 11:55):
有能搞定的可以有偿+v可以详谈,目前我已经写了程序 反馈错误代码17,可提供我写的源码进行修改,页游官方DEMO可以参照 海康SDK NET_DVR_STDXMLConfig |
|