eLTE_RET XMLProcess::SetXmlStringEventNotifySDSStatus(const SdsMessageInfo* pInfo, CString& xmlStr) { /************************************************************************ --- XML 格式 --- <Content> <SdsMsgId>消息ID</SdsMsgId> <SdsRetCode>消息发送状态</SdsRetCode> </Content> ************************************************************************/ LOG_TRACE(); CXml xml; (void)xml.AddElem("Content"); (void)xml.AddChildElem("SdsMsgId"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strSubject.c_str()); (void)xml.AddElem("SdsRetCode"); (void)xml.SetElemValue(pInfo->strRetCode.c_str()); xml.OutOfElem(); IVS_UINT32 uiLen = 0; const char* pXmlStr = xml.GetXMLStream(uiLen); if (NULL == pXmlStr) { LOG_RUN_ERROR("pXmlStr is null."); return eLTE_ERR_FAILED; } xmlStr = eLTE_Tool::ANSIToUnicode(pXmlStr).c_str(); INFO_PARAM1(pXmlStr); return eLTE_ERR_SUCCESS; }
// 拼装客户端抓拍通用返回xml IVS_INT32 OCXCapturePictureXMLProcess::LocalCaptureBuildXMLGeneric(LONG iEventCode, ULONG iWndID, const IVS_CHAR* pFileName, CXml &xml) { // CHECK_POINTER(pFileName, IVS_OPERATE_MEMORY_ERROR); // 可以为空 IVS_DEBUG_TRACE(""); char buf[IVS_FILE_NAME_LEN + 1] = {0}; CHECK_SUCCESS(xml.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xml.AddElem("Content")); CHECK_SUCCESS(xml.AddChildElem("WndID")); xml.IntoElem(); (void)_itoa_s((int)iWndID, buf, 10);//lint !e713 CHECK_SUCCESS(xml.SetElemValue(buf)); CHECK_SUCCESS(xml.AddElem("EventID")); (void)_itoa_s(iEventCode, buf, 10); CHECK_SUCCESS(xml.SetElemValue(buf)); if (NULL != pFileName) { CHECK_SUCCESS(xml.AddElem("FileName")); CHECK_SUCCESS(xml.SetElemValue(pFileName)); } xml.OutOfElem(); return IVS_SUCCEED; }
//查询MU的资源预算是否达到上限及当前摄像机视频流是否被引用 IVS_INT32 CMediaXMLProcess::VideoNumAndResourceGetXML(const std::string& strCameraCode, CXml &xml) { IVS_DEBUG_TRACE(""); (void)xml.AddDeclaration("1.0", "UTF-8", ""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("CameraCode"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strCameraCode.c_str()); xml.OutOfElem(); return IVS_SUCCEED; }
eLTE_RET XMLProcess::SetXmlStringEventNotifyGisReport(const GisReportInfo* pInfo, CString& xmlStr) { /************************************************************************ --- XML 格式 --- <Content> <ResourceID>上报方</ResourceID> <Time>最后一次上报时间</Time> <Altitude>高度</Altitude> <Latitude>纬度</Latitude> <Longtitude>经度</Longtitude> <TriggerCode>周期上报(0),特定事件(1、紧急呼叫)</TriggerCode> <ReportStatus>GPS正常开启(0),GPS搜星失败(1)或其它异常(2)</ReportStatus> </Content> ************************************************************************/ LOG_TRACE(); if (NULL == pInfo) { LOG_RUN_ERROR("pInfo is null."); return eLTE_ERR_FAILED; } CXml xml; (void)xml.AddElem("Content"); (void)xml.AddChildElem("ResourceID"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strSender.c_str()); (void)xml.AddElem("Time"); (void)xml.SetElemValue(pInfo->strTime.c_str()); (void)xml.AddElem("Altitude"); (void)xml.SetElemValue(pInfo->strAltitude.c_str()); (void)xml.AddElem("Latitude"); (void)xml.SetElemValue(pInfo->strLatitude.c_str()); (void)xml.AddElem("Longtitude"); (void)xml.SetElemValue(pInfo->strLongtitude.c_str()); (void)xml.AddElem("TriggerCode"); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iTriggerCode).c_str()); (void)xml.AddElem("ReportStatus"); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iReportState).c_str()); xml.OutOfElem(); IVS_UINT32 uiLen = 0; const char* pXmlStr = xml.GetXMLStream(uiLen); if (NULL == pXmlStr) { LOG_RUN_ERROR("pXmlStr is null."); return eLTE_ERR_FAILED; } xmlStr = eLTE_Tool::ANSIToUnicode(pXmlStr).c_str(); INFO_PARAM1(pXmlStr); return eLTE_ERR_SUCCESS; }
// 通用请求XML增加QueryField字段 IVS_INT32 CXmlProcess::AddQueryFieldForUnifiedFormatQueryXML(const IVS_CHAR* pField,const IVS_CHAR* pValue, CXml& xmlReq) { CHECK_POINTER(pField, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pValue, IVS_OPERATE_MEMORY_ERROR); std::string sQueryType = "EXACT"; if (xmlReq.FindElemEx("Content/PageInfo/QueryCond/QueryField")) { xmlReq.OutOfElem(); (void)xmlReq.AddElem("QueryField"); (void)xmlReq.AddChildElem("Field"); (void)xmlReq.IntoElem(); (void)xmlReq.SetElemValue(pField); (void)xmlReq.AddElem("Value"); (void)xmlReq.SetElemValue(pValue); (void)xmlReq.AddElem("QueryType"); (void)xmlReq.SetElemValue(sQueryType.c_str()); xmlReq.OutOfElem(); } return IVS_SUCCEED; }
// 构建获取图形失败的XML IVS_INT32 COCXDrawXMLProcess::GetGraphicsGetErrXML(IVS_INT32 iResultCode, CXml& xmlGraphics) { char val[64] = {0}; IVS_DEBUG_TRACE("iResultCode: %d", iResultCode); CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); CHECK_SUCCESS(xmlGraphics.AddChildElem("ResultCode")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(iResultCode, val, xmlGraphics); xmlGraphics.OutOfElem(); return IVS_SUCCEED; }
// 构建选中图形消息XML IVS_INT32 COCXDrawXMLProcess::SelectGraphicGetXML(CString &xmlToCU, IVS_ULONG ulGraphicGroup) { IVS_DEBUG_TRACE("GraphicGroup: %lu", ulGraphicGroup); CXml xmlGraphics; char val[64] = {0}; unsigned int uiLen = 0; CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); CHECK_SUCCESS(xmlGraphics.AddChildElem("GraphicGroup")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(ulGraphicGroup, val, xmlGraphics); xmlGraphics.OutOfElem(); xmlToCU = xmlGraphics.GetXMLStream(uiLen); return IVS_SUCCEED; }
//通用的查询请求 IVS_INT32 CXmlProcess::GetCommConfigGetXML(const IVS_CHAR* pDomainCode,const IVS_CHAR* pDevCode, CXml& xml, enConfigType enType) { CHECK_POINTER(pDomainCode,IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(pDevCode,IVS_OPERATE_MEMORY_ERROR); (void)xml.AddDeclaration("1.0","UTF-8",""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("DomainCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(pDomainCode); if (SDKCAMERA == enType) { (void)xml.AddElem("CameraCode"); } else if (SDKDEVICE == enType) { (void)xml.AddElem("DevCode"); } else if (SDKALARMINCODE == enType) { (void)xml.AddElem("AlarmInCode"); } else if (SDKALARMOUTCODE == enType) { (void)xml.AddElem("AlarmOutCode"); } else if (SDKSERIAL == enType) { (void)xml.AddElem("SerialCode"); } else if (SDKVOICE == enType) { (void)xml.AddElem("VoiceCode"); } (void)xml.SetElemValue(pDevCode); xml.OutOfElem(); return IVS_SUCCEED; }
// 解析抓拍图片查询参数xml IVS_INT32 OCXCapturePictureXMLProcess::GetSnapshotListParseXml(CXml &xml, IVS_QUERY_SNAPSHOT_PARAM *pQueryParam, const IVS_CHAR* pCameraCode) { CHECK_POINTER(pQueryParam,IVS_PARA_INVALID); CHECK_POINTER(pCameraCode, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); const char* szElemValue = NULL; const char* pTemp = NULL; if (!xml.FindElemEx("Content")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Parse Result XML", "xml.FindElem(Content/PageInfo) is fail"); return IVS_XML_INVALID; } GET_ELEM_VALUE_CHAR("CameraCode",szElemValue, pCameraCode,IVS_DEV_CODE_LEN, xml); if (!xml.FindElemEx("Content/PageInfo")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Parse Result XML", "xml.FindElem(Content/PageInfo) is fail"); return IVS_XML_INVALID; } (void)xml.IntoElem(); GET_ELEM_VALUE_NUM_FOR_UINT("FromIndex", pTemp, pQueryParam->stIndexRange.uiFromIndex, xml); GET_ELEM_VALUE_NUM_FOR_UINT("ToIndex", pTemp, pQueryParam->stIndexRange.uiToIndex, xml); if (!xml.FindElemEx("Content/TimeInfo")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Parse Result XML", "xml.FindElem(Content/PageInfo) is fail"); return IVS_XML_INVALID; } (void)xml.IntoElem(); GET_ELEM_VALUE_CHAR("FromTime",szElemValue, pQueryParam->stTimeSpan.cStart, IVS_TIME_LEN, xml); GET_ELEM_VALUE_CHAR("ToTime",szElemValue, pQueryParam->stTimeSpan.cEnd, IVS_TIME_LEN, xml); xml.OutOfElem(); GET_ELEM_VALUE_NUM_FOR_UINT("SnapType", pTemp, pQueryParam->uiSnapType, xml); // plint !e return IVS_SUCCEED; }
//请求录像加密的工作密钥或者异或因子xml IVS_INT32 CMediaXMLProcess::ApplyStreamencryPwdGetXML(const std::string& strCameraCode,const std::string& strDomainCode, const std::string& strDestModule,int& iStreamType,const std::string& strSessionID,const std::string& strSecurityTransID, CXml &xml) { IVS_DEBUG_TRACE(""); (void)xml.AddDeclaration("1.0", "UTF-8", ""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("CameraCode"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strCameraCode.c_str()); (void)xml.AddElem("DomainCode"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strDomainCode.c_str()); (void)xml.AddElem("DestModule"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strDestModule.c_str()); if(!strSessionID.empty()) { (void)xml.AddElem("SessionID"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strSessionID.c_str()); } (void)xml.AddElem("StreamID"); (void)(xml.IntoElem()); (void)xml.SetElemValue(CToolsHelp::Int2Str(iStreamType).c_str()); (void)xml.AddElem("ExchangeTransNo"); (void)(xml.IntoElem()); (void)xml.SetElemValue(strSecurityTransID.c_str()); xml.OutOfElem(); return IVS_SUCCEED; }
// 构建获取图形的XML IVS_INT32 COCXDrawXMLProcess::GetGraphicsGetXML(const IA_GRAPHICS *pGraphicsArr, IVS_INT32 iResultCode, ULONG ulNum, CXml& xmlGraphics, const SIZE &szGraphic) { CHECK_POINTER(pGraphicsArr, IVS_FAIL); IVS_DEBUG_TRACE("iResultCode: %d, ulNum:%d, GraphicWidth: %d, GraphicHeight: %d", iResultCode, ulNum, szGraphic.cx, szGraphic.cy); char val[64] = {0}; CHECK_SUCCESS(xmlGraphics.AddDeclaration("1.0","UTF-8","")); CHECK_SUCCESS(xmlGraphics.AddElem("Content")); CHECK_SUCCESS(xmlGraphics.AddChildElem("ResultCode")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(iResultCode, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Graphics")); CHECK_SUCCESS(xmlGraphics.AddChildElem("GraphicNum")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(ulNum, val, xmlGraphics); if (0 == ulNum) { xmlGraphics.OutOfElem(); xmlGraphics.OutOfElem(); return IVS_SUCCEED; } CHECK_SUCCESS(xmlGraphics.AddElem("GraphicList")); for (ULONG i = 0; i < ulNum; i++) { if (i == 0) { CHECK_SUCCESS(xmlGraphics.AddChildElem("GraphicInfo")); CHECK_SUCCESS(xmlGraphics.IntoElem()); } else { CHECK_SUCCESS(xmlGraphics.AddElem("GraphicInfo")); } CHECK_SUCCESS(xmlGraphics.AddChildElem("GraphicType")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(pGraphicsArr[i].ulGraphicType, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("GraphicGroup")); SET_ELEMENT_LONG(pGraphicsArr[i].ulGraphicGroup, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("GraphicGroupName")); SET_ELEMENT_STRING(pGraphicsArr[i].GraphicGroupName, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("GraphicBackgroundColor")); CHECK_SUCCESS(xmlGraphics.AddChildElem("Opacity")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(pGraphicsArr[i].BgColor.Alpha, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Red")); SET_ELEMENT_LONG(pGraphicsArr[i].BgColor.Red, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Green")); SET_ELEMENT_LONG(pGraphicsArr[i].BgColor.Green, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Blue")); SET_ELEMENT_LONG(pGraphicsArr[i].BgColor.Blue, val, xmlGraphics); xmlGraphics.OutOfElem(); CHECK_SUCCESS(xmlGraphics.AddElem("GraphicLineColor")); CHECK_SUCCESS(xmlGraphics.AddChildElem("Opacity")); CHECK_SUCCESS(xmlGraphics.IntoElem()); SET_ELEMENT_LONG(pGraphicsArr[i].LineColor.Alpha, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Red")); SET_ELEMENT_LONG(pGraphicsArr[i].LineColor.Red, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Green")); SET_ELEMENT_LONG(pGraphicsArr[i].LineColor.Green, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Blue")); SET_ELEMENT_LONG(pGraphicsArr[i].LineColor.Blue, val, xmlGraphics); xmlGraphics.OutOfElem(); CHECK_SUCCESS(xmlGraphics.AddElem("GraphicLineWidth")); SET_ELEMENT_LONG(pGraphicsArr[i].ulLineWidth, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("PointNum")); SET_ELEMENT_LONG(pGraphicsArr[i].ulPointsNum, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("PointList")); for (ULONG j = 0; j < pGraphicsArr[i].ulPointsNum; j++) { if (0 == j) { CHECK_SUCCESS(xmlGraphics.AddChildElem("Point")); CHECK_SUCCESS(xmlGraphics.IntoElem()); } else { CHECK_SUCCESS(xmlGraphics.AddElem("Point")); } CHECK_SUCCESS(xmlGraphics.AddChildElem("X")); CHECK_SUCCESS(xmlGraphics.IntoElem()); if ((0 == szGraphic.cx) || (0 == szGraphic.cy)) { SET_ELEMENT_LONG(pGraphicsArr[i].IAPoints[j].x, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("Y")); SET_ELEMENT_LONG(pGraphicsArr[i].IAPoints[j].y, val, xmlGraphics); } else { char cPointValue[10]; memset(cPointValue, 0, sizeof(cPointValue)); double dPointValue = (double)pGraphicsArr[i].IAPoints[j].x / szGraphic.cx; (void)_snprintf_s(cPointValue, sizeof(cPointValue) - 1, "%f", dPointValue); cPointValue[8] = '\0'; CHECK_SUCCESS(xmlGraphics.SetElemValue(cPointValue)); CHECK_SUCCESS(xmlGraphics.AddElem("Y")); memset(cPointValue, 0, sizeof(cPointValue)); dPointValue = (double)pGraphicsArr[i].IAPoints[j].y / szGraphic.cy; (void)_snprintf_s(cPointValue, sizeof(cPointValue) - 1, "%f", dPointValue); cPointValue[8] = '\0'; CHECK_SUCCESS(xmlGraphics.SetElemValue(cPointValue)); } xmlGraphics.OutOfElem(); } xmlGraphics.OutOfElem(); CHECK_SUCCESS(xmlGraphics.AddElem("NamePosition")); SET_ELEMENT_LONG(pGraphicsArr[i].NamePosition, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("DeleteByMouse")); SET_ELEMENT_LONG(pGraphicsArr[i].bAllowDelete, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("AddNewPoint")); SET_ELEMENT_LONG(pGraphicsArr[i].bAllowAddNewPoint, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("AllowModifySize")); SET_ELEMENT_LONG(pGraphicsArr[i].bAllowModifySize, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("ArrowType")); SET_ELEMENT_LONG(pGraphicsArr[i].ulArrowType, val, xmlGraphics); CHECK_SUCCESS(xmlGraphics.AddElem("KeepHorizon")); SET_ELEMENT_LONG(pGraphicsArr[i].bKeepHorizon, val, xmlGraphics); xmlGraphics.OutOfElem(); } xmlGraphics.OutOfElem(); xmlGraphics.OutOfElem(); return IVS_SUCCEED; }
eLTE_RET XMLProcess::SetXmlStringPlayerEvent(int iEventId, const PlayerEventParamInfo* pInfo, CString& xmlStr) { LOG_TRACE(); if (NULL == pInfo) { LOG_RUN_ERROR("pInfo is null."); return eLTE_ERR_FAILED; } CXml xml; switch (iEventId) { case eLTE_PLAYER_REVERSE: // OCX 播放器切换镜头 { /************************************************************************ --- XML 格式 --- <Content> <VideoFormat></VideoFormat> <CameraType></CameraType> <UserConfirmType></UserConfirmType> <MuteType></MuteType> </Content> ************************************************************************/ (void)xml.AddElem("Content"); (void)xml.AddChildElem("VideoFormat"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strFmtValue.c_str()); (void)xml.AddElem("CameraType"); (void)xml.SetElemValue(pInfo->strCameraType.c_str()); (void)xml.AddElem("UserConfirmType"); (void)xml.SetElemValue(pInfo->strUserCfmType.c_str()); (void)xml.AddElem("MuteType"); (void)xml.SetElemValue(pInfo->strMuteType.c_str()); xml.OutOfElem(); } break; case eLTE_PLAYER_SNAPSHOT: // OCX 播放器抓图 { /************************************************************************ --- XML 格式 --- <Content> <SnapshotPath></SnapshotPath> </Content> ************************************************************************/ (void)xml.AddElem("Content"); (void)xml.AddChildElem("SnapshotPath"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strSnapshotPath.c_str()); xml.OutOfElem(); } break; case eLTE_PLAYER_POSITION: // OCX 播放器坐标变动 { /************************************************************************ --- XML 格式 --- <Content> <Left></Left> <Top></Top> <Width></Width> <Height></Height> </Content> ************************************************************************/ (void)xml.AddElem("Content"); (void)xml.AddChildElem("Left"); (void)xml.IntoElem(); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iLeft).c_str()); (void)xml.AddElem("Top"); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iTop).c_str()); (void)xml.AddElem("Width"); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iWidth).c_str()); (void)xml.AddElem("Height"); (void)xml.SetElemValue(eLTE_Tool::Int2String(pInfo->iHeight).c_str()); xml.OutOfElem(); } break; case eLTE_PLAYER_TITLE: // OCX 播放器窗口标题 { /************************************************************************ --- XML 格式 --- <Content> <TitleText></TitleText> </Content> ************************************************************************/ (void)xml.AddElem("Content"); (void)xml.AddChildElem("TitleText"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strTitle.c_str()); xml.OutOfElem(); } break; default: { LOG_RUN_ERROR("Invalid eventId."); return eLTE_ERR_FAILED; } } IVS_UINT32 uiLen = 0; const char* pXmlStr = xml.GetXMLStream(uiLen); if (NULL == pXmlStr) { LOG_RUN_ERROR("pXmlStr is null."); return eLTE_ERR_FAILED; } xmlStr = eLTE_Tool::ANSIToUnicode(pXmlStr).c_str(); //INFO_PARAM1(xmlStr); return eLTE_ERR_SUCCESS; }
// 通用查询转换成XML IVS_INT32 CXmlProcess::GetUnifiedFormatQueryXML(const IVS_QUERY_UNIFIED_FORMAT* pUnifiedQuery, CXml &xml, const IVS_CHAR* pDomainCode/* = NULL*/,const IVS_CHAR* pCamerCode) { // pDomainCode不要事先判空,作为默认参数 CHECK_POINTER(pUnifiedQuery, IVS_OPERATE_MEMORY_ERROR); (void)xml.AddDeclaration("1.0","UTF-8",""); (void)xml.AddElem("Content"); if (NULL != pDomainCode) { (void)xml.AddChildElem("DomainCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(pDomainCode); (void)xml.AddElem("PageInfo"); } else { (void)xml.AddChildElem("PageInfo"); } (void)xml.IntoElem(); (void)xml.AddChildElem("FromIndex"); (void)xml.IntoElem(); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>((pUnifiedQuery->stIndex).uiFromIndex)).c_str()); (void)xml.AddElem("ToIndex"); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>((pUnifiedQuery->stIndex).uiToIndex)).c_str()); IVS_UINT32 iFieldNum = static_cast<IVS_UINT32>(pUnifiedQuery->iFieldNum); if (iFieldNum > 0) //如果是0的话,这个QueryCond节点都不要了 { IVS_CHAR szValue[IVS_QUERY_VALUE_LEN+1]={0}; (void)xml.AddElem("QueryCond"); for (unsigned int i=0;i < iFieldNum;i++) { if (0 == i) { (void)xml.AddChildElem("QueryField"); } else { (void)xml.AddElem("QueryField"); } (void)xml.IntoElem(); (void)xml.AddChildElem("Field"); (void)xml.IntoElem(); std::string iField = QUERYFILED.GetValue(pUnifiedQuery->stQueryField[i].eFieID); (void)xml.SetElemValue(iField.c_str()); (void)xml.AddElem("Value"); if (QUERY_CAMERA_CODE == pUnifiedQuery->stQueryField[i].eFieID || QUERY_OPERATION_OBJECT_CODE == pUnifiedQuery->stQueryField[i].eFieID) { if (NULL != pCamerCode) { (void)xml.SetElemValue(pCamerCode); } else { IVS_CHAR chDevCode[IVS_DEV_CODE_LEN+1]; IVS_CHAR chDomaCode[IVS_DOMAIN_CODE_LEN+1]; (IVS_VOID)CXmlProcess::ParseDevCode(pUnifiedQuery->stQueryField[i].cValue, chDevCode, chDomaCode); (void)xml.SetElemValue(chDevCode); } } else { if (!CToolsHelp::Memcpy(szValue, IVS_QUERY_VALUE_LEN, pUnifiedQuery->stQueryField[i].cValue, IVS_QUERY_VALUE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Unified Format Query XML", "Memcpy szValue failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(szValue); } //注意如果这里的值不是0/1,直接返回参数错误的错误码 CHECK_IVSBOOL(pUnifiedQuery->stQueryField[i].bExactQuery); (void)xml.AddElem("QueryType"); if (MATCHED_SUCCEED == pUnifiedQuery->stQueryField[i].bExactQuery) { (void)xml.SetElemValue("EXACT"); } else { (void)xml.SetElemValue("INEXACT"); } xml.OutOfElem(); } xml.OutOfElem(); //注意如果这里的值不是0/1,直接返回参数错误的错误码 CHECK_IVSBOOL(pUnifiedQuery->stOrderCond.bEnableOrder); if (pUnifiedQuery->stOrderCond.bEnableOrder) { (void)xml.AddElem("OrderCond"); (void)xml.AddChildElem("OrderField"); (void)xml.IntoElem(); std::string iOrderField = QUERYFILED.GetValue(pUnifiedQuery->stOrderCond.eFieID); (void)xml.SetElemValue(iOrderField.c_str()); //注意如果这里的值不是0/1,直接返回参数错误的错误码 CHECK_IVSBOOL(pUnifiedQuery->stOrderCond.bUp); (void)xml.AddElem("Order"); if (MATCHED_SUCCEED==pUnifiedQuery->stOrderCond.bUp) { (void)xml.SetElemValue("UP"); } else { (void)xml.SetElemValue("DOWN"); } xml.OutOfElem(); } } xml.OutOfElem(); return IVS_SUCCEED; }
IVS_INT32 CMediaXMLProcess::GetURLResponseData(CXml &xmlRsp, ST_MEDIA_RSP& stMediaRsp, bool& bAssociatedAudio) { IVS_DEBUG_TRACE(""); memset(&stMediaRsp, 0, sizeof(ST_MEDIA_RSP)); const char*AttriValue = NULL; //临时存储单个节点值 bool bRet = false; CHECK_SUCCESS(xmlRsp.FindElem("Content")); CHECK_SUCCESS(xmlRsp.IntoElem()); CHECK_SUCCESS(xmlRsp.FindElem("URL")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szURL, URL_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } if (xmlRsp.FindElem("AssociatedAudio")) { CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bAssociatedAudio = (bool)atoi(AttriValue); } CHECK_SUCCESS(xmlRsp.FindElem("RtspIP")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP, IVS_IP_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } CHECK_SUCCESS(xmlRsp.FindElem("RtspPort")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT, PORT_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } //add by zwx211831, Date:20140625, 在URL中添加UserID和DomainID,以实现查询点播业务。 //如果是旧的版本,则不变。 if (xmlRsp.FindElem("UserId") && xmlRsp.FindElem("DomainId")) { (void)xmlRsp.FindElem("DomainId"); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); std::string strDomainCode("DomainCode="); strDomainCode += AttriValue; strDomainCode += "&"; if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strDomainCode.c_str())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.FindElem("UserId"); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); IVS_UINT32 uiUserID = 0; std::string strUserID("UserId="); GET_ELEM_VALUE_NUM_FOR_UINT("UserId", AttriValue, uiUserID, xmlRsp); strUserID += CToolsHelp::Int2Str(uiUserID); strUserID += "&"; if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strUserID.c_str())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error."); return IVS_ALLOC_MEMORY_ERROR; } } xmlRsp.OutOfElem(); return IVS_SUCCEED; #if 0 //XML增加AssociatedAudio字段 (void)xmlRsp.GetElem(); // Content (void)xmlRsp.IntoElem(); (void)xmlRsp.GetElem(); // URL AttriValue=xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "URL is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bool bRet = CToolsHelp::Memcpy(stMediaRsp.szURL,URL_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.NextElem(); // RtspIP (void)xmlRsp.GetElem(); AttriValue = xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "RtspIP is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP,IVS_IP_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.NextElem(); // RtspPort (void)xmlRsp.GetElem(); AttriValue = xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "RtspPort is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT,PORT_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } return IVS_SUCCEED; #endif }
// 拼装查询操作日志响应的xml IVS_INT32 COCXLogMgrXMLProcess::GetResOperationLogXML(IVS_OPERATION_LOG_LIST* pOperationLogList, CXml& xmlRes) { CHECK_POINTER(pOperationLogList, IVS_XML_INVALID); IVS_DEBUG_TRACE(""); (void)xmlRes.AddDeclaration("1.0","UTF-8",""); (void)xmlRes.AddElem("Content"); (void)xmlRes.AddChildElem("ResultCode"); (void)xmlRes.IntoElem(); (void)xmlRes.SetElemValue("0"); (void)xmlRes.AddElem("PageInfo"); (void)xmlRes.IntoElem(); (void)xmlRes.AddChildElem("RealNum"); (void)xmlRes.IntoElem(); (void)xmlRes.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pOperationLogList->uiTotal)).c_str()); (void)xmlRes.AddElem("FromIndex"); (void)xmlRes.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>((pOperationLogList->stIndexRange).uiFromIndex)).c_str()); (void)xmlRes.AddElem("ToIndex"); (void)xmlRes.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>((pOperationLogList->stIndexRange).uiToIndex)).c_str()); xmlRes.OutOfElem(); (void)xmlRes.AddElem("OperationLogList"); IVS_UINT32 uiFromIndex = pOperationLogList->stIndexRange.uiFromIndex; IVS_UINT32 uiToIndex = pOperationLogList->stIndexRange.uiToIndex; IVS_UINT32 uiTotal = pOperationLogList->uiTotal; IVS_UINT32 uiRestltNum = 0; // 判断实际返回来的数据有多少条 if (uiTotal <= uiToIndex ) { uiRestltNum = (uiTotal - uiFromIndex) + 1; } else { uiRestltNum = (uiToIndex - uiFromIndex) + 1; } IVS_UINT32 i = 0; while(i < uiRestltNum) { IVS_OPERATION_LOG_INFO &pOperationLogInfo = pOperationLogList->stOperationInfo[i]; i == 0?(void)xmlRes.AddChildElem("OperationLogInfo"):(void)xmlRes.AddElem("OperationLogInfo"); (void)xmlRes.IntoElem(); (void)xmlRes.AddChildElem("Account"); (void)xmlRes.IntoElem(); IVS_CHAR szAccount[IVS_NAME_LEN + 1]; memset(szAccount, 0x0, IVS_NAME_LEN + 1); if (!CToolsHelp::Memcpy(szAccount, IVS_NAME_LEN, pOperationLogInfo.cAccount, IVS_NAME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cAccount failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.SetElemValue(szAccount); IVS_CHAR szClientIP[IVS_IP_LEN + 1]; memset(szClientIP, 0x0, IVS_IP_LEN + 1); if (!CToolsHelp::Memcpy(szClientIP, IVS_IP_LEN, pOperationLogInfo.cClientIp, IVS_IP_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cClientIp failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("ClientIP"); (void)xmlRes.SetElemValue(szClientIP); (void)xmlRes.AddElem("Grade"); (void)xmlRes.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pOperationLogInfo.iGrade)).c_str()); IVS_CHAR szServiceCode[IVS_DESCRIBE_LEN + 1]; memset(szServiceCode, 0x0, IVS_DESCRIBE_LEN + 1); if (!CToolsHelp::Memcpy(szServiceCode, IVS_DESCRIBE_LEN, pOperationLogInfo.cServiceCode, IVS_DESCRIBE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cServiceCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("ServiceCode"); (void)xmlRes.SetElemValue(szServiceCode); IVS_CHAR szModuleType[IVS_DESCRIBE_LEN + 1]; memset(szModuleType, 0x0, IVS_DESCRIBE_LEN + 1); if (!CToolsHelp::Memcpy(szModuleType, IVS_DESCRIBE_LEN, pOperationLogInfo.cModuleType, IVS_DESCRIBE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cModuleType failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("ModuleType"); (void)xmlRes.SetElemValue(szModuleType); IVS_CHAR szModuleCode[IVS_DEV_CODE_LEN + 1]; memset(szModuleCode, 0x0, IVS_DEV_CODE_LEN + 1); if (!CToolsHelp::Memcpy(szModuleCode, IVS_DEV_CODE_LEN, pOperationLogInfo.cModuleCode, IVS_DEV_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cModuleCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("ModuleCode"); (void)xmlRes.SetElemValue(szModuleCode); IVS_CHAR szOperationCode[IVS_DEV_CODE_LEN + 1]; memset(szOperationCode, 0x0, IVS_DEV_CODE_LEN + 1); if (!CToolsHelp::Memcpy(szOperationCode, IVS_DEV_CODE_LEN, pOperationLogInfo.cOperationCode, IVS_DEV_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cOperationCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("OperationCode"); (void)xmlRes.SetElemValue(szOperationCode); IVS_CHAR szOperationObjectCode[IVS_DESCRIBE_LEN + 1]; memset(szOperationObjectCode, 0x0, IVS_DESCRIBE_LEN + 1); if (!CToolsHelp::Memcpy(szOperationObjectCode, IVS_DESCRIBE_LEN, pOperationLogInfo.cOperationObjectCode, IVS_DESCRIBE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cOperationCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("OperationObjectCode"); (void)xmlRes.SetElemValue(szOperationObjectCode); IVS_CHAR szOccurTime[IVS_TIME_LEN + 1]; memset(szOccurTime, 0x0, IVS_TIME_LEN + 1); if (!CToolsHelp::Memcpy(szOccurTime, IVS_TIME_LEN, pOperationLogInfo.cOccurTime, IVS_TIME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy szOccurTime failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("OccurTime"); (void)xmlRes.SetElemValue(szOccurTime); IVS_CHAR szErrorCode[IVS_DESCRIBE_LEN + 1]; memset(szErrorCode, 0x0, IVS_DESCRIBE_LEN + 1); if (!CToolsHelp::Memcpy(szErrorCode, IVS_DESCRIBE_LEN, pOperationLogInfo.cErrorCode, IVS_DESCRIBE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cErrorCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("ErrorCode"); (void)xmlRes.SetElemValue(szErrorCode); (void)xmlRes.AddElem("Result"); (void)xmlRes.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pOperationLogInfo.iResult)).c_str()); IVS_CHAR szAdditionalInfo[IVS_DESCRIBE_LEN + 1]; memset(szAdditionalInfo, 0x0, IVS_DESCRIBE_LEN + 1); if (!CToolsHelp::Memcpy(szAdditionalInfo, IVS_DESCRIBE_LEN, pOperationLogInfo.cAdditionalInfo, IVS_DESCRIBE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Response Operation Log XML", "Memcpy cAdditionalInfo failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRes.AddElem("AdditionalInfo"); (void)xmlRes.SetElemValue(szAdditionalInfo); xmlRes.OutOfElem(); i++; } xmlRes.OutOfElem(); xmlRes.OutOfElem(); return IVS_SUCCEED; }
// 解析设置图形的XML IVS_INT32 COCXDrawXMLProcess::SetGraphicsPraseXML(IA_GRAPHICS *pGraphicsArr, ULONG &ulNum, LPCTSTR pGraphicsXml, const SIZE &szGraphic, BOOL bPersent) { CHECK_POINTER(pGraphicsArr, IVS_FAIL); CHECK_POINTER(pGraphicsXml, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE("GraphicsXml: %s, GraphicWidth: %d, GraphicHeight: %d",pGraphicsXml, szGraphic.cx, szGraphic.cy); CXml xml; if (!xml.Parse(pGraphicsXml)) { return IVS_FAIL; } CHECK_SUCCESS(xml.FindElem("Content")); CHECK_SUCCESS(xml.IntoElem()); CHECK_SUCCESS(xml.FindElem("Graphics")); CHECK_SUCCESS(xml.IntoElem()); const char *value = NULL; CHECK_SUCCESS(xml.FindElem("GraphicNum") && (NULL != (value = xml.GetElemValue()))); ulNum = (ULONG)atoi(value); // 若设置的图形数大于图形数组长度,截断到最大画图个数 if (ulNum > GRAPHICS_NUM_MAX) { BP_RUN_LOG_INF("COCXDrawXMLProcess::SetGraphicsPraseXML", "GraphicNum Truncated to GRAPHICS_NUM_MAX"); ulNum = GRAPHICS_NUM_MAX; } CHECK_SUCCESS(xml.FindElem("GraphicList")); CHECK_SUCCESS(xml.IntoElem()); for (ULONG i = 0; i < ulNum; i++) { // 给图形可选字段赋默认值 memset(&pGraphicsArr[i], 0, sizeof(IA_GRAPHICS)); pGraphicsArr[i].ulLineWidth = 3; // 默认基本线宽为3 pGraphicsArr[i].bAllowDelete = TRUE; // 允许删除 pGraphicsArr[i].bAllowModifySize = TRUE; // 允许修改矩形大小 if (0 == i) { CHECK_SUCCESS(xml.FindElem("GraphicInfo")); } else { CHECK_SUCCESS(xml.NextElem()); } CHECK_SUCCESS(xml.IntoElem()); CHECK_SUCCESS(xml.FindElem("GraphicType") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].ulGraphicType = (ULONG)atoi(value); GET_ELEMENT_ULONG(pGraphicsArr[i].ulGraphicGroup, GraphicGroup, xml); GET_ELEMENT_STRING(pGraphicsArr[i].GraphicGroupName, CHARACTER_NUM_MAX, GraphicGroupName, xml); if (xml.FindElem("GraphicBackgroundColor")) { CHECK_SUCCESS(xml.IntoElem()); GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Alpha, Opacity, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Red, Red, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Green, Green, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Blue, Blue, xml); xml.OutOfElem(); } if (xml.FindElem("GraphicLineColor")) { CHECK_SUCCESS(xml.IntoElem()); GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Alpha, Opacity, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Red, Red, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Green, Green, xml); GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Blue, Blue, xml); xml.OutOfElem(); } GET_ELEMENT_ULONG(pGraphicsArr[i].ulLineWidth, GraphicLineWidth, xml); CHECK_SUCCESS(xml.FindElem("PointNum") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].ulPointsNum = (ULONG)atoi(value); CHECK_SUCCESS(xml.FindElem("PointList")); CHECK_SUCCESS(xml.IntoElem()); for (ULONG j = 0; j < pGraphicsArr[i].ulPointsNum; j++) { if (0 == j) { CHECK_SUCCESS(xml.FindElem("Point")); } else { CHECK_SUCCESS(xml.NextElem()); } CHECK_SUCCESS(xml.IntoElem()); if ((0 == szGraphic.cx) || (0 == szGraphic.cy)) { if (bPersent) { CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF); CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF); } else { CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].x = (LONG)atoi(value); CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].y = (LONG)atoi(value); } } else { CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * szGraphic.cx + 0.5); CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue()))); pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * szGraphic.cy + 0.5); } xml.OutOfElem(); } xml.OutOfElem(); GET_ELEMENT_ULONG(pGraphicsArr[i].NamePosition, NamePosition, xml); GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowDelete, DeleteByMouse, xml); GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowAddNewPoint, AddNewPoint, xml); GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowModifySize, AllowModifySize, xml); GET_ELEMENT_ULONG(pGraphicsArr[i].ulArrowType, ArrowType, xml); GET_ELEMENT_BOOL(pGraphicsArr[i].bKeepHorizon, KeepHorizon, xml); xml.OutOfElem(); } xml.OutOfElem(); xml.OutOfElem(); return IVS_SUCCEED; }
eLTE_RET XMLProcess::SetXmlStringEventNotifyGisStatus(const GisReportInfo* pInfo, CString& xmlStr) { /************************************************************************ --- XML 格式 --- <Content> <ResourceID>上报方</ResourceID> <AckStatusList> <AckStatus>终端号:订阅状态,举例如下: 1001:0。</AckStatus> </AckStatusList> </Content> ************************************************************************/ LOG_TRACE(); if (NULL == pInfo) { LOG_RUN_ERROR("pInfo is null."); return eLTE_ERR_FAILED; } CXml xml; (void)xml.AddElem("Content"); (void)xml.AddChildElem("ResourceID"); (void)xml.IntoElem(); (void)xml.SetElemValue(pInfo->strSender.c_str()); (void)xml.AddElem("AckStatusList"); AckStateMap::iterator itor_b = (const_cast<GisReportInfo*>(pInfo))->ackStateMap.begin(); AckStateMap::iterator itor_e = (const_cast<GisReportInfo*>(pInfo))->ackStateMap.end(); std::string strAckStatus; for(; itor_b != itor_e; ++itor_b) { if(itor_b == pInfo->ackStateMap.begin()) { (void)xml.AddChildElem("AckStatus"); (void)xml.IntoElem(); } else { (void)xml.AddElem("AckStatus"); } strAckStatus.clear(); strAckStatus = ""; strAckStatus.append(eLTE_Tool::Int2String(itor_b->first).c_str()); strAckStatus.append(":"); strAckStatus.append(eLTE_Tool::Int2String(itor_b->second).c_str()); (void)xml.SetElemValue(strAckStatus.c_str()); } xml.OutOfElem(); xml.OutOfElem(); IVS_UINT32 uiLen = 0; const char* pXmlStr = xml.GetXMLStream(uiLen); if (NULL == pXmlStr) { LOG_RUN_ERROR("pXmlStr is null."); return eLTE_ERR_FAILED; } xmlStr = eLTE_Tool::ANSIToUnicode(pXmlStr).c_str(); INFO_PARAM1(pXmlStr); return eLTE_ERR_SUCCESS; }
// 解析域路由到List IVS_INT32 CDomainRouteMgr::GetDomainRouteToListParseXML(DOMAIN_CODE_LIST& stCodeInfoList, CXml &xmlRsp) { BP_RUN_LOG_INF("Parse XML to List", "Enter"); if (!xmlRsp.FindElemEx("Content/DomainRoutes")) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Parse XML to List", "no 'Content/DomainRoutes' elemenet"); return IVS_XML_INVALID; } if (!xmlRsp.FindElem("DomainRoute")) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Parse XML to List", "no 'DevInfo' elemenet"); return IVS_XML_INVALID; } const IVS_CHAR *pSzElement = NULL; IVS_UINT32 uiSTLen = sizeof(IVS_DOMAIN_ROUTE); const int tempLength = 10; IVS_CHAR tempChar[tempLength]={0}; do { if (!xmlRsp.FindElemValue("DomainRoute")) { break; } xmlRsp.IntoElem(); IVS_DOMAIN_ROUTE *pDomain_route = IVS_NEW(pDomain_route); if (NULL == pDomain_route) { return IVS_FAIL; } memset(pDomain_route, 0, uiSTLen); //域编码 GET_ELEM_VALUE_CHAR("DomainCode", pSzElement, pDomain_route->cDomainCode, IVS_DOMAIN_CODE_LEN, xmlRsp); //域名称 GET_ELEM_VALUE_CHAR("DomainName", pSzElement, pDomain_route->cDomainName, IVS_NAME_LEN, xmlRsp); //域IP GET_ELEM_VALUE_CHAR("DomainIP", pSzElement, pDomain_route->stIP.cIP, IVS_IP_LEN, xmlRsp); //域端口 //GET_ELEM_VALUE_NUM_FOR_UINT("DomainPort", pSzElement, pDomain_route->uiPort, xmlRsp); //域模式 GET_ELEM_VALUE_NUM_FOR_UINT("DomainType", pSzElement, pDomain_route->uiDomainType, xmlRsp); //是否代理 GET_ELEM_VALUE_NUM("IsProxy", pSzElement, pDomain_route->bIsAgent, xmlRsp); //代理网段 //GET_ELEM_VALUE_NUM("ProxySegment", pSzElement, stDomainRoute.bIsAgent, xmlRsp); //上级域编码 GET_ELEM_VALUE_CHAR("SuperDomain", pSzElement, pDomain_route->cSuperDomain, IVS_DOMAIN_CODE_LEN, xmlRsp); GET_ELEM_VALUE_CHAR("IsOnline", pSzElement, tempChar, sizeof(tempChar) - 1, xmlRsp); pDomain_route->uiStatus = CDevEnum::GetDevStatusEnum(tempChar); //是否本域 GET_ELEM_VALUE_NUM("IsLocalDomain", pSzElement, pDomain_route->bIsLocalDomain, xmlRsp); pDomain_route->uiPort = DEFAULT_SMU_PORT; stCodeInfoList.push_back(pDomain_route); xmlRsp.OutOfElem(); } while (xmlRsp.NextElem()); BP_RUN_LOG_INF("Parse XML to List", "Leave"); return IVS_SUCCEED; } //lint !e1762
//查询平台抓拍计划:将响应结构体转换为结果XML IVS_INT32 OCXCapturePictureXMLProcess::GetSnapshotPlanGetXML(IVS_INT32 iRet,const IVS_CHAR* pCameraCode,const IVS_SNAPSHOT_PLAN* pSnapShotPlan,CXml &xml) { CHECK_POINTER(pCameraCode, IVS_PARA_INVALID); CHECK_POINTER(pSnapShotPlan, IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); (void)xml.AddDeclaration("1.0","UTF-8",""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("ResultCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(iRet)).c_str()); (void)xml.AddElem("SnapshotPlanInfo"); (void)xml.AddChildElem("CameraCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(pCameraCode); (void)xml.AddElem("IsEnable"); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pSnapShotPlan->bEnable)).c_str()); (void)xml.AddElem("PlanType"); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pSnapShotPlan->uiPlanType)).c_str()); (void)xml.AddElem("PlanList"); IVS_CHAR cStartTime[IVS_TIME_LEN+1] = {0}; IVS_CHAR cEndTime[IVS_TIME_LEN+1] = {0}; for (IVS_UINT32 i=0; i<pSnapShotPlan->uiPlanInfoNum; i++) { if (i == 0) { (void)xml.AddChildElem("PlanInfo"); (void)xml.IntoElem();// ------------4 } else { (void)xml.AddElem("PlanInfo"); } (void)xml.AddChildElem("DayType"); (void)xml.IntoElem();// -------------3 (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pSnapShotPlan->stPlanInfo[i].uiDayType)).c_str()); (void)xml.AddElem("TimeList"); for (IVS_UINT32 j=0; j<pSnapShotPlan->stPlanInfo[i].uiTimeSpanInfoNum; j++) { if (j == 0) { (void)xml.AddChildElem("TimeInfo"); (void)xml.IntoElem();// ---------------------- 2 } else{ (void)xml.AddElem("TimeInfo"); } if (!CToolsHelp::Memcpy(cStartTime, IVS_TIME_LEN, pSnapShotPlan->stPlanInfo[i].stTimeSpanInfo[j].cStart, IVS_TIME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot Plan Get XML", "Memcpy cStartTime failed"); return IVS_ALLOC_MEMORY_ERROR; } if (!CToolsHelp::Memcpy(cEndTime, IVS_TIME_LEN, pSnapShotPlan->stPlanInfo[i].stTimeSpanInfo[j].cEnd, IVS_TIME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot Plan Get XML", "Memcpy cEndTime failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.AddChildElem("StartTime"); (void)xml.IntoElem();//-------------------------1 (void)xml.SetElemValue(cStartTime); (void)xml.AddElem("EndTime"); (void)xml.SetElemValue(cEndTime); (void)xml.AddElem("SnapInterval"); (void)xml.SetElemValue(CToolsHelp::Int2Str(static_cast<IVS_INT32>(pSnapShotPlan->stPlanInfo[i].stTimeSpanInfo[j].SnapInterval)).c_str()); xml.OutOfElem();//-------------------------1 } xml.OutOfElem();// ---------------------2 xml.OutOfElem();//----------------3 } xml.OutOfElem();//----------------4 xml.OutOfElem(); return IVS_SUCCEED; }
IVS_INT32 CDomainRouteMgr::GetShareCatalogList(const IVS_CHAR* pQueryInfo, IVS_CHAR** pRspXml) { CHECK_POINTER(m_pUserMgr, IVS_OPERATE_MEMORY_ERROR); if (NULL == pQueryInfo) { BP_RUN_LOG_ERR(IVS_FAIL, "Get Share Cata log List", "Query Info is NULL"); return IVS_FAIL; } // 获取本域SMU连接 std::string strSMULinkID; IVS_INT32 iGetLinkRet = m_pUserMgr->GetLocalDomainLinkID(NET_ELE_SMU_NSS, strSMULinkID); if (IVS_SUCCEED != iGetLinkRet) { BP_RUN_LOG_ERR(iGetLinkRet, "Get LocalDomainLinkID failed", "NA"); return iGetLinkRet; } CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(NSS_GET_SHARE_CATALOG_LIST_REQ, pQueryInfo, strSMULinkID); CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); //发送消息 IVS_INT32 iRet = IVS_FAIL; CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd); CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT); const char* pBefore = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); if (IVS_SUCCEED != iRet || NULL == pBefore) { HW_DELETE(pCmdRsp); BP_RUN_LOG_ERR(iRet, "Share Cata log list", "XML illegal "); return iRet; } HW_DELETE(pCmdRsp); std::string strBefore = pBefore; IVS_DELETE(pBefore, MUILI); //std::string strBefore("<Content><ShareDevList><ShareDevInfo><OriginDevCode>123456</OriginDevCode><OriginDomainCode>0123456789</OriginDomainCode><LocalDevCode>0123#001</LocalDevCode></ShareDevInfo></ShareDevList></Content>"); //std::string strBefore("<OriginDevCode>00000010000000000301</OriginDevCode><OriginDomainCode>001</OriginDomainCode><Latitude>0</Latitude><OriginDevCode>00000010000000000201#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><LocalDevCode /><Latitude>0</Latitude><OriginDevCode>00000010000000000101#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><OriginDevCode>1</OriginDevCode><OriginDomainCode /><LocalDevCode />"); std::string strAfter; iRet = ComplicationDevDomainCode(strBefore,strAfter); CXml xml; std::string strDomainCode; m_pUserMgr->GetDomainCode(strDomainCode); std::string strLocalDevCode; if (!xml.Parse(strAfter.c_str())) { BP_RUN_LOG_ERR(IVS_OPERATE_MEMORY_ERROR, "xml.Parse(strAfter) fail", "NA"); return IVS_OPERATE_MEMORY_ERROR; } if (!xml.FindElemEx("Content/ShareDevList")) { BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElemEx(Content/ShareDevList) fail", "NA"); return IVS_SMU_DEV_REQ_XML_INVALID; } if (!xml.FindElem("ShareDevInfo")) { IVS_UINT32 uiXmlLen = 0; const IVS_CHAR* pRsp = xml.GetXMLStream(uiXmlLen); if (NULL == pRsp) { return IVS_SMU_DEV_REQ_XML_INVALID; } IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsp) + 1); if (NULL == cTmp) { return IVS_ALLOC_MEMORY_ERROR; } memset(cTmp, 0, strlen(pRsp) + 1); memcpy(cTmp, pRsp, strlen(pRsp)); *pRspXml = cTmp; return IVS_SUCCEED; } do { (void)xml.IntoElem(); if (!xml.FindElem("LocalDevCode")) { BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElem(LocalDevCode) fail", "NA"); return IVS_SMU_DEV_REQ_XML_INVALID; } const IVS_CHAR* pLocalDevCode = xml.GetElemValue(); if (NULL != pLocalDevCode) { strLocalDevCode = pLocalDevCode; } if (0 != strcmp(strLocalDevCode.c_str(), "")) { strLocalDevCode.append("#"); strLocalDevCode.append(strDomainCode); xml.ModifyElemValue(strLocalDevCode.c_str()); } xml.OutOfElem(); } while (xml.NextElem()); IVS_UINT32 uiLen = 0; const IVS_CHAR* pRsq = xml.GetXMLStream(uiLen); if (NULL == pRsq) { return IVS_SMU_DEV_REQ_XML_INVALID; } IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsq) + 1); if (NULL == cTmp) { return IVS_ALLOC_MEMORY_ERROR; } memset(cTmp, 0, strlen(pRsq) + 1); memcpy(cTmp, pRsq, strlen(pRsq)); *pRspXml = cTmp; return iRet; }//lint !e1762
// 拼装抓拍图片告警信息xml IVS_INT32 OCXCapturePictureXMLProcess::GetSnapshotListGetXml(CXml &xml, const IVS_SNAPSHOT_INFO_LIST *pSnapshotList, IVS_UINT32 iTotalNum) { CHECK_POINTER(pSnapshotList,IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); (void)xml.AddElem("Content"); (void)xml.AddChildElem("ResultCode"); (void)xml.IntoElem(); (void)xml.SetElemValue("0"); (void)xml.AddElem("PageInfo"); (void)xml.AddChildElem("RealNum"); (void)xml.IntoElem(); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)pSnapshotList->uiTotal).c_str()); (void)xml.AddElem("FromIndex"); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)pSnapshotList->stIndexRange.uiFromIndex).c_str()); (void)xml.AddElem("ToIndex"); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)pSnapshotList->stIndexRange.uiToIndex).c_str()); xml.OutOfElem(); (void)xml.AddElem("SnapshotList"); IVS_UINT32 uIndex = 0; if ((pSnapshotList->uiTotal) > iTotalNum) { uIndex = iTotalNum; } else { uIndex = pSnapshotList->uiTotal; } for (IVS_UINT32 i = 0; i < uIndex; i++) { IVS_SNAPSHOT_INFO cSnapshotInfo = pSnapshotList->stSnapshotInfo[i]; i == 0 ? xml.AddChildElem("SnapInfo") : xml.AddElem("SnapInfo"); (void)xml.IntoElem(); (void)xml.AddChildElem("PictureID"); (void)xml.IntoElem(); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)cSnapshotInfo.uiPictureID).c_str()); (void)xml.AddElem("PictureName"); IVS_CHAR cPictureName[IVS_FILE_NAME_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cPictureName, IVS_FILE_NAME_LEN, cSnapshotInfo.cPictureName, IVS_FILE_NAME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot List GetXml", "Memcpy pPictureName failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(cPictureName); //直接用CU的大CameraCode (void)xml.AddElem("CameraCode"); IVS_CHAR cCameraCode[IVS_DEV_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cCameraCode, IVS_DEV_CODE_LEN, cSnapshotInfo.cCameraCode, IVS_DEV_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot List GetXml", "Memcpy cCameraCode failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(cCameraCode); (void)xml.AddElem("SnapTime"); IVS_CHAR cSnapTime[IVS_TIME_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cSnapTime, IVS_TIME_LEN, cSnapshotInfo.cSnapTime, IVS_TIME_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot List GetXml", "Memcpy cSnapTime failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(cSnapTime); (void)xml.AddElem("SnapType"); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)cSnapshotInfo.uiSnapType).c_str()); (void)xml.AddElem("PictureSize"); (void)xml.SetElemValue(CToolsHelp::Int2Str((int)cSnapshotInfo.uiPictureSize).c_str()); (void)xml.AddElem("PreviewUrl"); IVS_CHAR cPreviewUrl[IVS_URL_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cPreviewUrl, IVS_URL_LEN, cSnapshotInfo.cPreviewUrl, IVS_URL_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot List GetXml", "Memcpy cPreviewUrl failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(cPreviewUrl); (void)xml.AddElem("PictureUrl"); IVS_CHAR cPictureUrl[IVS_URL_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cPictureUrl, IVS_URL_LEN, cSnapshotInfo.cPictureUrl, IVS_URL_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Snapshot List GetXml", "Memcpy cPictureUrl failed"); return IVS_ALLOC_MEMORY_ERROR; } (void)xml.SetElemValue(cPictureUrl); xml.OutOfElem(); } xml.GetRootPos(); return IVS_SUCCEED; }
//设置平台抓拍计划:将请求XML转换为结构体 IVS_INT32 OCXCapturePictureXMLProcess::SetSnapshotPlanGetXML(IVS_CHAR* pCameraCode,IVS_SNAPSHOT_PLAN* pSnapShotPlan, CXml &xml) { CHECK_POINTER(pCameraCode,IVS_PARA_INVALID); CHECK_POINTER(pSnapShotPlan,IVS_PARA_INVALID); IVS_DEBUG_TRACE(""); if (!xml.FindElemEx("Content/SnapshotPlanInfo")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "fail", "no 'SnapshotPlanInfo' elemenet"); return IVS_XML_INVALID; } (void)xml.IntoElem(); const char* szElemValue = NULL; // 摄像机编码 if (!xml.FindElem("CameraCode")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'CameraCode' elemenet"); return IVS_XML_INVALID; } GET_ELEM_VALUE_CHAR("CameraCode",szElemValue,pCameraCode,IVS_DEV_CODE_LEN,xml); // 是否启用 if (!xml.FindElem("IsEnable")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'IsEnable' elemenet"); return IVS_XML_INVALID; } const IVS_CHAR* cpszIsEnable = xml.GetElemValue(); if (NULL == cpszIsEnable) { return IVS_XML_INVALID; } pSnapShotPlan->bEnable = static_cast<IVS_BOOL>(atoi(cpszIsEnable)); // 计划方式(周计划 日计划 全程录像) if (!xml.FindElem("PlanType")) { BP_RUN_LOG_ERR(IVS_XML_INVALID,"Set Snapshot Plan Get XML", "faill", "no 'PlanType' elemenet"); return IVS_XML_INVALID; } GET_ELEM_VALUE_NUM_FOR_UINT("PlanType",szElemValue,pSnapShotPlan->uiPlanType,xml); IVS_UINT32 iPlanInfoNum = 0; IVS_INT32 iTimeInfoNum = 0; if (xml.FindElemEx("Content/SnapshotPlanInfo/PlanList")) { do { (void)xml.IntoElem(); //解析PlanInfo (void)xml.IntoElem(); memset(&pSnapShotPlan->stPlanInfo[iPlanInfoNum],0, sizeof(IVS_SNAPSHOT_PLAN_INFO)); GET_ELEM_VALUE_NUM_FOR_UINT("DayType",szElemValue,pSnapShotPlan->stPlanInfo[iPlanInfoNum].uiDayType,xml); if (xml.FindElem("TimeList")) { xml.IntoElem(); } if(xml.FindElem("TimeInfo")) { do{ (void)xml.IntoElem(); GET_ELEM_VALUE_CHAR("StartTime",szElemValue, pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].cStart,IVS_TIME_LEN,xml); GET_ELEM_VALUE_CHAR("EndTime",szElemValue, pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].cEnd,IVS_TIME_LEN,xml); GET_ELEM_VALUE_NUM_FOR_UINT("SnapInterval",szElemValue,pSnapShotPlan->stPlanInfo[iPlanInfoNum].stTimeSpanInfo[iTimeInfoNum].SnapInterval,xml); iTimeInfoNum++; xml.OutOfElem(); }while(xml.NextElem()); } pSnapShotPlan->stPlanInfo[iPlanInfoNum].uiTimeSpanInfoNum = static_cast<IVS_UINT32>(iTimeInfoNum); xml.OutOfElem(); xml.OutOfElem(); iPlanInfoNum++; iTimeInfoNum = 0; } while(xml.NextElem()); } pSnapShotPlan->uiPlanInfoNum = iPlanInfoNum; xml.OutOfElem(); return IVS_SUCCEED; }
eLTE_RET XMLProcess::SetXmlStringEventNotifySDSReport(const std::string& strSrc, CString& xmlStr) { /************************************************************************ --- XML 格式 --- <Content> <SdsType>消息类型</SdsType> <SdsContent>消息内容</SdsContent> <SdsFrom>发件人</SdsFrom> <SdsMmsFileNameList> <SdsMmsFileName>附件文件名列表</SdsMmsFileName> <SdsMmsFileName>附件文件名列表</SdsMmsFileName> </SdsMmsFileNameList> <SdsSubject>消息主题</SdsSubject> <SdsDate>消息发送日期</SdsDate> <SdsTime>消息发送时间</SdsTime> </Content> ************************************************************************/ LOG_TRACE(); CXml xmlParse; if (!xmlParse.Parse(strSrc.c_str())) { LOG_RUN_ERROR("parse xml failed."); return eLTE_ERR_FAILED; } if (!xmlParse.FindElem("Content")) { LOG_RUN_ERROR("FindElem Content failed."); return eLTE_ERR_FAILED; } (void)xmlParse.IntoElem(); if (!xmlParse.FindElem("SdsType")) { LOG_RUN_ERROR("FindElem CallStatus failed."); return eLTE_ERR_FAILED; } std::string strSdsType = xmlParse.GetElemValue(); std::string strSdsContent = ""; if(xmlParse.FindElem("SdsContent")) { strSdsContent = xmlParse.GetElemValue(); } if (!xmlParse.FindElem("SdsFrom")) { LOG_RUN_ERROR("FindElem SdsFrom failed."); return eLTE_ERR_FAILED; } std::string strSdsFrom = xmlParse.GetElemValue(); std::list<std::string> fileNameList; //彩信 if (xmlParse.FindElem("SdsMmsFileNameList") && xmlParse.IntoElem()) { do { std::string srcValue = xmlParse.GetElemValue(); if(!srcValue.empty()) { fileNameList.push_back(srcValue); } } while (xmlParse.NextElem()); xmlParse.OutOfElem(); } if (!xmlParse.FindElem("SdsSubject")) { LOG_RUN_ERROR("FindElem SdsSubject failed."); return eLTE_ERR_FAILED; } std::string strSdsSubject = xmlParse.GetElemValue(); if (!xmlParse.FindElem("SdsDate")) { LOG_RUN_ERROR("FindElem SdsDate failed."); return eLTE_ERR_FAILED; } std::string strSdsDate = xmlParse.GetElemValue(); if (!xmlParse.FindElem("SdsTime")) { LOG_RUN_ERROR("FindElem SdsTime failed."); return eLTE_ERR_FAILED; } std::string strSdsTime = xmlParse.GetElemValue(); //拼接xml xmlStr.Append(_T("<Content>")); xmlStr.Append(_T("<SdsType>")); xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsType).c_str()); xmlStr.Append(_T("</SdsType>")); if(!strSdsContent.empty()) { xmlStr.Append(_T("<SdsContent>")); xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsContent).c_str()); xmlStr.Append(_T("</SdsContent>")); } xmlStr.Append(_T("<SdsFrom>")); xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsFrom).c_str()); xmlStr.Append(_T("</SdsFrom>")); if(0 < fileNameList.size()) { xmlStr.Append(_T("<SdsMmsFileNameList>")); std::list<std::string>::iterator it = fileNameList.begin(); for (; it != fileNameList.end(); ++it) { xmlStr.Append(_T("<SdsMmsFileName>")); xmlStr.Append(eLTE_Tool::UTF8ToUnicode(*it).c_str()); xmlStr.Append(_T("</SdsMmsFileName>")); } xmlStr.Append(_T("</SdsMmsFileNameList>")); } xmlStr.Append(_T("<SdsSubject>")); xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsSubject).c_str()); xmlStr.Append(_T("</SdsSubject>")); xmlStr.Append(_T("<SdsDirection>")); xmlStr.Append(_T("false")); xmlStr.Append(_T("</SdsDirection>")); xmlStr.Append(_T("<SdsDate>")); xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsDate).c_str()); xmlStr.Append(_T("</SdsDate>")); xmlStr.Append(_T("<SdsTime>")); xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsTime).c_str()); xmlStr.Append(_T("</SdsTime>")); xmlStr.Append(_T("</Content>")); return eLTE_ERR_SUCCESS; }
// 解析画图前图形属性设置XML IVS_INT32 COCXDrawXMLProcess::DrawGraphicsPraseXML(IA_GRAPHICS &GraphicAttribute, ULONG &ulGroupDrawMaxNum, LPCTSTR pGraphicsXml) { CHECK_POINTER(pGraphicsXml, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE("GroupDrawMaxNum: %lu, GraphicsXml: %s", ulGroupDrawMaxNum, pGraphicsXml); CXml xml; if (!xml.Parse(pGraphicsXml)) { return IVS_FAIL; } CHECK_SUCCESS(xml.FindElem("Content")); CHECK_SUCCESS(xml.IntoElem()); CHECK_SUCCESS(xml.FindElem("Graphics")); CHECK_SUCCESS(xml.IntoElem()); const char *value = NULL; CHECK_SUCCESS(xml.FindElem("GraphicNum") && (NULL != (value = xml.GetElemValue()))); ulGroupDrawMaxNum = (ULONG)atoi(value); // 若设置的图形数大于图形数组长度,截断到最大画图个数 if (ulGroupDrawMaxNum > GRAPHICS_NUM_MAX) { BP_RUN_LOG_INF("COCXDrawXMLProcess::DrawGraphicsPraseXML", "GroupDrawMaxNum Truncated to GRAPHICS_NUM_MAX"); ulGroupDrawMaxNum = GRAPHICS_NUM_MAX; } CHECK_SUCCESS(xml.FindElem("GraphicList")); CHECK_SUCCESS(xml.IntoElem()); // 给图形可选字段赋默认值 memset(&GraphicAttribute, 0, sizeof(IA_GRAPHICS)); GraphicAttribute.ulLineWidth = 3; // 默认基本线宽为3 GraphicAttribute.bAllowDelete = TRUE; // 允许删除 GraphicAttribute.bAllowModifySize = TRUE; // 允许修改矩形大小 CHECK_SUCCESS(xml.FindElem("GraphicInfo")); CHECK_SUCCESS(xml.IntoElem()); CHECK_SUCCESS(xml.FindElem("GraphicType") && (NULL != (value = xml.GetElemValue()))); GraphicAttribute.ulGraphicType = (ULONG)atoi(value); GET_ELEMENT_ULONG(GraphicAttribute.ulGraphicGroup, GraphicGroup, xml); GET_ELEMENT_STRING(GraphicAttribute.GraphicGroupName, CHARACTER_NUM_MAX, GraphicGroupName, xml); if (xml.FindElem("GraphicBackgroundColor")) { CHECK_SUCCESS(xml.IntoElem()); GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Alpha, Opacity, xml); GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Red, Red, xml); GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Green, Green, xml); GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Blue, Blue, xml); xml.OutOfElem(); } if (xml.FindElem("GraphicLineColor")) { CHECK_SUCCESS(xml.IntoElem()); GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Alpha, Opacity, xml); GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Red, Red, xml); GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Green, Green, xml); GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Blue, Blue, xml); xml.OutOfElem(); } GET_ELEMENT_ULONG(GraphicAttribute.ulLineWidth, GraphicLineWidth, xml); GET_ELEMENT_ULONG(GraphicAttribute.NamePosition, NamePosition, xml); GET_ELEMENT_BOOL(GraphicAttribute.bAllowDelete, DeleteByMouse, xml); GET_ELEMENT_BOOL(GraphicAttribute.bAllowAddNewPoint, AddNewPoint, xml); GET_ELEMENT_BOOL(GraphicAttribute.bAllowModifySize, AllowModifySize, xml); GET_ELEMENT_ULONG(GraphicAttribute.ulArrowType, ArrowType, xml); GET_ELEMENT_BOOL(GraphicAttribute.bKeepHorizon, KeepHorizon, xml); xml.OutOfElem(); xml.OutOfElem(); xml.OutOfElem(); return IVS_SUCCEED; }
//对XML中的设备编码拼装与编码 int CSDKMainctrl::ModifyDevCode(CXml& xml, IVS_CHAR* pData)const { CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); if (!xml.Parse(pData)) { BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.Parse(pData)", "NA"); //IVS_DELETE(pData, MUILI); return IVS_SMU_XML_INVALID; } if (!xml.FindElemEx("Content/Action")) { BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(Content/Action)", "NA"); //IVS_DELETE(pData, MUILI); return IVS_SMU_XML_INVALID; } // 若xml包含DevList,需要处理DevCode(拼接设备所在域编码DevDomainCode) if (xml.FindElem("DevList")) { xml.IntoElem(); if (!xml.FindElem("DevInfo")) { BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevInfo)", "NA"); //IVS_DELETE(pData, MUILI); return IVS_SMU_XML_INVALID; } do { (void)xml.IntoElem(); // 找到设备所在域编码拼在DevCode后面 if (!xml.FindElem("DevDomainCode")) { BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA"); //IVS_DELETE(pData, MUILI); return IVS_SMU_XML_INVALID; } std::string strDevDomainCode; const IVS_CHAR* pDevDomainCode = xml.GetElemValue(); if (NULL != pDevDomainCode) { strDevDomainCode = pDevDomainCode; } // 拼接设备所在域编码 if (!xml.FindElem("DevCode")) { BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA"); //IVS_DELETE(pData, MUILI); return IVS_SMU_XML_INVALID; } std::string strDevCode; const IVS_CHAR* pDevCode = xml.GetElemValue(); if (NULL != pDevCode) { strDevCode = pDevCode; } if (!strDevCode.empty()) { strDevCode.append("#").append(strDevDomainCode); xml.ModifyElemValue(strDevCode.c_str()); } xml.OutOfElem(); } while (xml.NextElem()); xml.OutOfElem(); } // // IVS_UINT32 uiXmlLen = 0; // pDataXml = xml.GetXMLStream(uiXmlLen); // CHECK_POINTER(pDataXml, IVS_OPERATE_MEMORY_ERROR); return IVS_SUCCEED; }//lint !e818
IVS_INT32 CMediaXMLProcess::GetURLXML(const ST_URL_MEDIA_INFO& stUrlMediaInfo, const ST_SRU_LOGIN_RSP& /*stSRULoginRsp*/, CXml &xml) { IVS_DEBUG_TRACE(""); (void)xml.AddDeclaration("1.0","UTF-8",""); (void)xml.AddElem("Content"); if ( 0 != strlen(stUrlMediaInfo.cDomainCode)) { (void)xml.AddChildElem("DomainCode"); (void)(xml.IntoElem()); (void)xml.SetElemValue(stUrlMediaInfo.cDomainCode); (void)xml.AddElem("MediaInfo"); (void)xml.IntoElem(); } else { (void)xml.AddChildElem("MediaInfo"); (void)xml.IntoElem(); } // { (void)xml.AddChildElem("ServiceType"); (void)xml.IntoElem(); (void)xml.SetElemValue(CToolsHelp::Int2Str(stUrlMediaInfo.ServiceType).c_str()); (void)xml.AddElem("SrcCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szSrcCode); (void)xml.AddElem("DstCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szDstCode); const IVS_MEDIA_PARA& stMediaPara = stUrlMediaInfo.MediaPara; std::string strStreamType = CToolsHelp::Int2Str(stMediaPara.StreamType); (void)xml.AddElem("StreamID"); (void)xml.IntoElem(); (void)xml.SetElemValue(strStreamType.c_str()); (void)xml.AddElem("DstTP"); (void)xml.IntoElem(); std::string strProtocolType = CToolsHelp::Int2Str(stMediaPara.ProtocolType); (void)xml.SetElemValue(strProtocolType.c_str()); (void)xml.AddElem("DstPP"); (void)xml.IntoElem(); std::string strPP = CToolsHelp::Int2Str(PACK_PROTOCOL_ES); (void)xml.SetElemValue(strPP.c_str()); (void)xml.AddElem("DstCast"); (void)xml.IntoElem(); std::string strBroadcastType = CToolsHelp::Int2Str(stMediaPara.BroadCastType); (void)xml.SetElemValue(strBroadcastType.c_str()); (void)xml.AddElem("DstIP"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szDstIP); (void)xml.AddElem("DstPort"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szDstPort); if(stUrlMediaInfo.ServiceType != SERVICE_TYPE_AUDIO_CALL && stUrlMediaInfo.ServiceType != SERVICE_TYPE_AUDIO_BROADCAST) { (void)xml.AddElem("VMedia"); (void)xml.IntoElem(); // 视频格式改为由MU去数据库中查,SDK只把MP的视频解码能力通知给MU std::string strVideoDecType = IVS_C02_VIDEO_DEC_ABILITY; (void)xml.SetElemValue(strVideoDecType.c_str()); } (void)xml.AddElem("AMedia"); (void)xml.IntoElem(); // 音频格式改为由MU去数据库中查,SDK只把MP的音频解码能力通知给MU std::string strAudioDecType = IVS_C02_AUDIO_DEC_ABILITY; (void)xml.SetElemValue(strAudioDecType.c_str()); if(SERVICE_TYPE_PLAYBACK == stUrlMediaInfo.ServiceType || SERVICE_TYPE_PU_PLAYBACK == stUrlMediaInfo.ServiceType || SERVICE_TYPE_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_PU_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_BACKUPRECORD_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_BACKUPRECORD_PLAYBACK == stUrlMediaInfo.ServiceType // add by lilongxin || SERVICE_TYPE_DISASTEBACKUP_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_DISASTEBACKUP_PLAYBACK == stUrlMediaInfo.ServiceType ) { (void)xml.AddElem("TimeSpan"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szTimeSpan); //add by c00206592 添加NVRCode if (0 != strlen(stUrlMediaInfo.szNVRCode)) { (void)xml.AddElem("NVRCode"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szNVRCode); } //end add } (void)xml.AddElem("TransMode"); (void)xml.IntoElem(); std::string strTransMode = CToolsHelp::Int2Str(stMediaPara.TransMode); (void)xml.SetElemValue(strTransMode.c_str()); if(0!=stUrlMediaInfo.iClientType) { std::string strClientType = CToolsHelp::Int2Str(stUrlMediaInfo.iClientType); (void)xml.AddElem("ClientType"); (void)xml.IntoElem(); (void)xml.SetElemValue(strClientType.c_str()); } if(strlen(stUrlMediaInfo.szEncryAlgorithm)>0) { (void)xml.AddElem("EncryAlgorithm"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szEncryAlgorithm); } if(SERVICE_TYPE_PLAYBACK == stUrlMediaInfo.ServiceType || SERVICE_TYPE_PU_PLAYBACK == stUrlMediaInfo.ServiceType || SERVICE_TYPE_PU_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_BACKUPRECORD_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_BACKUPRECORD_PLAYBACK == stUrlMediaInfo.ServiceType // add by lilongxin || SERVICE_TYPE_DISASTEBACKUP_DOWNLOAD == stUrlMediaInfo.ServiceType || SERVICE_TYPE_DISASTEBACKUP_PLAYBACK == stUrlMediaInfo.ServiceType ) { (void)xml.AddElem("FileName"); (void)xml.IntoElem(); (void)xml.SetElemValue(stUrlMediaInfo.szFileName); } xml.OutOfElem(); //} return IVS_SUCCEED; }