Ejemplo n.º 1
0
DWORD IGFrame::GetImageType (LPCWSTR lpPicturePath)
{
	CAtlStringW cstrExtension (lpPicturePath);
	if (cstrExtension.GetLength() < 5)
		return CXIMAGE_FORMAT_UNKNOWN;	
	cstrExtension = cstrExtension.Right (4);
	// supported file extenstion length may be 2, 3 or 4
	if (cstrExtension.GetAt (0) == L'.')
		cstrExtension = cstrExtension.Right (3);
	else if (cstrExtension.GetAt (1) == L'.')
		cstrExtension = cstrExtension.Right (2);		
	cstrExtension.MakeUpper();
	if (cstrExtension == L"BMP")
		return CXIMAGE_FORMAT_BMP;
	else if (cstrExtension == L"JPG")
		return CXIMAGE_FORMAT_JPG;
	else if (cstrExtension == L"PNG")
		return CXIMAGE_FORMAT_PNG;
	else if (cstrExtension == L"ICO")
		return CXIMAGE_FORMAT_ICO;
	else if (cstrExtension == L"GIF")
		return CXIMAGE_FORMAT_GIF;
	else if (cstrExtension == L"TIF")
		return CXIMAGE_FORMAT_TIF;
	else if (cstrExtension == L"IG")
		return CXIMAGE_FORMAT_IG;
	return CXIMAGE_FORMAT_UNKNOWN;
}
Ejemplo n.º 2
0
HRESULT CDBHistory::QueryHistory_InspectionRecord(HDBCONNECTION hDBConnection, 
													SYSTEMTIME sysTimeFrom,
													SYSTEMTIME sysTimeTo,
													long l_LRUIndex,
													LPCWSTR lpszSerial,
													long	lResult,
													LPCWSTR lpszUserID,
													long	l_Index,
													LPDB_HISTORY_COMMON pRecord,
													BSTR* pbstrResult)
{
	HRESULT hr = E_FAIL;

	IMT::CDBConnection* pDBConnection = reinterpret_cast<IMT::CDBConnection*>(hDBConnection);
	if (pDBConnection != NULL)
	{
		ATL::CCommand<ATL::CAccessor<IMT::CDBHistory>> Command;

		ATL::CDBPropSet _DBPropSet(DBPROPSET_ROWSET);
		pDBConnection->GetRowsetProperties(&_DBPropSet);

		CAtlStringW strCommand;
		CAtlStringW strTemp;
		strCommand.Format(QUERY_USER_BY_VALID_CONDITIONS, sysTimeFrom.wYear,
														  sysTimeFrom.wMonth,
														  sysTimeFrom.wDay,
														  sysTimeTo.wYear,
														  sysTimeTo.wMonth,
														  sysTimeTo.wDay);

		BOOL isExist = FALSE;

		strTemp = strCommand;
		strCommand += L"AND ";

		if(l_LRUIndex != 0)
		{
			strTemp.Format(L"(LRU_Index = %d) ", l_LRUIndex);
			strCommand += strTemp;
			strTemp = strCommand;
			strCommand += L"AND ";
		}
		else
			TRACE(L"");

		if(::lstrcmpi(lpszSerial, L"Àüü") != 0)
		{
			strTemp.Format(L"(SerialNum = '%s') ", lpszSerial);
			strCommand += strTemp;
			strTemp = strCommand;
			strCommand += L"AND ";
		}
		else
			TRACE(L"");

		if(lResult != dfRESULT_ALL)
		{
			strTemp.Format(L"(State = %d) ", lResult);
			strCommand += strTemp;
			strTemp = strCommand;
			strCommand += L"AND ";
		}
		else
			TRACE(L"");

		if(::lstrcmpi(lpszUserID, L"Àüü") != 0)
		{
			strTemp.Format(L"(User = '******') ", lpszUserID);
			strCommand += strTemp;
			strTemp = strCommand;
			strCommand += L"AND ";
		}
		else
			TRACE(L"");

		if(::lstrcmpi(strCommand.Right(4), L"AND ") == 0)
		{
			strCommand = strTemp;
		}
		else
			TRACE(L"");


		hr = Command.Open(ATL::CSession(*pDBConnection), strCommand, &_DBPropSet);
		if (hr != S_OK)
		{
			if (pbstrResult != NULL)
				IMT::GetDBErrorString(hr, pbstrResult);
		}
		else
		{
			TRACE(_T(":::[CDBHistory]-[QUERY] SUCCEEDED :::\n"));
			for(long i = 0; i < l_Index; i++)
			{
				hr = Command.MoveNext();
			}
			if (hr == S_OK)
				::CopyMemory(pRecord, LPDB_HISTORY_COMMON(Command), sizeof(DB_HISTORY_COMMON));
		}
	}

	return hr;
}