Exemple #1
0
VOID
CAdvancedPage::OnDeactivateDevice(UINT uCode, int nCtrlID, HWND hwndCtrl)
{
	ATLASSERT(NULL != m_pDevice);

	CString strMessage, strTitle;
	BOOL fSuccess = strMessage.LoadString(IDS_CONFIRM_DEACTIVATE_DEVICE);
	ATLASSERT(fSuccess);

	strTitle.LoadString(IDS_MAIN_TITLE);
	ATLASSERT(fSuccess);

	INT_PTR iResponse = MessageBox(
		strMessage, 
		strTitle, 
		MB_YESNO | MB_ICONQUESTION);

	if (IDYES != iResponse) {
		return;
	}

	fSuccess = m_pDevice->Enable(FALSE);
	if (!fSuccess) {
		ShowErrorMessageBox(IDS_ERROR_DISABLE_DEVICE);
	}

	m_wndDeactivate.EnableWindow(FALSE);
	m_wndReset.EnableWindow(FALSE);
}
Exemple #2
0
void CRecoverDlg::Start()
{
	WTL::CString strBtnFace;

	//
	// Launch working thread
	//
	m_btnOK.EnableWindow(FALSE);

	strBtnFace.LoadString( IDS_RECOVER_BTN_CANCEL );
	m_btnCancel.SetWindowText( strBtnFace );
	m_btnCancel.EnableWindow(FALSE);

	m_bRunning = TRUE;

	HANDLE hThread;
	hThread = CreateThread(
		NULL,
		0,
		ThreadRecover,
		this,
		NULL, // run immediately
		NULL);

	if(!hThread)
	{
		WTL::CString strMsg = _T("");
		ShowErrorMessageBox(strMsg);

		strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE );
		m_btnCancel.SetWindowText( strBtnFace );
		m_bRunning = FALSE;
		m_bFinished = TRUE;
	}
}
Exemple #3
0
void CMainFrame::OnSpareAdd(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
		return;

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SPARE_ADD_DLG_CAPTION, 
		IDS_SPARE_ADD_DLG_MESSAGE, 
		GetOperatableSingleDevices(), 
		1, 
		CheckCapacityForSpare, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	CNBUnitDevice *pUnitDevice = dlgSelectDevice.GetSelectedDevice();

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ci, ci_spare;
	(*pLogicalDevice)[0]->InitConnectionInfo(&ci, TRUE);
	pUnitDevice->InitConnectionInfo(&ci_spare, TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResults = NdasOpSpareAdd(
		&ci, &ci_spare);
	l_auto_cursor.Release();

	pLogicalDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Exemple #4
0
void CGeneralPage::OnModifyWriteKey(UINT, int, HWND)
{
	ACCESS_MASK access = m_pDevice->GetGrantedAccess();
	if (access & GENERIC_WRITE) {

		INT_PTR iResult = pShowMessageBox(
			IDS_REMOVE_WRITE_KEY_CONFIRM,
			IDS_REMOVE_WRITE_KEY_CONFIRM_TITLE,
			m_hWnd,
			_T("DontConfirmRemoveWriteKey"),
			IDNO,
			IDYES);

		if (IDYES == iResult) {
			BOOL fSuccess = m_pDevice->SetAsReadOnly();
			if (!fSuccess) {
				ShowErrorMessageBox(IDS_ERROR_REMOVE_WRITE_KEY);
			} else {
				UpdateData();
			}
		}
	} else {

		CAddWriteKeyDlg dlg;
		dlg.SetDeviceId(m_pDevice->GetStringId());
		dlg.SetDeviceName(m_pDevice->GetName());
		INT_PTR iResult = dlg.DoModal();

		ATLTRACE(_T("iResult = %d\n"), iResult);

		if (iResult == IDOK) {
			BOOL fSuccess = m_pDevice->SetAsReadWrite(dlg.GetWriteKey());
			if (!fSuccess) {
				ShowErrorMessageBox(IDS_ERROR_ADD_WRITE_KEY);
			} else {
				UpdateData();
			}
		} else {
			;
		}
	}
}
Exemple #5
0
void CMainFrame::OnSpareRemove(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBUnitDevice *pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
	if(!pUnitDevice || !pUnitDevice->GetLogicalDevice()->IsOperatableAll())
		return;

	NBUnitDevicePtrList listUnitDevices;
	listUnitDevices.push_back(pUnitDevice);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SPARE_REMOVE_DLG_CAPTION, 
		IDS_SPARE_REMOVE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO ci;
	pUnitDevice->InitConnectionInfo(&ci, TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResults = NdasOpSpareRemove(&ci);
	l_auto_cursor.Release();

	pUnitDevice->GetLogicalDevice()->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Exemple #6
0
INT_PTR ShowErrorMessageBox(
	UINT uMessageID, UINT uTitleID, HWND hWnd, DWORD dwError)
{
	WTL::CString strMessage, strTitle;

	BOOL fSuccess = strMessage.LoadString(uMessageID);
	ATLASSERT(fSuccess);

	if (0 != uTitleID) {

		fSuccess = strTitle.LoadString(uTitleID);
		ATLASSERT(fSuccess);

		return ShowErrorMessageBox(strMessage,strTitle,hWnd,dwError);

	} else {

		return ShowErrorMessageBox(strMessage,NULL,hWnd,dwError);

	}
}
Exemple #7
0
VOID
CAdvancedPage::OnResetDevice(UINT uCode, int nCtrlID, HWND hwndCtrl)
{
	ATLASSERT(NULL != m_pDevice);

	CString strMessage, strTitle;
	BOOL fSuccess = strMessage.LoadString(IDS_CONFIRM_RESET_DEVICE);
	ATLASSERT(fSuccess);

	strTitle.LoadString(IDS_MAIN_TITLE);
	ATLASSERT(fSuccess);

	INT_PTR iResponse = MessageBox(
		strMessage, 
		strTitle, 
		MB_YESNO | MB_ICONQUESTION);

	if (IDYES != iResponse) {
		return;
	}

	fSuccess = m_pDevice->Enable(FALSE);
	if (!fSuccess) {
		ShowErrorMessageBox(IDS_ERROR_RESET_DEVICE);
		return;
	}

	::Sleep(2000);

	fSuccess = m_pDevice->Enable(TRUE);
	if (!fSuccess) {
		ShowErrorMessageBox(IDS_ERROR_RESET_DEVICE);
	}

	::PostMessage(GetParent(), IDCLOSE, 0, 0);
}
Exemple #8
0
void 
CGeneralPage::OnRename(UINT, int, HWND)
{
	CRenameDialog wndRename;
	wndRename.SetName(m_pDevice->GetName());
	INT_PTR iResult = wndRename.DoModal();

	if (IDOK == iResult) {
		CString strNewName = wndRename.GetName();
		if (0 != strNewName.Compare(m_pDevice->GetName())) {

			BOOL fSuccess = m_pDevice->SetName(strNewName);
			if (!fSuccess) {
				ShowErrorMessageBox(IDS_ERROR_RENAME_DEVICE);
			} else {
				m_edtDevName.SetWindowText(strNewName);
				UpdateData();
			}
		}
	}
}
Exemple #9
0
DWORD WINAPI ThreadRecover( LPVOID lpParam ) 
{ 
	CRecoverDlg *pDlgRecover = (CRecoverDlg *)lpParam;
	BOOL bResults;

	NDAS_CONNECTION_INFO ConnectionInfo;
	ConnectionInfo.bWriteAccess = TRUE;
	ConnectionInfo.type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
	ConnectionInfo.UnitNo = pDlgRecover->m_pDevice->GetLocation()->GetUnitDiskLocation()->UnitNumber;;
	ConnectionInfo.protocol = IPPROTO_LPXTCP;
	ConnectionInfo.ui64OEMCode = 0;
	CopyMemory(ConnectionInfo.MacAddress, 
		pDlgRecover->m_pDevice->GetLocation()->GetUnitDiskLocation()->MACAddr, sizeof(ConnectionInfo.MacAddress));
	
	bResults = NdasOpRecover(&ConnectionInfo, CallBackRecover, lpParam);

	if(!bResults)
	{
		ShowErrorMessageBox(IDS_RECOVERDLG_FAIL);
	}

	ExitThread(0);
	return 0; 
} 
Exemple #10
0
void CMainFrame::OnMigrate(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	if (NMT_MIRROR != pLogicalDevice->GetType() &&
		NMT_RAID1 != pLogicalDevice->GetType() &&
		NMT_RAID4 != pLogicalDevice->GetType())
		return;

	// warning message
	CString strMsg;

	NBUnitDevicePtrList listUnitDevices = pLogicalDevice->GetOperatableDevices();
	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_MIGRATE_DLG_CAPTION, 
		IDS_MIGRATE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO *ci = new NDASCOMM_CONNECTION_INFO[listUnitDevices.size()];

	UINT32 i = 0;

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->InitConnectionInfo(&ci[i], TRUE);
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResult = NdasOpMigrate(&ci[0]);
	l_auto_cursor.Release();

	DWORD dwLastError = ::GetLastError();

	if(!bResult)
	{
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
	}

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->HixChangeNotify(pGetNdasHostGuid());
	}

	delete [] ci;

	OnRefreshStatus(NULL, NULL, NULL);

	return;
}
Exemple #11
0
void CMainFrame::OnAddMirror(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice || pLogicalDevice->IsGroup())
		return;

	NBUnitDevicePtrList listUnitDevices = GetOperatableSingleDevices();
	// remove self
	listUnitDevices.remove((*pLogicalDevice)[0]);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_MIRROR_ADD_DLG_CAPTION, 
		IDS_MIRROR_ADD_DLG_MESSAGE, 
		listUnitDevices, 
		1, 
		CheckCapacityForMirror, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	CNBUnitDevice *pUnitDeviceAdd = dlgSelectDevice.GetSelectedDevice();
	CNBUnitDevice *pUnitDevice = pUnitDevice = (*pLogicalDevice)[0];

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ConnectionInfo[2];
	pUnitDevice->InitConnectionInfo(&ConnectionInfo[0], TRUE);
	pUnitDeviceAdd->InitConnectionInfo(&ConnectionInfo[1], TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(
		2,
		ConnectionInfo,
		NMT_SAFE_RAID1,
		0);
	l_auto_cursor.Release();

	if(2 != BindResult)
	{


		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, 
				(BindResult == 0) ? pUnitDevice->GetName() : pUnitDeviceAdd->GetName());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);

		return;
	}

	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDeviceAdd->HixChangeNotify(pGetNdasHostGuid());

/*
	CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_ADD_MIRROR);

	ATLASSERT(FALSE);
//		dlgRecover.SetMemberDevice(pUnitDeviceAdd);
	dlgRecover.DoModal();
*/

	OnRefreshStatus(NULL, NULL, NULL);
}
Exemple #12
0
void CMainFrame::OnReplaceUnitDevice(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	// find the missing device

	CNBLogicalDevice *pLogicalDeviceReplace = NULL;
	CNBUnitDevice *pUnitDeviceReplace = NULL;
	NBUnitDevicePtrList listUnitDevicesReplace;
	NBLogicalDevicePtrList::iterator itLogicalDevice;
	for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++)
	{
		if(!(*pLogicalDevice)[i])
		{
			for(itLogicalDevice = m_listLogicalDevices.begin(); 
				itLogicalDevice != m_listLogicalDevices.end(); 
				++itLogicalDevice)
			{
				pLogicalDeviceReplace = *itLogicalDevice;
				if(pLogicalDeviceReplace)
				{
					if (pLogicalDeviceReplace->IsHDD() &&
						!pLogicalDeviceReplace->IsGroup() &&
						pLogicalDeviceReplace->IsOperatable())
					{
						pUnitDeviceReplace = (*pLogicalDeviceReplace)[0];
						if (pUnitDeviceReplace->IsThis(
							pLogicalDevice->DIB()->UnitDisks[i].MACAddr,
							pLogicalDevice->DIB()->UnitDisks[i].UnitNumber))
						{
							// ok we found replacable HDD
							listUnitDevicesReplace.push_back(pUnitDeviceReplace);

						}
					}
				}
			}
		}
	}

	if(!listUnitDevicesReplace.size())
		return;

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_REPLACE_UNIT_DEVICE_DLG_CAPTION, 
		IDS_REPLACE_UNIT_DEVICE_DLG_MESSAGE, 
		listUnitDevicesReplace, 
		0, 
		CheckCapacityForSpare, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	// dlgSelectDevice is not selective dialog. get unit device from listUnitDevicesReplace
	CNBUnitDevice *pUnitDevice = *(listUnitDevicesReplace.begin());

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ci, ci_replace;
	pLogicalDevice->InitConnectionInfo(&ci, TRUE); // use write access. this function does not support run time replace yet.
	pUnitDevice->InitConnectionInfo(&ci_replace, TRUE);

	for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++)
	{
		if (!(*pLogicalDevice)[i])
		{
			break;
		}
	}

	if(pLogicalDevice->DevicesTotal() == i)
	{
		// failed to find missing device
		return;
	}

	AutoCursor l_auto_cursor(IDC_WAIT);

	BOOL bResults = NdasOpReplaceUnitDevice(
		&ci, &ci_replace, i);
	l_auto_cursor.Release();

	pLogicalDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Exemple #13
