示例#1
0
BOOL CdIpmDoc::Initiate(LPCTSTR lpszNode, LPCTSTR lpszServerClass, LPCTSTR lpszUser, LPCTSTR lpszOption)
{
	try
	{
		m_connectedInfo.SetNode(lpszNode);
		if (lpszServerClass)
			m_connectedInfo.SetServerClass(lpszServerClass);
		if (lpszUser)
			m_connectedInfo.SetUser(lpszUser);

		BOOL bOK = IPM_Initiate(this);
		if (bOK)
		{
			// 
			// LPARAM = 1 (Instruct the view that the function initiate has been invoked)
			UpdateAllViews(NULL, (LPARAM)1);
			m_bInitiate = TRUE;
			//
			// Create a Thread that periodically scans the DBEvents in order to
			// update the tree and the right pane:
			if (!m_pThreadScanDBEvents)
			{
				CTreeCtrl* pTree = m_pTreeGD->GetPTree();
				ASSERT (pTree);
				if (pTree)
				{
					CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame();
					m_ThreadParam.hWndFrame = pIpmFrame? pIpmFrame->m_hWnd: NULL;
				}
				m_ThreadParam.hEvent  = m_hEventRaisedDBEvents;
				m_ThreadParam.pIpmDoc = this;

				m_pThreadScanDBEvents = AfxBeginThread(
					(AFX_THREADPROC)ThreadControlScanDBEvents, 
					&m_ThreadParam, 
					THREAD_PRIORITY_NORMAL,
					0,
					CREATE_SUSPENDED);
				if (m_pThreadScanDBEvents)
					ResumeThread(m_pThreadScanDBEvents->m_hThread);
			}
		}
		return bOK;
	}
	catch (CeIpmException e)
	{
		AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK);
	}
	catch (...)
	{
		TRACE0("Exception in: CdIpmDoc::Initiate\n");
	}
	return FALSE;
}
示例#2
0
void CdIpmDoc::SearchItem()
{
	CTreeCtrl* pTree = m_pTreeGD->GetPTree();
	ASSERT (pTree);
	if (!pTree)
		return;
	CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame();
	CvIpmLeft* pView = (CvIpmLeft*)pIpmFrame->GetLeftPane();
	if (!pView)
		return;
	pView->SearchItem();
}
示例#3
0
void CdIpmDoc::ProhibitActionOnTreeCtrl(BOOL bProhibit)
{
	CTreeCtrl* pTree = m_pTreeGD->GetPTree();
	ASSERT (pTree);
	if (!pTree)
		return;
	CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame();
	CvIpmLeft* pView = (CvIpmLeft*)pIpmFrame->GetLeftPane();
	if (!pView)
		return;
	pView->ProhibitActionOnTreeCtrl(bProhibit);
}
示例#4
0
BOOL CdIpmDoc::UpdateDisplay()
{
	TRACE0("CdIpmDoc::UpdateDisplay()\n");
	try
	{
		m_pTreeGD->RefreshAllTreeBranches(); // refresh left pane
		
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof (ups));
		CTreeItem* pItem = NULL;
		CTreeCtrl* pTree = m_pTreeGD->GetPTree();
		ASSERT (pTree);
		HTREEITEM hSelectedItem = pTree->GetSelectedItem();
		if (!hSelectedItem)
			return FALSE;
		pItem = (CTreeItem*)pTree->GetItemData(hSelectedItem);
		ASSERT (pItem);
		if (pItem->IsNoItem() || pItem->IsErrorItem())
		{
			m_pTabDialog->DisplayPage (NULL);
		}
		else 
		if (pItem->ItemDisplaysNoPage()) 
		{
			CString caption = pItem->ItemNoPageCaption();
			m_pTabDialog->DisplayPage (NULL, caption);
		}
		else 
		{
			int nImage = -1, nSelectedImage = -1;
			CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL);
			HICON hIcon = NULL;
			int nImageCount = pImageList? pImageList->GetImageCount(): 0;
			if (pImageList && pTree->GetItemImage(hSelectedItem, nImage, nSelectedImage))
			{
				if (nImage < nImageCount)
					hIcon = pImageList->ExtractIcon(nImage);
			}
			CuPageInformation* pPageInfo = pItem->GetPageInformation();
			CString strItem = pItem->GetRightPaneTitle();

			ups.nType   = pItem->GetType();
			ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL;
			ups.pSFilter= m_pTreeGD->GetPSFilter();
			pPageInfo->SetUpdateParam (&ups);
			pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, this);

			pPageInfo->SetImage  (hIcon);
			m_pTabDialog->DisplayPage (pPageInfo);
		}

		// Replicator Monitor special management
		// ASSUMES we did not change the current item!
		BOOL bReplMonWasOn = (m_hReplMonHandle != -1) ? TRUE: FALSE;
		BOOL bReplMonToBeOn = pItem->HasReplicMonitor();
		// 3 cases :
		//    - on to off ---> replicator has been uninstalled
		//    - off to on ---> replicator has been installed
		//    - on to on, or off to off: state has not changed
		if (bReplMonWasOn && !bReplMonToBeOn) 
		{
			BOOL bOK = TerminateReplicator();
			ASSERT (bOK);
		}
		else 
		if (!bReplMonWasOn && bReplMonToBeOn)
		{
			CString csDbName = pItem->GetDBName();
			BOOL bOK = InitializeReplicator(csDbName);
			ASSERT (bOK);
		}
		//
		// Refresh right pane
		CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame();
		UpdateAllViews((CView *)pIpmFrame->GetLeftPane());
	}
	catch(CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
		return FALSE;
	}
	catch(CResourceException* e)
	{
		//_T("Cannot load dialog box");
		AfxMessageBox (IDS_E_LOAD_DLG);
		e->Delete();
		return FALSE;
	}
	catch(...)
	{
		//_T("Cannot construct the property pane");
		AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY);
		return FALSE;
	}

	return TRUE;
}