void CSelectDiskPage::OnClickAddRemove(UINT /*wNotifyCode*/, int wID, HWND /*hwndCtl*/) { CNBListViewCtrl *pWndFrom, *pWndTo; switch(wID) { case IDC_BTN_ADD: pWndFrom = &m_wndListSingle; pWndTo = &m_wndListBind; break; case IDC_BTN_REMOVE_ALL: m_wndListBind.SelectAllDiskObject(); case IDC_BTN_REMOVE: pWndFrom = &m_wndListBind; pWndTo = &m_wndListSingle; break; default: return; } NBUnitDevicePtrList selectedDisks = pWndFrom->GetSelectedDiskObjectList(); if ( selectedDisks.size() == 0 ) return; pWndFrom->DeleteDiskObjectList( selectedDisks ); pWndTo->AddDiskObjectList( selectedDisks ); pWndTo->SelectDiskObjectList( selectedDisks ); /* for ( UINT i=0; i < selectedDisks.size(); i++ ) { if ( bFromSingle ) m_wndDiskList.InsertItem(); else m_wndDiskList.DeleteItem(); } */ UpdateControls(); }
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; }
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; }
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); }