Esempio n. 1
0
void CuSdaCtrl::StoreSchema(LPCTSTR lpszNode, LPCTSTR lpszDatabase, LPCTSTR lpszUser, LPCTSTR lpszFile) 
{
	CaVsdStoreSchema* pStoreSchema = new CaVsdStoreSchema(&(theApp.m_sessionManager), lpszFile, lpszNode, lpszDatabase, lpszUser);
	pStoreSchema->SetFetchObjects(CaLLQueryInfo::FETCH_USER);
	CaExecParamInstallation* p = new CaExecParamInstallation(pStoreSchema);
	CString strDirException;
	strDirException.Empty();
	CString strDir = lpszFile;
	strDir = strDir.Left(strDir.ReverseFind('\\'));
	if(_access(strDir.GetBuffer(strDir.GetLength()),0) == -1)
	{
		//Invalid directory
		CFileException e;
		e.m_cause = CFileException::badPath;
		MSGBOX_FileExceptionMessage (&e, strDirException);
	}

	CString strMsgAnimateTitle = _T("Saving...");
	if (pStoreSchema->GetDatabase().IsEmpty())
		strMsgAnimateTitle.LoadString(IDS_TITLE_STORE_INSTALLATION);
	else
		strMsgAnimateTitle.LoadString(IDS_TITLE_STORE_DATABASE_SCHEMA);
#if defined (_ANIMATION_)
	CxDlgWait dlg (strMsgAnimateTitle);
	dlg.SetUseAnimateAvi(AVI_FETCHF);
	dlg.SetExecParam (p);
	dlg.SetDeleteParam(FALSE);
	dlg.SetShowProgressBar(FALSE);
	dlg.SetUseExtraInfo();
	dlg.SetHideCancelBottonAlways(TRUE);
	dlg.DoModal();
#else
	p->Run();
#endif
	CString strError = p->GetFailMessage();
	if(!strDirException.IsEmpty())
	{
		strError += consttchszReturn;
		strError += strDirException;
	}
	delete p;

	if (!strError.IsEmpty())
	{
		AfxMessageBox (strError);
	}
}
Esempio n. 2
0
//
// wParam = CHECK_CONFIRM_CHOICE (Update the control m_cCheckConfirmChoice. lParam = 0|1)
// wParam = 0 (General, lParam = address of class CaIIAInfo)
LONG CuDlgPageCsv::OnUpdateData (WPARAM wParam, LPARAM lParam)
{
	int nMode = (int)wParam;
	if (nMode == CHECK_CONFIRM_CHOICE)
	{
		int nCheck = (int)lParam;
		m_cCheckConfirmChoice.SetCheck (nCheck);
		return 0;
	}

	ASSERT (m_pData);
	ASSERT (m_pSeparatorSet);
	if (!(m_pData && m_pSeparatorSet))
		return 0;

	CaDataPage1& dataPage1 = m_pData->m_dataPage1;
	CaDataPage2& dataPage2 = m_pData->m_dataPage2;
	CPtrArray& arrayRecord = dataPage2.GetArrayRecord();
	int i, nSize = arrayRecord.GetSize();
	for (i=0; i<nSize; i++)
	{
		CaRecord* pRec = (CaRecord*)arrayRecord.GetAt(i);
		delete pRec;
	}
	arrayRecord.RemoveAll();
	m_listCtrlHuge.ResizeToFit();

	CaExecParamQueryRecords* p = new CaExecParamQueryRecords(m_pData, m_pSeparatorSet, &m_nCoumnCount);
#if defined (_ANIMATION_)
	CString strMsgAnimateTitle;
	strMsgAnimateTitle.LoadString(IDS_ANIMATE_TITLE_QUERYING);
	CxDlgWait dlg (strMsgAnimateTitle);
	dlg.SetUseAnimateAvi(AVI_CLOCK);
	dlg.SetExecParam (p);
	dlg.SetDeleteParam(FALSE);
	dlg.SetShowProgressBar(TRUE);
	dlg.SetUseExtraInfo();
	dlg.DoModal();
#else
	p->Run();
	p->OnTerminate(m_hWnd);
#endif
	delete p;
	SetForegroundWindow ();

	m_bFirstUpdate = FALSE;
	//
	// Display the separator:
	DisplaySeparatorSetInfo(m_pSeparatorSet, m_pSeparator);

	//
	// Initialize headers:
	CString strHeader;
	if (m_nCoumnCount > 0)
	{
		LSCTRLHEADERPARAMS* pLsp = new LSCTRLHEADERPARAMS[m_nCoumnCount];
		CStringArray arrayHeader;
		BOOL bFirstLineAsHeader = GenerateHeader(dataPage1, m_pSeparatorSet, m_pSeparator, m_nCoumnCount, arrayHeader);
		for (i=0; i<m_nCoumnCount; i++)
		{
			if (bFirstLineAsHeader)
				strHeader = arrayHeader.GetAt(i);
			else
				strHeader.Format(_T("col%d"), i+1);

#if defined (MAXLENGTH_AND_EFFECTIVE)
			int& nFieldMax = dataPage2.GetFieldSizeMax(i);
			int& nFieldEff = dataPage2.GetFieldSizeEffectiveMax(i);
			//if (nFieldEff < nFieldMax)
			//	strHeader.Format(_T("col%d (%d+%d)"), i+1, nFieldEff, nFieldMax-nFieldEff);
			//else
			CString strSize;
			strSize.Format(_T(" (%d)"), nFieldMax);
			strHeader += strSize;
#endif
			pLsp[i].m_fmt = LVCFMT_LEFT;
			if (strHeader.GetLength() > MAXLSCTRL_HEADERLENGTH)
				lstrcpyn (pLsp[i].m_tchszHeader, strHeader, MAXLSCTRL_HEADERLENGTH);
			else
				lstrcpy  (pLsp[i].m_tchszHeader, strHeader);
			pLsp[i].m_cxWidth= 100;
			pLsp[i].m_bUseCheckMark = FALSE;
		}

		m_listCtrlHuge.InitializeHeader(pLsp, m_nCoumnCount);
		m_listCtrlHuge.SetDisplayFunction(DisplayListCtrlHugeItem, NULL);
		m_listCtrlHuge.SetSharedData (&arrayRecord);
		delete pLsp;
	}

	//
	// Display the new records:
	m_listCtrlHuge.ResizeToFit();

	//If one tab displays for import format, then just check 
	//the tab checkbox automatically
	CTabCtrl *cTab = (CTabCtrl *) this->GetParent();
	int size = cTab->GetItemCount();
	if (cTab->GetItemCount()==1)
		m_cCheckConfirmChoice.SetCheck(TRUE);

	return TRUE;
}