Exemplo n.º 1
0
	void ToArea( Kxe_Area_Param& areaParam, KArea& area )
	{
		area.SetName( ATL::CString(areaParam.strName.c_str()) );
		area.SetType( areaParam.nAreaType );

		BYTE byteMac[6]  = {0};
		ToMAC( &(areaParam.vecGateMac), byteMac );
		area.SetGateMac( byteMac );

		area.SetCreateTime( &(areaParam.ftCreate) );
		area.SetGateIp( areaParam.uIp );
		area.SetWireless( areaParam.bWireless );
		area.SetLastChangeTime( areaParam.nLastChangeTime );
	}
Exemplo n.º 2
0
inline HRESULT	KAreaFile::ReadArea(KRecord* pRecord)
{
	HRESULT hr = S_OK;
	ASSERT(pRecord->GetType() == AreaInfo_Area);
	KArea* pArea = m_pAreaMgr->CreateArea();

	KRecord rule = pRecord->FirstSubRecord();
	while (pRecord->IsSubRecord(rule)) 
	{
		if (!rule.Ok())
		{
			hr = E_AREA_FILE_UNKNOWN_FMT;
			break;
		}
		switch (rule.GetType())
		{
		case AreaInfo_Name:
			pArea->SetName( (LPWSTR)rule.GetData() );
			break;
		case AreaInfo_CreateDate:
			ASSERT(rule.GetDataSize() == sizeof(FILETIME));
			pArea->SetCreateTime((FILETIME*)rule.GetData());
			break;
		case AreaInfo_Type:
			ASSERT(rule.GetDataSize() == sizeof(AreaType));
			pArea->SetType( *(AreaType*)rule.GetData());
			break;
		case AreaInfo_Gate:
			ASSERT(rule.GetDataSize() == sizeof(BYTE[6]));
			pArea->SetGateMac( (BYTE*)rule.GetData());
			break;
		case AreaInfo_GateIp:
			pArea->SetGateIp( *((UINT*)rule.GetData()));
			break;
		}
		rule = rule.NextRecord();
	}

	if (SUCCEEDED(hr))
	{
		if (SUCCEEDED(m_pAreaMgr->AddArea(pArea)))
			return hr;
	}
	delete pArea;
	return hr;
}