void VehicleRequestDispatcher::TowTruckServiceRequestDispatch()
{
	int nReqCount = m_vTowTruckServiceRequest.size();

	for (int i = 0; i <nReqCount; i++)
	{
		TowTruckServiceRequest* pRequest = m_vTowTruckServiceRequest.at(i);
		std::vector<int> vIDs;
		vIDs = m_pFlightServiceRequirement->GetVehicleTypeIDByBaseType(VehicleType_TowTruck);
		AirsideFlightInSim* pFlight = pRequest->GetServiceFlight();

		if (vIDs.empty())
		{
			CString strVehicleType = "Tow Truck";
			CString strWarn;
			strWarn.Format("There is no definition for the type of tow truck in Vehicle Specification for the flight Push&Tow operation ");
			CString strError = _T("DEFINITION ERROR");
			AirsideSimErrorShown::SimWarning(pFlight,strWarn,strError);	
			DeleteRequest(pRequest);
			nReqCount--;
			continue;
		}

		int nCount = vIDs.size();
		bool bExistTowTruckPool = false;
		for (int i = 0; i < nCount; i++)
		{
			int nVehicleID = vIDs.at(i);
			std::vector<int> vPoolIDs;
			vPoolIDs.clear();
			m_pPoolsDeployment->GetTowTruckServicePool(pFlight,nVehicleID,vPoolIDs);
			if (vPoolIDs.empty())
				continue;

			bExistTowTruckPool = true;
			pRequest->SetServiceVehicleTypeID(nVehicleID);
			if (IsTowingRequestHandledByPools(pRequest,vPoolIDs))
			{
				pRequest->SetProceed(true);
				DeleteRequest(pRequest);
				nReqCount--;
				break;
			}

		}
		if (!bExistTowTruckPool)
		{
			//CString strWarn = _T("There is no definition for the type of tow truck in Vehicle Pool Deployment,the flight cannot be serviced");
			//CString strError = _T("DEFINITION ERROR");
			//AirsideSimErrorShown::SimWarning(pFlight,strWarn,strError);	
			DeleteRequest(pRequest);
			nReqCount--;
			
		}
	}
}
void CALLBACK CDirectoryMonitor::CompletionRoutine(DWORD dwErrorCode,
DWORD NumberOfBytesTransferred,LPOVERLAPPED lpOverlapped)
{
	CDirInfo				*pDirInfo = NULL;
	FILE_NOTIFY_INFORMATION	*pfni = NULL;
	TCHAR					szFileName[MAX_PATH];

	if((dwErrorCode == ERROR_SUCCESS) && (NumberOfBytesTransferred != 0))
	{
		if(lpOverlapped->hEvent == NULL)
			return;

		pDirInfo = reinterpret_cast<CDirInfo *>(lpOverlapped->hEvent);

		pfni = pDirInfo->m_FileNotifyBuffer;

		CopyDirectoryChangeFileName(pfni,szFileName,SIZEOF_ARRAY(szFileName));

		pDirInfo->m_DirectoryAltered(szFileName,pfni->Action,pDirInfo->m_pData);

		while(pfni->NextEntryOffset != 0)
		{
			pfni = (FILE_NOTIFY_INFORMATION *)((LPBYTE)pfni + pfni->NextEntryOffset);

			CopyDirectoryChangeFileName(pfni,szFileName,SIZEOF_ARRAY(szFileName));

			pDirInfo->m_DirectoryAltered(szFileName,pfni->Action,pDirInfo->m_pData);
		}

		free(pDirInfo->m_FileNotifyBuffer);

		pDirInfo->m_FileNotifyBuffer = NULL;

		/* Rewatch the directory. */
		WatchDirectoryInternal((ULONG_PTR)pDirInfo);
	}
	else if(dwErrorCode == ERROR_OPERATION_ABORTED)
	{
		pDirInfo = reinterpret_cast<CDirInfo *>(lpOverlapped->hEvent);

		/* The specified directory has stop been watched.
		Remove its entry from the queue. */
		DeleteRequest((ULONG_PTR)pDirInfo);
	}
}