コード例 #1
0
ファイル: TaskModel.cpp プロジェクト: jaylauffer/loadngo
Task::TaskSet * CTaskModel::GetChildren(Task::TaskSet *pSet)
{
	//if(!m_pTaskManager)return pSet;
	MSXML2::IXMLDOMNodeList *pNodeList = 0;
	BSTR xpath = SysAllocString(_T("./task"));
	HRESULT hr = m_pNode->selectNodes(xpath, &pNodeList);
	SysFreeString(xpath);
	MSXML2::IXMLDOMNode *pNode = 0;
	if(pNodeList)
	{
		while((hr = pNodeList->nextNode(&pNode)) == S_OK)
		{
			unsigned __int64 childID = 0;
			XMLHelper::GetAttributeI64(pNode, TASKID, &childID);
			Task *pTask = new(childID) CTaskModel(pNode);
			if(pTask)
			{
				pSet->Add(*pTask);
			}
			pNode->Release();
			pNode = 0;
		}
	}
	pNodeList->Release();
	pNodeList = 0;
	return pSet;
}
コード例 #2
0
//The big issue here will be the whether the input time is local or UTC, there could be problems
//between users in different timezones and the proper realization of template...
//TODO: review code to ensure template is realized properly
void RecurrenceManager::RealizeRecurrences(unsigned __int64 date)
{
	if(date > m_pDataManager->GetDayManagerInstance()->GetToday() - 1)
	{
		SYSTEMTIME st = ModelUtils::I64ToSystemTime(date);
		StringBuffer sb(_T("//recurrence[schedule/@"));
		sb.append(days[st.wDayOfWeek]);
		sb.append(_T("='true']"));

		BSTR xpath = SysAllocString(sb);
		MSXML2::IXMLDOMNodeList *pList = 0;

		HRESULT hr = m_pXMLDoc->selectNodes(xpath, &pList);
		if(hr == S_OK && pList)
		{
			MSXML2::IXMLDOMNode *pNode = 0;
			while((hr = pList->nextNode(&pNode)) == S_OK)
			{
				RealizeRecurrence(pNode, st);
				pNode->Release();
			}
			pList->Release();
		}
	}
}
コード例 #3
0
ファイル: XMLHelperTests.cpp プロジェクト: jaylauffer/loadngo
	TEST_FIXTURE(XmlFixture, CreateChild2)
	{
		MSXML2::IXMLDOMNode *node = 0;
		HRESULT hr = XMLHelper::CreateChild(root, &node, _T("test"));
		CHECK_OK(hr);
		CHECK(node);
		node->Release();
		node = 0;
		BSTR query = SysAllocString(_T("//test"));
		MSXML2::IXMLDOMNodeList *nodeList = 0;
		hr = doc->selectNodes(query, &nodeList);
		SysFreeString(query);
		CHECK_OK(hr);
		CHECK(nodeList);
		long length = 0;
		hr = nodeList->get_length(&length);
		CHECK_OK(hr);
		CHECK_EQUAL(1, length);
		hr = nodeList->nextNode(&node);
		CHECK_OK(hr);
		CHECK(node);
		BSTR name = 0;
		hr = node->get_nodeName(&name);
		CHECK_OK(hr);
		CHECK_EQUAL(0, _tcscmp(name, _T("test")));
		SysFreeString(name);
	}
