Esempio n. 1
0
void CaReplicationItemList::VerifyValueForFlag()
{
	POSITION pos = GetHeadPosition();
	BOOL bDefault;
	int answ;
	CString Tempo,strValue,strErrorMsg,strDefault;
	while (pos != NULL) {

		CaReplicationItem* obj = GetNext(pos);
		Tempo = obj->GetFlagContent( bDefault );
		strDefault = obj->GetDefaultValue();
		if (Tempo.IsEmpty() == TRUE && ( obj->IsMandatory () || obj->IsDefaultMandatoryInFile())) {
			//"%s (mandatory) parameter not found in runrepl.opt. Will be set to Default."
			strErrorMsg.Format(IDS_F_REP_FLAG_DEFAULT,(LPCTSTR)obj->GetFlagName());
			AfxMessageBox(strErrorMsg, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
			strValue = obj->GetDefaultValue();
			obj->SetFlagContent(strValue);
			obj->SetValueModifyByUser(TRUE);
		}
		if ( obj->IsReadOnlyFlag() && Tempo.Compare(strDefault) !=0 && ( obj->IsMandatory () || obj->IsDefaultMandatoryInFile()))    {
			//"Inconsistent value for %s parameter.\n"
			//"Value in runrepl.opt file  : %s\n"
			//"Required Value : %s\n"
			//"Apply required value?"
			strErrorMsg.Format(
				IDS_F_REP_FLAG_INCONSISTENT, 
				(LPCTSTR)obj->GetDescription(),
				(LPCTSTR)Tempo,
				(LPCTSTR)strDefault);
			answ = AfxMessageBox(strErrorMsg, MB_ICONEXCLAMATION | MB_YESNO | MB_TASKMODAL);
			if ( answ == IDYES ){
				strValue = obj->GetDefaultValue();
				obj->SetFlagContent(strValue);
				obj->SetValueModifyByUser(TRUE);
			}
			else {
				// remove all flags in the list, no modication available.
				MyRemoveAll();
				return;
			}
		}
	}
}
Esempio n. 2
0
int SetReplicServerParams (CdIpmDoc* pIpmDoc, LPREPLICSERVERDATAMIN lpReplicServerDta , CaReplicationItemList *pList )
{
	TCHAR  tchszCommandLine[200];
	TCHAR* tchszCurLine;
	CString LocalDBNameOnServerNode;
	int ires;
	CString InputString=_T("");

	CString strVName = lpReplicServerDta->RunNode;
	// Verify if vnode name exist before start the remote command.
	VerifyAndUpdateVnodeName (&strVName);
	if (strVName.IsEmpty())
		return RES_ERR;

	GenerateVnodeName_DbName (lpReplicServerDta ,&LocalDBNameOnServerNode);
	_stprintf(tchszCommandLine, _T("ddstoref %s %d"), (LPTSTR)(LPCTSTR) LocalDBNameOnServerNode, lpReplicServerDta->serverno);

	// generate input to be sent to rmcmd
	CString strFormatFlag;
	CString strContent;
	BOOL bDefaultValue;
	POSITION pos;

	pos = pList->GetHeadPosition();
	while (pos != NULL) {
		CaReplicationItem* obj = pList->GetNext(pos);
		strFormatFlag.Empty();
		strContent = obj->GetFlagContent(bDefaultValue);
		if ( obj->IsMandatory() || obj->IsDefaultMandatoryInFile() ) {
			if (obj->GetType() != CaReplicationItem::REP_BOOLEAN)
				if (!strContent.IsEmpty())
					strFormatFlag = obj->GetFlagName() + strContent;
				else {
					CString csError;
					csError.Format(IDS_F_NO_VALUE,(LPCTSTR)obj->GetFlagName());//"Flag %s has no value and is not used."
					AfxMessageBox(csError, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
				}
			else {
				if ( strContent.Compare(_T("TRUE")) == 0)
					strFormatFlag = obj->GetFlagName();
			}
		}
		else {
			if ( bDefaultValue == FALSE) {
				if (obj->GetType() != CaReplicationItem::REP_BOOLEAN) {
					if ( !strContent.IsEmpty() )
						strFormatFlag = obj->GetFlagName() + strContent;
				}
				else {
					if ( strContent.Compare(_T("TRUE")) == 0)
						strFormatFlag = obj->GetFlagName();
					if (strFormatFlag.Compare(_T("-TPC")) == 0)
						strFormatFlag += _T("0"); // Two phase commit is turned off.
				}
			}
		}
		if (!strFormatFlag.IsEmpty())
			InputString += (strFormatFlag + _T("\n"));
		}
	/* empty line in order to stop the ddstoref command*/
	InputString += _T("\n");

	ires=RES_SUCCESS;
	if (!LIBMON_ExecRmcmdInBackground((TCHAR *)lpReplicServerDta->RunNode, tchszCommandLine, (LPTSTR)(LPCTSTR)InputString)) {
		ires=RES_ERR;
	}
	// display error message lines (starting with a '*' character) from output
	for (tchszCurLine=LIBMON_GetFirstTraceLine();tchszCurLine;tchszCurLine = LIBMON_GetNextSignificantTraceLine()) {
		if (tchszCurLine[0]==_T('*')) {
			tchszCurLine++;
			AfxMessageBox(tchszCurLine, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
				ires=RES_ERR;
		}
	}
	return ires;
}