0
void CMainFrame::OnRepair(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
#ifdef __NEVER_DEFINED__
	BOOL bResults;
	BOOL bReturn = FALSE;

	int iItemSelected = m_viewTreeList.GetSelectedItemData();
	if (-1 == iItemSelected)
	{
		
		return;
	}
	
	CDiskObjectPtr obj = m_mapObject[iItemSelected];


	if( dynamic_cast<CDiskObjectComposite *>(obj.get()) == NULL )
	{
		
		return;
	}

	CDiskObjectCompositePtr DiskObjectComposite =
		boost::dynamic_pointer_cast<CDiskObjectComposite>(obj);

	if(!((NMT_RAID1 == DiskObjectComposite->GetNDASMediaType() ||
		NMT_RAID4 == DiskObjectComposite->GetNDASMediaType()) &&
		1 == DiskObjectComposite->GetMissingMemberCount()))
	{
		
		// TODO : No disk is available
		CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NOT_READY_REPAIR );
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONERROR
			);
		return;
	}		


	CSelectDiskDlg dlgSelect(IDD_REPAIR);
	CDiskObjectList singleDisks;
	CFindIfVisitor<FALSE> singleDiskFinder;
	singleDisks = singleDiskFinder.FindIf(m_pRoot, IsWritableUnitDisk);

	if ( singleDisks.size() == 0 )
	{
		
		// TODO : No disk is available
		CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NO_DISK_REPAIR );
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	dlgSelect.SetSingleDisks(singleDisks);

	if ( dlgSelect.DoModal() != IDOK )
		return;

	CUnitDiskObjectPtr replaceDisk, sourceDisk;
	sourceDisk = DiskObjectComposite->GetAvailableUnitDisk();
	replaceDisk = dlgSelect.GetSelectedDisk();

	if(NULL == sourceDisk.get())
		return;
	
	NDASCOMM_CONNECTION_INFO ci, ciReplace;

	ZeroMemory(&ci, sizeof(NDASCOMM_CONNECTION_INFO));
	ci.Size = sizeof(NDASCOMM_CONNECTION_INFO);
	ci.AddressType = NDASCOMM_CIT_DEVICE_ID;
	ci.LoginType = NDASCOMM_LOGIN_TYPE_NORMAL;
	ci.UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ci.WriteAccess = TRUE;
	ci.Protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(
		ci.DeviceId.Node, 
		sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		sizeof(ci.DeviceId.Node));

	ZeroMemory(&ciReplace, sizeof(NDASCOMM_CONNECTION_INFO));
	ciReplace.Size = sizeof(NDASCOMM_CONNECTION_INFO);
	ciReplace.AddressType = NDASCOMM_CIT_DEVICE_ID;
	ciReplace.LoginType = NDASCOMM_LOGIN_TYPE_NORMAL;
	ciReplace.UnitNo = replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ciReplace.WriteAccess = TRUE;
	ciReplace.Protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(
		ciReplace.DeviceId.Node,
		replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		sizeof(ciReplace.DeviceId.Node));

	AutoCursor l_auto_cursor(IDC_WAIT);
	bResults = NdasOpRepair(&ci, &ciReplace);
	l_auto_cursor.Release();

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();
		strMsg.LoadString(IDS_REPAIR_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		CUnitDiskObjectPtr UnitDiskObjectPtr;
		NDAS_UNITDEVICE_ID unitDeviceId;

		CDiskObjectComposite::const_iterator itr;
		for ( itr = DiskObjectComposite->begin(); itr != DiskObjectComposite->end(); ++itr )
		{
			if((dynamic_cast<CEmptyDiskObject*>((*itr).get()) != NULL))
				continue;

			UnitDiskObjectPtr = 
				boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

			CopyMemory(unitDeviceId.DeviceId.Node, 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}

		CopyMemory(unitDeviceId.DeviceId.Node, 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		HixChangeNotify.Notify(unitDeviceId);
	}


	CRecoverDlg dlgRecover(
		TRUE, 
        (NMT_RAID1 == DiskObjectComposite->GetNDASMediaType()) ?
		IDS_LOGDEV_TYPE_DISK_RAID1 : IDS_LOGDEV_TYPE_DISK_RAID4,
		IDS_RECOVERDLG_TASK_REPAIR);

	dlgRecover.SetMemberDevice(sourceDisk);
	dlgRecover.DoModal();

	OnRefreshStatus(NULL, NULL, NULL);
#endif
	
	return;
}
Exemple #14
0
void CUnBindDlg::OnOK(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	UINT32 nDiskCount = 0;
	unsigned int i;
	NDASCOMM_CONNECTION_INFO *pConnectionInfo;
	CFindIfVisitor<TRUE> unitDiskFinder;
	CDiskObjectList listUnbind;	// List of disks to unbind
	CDiskObjectList::iterator itr;
	CUnitDiskObjectPtr unitDisk;
	WTL::CString strMsg;
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);
	BOOL bUnbindMirror;

	BOOL bReadyToUnbind;
	UINT32 BindResult;

	bUnbindMirror = (dynamic_cast<const CMirDiskObject*>(m_pDiskUnbind.get()) != NULL);

	// warning message
	strMsg.LoadString((bUnbindMirror) ? IDS_WARNING_UNBIND_MIR : IDS_WARNING_UNBIND);
	int id = MessageBox(
		strMsg,
		strTitle,
		MB_YESNO|MB_ICONEXCLAMATION
		);
	if(IDYES != id)
		return;

	listUnbind = unitDiskFinder.FindIf( m_pDiskUnbind, IsUnitDisk);
	nDiskCount = listUnbind.size();
	pConnectionInfo = new NDASCOMM_CONNECTION_INFO[nDiskCount];
	ZeroMemory(pConnectionInfo, sizeof(NDASCOMM_CONNECTION_INFO) * nDiskCount);

	bReadyToUnbind = TRUE;
	for ( itr = listUnbind.begin(), i = 0; itr != listUnbind.end(); ++itr )
	{
		if(!(*itr)->IsUnitDisk())
			continue;

		unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

		ZeroMemory(&pConnectionInfo[i], sizeof(NDASCOMM_CONNECTION_INFO));
		pConnectionInfo[i].address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
		pConnectionInfo[i].login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
		pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		pConnectionInfo[i].bWriteAccess = TRUE;
		pConnectionInfo[i].ui64OEMCode = NULL;
		pConnectionInfo[i].bSupervisor = FALSE;
		pConnectionInfo[i].protocol = NDASCOMM_TRANSPORT_LPX;

		CopyMemory(pConnectionInfo[i].AddressLPX, 
			unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);
		
		if(!(unitDisk->GetAccessMask() & GENERIC_WRITE))
		{
			// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
			strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
				unitDisk->GetTitle()
				);
			MessageBox(
				strMsg,
				strTitle,
				MB_OK|MB_ICONERROR
				);

			bReadyToUnbind = FALSE;
		}

		i++;
	}

	if(!bReadyToUnbind)
	{
		delete [] pConnectionInfo;
		EndDialog(IDCANCEL);
	}

	BindResult = NdasOpBind(i, pConnectionInfo,NMT_SINGLE);

	DWORD dwLastError = ::GetLastError();

	m_unboundDisks = listUnbind;

	if(i == BindResult)
	{
		strMsg.LoadString(
			(bUnbindMirror) ? IDS_WARNING_UNBIND_AFTER_MIR : 
			IDS_WARNING_UNBIND_AFTER);

		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{
		for ( itr = listUnbind.begin(); itr != listUnbind.end(); ++itr )
		{
			unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

			if(!BindResult)
				break;
			BindResult--;
		}

		::SetLastError(dwLastError);

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, unitDisk->GetTitle());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
 	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for(i = 0; i < BindResult; i++)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}

	delete [] pConnectionInfo;

	EndDialog(IDOK);
}
void CDiskPropertyPage1::OnMigrate(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	UINT32 BindResult;
	CDiskObjectPtr disk = GetParentSheet()->GetDiskObject();
	NDAS_CONNECTION_INFO pConnectionInfo[NUMBER_MIGRATE_DISK];
	UINT32 i;
	
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);

	// Find aggregation root
	if (NUMBER_MIGRATE_DISK != disk->GetDiskCount())
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_DISK_NOT_EXIST );
		MessageBox(
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	WTL::CString strConfirmMsg;
	strConfirmMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_CONFIRM );
	if ( IDYES != MessageBox( 
					strConfirmMsg,
					strTitle,
					MB_YESNO | MB_ICONWARNING
					) 
		)
	{
		return;
	}

	if ( !disk->CanAccessExclusive() )
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_ACCESS_FAIL );
		MessageBox( 
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	CDiskObjectCompositePtr pDiskObjectComposite = 
		boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);

	CDiskObjectComposite::const_iterator itr;
	for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
	{
		CUnitDiskObjectPtr unitDisk = 
			boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
		
		pConnectionInfo[i].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
		pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		pConnectionInfo[i].bWriteAccess = TRUE;
		pConnectionInfo[i].ui64OEMCode = NULL;
		pConnectionInfo[i].protocol = IPPROTO_LPXTCP;
		CopyMemory(pConnectionInfo[i].MacAddress, 
			unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);
	}

	BindResult = NdasOpBind(NUMBER_MIGRATE_DISK, pConnectionInfo, NMT_RAID1);

	WTL :: CString strMsg;
	if(NUMBER_MIGRATE_DISK == BindResult)
	{
		strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_SUCCESS);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);

		GetDlgItem(IDC_TEXT_MIGRATE).ShowWindow( SW_HIDE );
		GetDlgItem(IDC_BTN_MIGRATE).ShowWindow( SW_HIDE );
		GetDlgItem(IDC_ST_MIGRATE).ShowWindow( SW_HIDE );
	}
	else
	{
		DWORD dwLastError = ::GetLastError();
		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
			{
				CUnitDiskObjectPtr unitDisk = 
					boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
				if(BindResult == i)
					strMsg.FormatMessage(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL_AT_FMT, unitDisk->GetTitle());
			}

			break;
		default:
			strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for(i = 0; i < NUMBER_MIGRATE_DISK; i++)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].MacAddress, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}
}
Exemple #16
0
void CMainFrame::OnSingle(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CString strMsg;

	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBUnitDevice *pUnitDevice;
	if(dynamic_cast<CNBLogicalDevice *>(pDevice))
	{
		CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
		if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
			return;

		pUnitDevice = (*pLogicalDevice)[0];
	}
	else
	{
		pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
		if(!pUnitDevice || !pUnitDevice->IsOperatable())
			return;
	}

	if(!pUnitDevice)
		return;

	NBUnitDevicePtrList listUnitDevices;
	listUnitDevices.push_back(pUnitDevice);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SINGLE_DLG_CAPTION, 
		IDS_SINGLE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;


	NDASCOMM_CONNECTION_INFO ConnectionInfo;
	if(!pUnitDevice->InitConnectionInfo(&ConnectionInfo, TRUE))
	{
		
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			pUnitDevice->GetName()
			);
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE,
		0);
	l_auto_cursor.Release();

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, pUnitDevice->GetName());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	OnRefreshStatus(NULL, NULL, NULL);
}
Exemple #17
0
void CMainFrame::OnUnBind(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	BOOL bUnbindMirror = 
		(NMT_RAID1 == pLogicalDevice->GetType() ||
		NMT_RAID1R == pLogicalDevice->GetType() ||
		NMT_MIRROR == pLogicalDevice->GetType());

	// warning message
	CString strMsg;

	NBUnitDevicePtrList listUnitDevices = pLogicalDevice->GetOperatableDevices();
	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_UNBIND_DLG_CAPTION, 
		(bUnbindMirror) ? IDS_WARNING_UNBIND_MIR : IDS_WARNING_UNBIND, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO *ci = new NDASCOMM_CONNECTION_INFO[listUnitDevices.size()];

	UINT32 i = 0;

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->InitConnectionInfo(&ci[i], TRUE);
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(listUnitDevices.size(), ci, NMT_SINGLE, 0);
	l_auto_cursor.Release();

	DWORD dwLastError = ::GetLastError();

	if(i == BindResult)
	{
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		strMsg.LoadString(
			(bUnbindMirror) ? IDS_WARNING_UNBIND_AFTER_MIR : 
		IDS_WARNING_UNBIND_AFTER);

		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{

		::SetLastError(dwLastError);

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			if(BindResult < listUnitDevices.size())
			{
				i = 0;
				for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
					itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
				{
					if(i == BindResult)
						strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, (*itUnitDevice)->GetName());
				}
				
			}
			else
				strMsg.LoadString(IDS_BIND_FAIL);
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
	}

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->HixChangeNotify(pGetNdasHostGuid());
	}

	delete [] ci;

	OnRefreshStatus(NULL, NULL, NULL);

	return;
}
Exemple #18
0
void CMainFrame::OnSingle(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	WTL::CString strMsg;

	CTreeItem itemSelected = m_view.GetSelectedItem();
	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectPtr obj, parent;
	obj = m_mapObject[m_view.GetItemData(itemSelected)];

	if(!obj->IsUnitDisk())
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	// AING_TO_DO
	{
		strMsg.LoadString(IDS_WARNING_SINGLE);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		int ret = MessageBox( 
			strMsg,
			strTitle,
			MB_YESNO | MB_ICONWARNING
			);

		if(IDYES != ret)
		{
			LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
			return;
		}
	}

	//
	// Check whether any disk is being accessed by other program/computer
	//
	if ( !obj->CanAccessExclusive() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		strMsg.LoadString(IDS_FAIL_TO_ACCESS_EXCLUSIVELY);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox( 
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	if(!(obj->GetAccessMask() & GENERIC_WRITE))
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			obj->GetTitle()
			);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	NDAS_CONNECTION_INFO ConnectionInfo;

	CUnitDiskObjectPtr unitDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	
	ZeroMemory(&ConnectionInfo, sizeof(NDAS_CONNECTION_INFO));

	ConnectionInfo.type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
	ConnectionInfo.UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ConnectionInfo.bWriteAccess = TRUE;
	ConnectionInfo.ui64OEMCode = NULL;
	ConnectionInfo.protocol = IPPROTO_LPXTCP;
	CopyMemory(ConnectionInfo.MacAddress, 
		unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		LPXADDR_NODE_LENGTH);

	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE);

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, unitDisk->GetTitle());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		NDAS_UNITDEVICE_ID unitDeviceId;
		CopyMemory(unitDeviceId.DeviceId.Node, ConnectionInfo.MacAddress, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = ConnectionInfo.UnitNo;
		HixChangeNotify.Notify(unitDeviceId);
	}

	OnRefreshStatus(NULL, NULL, NULL);


}
Exemple #19
0
BOOL CMirDiskUIHandler::OnMigrate(CDiskObjectPtr obj ) const
{
	CMirDiskObjectPtr mirDisk = 
		boost::dynamic_pointer_cast<CMirDiskObject>(obj);
	if(NMT_MIRROR != mirDisk->GetNDASMediaType())
		return FALSE;

	UINT32 BindResult;
	CDiskObjectPtr disk = obj;
	NDASCOMM_CONNECTION_INFO pConnectionInfo[NUMBER_MIGRATE_DISK];
	UINT32 i;
	
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);

	// Find aggregation root
	if (NUMBER_MIGRATE_DISK != disk->GetDiskCount())
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_DISK_NOT_EXIST );
		MessageBox(
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return FALSE;
	}

	WTL::CString strConfirmMsg;
	strConfirmMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_CONFIRM );
	if ( IDYES != MessageBox( 
					::GetFocus(),
					strConfirmMsg,
					strTitle,
					MB_YESNO | MB_ICONWARNING
					) 
		)
	{
		return FALSE;
	}

	if ( !disk->CanAccessExclusive() )
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY );
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return FALSE;
	}

	CDiskObjectCompositePtr pDiskObjectComposite = 
		boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);

	CDiskObjectComposite::const_iterator itr;
	for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
	{
		CUnitDiskObjectPtr unitDisk = 
			boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
		
		ZeroMemory(&pConnectionInfo[i], sizeof(NDASCOMM_CONNECTION_INFO));
		pConnectionInfo[i].address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
		pConnectionInfo[i].login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
		pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		pConnectionInfo[i].bWriteAccess = TRUE;
		pConnectionInfo[i].ui64OEMCode = NULL;
		pConnectionInfo[i].bSupervisor = FALSE;
		pConnectionInfo[i].protocol = NDASCOMM_TRANSPORT_LPX;
		CopyMemory(pConnectionInfo[i].AddressLPX, 
			unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);
	}

	BindResult = NdasOpBind(NUMBER_MIGRATE_DISK, pConnectionInfo, NMT_RAID1);

	WTL :: CString strMsg;
	if(NUMBER_MIGRATE_DISK == BindResult)
	{
		strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_SUCCESS);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{
		DWORD dwLastError = ::GetLastError();
		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
			{
				CUnitDiskObjectPtr unitDisk = 
					boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
				if(BindResult == i)
					strMsg.FormatMessage(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL_AT_FMT, unitDisk->GetTitle());
			}

			break;
		default:
			strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for(i = 0; i < NUMBER_MIGRATE_DISK; i++)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}
	return TRUE;
}
Exemple #20
0
void CMainFrame::OnAddMirror(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	CTreeItem itemSelected = m_view.GetSelectedItem();

	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectList singleDisks;
	CUnitDiskObjectPtr  sourceDisk;
	sourceDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(
			m_mapObject[m_view.GetItemData(itemSelected)]
			);
	ATLASSERT( sourceDisk.get() != NULL );

	CFindIfVisitor<FALSE> singleDiskFinder;
	singleDisks = singleDiskFinder.FindIf(m_pRoot, IsWritableUnitDisk);
	singleDisks.remove( sourceDisk );
	if ( singleDisks.size() == 0 )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// TODO : No disk is available
		WTL::CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NO_DISK_TO_MIRROR );
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	DWORD UnitNo = 0;
	CSelectMirDlg dlgSelDisk(IDD_ADDMIR);
	dlgSelDisk.SetSingleDisks( singleDisks );
	dlgSelDisk.SetSourceDisk( sourceDisk );
	if ( dlgSelDisk.DoModal() == IDOK )
	{
		CUnitDiskObjectPtr mirDisk = dlgSelDisk.GetSelectedDisk();

		// Bind & Synchronize 
		NDAS_CONNECTION_INFO ConnectionInfo[2];

		ZeroMemory(&ConnectionInfo[0], sizeof(NDAS_CONNECTION_INFO));

		ConnectionInfo[0].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
		ConnectionInfo[0].UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		ConnectionInfo[0].bWriteAccess = TRUE;
		ConnectionInfo[0].ui64OEMCode = NULL;
		ConnectionInfo[0].protocol = IPPROTO_LPXTCP;
		CopyMemory(ConnectionInfo[0].MacAddress, 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);

		ZeroMemory(&ConnectionInfo[1], sizeof(NDAS_CONNECTION_INFO));

		ConnectionInfo[1].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
		ConnectionInfo[1].UnitNo = mirDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		ConnectionInfo[1].bWriteAccess = TRUE;
		ConnectionInfo[1].ui64OEMCode = NULL;
		ConnectionInfo[1].protocol = IPPROTO_LPXTCP;
		CopyMemory(ConnectionInfo[1].MacAddress, 
			mirDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);

		UINT32 BindResult = NdasOpBind(
			2,
			ConnectionInfo,
			NMT_SAFE_RAID1);

		if(2 != BindResult)
		{
	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

			WTL :: CString strMsg;

			DWORD dwLastError = ::GetLastError();

			switch(dwLastError)
	{
			case NDASCOMM_ERROR_RW_USER_EXIST:
			case NDASOP_ERROR_ALREADY_USED:
			case NDASOP_ERROR_DEVICE_FAIL:
			case NDASOP_ERROR_NOT_SINGLE_DISK:
			case NDASOP_ERROR_DEVICE_UNSUPPORTED:
				strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, 
					(BindResult == 0) ? sourceDisk->GetTitle() : mirDisk->GetTitle());
				break;
			default:
				strMsg.LoadString(IDS_BIND_FAIL);
				break;
	}

			ShowErrorMessageBox(strMsg);

		return;
	}

		CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
		BOOL bResults = HixChangeNotify.Initialize();
		if(bResults)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;

			CopyMemory(unitDeviceId.DeviceId.Node, 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);

			CopyMemory(unitDeviceId.DeviceId.Node, 
				mirDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				mirDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}

		CRecoverDlg dlgRecover(TRUE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_ADD_MIRROR);

		dlgRecover.SetMemberDevice(mirDisk);
		dlgRecover.DoModal();

		OnRefreshStatus(NULL, NULL, NULL);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}