Beispiel #1
0
Variant TPropertyHandler::GetValue(TComponent* comp, String prName)
{
	if (!PropertyExists(comp, prName)) return NULL;
	if (IsClass(comp, prName)) return NULL;
	return GetPropValue(comp, prName, true);
	// Parameter true: Strings are preferred returntype (see TypeInfo.pas).
}
void CCUBRIDSession::EnterAutoCommitMode()
{
	m_bAutoCommit = true;

	CComVariant var;
	GetPropValue(&DBPROPSET_SESSION, DBPROP_SESS_AUTOCOMMITISOLEVELS, &var);
	SetCASCCIIsoLevel(V_I4(&var));
}
Beispiel #3
0
String TPropertyHandler::GetClassNamesValues(TComponent* comp, String prName)
{
	TObject *subObj = (TObject *)GetOrdProp(comp, prName);
	if (subObj == NULL) return ""; // In case the prop-value is empty (like Action).

/*  TObject* subObj is needed to find out if the subprop points to
	another Component (like ActiveControl).
	If it is only the value of that property is returned (ie.: "CheckBox1").
	If it is a class like Font all of the props+values of
	comp->Font are returned. */

	if (dynamic_cast<TComponent*>(subObj))
	{   // Find out if subObj points to another Component by casting.
		return prName + "=" + GetValue((TComponent*)subObj,"Name");
	}

/*  subObj does not point to another Component, but we can convert
	it to a TComponent* subComp so it can be used te get the subProps+values.
	This sounds weird but don't forget that a TFont encapsulated in a TForm
	becomes a descendant of TForm, which is a descendant of TComponent!! */

	TComponent* subComp = (TComponent*)subObj;

	TStringList *tempList = new TStringList;
	String temp;
	try
	{
		PTypeInfo TypeInfo = (PTypeInfo)subComp->ClassInfo();
		PPropInfo* PropList = new TPropList;
		GetPropInfos(TypeInfo, (PPropList)PropList);

		tempList->Sorted = true;
		for (int i=0; i < PropertyCount(subComp); i++)
		{
			String subProp = String(PropList[i]->Name);
			tempList->Add(
				prName + "." + subProp
				+ "=" + GetPropValue(subComp, subProp, true) );
		}

		delete[] PropList;

		temp = tempList->Text;
		// Remove trailing carriage-returns:
		int cr = temp.LastDelimiter("\r");
		if (cr) temp.Delete(cr, 2);
	}
	__finally
	{
		delete tempList;
	}

	return temp;
}
Beispiel #4
0
void CSpriteSet::OnOK()
{
	m_strSurfaceName = GetPropValue(m_pPropSurfaceName).GetBuffer();
	if(m_strSurfaceName == "")
	{
		MessageBox("请设置SurfaceName!");
		return;
	}

	m_strFileName = GetPropValue(m_pPropFileName).GetBuffer();
	if(m_strSpriteType == "VBitmapSprite" || m_strSpriteType == "VBitmapBaseSprite" || m_strSpriteType == "VButtonSprite")
	{
		if(m_strFileName == "")
		{
			MessageBox("请设置FileName!");
			return;
		}

		CString strValue = GetPropValue(m_pPropRow).GetBuffer();
		m_nRow = atoi(strValue.GetBuffer());

		strValue = GetPropValue(m_pPropCol).GetBuffer();
		m_nCol = atoi(strValue.GetBuffer());

		if(m_nRow <= 0 || m_nCol <= 0 )
		{
			MessageBox("请设置准确的Row,Col值!");
			return;
		}
	}
	else
	{
		m_strFileName = "";
		m_nCol = 1;
		m_nRow = 1;
	}

	CDialogEx::OnOK();
}
// CMSOmniProvRowset :: CreateColInfo 
// This function creates all of the column information and stores it in the rowset.
// It currently uses all of the columns of the table
void CMSOmniProvRowset::CreateColInfo()
{
	// check if bookmarks are set 
	bool bUseBookmarks = false;
	CComVariant varBookmarks;
	HRESULT hrLocal = GetPropValue(&DBPROPSET_ROWSET, DBPROP_BOOKMARKS, &varBookmarks);
	bUseBookmarks = (hrLocal == S_OK &&  varBookmarks.boolVal == VARIANT_TRUE);

	// get column info from the .INI file
	DBORDINAL ulNumCols;
	ATLCOLUMNINFO * prgColInfo = m_DBFile.GetSchemaInfo(&ulNumCols);
	
	// Need to add bookmark column info?
	if (bUseBookmarks)
	{
		// create new set of column information which includes bookmarks
		ATLCOLUMNINFO * prgColInfoNew;
		prgColInfoNew = new ATLCOLUMNINFO[ulNumCols+1];

		// set bindings for the bookmark
		memset(&prgColInfoNew[0], 0, sizeof(ATLCOLUMNINFO));
		prgColInfoNew[0].cbOffset = 0;
		prgColInfoNew[0].iOrdinal = 0;
		prgColInfoNew[0].columnid.eKind = DBKIND_NAME;
		prgColInfoNew[0].columnid.uGuid.guid = GUID_NULL;
		prgColInfoNew[0].columnid.uName.pwszName = OLESTR("Bookmark");
		prgColInfoNew[0].pwszName = OLESTR("Bookmark");
		prgColInfoNew[0].wType = DBTYPE_I4;
		prgColInfoNew[0].ulColumnSize = 4;
		prgColInfoNew[0].dwFlags = DBCOLUMNFLAGS_ISBOOKMARK;
		
		// copy the old information into the new
		for (DBORDINAL i = 1; i <= ulNumCols; i++)
		{
			prgColInfoNew[i] = prgColInfo[i-1];  
			prgColInfoNew[i].cbOffset +=4;  //adjust space for bookmark
		}

		ulNumCols++;
		prgColInfo = prgColInfoNew;
	}

	// store column info in the rowset object
	SetSchemaInfo(prgColInfo, ulNumCols);
	// 2.0
	// Release the temporary prgColInfo
	delete [] prgColInfo;
}
Beispiel #6
0
STDMETHODIMP CCUBRIDDataSource::CreateSession(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppDBSession)
{
	if(ppDBSession==NULL) return E_INVALIDARG;
	*ppDBSession = NULL;

	// DBPROP_ACTIVESESSIONS 개수 이상의 session을 열 수 없다.
	{
		CComVariant var;
		HRESULT hr = GetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_ACTIVESESSIONS, &var);
		if(FAILED(hr)) return hr;

		ATLASSERT(var.vt==VT_I4);
		int cActSessions = V_I4(&var);

		if(cActSessions!=0 && this->m_cSessionsOpen>=cActSessions)
			return DB_E_OBJECTCREATIONLIMITREACHED;
	}

	// DBPROP_MULTIPLECONNECTIONS==FALSE면
	// 여러 개의 connection handle을 여는 것을 허용하지 않음
	/*
	{
		CComVariant var;
		HRESULT hr = GetPropValue(&DBPROPSET_DATASOURCE, DBPROP_MULTIPLECONNECTIONS, &var);
		if(FAILED(hr)) return hr;

		ATLASSERT(var.vt==VT_BOOL);
		bool bMulSessions = V_BOOL(&var);

		if(!bMulSessions && this->m_cSessionsOpen!=0)
			return DB_E_OBJECTOPEN;
	}
	*/

	return IDBCreateSessionImpl<CCUBRIDDataSource, CCUBRIDSession>::CreateSession(pUnkOuter, riid, ppDBSession);
}
// CMSOmniProvRowset::Execute
// 1. Parse the SQL query,
// 2. Execute the query, and 
// 3. Build the initial rowset
HRESULT CMSOmniProvRowset::Execute(DBPARAMS * pParams, DBROWCOUNT* pcRowsAffected)
{
	USES_CONVERSION;
	CMSOmniProvRowset* pT = (CMSOmniProvRowset*) this;
	CMSOmniProvRowset::ObjectLock cab((CMSOmniProvRowset*) this);
	HRESULT hr;

	_bstr_t m_bstrFileName; 
	if ( FAILED(hr=pT->GetDataSource(m_bstrFileName)) )
		return hr;

	// Check the property value whether read/ updatabiliy property is set or not...
	_variant_t varUpd;
	GetPropValue(&DBPROPSET_ROWSET,DBPROP_UPDATABILITY, &varUpd);
	if ( 0 != varUpd.iVal )
	{
		// 1. a) Build the file's Schema m_prgColInfo from the '.sxt' file,
		//     b) Open the file '.txt', and 
		//     c) Fill the m_DBFile.m_Rows structure
		// Open in exclusive mode
		if (!m_DBFile.Open((LPCTSTR) m_bstrFileName,true))
			return DB_E_NOTABLE;
		if (!m_DBFile.FillRowArray()) 
				return E_FAIL;
	}
	else // Open in non-exclusive mode
	{
		if (!m_DBFile.Open((LPCTSTR) m_bstrFileName,false))
			return DB_E_NOTABLE;
		if (!m_DBFile.FillRowArray()) 
				return E_FAIL;
	}

	// Validate Command 
    // 2. PARSE the SQL Query here  (Only SELECT * FROM <Table_Name> is supported)
	TCHAR sep[] = " ";
	_bstr_t bstrSQL(pT->m_strCommandText);
	LPTSTR  pchNextToken = NULL;
	TCHAR * token = _tcstok_s((TCHAR*) bstrSQL, (TCHAR*) sep, &pchNextToken);

	if (!CheckTable((TCHAR*) token)) 
	{
		// The Rowset was created using the ICommand::Execute( )...
		// Only "SELECT * FROM Table_Name"  Queries are supported
		if(_tcsicmp(token,TEXT("select")) != 0)
		{
			ATLTRACE2(atlTraceDBProvider,0,(const TCHAR*) (_bstr_t("Query: '")+ bstrSQL + _bstr_t("' is not a valid Query\n")));
			return DB_E_ERRORSINCOMMAND;
		}
		ATLTRACE2(atlTraceDBProvider,0,(const TCHAR*) (_bstr_t("\tIt is a valid '")+_bstr_t(token) + _bstr_t("' Query\n")));
		
		TCHAR szTblNm[MAX_TABLE_NAME_SIZE];
		while (token != NULL)
		{
			_tcscpy_s(szTblNm, _countof(szTblNm), token);
			token= _tcstok_s(NULL,(TCHAR*) sep, &pchNextToken);
		}
		if (!CheckTable((TCHAR*) szTblNm)) 
			return DB_E_NOTABLE;
	}

	// Allocate proxy buffers based on the schema information 
	// Each CRow contains proxy buffer that the data is trasnferred to in the native 
	// format.  This information then needs to be copied out to the file in character format
	// on SetData() calls.

	CreateColInfo();

	AllocateProxyBuffers();

	if (pcRowsAffected != NULL)
		*pcRowsAffected = m_DBFile.m_Rows.GetCount();

	return S_OK;  
}
Beispiel #8
0
STDMETHODIMP CCUBRIDDataSource::Initialize(void)
{
	ATLTRACE2(atlTraceDBProvider, 2, "CCUBRIDDataSource::Initialize\n");

	// 현재 오류객체를 제거한다.
	ClearError();

	// 연결정보들(ID, 암호등)이 올바른지 확인한다.
	char dbmsver[16];
	{
		int hConn = 0;
		//T_CCI_ERROR error;

		HRESULT hr = Util::Connect(this, &hConn);
		if(FAILED(hr)) return hr;

		char buf[16];
		T_CCI_ERROR error;
		int rc = cci_get_db_version(hConn, buf, sizeof(buf));
		if(rc<0)
		{
			ATLASSERT(rc!=CCI_ER_CON_HANDLE);
			// rc==CCI_ER_CONNECT -> 주소나 포트가 틀림
			// rc==CAS_ER_DBMS -> DB 이름이나 ID, 암호가 틀림

			ATLTRACE2(atlTraceDBProvider, 0, "CCUBRIDDataSource::Initialize : cci_get_db_version failed with rc=%d\n", rc);
			Util::Disconnect(&hConn);

			CComVariant var;
			var = DBPROPVAL_CS_COMMUNICATIONFAILURE;
			SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_CONNECTIONSTATUS, &var);

			return RaiseError(DB_SEC_E_AUTH_FAILED, 0, __uuidof(IDBInitialize), (LPWSTR)0, L"42000");
		}

		//최대 스트링 갯수를 나타내는 데이터베이스 파라메터를 가져온다.
		rc = cci_get_db_parameter(hConn, CCI_PARAM_MAX_STRING_LENGTH, &PARAM_MAX_STRING_LENGTH, &error);
		if (rc < 0)
		{
			Util::Disconnect(&hConn);

			CComVariant var;
			var = DBPROPVAL_CS_COMMUNICATIONFAILURE;
			SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_CONNECTIONSTATUS, &var);

			return RaiseError(E_FAIL, 0, __uuidof(IDBInitialize), error.err_msg);
		}

		Util::Disconnect(&hConn);

		int a=0, b=0, c=0;
		sscanf(buf, "%2d.%2d.%2d", &a, &b, &c);
		sprintf(dbmsver, "%02d.%02d.%04d", a, b, c);
	}

	// ATL의 초기화 루틴을 호출
	{
		HRESULT hr = IDBInitializeImpl<CCUBRIDDataSource>::Initialize();
		if(FAILED(hr)) return hr;
	}

	// set properties
	{
		CComVariant var;
		// 읽기 전용 속성이므로 IDBProperties::SetProperties를 이용할 수 없다.
		// 대신 내부적으로 IDBProperties에 이용된 CUtlProps::SetPropValue를 사용한다.
		// 외부적으론 변경할 수 없지만, 내부적으로 변경할 수 있도록
		// DBPROPFLAGS_CHANGE flag를 추가한다.
		var = dbmsver;
		SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_DBMSVER, &var);

		VariantClear(&var);
		VariantInit(&var);
		var = "2.0.01.004";

		SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_PROVIDERVER, &var);

		GetPropValue(&DBPROPSET_DBINIT, DBPROP_INIT_LOCATION, &var);
		SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_DATASOURCENAME, &var);

		var = DBPROPVAL_CS_INITIALIZED;
		SetPropValue(&DBPROPSET_DATASOURCEINFO, DBPROP_CONNECTIONSTATUS, &var);
		
	}

	return S_OK;
}
Beispiel #9
0
String TPropertyHandler::BuildNameValue(TComponent* comp, String prName)
{
	return prName + "=" + GetPropValue(comp, prName, true);
}