Пример #1
0
LONG CuDlgReplicationServerPageStartupSetting::OnLoad (WPARAM wParam, LPARAM lParam)
{
	LPCTSTR pClass = (LPCTSTR)wParam;
	ASSERT (lstrcmp (pClass, _T("CaReplicationServerDataPageStartupSetting")) == 0);
	CaReplicationServerDataPageStartupSetting* pData = (CaReplicationServerDataPageStartupSetting*)lParam;
	ASSERT (pData);
	if (!pData)
		return 0L;
	CaReplicationItemList* listItems = &(pData->m_listItems);

	try
	{
		// For each column:
		const int LAYOUT_NUMBER = 3;
		for (int i=0; i<LAYOUT_NUMBER; i++)
			m_cListCtrl.SetColumnWidth(i, pData->m_cxHeader.GetAt(i));

		CaReplicationItem* pItem = NULL;
		while (!listItems->IsEmpty())
		{
			pItem = listItems->RemoveHead();
			if (pItem->IsDisplay())
				AddItem (pItem);
			else
				delete pItem;
		}
		m_cListCtrl.SetScrollPos (SB_HORZ, pData->m_scrollPos.cx);
		m_cListCtrl.SetScrollPos (SB_VERT, pData->m_scrollPos.cy);
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	return 0L;
}
Пример #2
0
LONG CuDlgReplicationServerPageStartupSetting::OnUpdateData (WPARAM wParam, LPARAM lParam)
{
	int iret,ires,irestype, nNodeHdl = -1;
	UCHAR DBAUsernameOntarget[MAXOBJECTNAME];
	UCHAR buf[EXTRADATASIZE];
	UCHAR extradata[EXTRADATASIZE];
	LPUCHAR parentstrings [MAXPLEVEL];
	CString cDefNumSvr,cDefDbName,cLocal;
	CString strMsg,strMsg1;

	LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam;
	m_pSvrDta = (LPREPLICSERVERDATAMIN)pUps->pStruct;
	EnableButtons();
	//
	// Specialize the OnUpdateData:
	if (!m_pSvrDta->m_bRefresh)
		return 0L;
	m_pSvrDta->m_bRefresh = FALSE;

	CdIpmDoc* pIpmDoc = NULL;
	CfIpmFrame* pIpmFrame = (CfIpmFrame*)GetParentFrame();
	ASSERT(pIpmFrame);
	if (pIpmFrame)
	{
		pIpmDoc = pIpmFrame->GetIpmDoc();
		ASSERT (pIpmDoc);
	}
	if (!pIpmDoc)
		return 0L;

	nNodeHdl  = LIBMON_OpenNodeStruct (m_pSvrDta->LocalDBNode);
	if (nNodeHdl == -1) {
		strMsg.LoadString(IDS_MAX_NB_CONNECT);  // _T("Maximum number of connections has been reached"
		strMsg1.LoadString (IDS_E_READ_FILE);   //    " - Cannot read file."
		strMsg += _T("\n") + strMsg1;
		MessageBox(strMsg ,NULL, MB_ICONHAND | MB_OK | MB_TASKMODAL);
		return 0L;
	}

	// Temporary for activate a session
	ires = DOMGetFirstObject (nNodeHdl, OT_DATABASE, 0, NULL, FALSE, NULL, buf, NULL, NULL);
	cDefDbName.Format(_T("%s::%s"), m_pSvrDta->LocalDBNode,m_pSvrDta->LocalDBName);
	//
	//Get DBA user name for this database
	parentstrings[0]=m_pSvrDta->LocalDBName;
	parentstrings[1]=NULL;
	memset (DBAUsernameOntarget,'\0',sizeof(DBAUsernameOntarget));
	iret = DOMGetObjectLimitedInfo( nNodeHdl,
	                                parentstrings [0],
	                                (UCHAR *)"",
	                                OT_DATABASE,
	                                0,
	                                parentstrings,
	                                TRUE,
	                                &irestype,
	                                buf,
	                                DBAUsernameOntarget,
	                                extradata
	                              );
	if (iret != RES_SUCCESS) {
		LIBMON_CloseNodeStruct(nNodeHdl);
		//wsprintf((char *)buf,"DBA owner on database : %s not found. Read file aborted.",parentstrings[0]);
		strMsg.Format(IDS_F_DB_OWNER,parentstrings[0]);
		MessageBox(strMsg, NULL, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
		return 0L;
	}
	LIBMON_CloseNodeStruct(nNodeHdl);
	m_csDBAOwner=DBAUsernameOntarget;
	cDefNumSvr.Format(_T("%d"),m_pSvrDta->serverno);
	
	if (m_csDBAOwner.IsEmpty() ||cDefNumSvr.IsEmpty()||cDefDbName.IsEmpty())   {
		return 0L;
	}

	Cleanup();
	m_cListCtrl.DeleteAllItems();

	CString csVnodeAndUsers;
	// Read default flags on "LocalDBNode (user:XXX)"
	csVnodeAndUsers.Format(_T("%s%s%s%s"),  m_pSvrDta->LocalDBNode,
	                                    LPUSERPREFIXINNODENAME,
	                                    (LPCTSTR)m_csDBAOwner,
										LPUSERSUFFIXINNODENAME);
	nNodeHdl  = LIBMON_OpenNodeStruct ((LPUCHAR)(LPCTSTR)csVnodeAndUsers);
	if (nNodeHdl == -1) {
		strMsg.LoadString (IDS_MAX_NB_CONNECT);  // _T("Maximum number of connections has been reached"
		strMsg1.LoadString (IDS_E_READ_FILE);    //    " - Cannot read file."
		strMsg +=  _T("\n") + strMsg1;
		MessageBox(strMsg ,NULL, MB_ICONHAND | MB_OK | MB_TASKMODAL);
		return 0L;
	}
	memset (DBAUsernameOntarget,'\0',sizeof(DBAUsernameOntarget));
	iret = DOMGetObjectLimitedInfo( nNodeHdl,
	                                parentstrings [0],
	                                (UCHAR *)"",
	                                OT_DATABASE,
	                                0,
	                                parentstrings,
	                                TRUE,
	                                &irestype,
	                                buf,
	                                DBAUsernameOntarget,
	                                extradata
	                              );
	if (iret != RES_SUCCESS) {
		LIBMON_CloseNodeStruct(nNodeHdl);
		//wsprintf((char *)buf,"DBA owner on database : %s not found. Read file aborted.",parentstrings[0]);
		strMsg.Format(IDS_F_DB_OWNER,parentstrings[0]);
		MessageBox(strMsg, NULL, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
		return 0L;
	}
	m_FlagsList.DefineAllFlagsWithDefaultValues(nNodeHdl , cDefNumSvr, cDefDbName, m_csDBAOwner);
	LIBMON_CloseNodeStruct(nNodeHdl);

	// Read Runrepl.opt from "LocalDBNode (user:XXX)" or From "RunNode"
	if (lstrcmp((char *)m_pSvrDta->LocalDBNode,(char *)m_pSvrDta->RunNode) == 0)
		csVnodeAndUsers.Format(_T("%s%s%s%s"), m_pSvrDta->LocalDBNode,
		                                   LPUSERPREFIXINNODENAME,
		                                   (LPCTSTR)m_csDBAOwner,
										   LPUSERSUFFIXINNODENAME);
	else
		csVnodeAndUsers = m_pSvrDta->RunNode;
	nNodeHdl  = LIBMON_OpenNodeStruct ((LPUCHAR)(LPCTSTR)csVnodeAndUsers);
	if (nNodeHdl == -1) {
		strMsg.LoadString(IDS_MAX_NB_CONNECT);  // _T("Maximum number of connections has been reached"
		strMsg1.LoadString (IDS_E_READ_FILE);   //    " - Cannot read file."
		strMsg += _T("\n") + strMsg1;
		MessageBox(strMsg ,NULL, MB_ICONHAND | MB_OK | MB_TASKMODAL);
		return 0L;
	}

	CWaitCursor hourglass;
	// Read file Runrepl.opt and fill m_FlagsList.
	iret = GetReplicServerParams   ( pIpmDoc, m_pSvrDta, &m_FlagsList );
	
	LIBMON_CloseNodeStruct (nNodeHdl);
	CaReplicationItem* pItem = NULL;
	while (!m_FlagsList.IsEmpty())
	{
		pItem = m_FlagsList.RemoveHead();
		if (pItem->IsDisplay())
			AddItem (pItem);
		else
			delete pItem;
	}

	EnableButtons();
	return 0L;
}