コード例 #4
0
ファイル: TaskModel.cpp プロジェクト: jaylauffer/loadngo
//TODO: review usage of TaskIDSet, in particular the local allocation and copying of contents
Task::TaskIDSet CTaskModel::GetAllPrerequisites()
{
	TaskIDSet ts;
	MSXML2::IXMLDOMNodeList *pNodeList = 0;
	BSTR xpath = SysAllocString(_T("ancestor-or-self::task/prerequisite"));
	HRESULT hr = m_pNode->selectNodes(xpath, &pNodeList);
	SysFreeString(xpath);
	MSXML2::IXMLDOMNode *pNode = 0;
	unsigned __int64 id = 0;
	BSTR bstr = 0;
	if(pNodeList)
	{
		while((hr = pNodeList->nextNode(&pNode)) == S_OK)
		{
			if(pNode)
			{
				hr = XMLHelper::GetAttribute(pNode, _T("taskid"), &bstr);
				if(hr == S_OK)
				{
					id = ModelUtils::fromHexString(bstr, wcslen(bstr));
					ts.Add(id);
					id = 0;
					SysFreeString(bstr);
				}
				bstr = 0;
				pNode->Release();
				pNode = 0;
			}
		}
		pNodeList->Release();
	}
	return ts;
}
コード例 #5
0
ファイル: TaskModel.cpp プロジェクト: jaylauffer/loadngo
int CTaskModel::CompleteChildCount()
{
	int ret = 0;
	BSTR xpath = SysAllocString(_T(".//task"));
	MSXML2::IXMLDOMNodeList *pNodeList;
	HRESULT hr = m_pNode->selectNodes(xpath, &pNodeList);
	if(pNodeList)
	{
		hr = pNodeList->get_length(reinterpret_cast<long *>(&ret));
		if(hr != S_OK)ret = 0;
	}
	return ret;
}
コード例 #6
0
ファイル: TaskModel.cpp プロジェクト: jaylauffer/loadngo
int CTaskModel::CountChildren()
{
	long count = 0;
	MSXML2::IXMLDOMNodeList *pNodeList = 0;
	BSTR xpath = SysAllocString(_T("./task"));
	HRESULT hr = m_pNode->selectNodes(xpath, &pNodeList);
	SysFreeString(xpath);
	if(pNodeList)
	{
		hr = pNodeList->get_length(&count);
		pNodeList->Release();
	}
	return static_cast<int>(count);
}
コード例 #7
0
Iterator<TimeEntry> * PlanEntryModelManager::IterateValues(BSTR xpath)
{
	MSXML2::IXMLDOMNodeList *pList = 0;
	HRESULT hr = m_pRoot->selectNodes(xpath, &pList);
	Iterator<TimeEntry> *pIter = 0;
	if(hr == S_OK && pList)
	{
		MSXML2::IXMLDOMSelection *pSelection = 0;
		hr = pList->QueryInterface(__uuidof(MSXML2::IXMLDOMSelection), reinterpret_cast<void **>(&pSelection));
		if(hr == S_OK && pSelection)
		{
			pIter = new PlanEntryIterator(pSelection);
			pSelection->Release();	
		}
		pList->Release();
	}
	return pIter;
}
コード例 #8
0
ファイル: TaskModel.cpp プロジェクト: jaylauffer/loadngo
Iterator<Annotation> * CTaskModel::ListAnnotations(bool)
{
	MSXML2::IXMLDOMNodeList *pList = 0;
	BSTR xpath = SysAllocString(_T("./annotation"));
	HRESULT hr = m_pNode->selectNodes(xpath, &pList);
	SysFreeString(xpath);
	Iterator<Annotation> *pIter = 0;
	if(hr == S_OK && pList)
	{
		MSXML2::IXMLDOMSelection *pSelection = 0;
		hr = pList->QueryInterface(__uuidof(MSXML2::IXMLDOMSelection), reinterpret_cast<void **>(&pSelection));
		if(hr == S_OK && pSelection)
		{
			pIter = new AnnotationIterator(pSelection);
			pSelection->Release();
		}
		pList->Release();
	}
	return pIter;
}
コード例 #9
0
ファイル: XMLPaser.cpp プロジェクト: F5000/spree
HRESULT XMLPaser::ND_hrGetTableValue( LPCTSTR strTable, LPCTSTR strField, 
		UINT idxRow, TCHAR* pVal )
{
	HRESULT hr = E_FAIL;
	MSXML2::IXMLDOMNode *pNode = NULL;
	long idxColumn = -1;
	long lTableChilds = 0;
	long lfirstRow = 0;

	try
	{
		pNode = ND_pGetTableNode( strTable );

		if ( pNode )
		{
			MSXML2::IXMLDOMNodeList* pRowNodeList;
			pNode->get_childNodes( &pRowNodeList );

			if ( pRowNodeList )
			{
				pRowNodeList->get_length( &lTableChilds );

				MSXML2::IXMLDOMNode *pRowNode;
				BSTR bstrName;
				LPSTR pszName;

				for ( long ll = 0; ll < lTableChilds; ll++ )
				{
					pRowNodeList->get_item( ll, &pRowNode );
					pRowNode->get_baseName( &bstrName );

					// 처음 Row가 나오는 순간
					UnicodeToAnsi( bstrName, &pszName );
					if ( stricmp( pszName, _T("Row") ) == 0 )
					{
						lfirstRow = ll;
						CoTaskMemFree( pszName );
						::SysFreeString( bstrName );
						break;
					}

					CoTaskMemFree( pszName );
					::SysFreeString( bstrName );
				}

				if ( lfirstRow >= lTableChilds )
				{
					return ( E_FAIL );
				}

				pRowNodeList->get_item( lfirstRow, &pRowNode );

				if ( pRowNode )
				{
					MSXML2::IXMLDOMNodeList* pCellNodeList;
					pRowNode->get_childNodes( &pCellNodeList );

					if ( pCellNodeList )
					{
						long lCell = 0;
						pCellNodeList->get_length( &lCell );
						
						for ( long ll = 0; ll < lCell; ll++ )
						{
							MSXML2::IXMLDOMNode *pCellNode;
							pCellNodeList->get_item( ll, &pCellNode );

							if ( pCellNode )
							{
								MSXML2::IXMLDOMNode *pDataNode;
								pCellNode->get_firstChild( &pDataNode );
								if ( pDataNode )
								{
									LPSTR pszColumnName;
									pDataNode->get_text( &bstrName );
									UnicodeToAnsi( bstrName, &pszColumnName );

									if ( stricmp( pszColumnName, strField ) == 0 )
									{
										idxColumn = ll;
									}

									CoTaskMemFree( pszColumnName );
									::SysFreeString( bstrName );
									pDataNode->Release();
								}
								pCellNode->Release();
							}
						}
						pCellNodeList->Release();
					}
					pRowNode->Release();
				}

				pRowNodeList->get_item( idxRow + lfirstRow + 1, &pRowNode );

				if ( pRowNode )
				{
					MSXML2::IXMLDOMNodeList* pCellNodeList;
					pRowNode->get_childNodes( &pCellNodeList );

					if ( pCellNodeList )
					{
						MSXML2::IXMLDOMNode *pDataNode;
						pCellNodeList->get_item( idxColumn, &pDataNode );

						if ( pDataNode )
						{
							BSTR bstrData;
							LPSTR pszData;
							pDataNode->get_text( &bstrData );
							UnicodeToAnsi( bstrData, &pszData );

							strcpy( pVal, pszData );
							hr = S_OK;

							CoTaskMemFree( pszData );
							::SysFreeString( bstrData );
							pDataNode->Release();
						}
						pCellNodeList->Release();
					}
					pRowNode->Release();
				}
				pRowNodeList->Release();
			}
			pNode->Release();
		}

		return ( hr );
	}
	catch(...)
	{
		return ( E_FAIL );
	}
}
コード例 #10
0
ファイル: XMLPaser.cpp プロジェクト: F5000/spree
// 이 함수의 리턴 값인 IXMLDOMNode 포인터는 쓰고 난 후에 Release를 해야한다.
MSXML2::IXMLDOMNode* XMLPaser::ND_pGetTableNode( LPCTSTR strTable )
{
	MSXML2::IXMLDOMNode *pWorksheetNode = NULL;
	MSXML2::IXMLDOMNode *pTableNode = NULL;
	long lFoundWorksheet = -1;

	try
	{
		m_pNodeList->reset();

		for ( long i = 0; i < m_lTableCount; i++ )
		{
			m_pNodeList->get_item( i, &pWorksheetNode );

			if ( pWorksheetNode )
			{
				MSXML2::IXMLDOMNamedNodeMap* pNodeMap;

				if ( SUCCEEDED( pWorksheetNode->get_attributes( &pNodeMap ) ) && pNodeMap )
				{
					MSXML2::IXMLDOMNode *pAttributeNode = NULL;
					pNodeMap->get_item( 0, &pAttributeNode );

					if ( pAttributeNode )
					{
						BSTR bstrName;
						_variant_t varTableName;
						pAttributeNode->get_nodeName( &bstrName );

						LPSTR pszName;
						UnicodeToAnsi( bstrName, &pszName );
						if ( strcmp( pszName, _T("ss:Name") ) == 0 )
						{
							pAttributeNode->get_nodeValue( &varTableName );

							if ( varTableName.vt == VT_BSTR )
							{
								LPSTR pszTableName;
								UnicodeToAnsi( varTableName.bstrVal, &pszTableName );

								// Found Worksheet!
								if ( stricmp( strTable, pszTableName ) == 0 )
								{
									lFoundWorksheet = i;
								}

								CoTaskMemFree( pszTableName );
							}
						}

						CoTaskMemFree( pszName );

						pAttributeNode->Release();
						VariantClear( &varTableName );
						::SysFreeString( bstrName );
					}
					pNodeMap->Release();
				}
				pWorksheetNode->Release();
			}
		}

		if ( lFoundWorksheet < 0 )
			throw ( 0 );

		m_pNodeList->get_item( lFoundWorksheet, &pWorksheetNode );

		if ( pWorksheetNode )
		{
			MSXML2::IXMLDOMNodeList* pNodeList;
			pWorksheetNode->get_childNodes( &pNodeList );
			if ( pNodeList )
			{
				for ( long i = 0; i < pNodeList->Getlength(); i++ )
				{
					pNodeList->get_item( i, &pTableNode );
					if ( pTableNode )
					{
						BSTR bstrName;
						pTableNode->get_nodeName( &bstrName );

						LPSTR pszName;
						UnicodeToAnsi( bstrName, &pszName );
						if ( strcmp( pszName, _T("Table") ) == 0 )
						{
							CoTaskMemFree( pszName );
							::SysFreeString( bstrName );
							pNodeList->Release();
							pWorksheetNode->Release();
							return ( pTableNode );
						}
						CoTaskMemFree( pszName );
						::SysFreeString( bstrName );
					}
				}
				pNodeList->Release();
			}
			pWorksheetNode->Release();
		}
		return ( NULL );
	}
	catch(...)
	{
		return ( NULL );
	}
}
コード例 #11
0
ファイル: DBManage_WebServer.cpp プロジェクト: minicool/IOCP
//通过WebService查询在巡防的终端信息,当终端发来GPS数据时,用来判断该终端是否在巡防,
//如果是还要将该GPS数据发给巡防管理服务
BOOL CDBManage_WebServer::WebServer_LoadDB_PatrolDeviceInfo(BOOL isUpdateOnLineDeviceList)
{
	BOOL bRet = FALSE;
	
	if (!gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.IsEmpty())
	{
		gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.ClearAll();
	}
	
	if(m_bWebServiceConn)
	{
		MSXML2::IXMLDOMDocumentPtr pDoc;
		HRESULT	hr;
		hr=pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument));
		if(FAILED(hr))
		{  
			gWriteLogApp.WriteLog( FOR_ALARM,_T("%s [SYS] 无法创建DOMDocument对象,请检查是否安装了MS XML Parser 运行库\n"),CTime::GetCurrentTime().Format("%H:%M:%S"));
			return FALSE;
		}

		CComBSTR hiResult;
		m_pWebService->HYTPGIS_PatroAreaUser_QueryAllDevice(&hiResult);
		char *pStr = NULL;
		pStr = _com_util::ConvertBSTRToString(hiResult);
		CString strXML;
		strXML.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><DataSet xmlns=\"http://tempuri.org/\"> %s</DataSet>",pStr);

		VARIANT_BOOL bRet = pDoc->loadXML((_bstr_t)strXML);
		if(bRet == -1)
		{
			MSXML2::IXMLDOMNodeListPtr	 pListNode;
			pListNode = pDoc->selectNodes("//Table");
			if(pListNode != NULL)
			{
				int i;
				long tLen;
				pListNode->get_length(&tLen);
				CString strTemp;

				for(i = 0 ; i < tLen; i++)
				{
					int j = 0;
					MSXML2::IXMLDOMNode	 *pTempNode;
					pListNode->get_item(i,&pTempNode);

					MSXML2::IXMLDOMNodeList *TempChildList;
					pTempNode->get_childNodes(&TempChildList);

					long listCount = 0;
					TempChildList->get_length(&listCount);

					MSXML2::IXMLDOMNode *tempListItem = NULL;
					_variant_t	tempValue;
					for(j = 0 ; j < listCount; j++)
					{
						TempChildList->get_item(j,&tempListItem);

						tempListItem->get_nodeTypedValue(&tempValue);
						strTemp.Format("%s",(char *)(_bstr_t)tempValue);
						strTemp = strTemp.TrimLeft();
						strTemp = strTemp.TrimRight();
						gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.AddItem(strTemp);
						if(isUpdateOnLineDeviceList) //当巡防路线修改时为TRUE,此时要更新在线终端的巡防状态字段
						{
							gPGisMainCtrlProc.m_BusinessManage_ConToPub.Update_OnlineDeviceList_PatrolState(strTemp);	//
						}
						TRACE("添加巡防用户信息 %s \n",strTemp);
					}
				} //end for(i = 0

				bRet = TRUE;
                gWriteLogApp.WriteLog( FOR_ALARM,_T("%s [SYS] 加载巡防终端信息 %d 成功 \n"),CTime::GetCurrentTime().Format("%H:%M:%S"),tLen);
				m_bWebConnOK = TRUE;
			}
		}

		if(pStr)
		{
			delete []pStr;
			pStr = NULL;
		}
	}

	return bRet;
}